[patch] Add offsets to dwarf dump of raw line tables

Cary Coutant ccoutant@google.com
Wed May 22 18:43:00 GMT 2013


It's next to impossible to match up relocations with the line number
table program, since the line number table dump doesn't show offsets
within the section. This patch prints the section offset for the
directory table, the file name table, and for each line number table
opcode, making it much easier to find the opcode that matches a
particular relocation. I've also numbered the directory table entries.

OK for trunk?

-cary


2013-05-22  Cary Coutant  <ccoutant@google.com>

binutils/
        * dwarf.c (display_debug_lines_raw): Print section offsets.


diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 862a060..4063f0a 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -2656,7 +2656,8 @@ display_debug_lines_raw (struct dwarf_section *section,
       DWARF2_Internal_LineInfo linfo;
       unsigned char *standard_opcodes;
       unsigned char *end_of_sequence;
-       int i;
+      unsigned int last_dir_entry = 0;
+      int i;

       if (const_strneq (section->name, ".debug_line.")
          /* Note: the following does not apply to .debug_line.dwo sections.
@@ -2715,11 +2716,12 @@ display_debug_lines_raw (struct dwarf_section *section,
            printf (_("\n The Directory Table is empty.\n"));
          else
            {
-             printf (_("\n The Directory Table:\n"));
+             printf (_("\n The Directory Table (offset 0x%lx):\n"),
+                     (long)(data - start));

              while (*data != 0)
                {
-                 printf ("  %s\n", data);
+                 printf ("  %d\t%s\n", ++last_dir_entry, data);

                  data += strnlen ((char *) data, end - data) + 1;
                }
@@ -2733,7 +2735,8 @@ display_debug_lines_raw (struct dwarf_section *section,
            printf (_("\n The File Name Table is empty.\n"));
          else
            {
-             printf (_("\n The File Name Table:\n"));
+             printf (_("\n The File Name Table (offset 0x%lx):\n"),
+                     (long)(data - start));
              printf (_("  Entry\tDir\tTime\tSize\tName\n"));

              while (*data != 0)
@@ -2784,6 +2787,8 @@ display_debug_lines_raw (struct dwarf_section *section,
              dwarf_vma uladv;
              unsigned int bytes_read;

+             printf ("  [0x%08lx]", (long)(data - start));
+
              op_code = *data++;

              if (op_code >= linfo.li_opcode_base)



More information about the Binutils mailing list