diff options
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/ChangeLog | 15 | ||||
-rw-r--r-- | binutils/addr2line.c | 18 | ||||
-rw-r--r-- | binutils/objdump.c | 40 |
3 files changed, 60 insertions, 13 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 3068937..0edd519 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,18 @@ +2012-07-24 Teresa Johnson <tejohnson@google.com> + + * addr2line.c (find_address_in_section): Invoke + bfd_find_nearest_line_discriminator to get the discriminator. + (find_offset_in_section): Likewise. + (translate_addresses): Print discriminator if it is non-zero. + * objdump.c (show_line): Invoke + bfd_find_nearest_line_discriminator to get the discriminator, + and keep track of prev_discriminator. Print discriminator + if it is non-zero. + (disassemble_data): Initialize prev_discriminator. + (dump_reloc_set): Invoke bfd_find_nearest_line_discriminator + to get the discriminator, and keep track of last_discriminator. + Print discriminator if it is non-zero. + 2012-07-17 Nick Clifton <nickc@redhat.com> * elfcomm.c (setup_archive): Extract index table and symbol table diff --git a/binutils/addr2line.c b/binutils/addr2line.c index 663da45..5febaea 100644 --- a/binutils/addr2line.c +++ b/binutils/addr2line.c @@ -139,6 +139,7 @@ static bfd_vma pc; static const char *filename; static const char *functionname; static unsigned int line; +static unsigned int discriminator; static bfd_boolean found; /* Look for an address in a section. This is called via @@ -165,8 +166,9 @@ find_address_in_section (bfd *abfd, asection *section, if (pc >= vma + size) return; - found = bfd_find_nearest_line (abfd, section, syms, pc - vma, - &filename, &functionname, &line); + found = bfd_find_nearest_line_discriminator (abfd, section, syms, pc - vma, + &filename, &functionname, + &line, &discriminator); } /* Look for an offset in a section. This is directly called. */ @@ -186,8 +188,9 @@ find_offset_in_section (bfd *abfd, asection *section) if (pc >= size) return; - found = bfd_find_nearest_line (abfd, section, syms, pc, - &filename, &functionname, &line); + found = bfd_find_nearest_line_discriminator (abfd, section, syms, pc, + &filename, &functionname, + &line, &discriminator); } /* Read hexadecimal addresses from stdin, translate into @@ -294,7 +297,12 @@ translate_addresses (bfd *abfd, asection *section) printf ("%s:", filename ? filename : "??"); if (line != 0) - printf ("%u\n", line); + { + if (discriminator != 0) + printf ("%u (discriminator %u)\n", line, discriminator); + else + printf ("%u\n", line); + } else printf ("?\n"); if (!unwind_inlines) diff --git a/binutils/objdump.c b/binutils/objdump.c index b22bf8b..49a2457 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -1086,6 +1086,7 @@ objdump_symbol_at_address (bfd_vma vma, struct disassemble_info * inf) static char *prev_functionname; static unsigned int prev_line; +static unsigned int prev_discriminator; /* We keep a list of all files that we have seen when doing a disassembly with source, so that we know how much of the file to @@ -1312,13 +1313,15 @@ show_line (bfd *abfd, asection *section, bfd_vma addr_offset) const char *filename; const char *functionname; unsigned int linenumber; + unsigned int discriminator; bfd_boolean reloc; if (! with_line_numbers && ! with_source_code) return; - if (! bfd_find_nearest_line (abfd, section, syms, addr_offset, &filename, - &functionname, &linenumber)) + if (! bfd_find_nearest_line_discriminator (abfd, section, syms, addr_offset, + &filename, &functionname, + &linenumber, &discriminator)) return; if (filename != NULL && *filename == '\0') @@ -1370,8 +1373,15 @@ show_line (bfd *abfd, asection *section, bfd_vma addr_offset) && (prev_functionname == NULL || strcmp (functionname, prev_functionname) != 0)) printf ("%s():\n", functionname); - if (linenumber > 0 && linenumber != prev_line) - printf ("%s:%u\n", filename == NULL ? "???" : filename, linenumber); + if (linenumber > 0 && (linenumber != prev_line || + (discriminator != prev_discriminator))) + { + if (discriminator > 0) + printf ("%s:%u (discriminator %u)\n", filename == NULL ? "???" : filename, + linenumber, discriminator); + else + printf ("%s:%u\n", filename == NULL ? "???" : filename, linenumber); + } } if (with_source_code @@ -1423,6 +1433,9 @@ show_line (bfd *abfd, asection *section, bfd_vma addr_offset) if (linenumber > 0 && linenumber != prev_line) prev_line = linenumber; + + if (discriminator != prev_discriminator) + prev_discriminator = discriminator; } /* Pseudo FILE object for strings. */ @@ -2115,6 +2128,7 @@ disassemble_data (bfd *abfd) print_files = NULL; prev_functionname = NULL; prev_line = -1; + prev_discriminator = 0; /* We make a copy of syms to sort. We don't want to sort syms because that will screw up the relocs. */ @@ -2895,6 +2909,7 @@ dump_reloc_set (bfd *abfd, asection *sec, arelent **relpp, long relcount) arelent **p; char *last_filename, *last_functionname; unsigned int last_line; + unsigned int last_discriminator; /* Get column headers lined up reasonably. */ { @@ -2913,12 +2928,14 @@ dump_reloc_set (bfd *abfd, asection *sec, arelent **relpp, long relcount) last_filename = NULL; last_functionname = NULL; last_line = 0; + last_discriminator = 0; for (p = relpp; relcount && *p != NULL; p++, relcount--) { arelent *q = *p; const char *filename, *functionname; unsigned int linenumber; + unsigned int discriminator; const char *sym_name; const char *section_name; bfd_vma addend2 = 0; @@ -2932,8 +2949,9 @@ dump_reloc_set (bfd *abfd, asection *sec, arelent **relpp, long relcount) if (with_line_numbers && sec != NULL - && bfd_find_nearest_line (abfd, sec, syms, q->address, - &filename, &functionname, &linenumber)) + && bfd_find_nearest_line_discriminator (abfd, sec, syms, q->address, + &filename, &functionname, + &linenumber, &discriminator)) { if (functionname != NULL && (last_functionname == NULL @@ -2949,10 +2967,16 @@ dump_reloc_set (bfd *abfd, asection *sec, arelent **relpp, long relcount) && (linenumber != last_line || (filename != NULL && last_filename != NULL - && filename_cmp (filename, last_filename) != 0))) + && filename_cmp (filename, last_filename) != 0) + || (discriminator != last_discriminator))) { - printf ("%s:%u\n", filename == NULL ? "???" : filename, linenumber); + if (discriminator > 0) + printf ("%s:%u\n", filename == NULL ? "???" : filename, linenumber); + else + printf ("%s:%u (discriminator %u)\n", filename == NULL ? "???" : filename, + linenumber, discriminator); last_line = linenumber; + last_discriminator = discriminator; if (last_filename != NULL) free (last_filename); if (filename == NULL) |