@@ -1172,9 +1172,9 @@ static _Unwind_Reason_Code unwind_callback(struct _Unwind_Context *context,
1172
1172
uintptr_t pc = _Unwind_GetIP (context );
1173
1173
if (pc != 0 ) {
1174
1174
pc -- ;
1175
- if (d -> size < LCOMPILERS_MAX_STACKTRACE_LENGTH ) {
1176
- d -> pc [d -> size ] = pc ;
1177
- d -> size ++ ;
1175
+ if (d -> pc_size < LCOMPILERS_MAX_STACKTRACE_LENGTH ) {
1176
+ d -> pc [d -> pc_size ] = pc ;
1177
+ d -> pc_size ++ ;
1178
1178
} else {
1179
1179
// TODO: Do not know how to report an error here
1180
1180
}
@@ -1214,6 +1214,27 @@ int shared_lib_callback(struct dl_phdr_info *info,
1214
1214
return 0 ;
1215
1215
}
1216
1216
1217
+ uint32_t file_size (int64_t fp ){
1218
+ FILE * fp_ = (FILE * )fp ;
1219
+ int prev = ftell (fp_ );
1220
+ fseek (fp_ , 0 , SEEK_END );
1221
+ int size = ftell (fp_ );
1222
+ fseek (fp_ , prev , SEEK_SET );
1223
+ return size ;
1224
+ }
1225
+
1226
+ void get_local_info_dwarfdump (struct Stacktrace d ) {
1227
+ uint64_t addresses [LCOMPILERS_MAX_STACKTRACE_LENGTH ];
1228
+ {
1229
+ char * filename = "lines.dat" ;
1230
+ int64_t fd = _lpython_open (filename , "rb" );
1231
+ uint32_t size = file_size (fd );
1232
+ char * file_contents = _lpython_read (fd , size );
1233
+ _lpython_close (fd );
1234
+ printf ("%s: %d\n" , file_contents , size );
1235
+ }
1236
+ }
1237
+
1217
1238
void get_local_address (struct Stacktrace d ) {
1218
1239
for (int32_t i = 0 ; i < d .pc_size ; i ++ ) {
1219
1240
d .current_pc = d .pc [i ];
@@ -1228,7 +1249,7 @@ void get_local_address(struct Stacktrace d) {
1228
1249
void print_stacktrace_addresses (struct Stacktrace d )
1229
1250
{
1230
1251
get_local_address (d );
1231
- // get_local_info_dwarfdump(d);
1252
+ get_local_info_dwarfdump (d );
1232
1253
// print stacktrace
1233
1254
}
1234
1255
0 commit comments