Skip to content

Commit 56ca046

Browse files
Implement get_local_info_dwarfdump
1 parent 239c580 commit 56ca046

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

src/libasr/runtime/lfortran_intrinsics.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,9 +1172,9 @@ static _Unwind_Reason_Code unwind_callback(struct _Unwind_Context *context,
11721172
uintptr_t pc = _Unwind_GetIP(context);
11731173
if (pc != 0) {
11741174
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++;
11781178
} else {
11791179
// TODO: Do not know how to report an error here
11801180
}
@@ -1214,6 +1214,26 @@ int shared_lib_callback(struct dl_phdr_info *info,
12141214
return 0;
12151215
}
12161216

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+
}
1235+
}
1236+
12171237
void get_local_address(struct Stacktrace d) {
12181238
for (int32_t i=0; i < d.pc_size; i++) {
12191239
d.current_pc = d.pc[i];
@@ -1228,7 +1248,7 @@ void get_local_address(struct Stacktrace d) {
12281248
void print_stacktrace_addresses(struct Stacktrace d)
12291249
{
12301250
get_local_address(d);
1231-
// get_local_info_dwarfdump(d);
1251+
get_local_info_dwarfdump(d);
12321252
// print stacktrace
12331253
}
12341254

0 commit comments

Comments
 (0)