From ae7b91b68008ab09635a97a18e7d07a35e8404aa Mon Sep 17 00:00:00 2001 From: Meng Hu Date: Thu, 5 Nov 2009 16:10:50 -0600 Subject: debuggerd: Show function names in tombstone backtraces This change enables debuggerd to provide backtraces with function names in tombstone files and log messages. It does this by reading the image file that the address is found in, and parsing the dynamic symbol table to try to extract the symbol corresponding to the given address. This works best when "-Wl,-export-dynamic" is added to the LDFLAGS of each library and executable, because this will cause all symbols to be added to the dynamic symbol table. If this flag is not present, it will still work, but it will only be able to identify functions which are part of the external API of the library/executable. Change-Id: I618baaff9ed9143b7d1a1f302224e9f21d2b0626 --- debuggerd/debuggerd.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'debuggerd/debuggerd.c') diff --git a/debuggerd/debuggerd.c b/debuggerd/debuggerd.c index 996e6c204..02bab2c63 100644 --- a/debuggerd/debuggerd.c +++ b/debuggerd/debuggerd.c @@ -55,7 +55,7 @@ static int logsocket = -1; /* Log information onto the tombstone */ void _LOG(int tfd, bool in_tombstone_only, const char *fmt, ...) { - char buf[128]; + char buf[512]; va_list ap; va_start(ap, fmt); @@ -98,10 +98,11 @@ mapinfo *parse_maps_line(char *line) mi->start = strtoul(line, 0, 16); mi->end = strtoul(line + 9, 0, 16); - /* To be filled in parse_exidx_info if the mapped section starts with + /* To be filled in parse_elf_info if the mapped section starts with * elf_header */ mi->exidx_start = mi->exidx_end = 0; + mi->symbols = 0; mi->next = 0; strcpy(mi->name, line + 49); @@ -335,7 +336,7 @@ void dump_crash_banner(int tfd, unsigned pid, unsigned tid, int sig) if(sig) dump_fault_addr(tfd, tid, sig); } -static void parse_exidx_info(mapinfo *milist, pid_t pid) +static void parse_elf_info(mapinfo *milist, pid_t pid) { mapinfo *mi; for (mi = milist; mi != NULL; mi = mi->next) { @@ -365,6 +366,9 @@ static void parse_exidx_info(mapinfo *milist, pid_t pid) break; } } + + /* Try to load symbols from this file */ + mi->symbols = symbol_table_create(mi->name); } } } @@ -402,7 +406,7 @@ void dump_crash_report(int tfd, unsigned pid, unsigned tid, bool at_fault) fclose(fp); } - parse_exidx_info(milist, tid); + parse_elf_info(milist, tid); /* If stack unwinder fails, use the default solution to dump the stack * content. @@ -422,6 +426,7 @@ void dump_crash_report(int tfd, unsigned pid, unsigned tid, bool at_fault) while(milist) { mapinfo *next = milist->next; + symbol_table_free(milist->symbols); free(milist); milist = next; } -- cgit v1.2.3