Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug: incorrect callsite stack traceback during .so file handling #53

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mpiPi.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ typedef struct SO_INFO
{
void *lvma;
void *uvma;
size_t offset;
char *fpath;
bfd *bfd;
} so_info_t;
Expand Down
16 changes: 9 additions & 7 deletions pc_lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ mpiPi_print_so_node_info (const void *so_node, VISIT which, int depth)
case preorder:
break;
case postorder:
printf ("%p - %p : %s\n", cso->lvma, cso->uvma, cso->fpath);
printf ("%p - %p %lx: %s\n", cso->lvma, cso->uvma, cso->offset, cso->fpath);
break;
case endorder:
break;
case leaf:
printf ("%p - %p : %s\n", cso->lvma, cso->uvma, cso->fpath);
printf ("%p - %p %lx: %s\n", cso->lvma, cso->uvma, cso->offset, cso->fpath);
break;
}
}
Expand Down Expand Up @@ -317,6 +317,7 @@ mpiPi_parse_maps ()
char fbuf[64];
FILE *fh;
void *lvma, *uvma;
size_t offset;
char *fpath, *inbuf = NULL, *tokptr;
so_info_t *cso = NULL;
size_t inbufsize;
Expand All @@ -334,9 +335,9 @@ mpiPi_parse_maps ()
}

if (sizeof (void *) == 4)
scan_str = "%x-%x";
scan_str = "%x-%x %*s %x";
else
scan_str = "%llx-%llx";
scan_str = "%llx-%llx %*s %llx";

mpiPi.so_info = NULL;

Expand All @@ -349,10 +350,10 @@ mpiPi_parse_maps ()
mpiPi_msg_debug ("maps getline is %s\n", inbuf);

/* scan address range */
if (sscanf (inbuf, scan_str, &lvma, &uvma) < 2)
if (sscanf (inbuf, scan_str, &lvma, &uvma, &offset) < 2)
return 0;

mpiPi_msg_debug ("Parsed range as %lx - %lx\n", lvma, uvma);
mpiPi_msg_debug ("Parsed range as %lx - %lx offset: %lx\n", lvma, uvma, offset);

/* get pointer to address range */
tokptr = strtok_r (inbuf, delim, &sp);
Expand Down Expand Up @@ -387,6 +388,7 @@ mpiPi_parse_maps ()
return 0;
cso->lvma = lvma;
cso->uvma = uvma;
cso->offset = offset;
cso->fpath = strdup (fpath);
cso->bfd = NULL;
if (tsearch (cso, (void **) &(mpiPi.so_info), mpiPi_so_info_compare) !=
Expand Down Expand Up @@ -468,7 +470,7 @@ mpiP_find_src_loc (void *i_addr_hex, char **o_file_str, int *o_lineno,
fso->bfd = (bfd *) open_bfd_object (fso->fpath);
}

pc = (char *) i_addr_hex - (char *) fso->lvma;
pc = (((char *) i_addr_hex - (char *) fso->lvma) + fso->offset);
mpiPi_msg_debug
("Calling bfd_map_over_sections with new bfd for %p\n", pc);

Expand Down