aboutsummaryrefslogtreecommitdiff
path: root/binutils/objdump.c
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@google.com>2012-07-24 21:06:58 +0000
committerCary Coutant <ccoutant@google.com>2012-07-24 21:06:58 +0000
commit9b8d1a36034b5bdf665b952f581d96a987faecdf (patch)
tree7d7c940776178575125abdf217cc7f201e1da032 /binutils/objdump.c
parent882f447fddcf308f10b2398c84fbb95a4905c49e (diff)
downloadgdb-9b8d1a36034b5bdf665b952f581d96a987faecdf.zip
gdb-9b8d1a36034b5bdf665b952f581d96a987faecdf.tar.gz
gdb-9b8d1a36034b5bdf665b952f581d96a987faecdf.tar.bz2
2012-07-24 Teresa Johnson <tejohnson@google.com>
bfd/ * bfd.c (bfd_find_nearest_line_discriminator): New macro. * coff-rs6000.c: Init _bfd_find_nearest_line_discriminator. * coff64-rs6000.c: Likewise. * dwarf2.c (struct line_info): Add discriminator field. (add_line_info): Fill in new discriminator field. (decode_line_info): Record discriminator information instead of ignoring it. (lookup_address_in_line_info_table): Return discriminator field if requested. (comp_unit_find_nearest_line): Add discriminator argument. (find_line): Likewise. (_bfd_dwarf2_find_nearest_line): Likewise. (_bfd_dwarf2_find_line): Likewise. * elf-bfd.h (_bfd_elf_find_nearest_line_discriminator): New. (_bfd_elf_find_line_discriminator): Likewise. (_bfd_generic_find_nearest_line_discriminator): Likewise. Defined. * elf.c (_bfd_elf_find_nearest_line): Change to a wrapper that invokes _bfd_elf_find_nearest_line_discriminator with correct arguments. (_bfd_elf_find_nearest_line_discriminator): New. (_bfd_elf_find_line): Change to a wrapper that invokes _bfd_elf_find_line_discriminator with correct arguments. (_bfd_elf_find_line_discriminator): New. * coffgen.c (coff_find_nearest_line_with_names): Handle new discriminator argument. * elf32-arm.c (elf32_arm_find_nearest_line): Likewise. * elf64-alpha.c (elf64_alpha_find_nearest_line): Likewise. * elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Likewise. * mach-o.c (bfd_mach_o_find_nearest_line): Likewise. * libbfd-in.h (_bfd_dwarf2_find_nearest_line): Add discriminator argument. (_bfd_dwarf2_find_line): Likewise. (_bfd_generic_find_nearest_line_discriminator): New. * libbfd.c (_bfd_generic_find_nearest_line_discriminator): New. * bfd-in2.h: Regenerated. * libbfd.h: Likewise. * targets.c (BFD_JUMP_TABLE_SYMBOLS): Initialize _bfd_find_nearest_line_discriminator with _bfd_generic_find_nearest_line_discriminator. (bfd_target): Add _bfd_find_nearest_line_discriminator. binutils/ * 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.
Diffstat (limited to 'binutils/objdump.c')
-rw-r--r--binutils/objdump.c40
1 files changed, 32 insertions, 8 deletions
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)