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

Cary Coutant ccoutant@google.com
Thu May 23 18:30:00 GMT 2013


>> I like the change, but not OK unless you also fix testsuite fallout.
>
> Thanks. I'm working on the testsuite fallout -- just wanted to find
> out whether the change in output format would be OK.

Here's the patch with testsuite changes. I looked for affected tests
in target-specific directories, but found only the two in i386 and
x86-64. I hope I didn't miss anything.

-cary


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

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

    binutils/testsuite/
        * binutils-all/dw2-1.W: Adjust expected output.
        * binutils-all/objdump.W: Likewise.
        * binutils-all/i386/compressed-1a.d: Likewise.
        * binutils-all/x86-64/compressed-1a.d: Likewise.
-------------- next part --------------
commit 39941aff3b149b99f663612deb11a4db30053884
Author: Cary Coutant <ccoutant@google.com>
Date:   Wed May 22 11:44:56 2013 -0700

    Print section offsets when printing DWARF line table.
    
    binutils/
    	* dwarf.c (display_debug_lines_raw): Print section offsets.
    
    binutils/testsuite/
    	* binutils-all/dw2-1.W: Adjust expected output.
    	* binutils-all/objdump.W: Likewise.
    	* binutils-all/i386/compressed-1a.d: Likewise.
    	* binutils-all/x86-64/compressed-1a.d: Likewise.

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)
diff --git a/binutils/testsuite/binutils-all/dw2-1.W b/binutils/testsuite/binutils-all/dw2-1.W
index 002802a..85ce9dd 100644
--- a/binutils/testsuite/binutils-all/dw2-1.W
+++ b/binutils/testsuite/binutils-all/dw2-1.W
@@ -61,17 +61,17 @@ Raw dump of debug contents of section .debug_line:
 
  The Directory Table is empty.
 
- The File Name Table:
+ The File Name Table \(offset 0x.*\):
   Entry	Dir	Time	Size	Name
   1	0	0	0	file1.txt
 
  Line Number Statements:
-  Extended opcode 2: set Address to .*
-  Advance Line by 3 to 4
-  Copy
-  Copy
-  Extended opcode 2: set Address to .*
-  Extended opcode 1: End of Sequence
+  \[0x.*\]  Extended opcode 2: set Address to 0x4
+  \[0x.*\]  Advance Line by 3 to 4
+  \[0x.*\]  Copy
+  \[0x.*\]  Copy
+  \[0x.*\]  Extended opcode 2: set Address to 0x8
+  \[0x.*\]  Extended opcode 1: End of Sequence
 
 
 Contents of the .debug_abbrev section:
diff --git a/binutils/testsuite/binutils-all/i386/compressed-1a.d b/binutils/testsuite/binutils-all/i386/compressed-1a.d
index bb609dd..f1883aa 100644
--- a/binutils/testsuite/binutils-all/i386/compressed-1a.d
+++ b/binutils/testsuite/binutils-all/i386/compressed-1a.d
@@ -88,21 +88,21 @@ Raw dump of debug contents of section .[z]?debug_line:
 
  The Directory Table is empty.
 
- The File Name Table:
+ The File Name Table \(offset 0x.*\):
   Entry	Dir	Time	Size	Name
   1	0	0	0	compressed-1.c
 
  Line Number Statements:
-  Extended opcode 2: set Address to 0x0
-  Advance Line by 10 to 11
-  Copy
-  Special opcode 6: advance Address by 0 to 0x0 and Line by 1 to 12
-  Advance Line by -7 to 5
-  Special opcode 229: advance Address by 16 to 0x10 and Line by 0 to 5
-  Special opcode 49: advance Address by 3 to 0x13 and Line by 2 to 7
-  Special opcode 46: advance Address by 3 to 0x16 and Line by -1 to 6
-  Advance PC by 5 to 0x1b
-  Extended opcode 1: End of Sequence
+  \[0x.*\]  Extended opcode 2: set Address to 0x0
+  \[0x.*\]  Advance Line by 10 to 11
+  \[0x.*\]  Copy
+  \[0x.*\]  Special opcode 6: advance Address by 0 to 0x0 and Line by 1 to 12
+  \[0x.*\]  Advance Line by -7 to 5
+  \[0x.*\]  Special opcode 229: advance Address by 16 to 0x10 and Line by 0 to 5
+  \[0x.*\]  Special opcode 49: advance Address by 3 to 0x13 and Line by 2 to 7
+  \[0x.*\]  Special opcode 46: advance Address by 3 to 0x16 and Line by -1 to 6
+  \[0x.*\]  Advance PC by 5 to 0x1b
+  \[0x.*\]  Extended opcode 1: End of Sequence
 
 
 Contents of the .[z]?debug_pubnames section:
diff --git a/binutils/testsuite/binutils-all/objdump.W b/binutils/testsuite/binutils-all/objdump.W
index 43c2451..f544d82 100644
--- a/binutils/testsuite/binutils-all/objdump.W
+++ b/binutils/testsuite/binutils-all/objdump.W
@@ -61,17 +61,17 @@ Raw dump of debug contents of section .debug_line:
 
  The Directory Table is empty.
 
- The File Name Table:
+ The File Name Table \(offset 0x.*\):
   Entry	Dir	Time	Size	Name
   1	0	0	0	file1.txt
 
  Line Number Statements:
-  Extended opcode 2: set Address to .*
-  Advance Line by 3 to 4
-  Copy
-  Copy
-  Extended opcode 2: set Address to .*
-  Extended opcode 1: End of Sequence
+  \[0x.*\]  Extended opcode 2: set Address to .*
+  \[0x.*\]  Advance Line by 3 to 4
+  \[0x.*\]  Copy
+  \[0x.*\]  Copy
+  \[0x.*\]  Extended opcode 2: set Address to .*
+  \[0x.*\]  Extended opcode 1: End of Sequence
 
 
 Contents of the .debug_abbrev section:
diff --git a/binutils/testsuite/binutils-all/x86-64/compressed-1a.d b/binutils/testsuite/binutils-all/x86-64/compressed-1a.d
index 06ab011..45f974d 100644
--- a/binutils/testsuite/binutils-all/x86-64/compressed-1a.d
+++ b/binutils/testsuite/binutils-all/x86-64/compressed-1a.d
@@ -88,20 +88,20 @@ Raw dump of debug contents of section .[z]?debug_line:
 
  The Directory Table is empty.
 
- The File Name Table:
+ The File Name Table \(offset 0x.*\):
   Entry	Dir	Time	Size	Name
   1	0	0	0	compressed-1.c
 
  Line Number Statements:
-  Extended opcode 2: set Address to 0x0
-  Advance Line by 10 to 11
-  Copy
-  Special opcode 6: advance Address by 0 to 0x0 and Line by 1 to 12
-  Advance Line by -7 to 5
-  Special opcode 229: advance Address by 16 to 0x10 and Line by 0 to 5
-  Special opcode 6: advance Address by 0 to 0x10 and Line by 1 to 6
-  Advance PC by 5 to 0x15
-  Extended opcode 1: End of Sequence
+  \[0x.*\]  Extended opcode 2: set Address to 0x0
+  \[0x.*\]  Advance Line by 10 to 11
+  \[0x.*\]  Copy
+  \[0x.*\]  Special opcode 6: advance Address by 0 to 0x0 and Line by 1 to 12
+  \[0x.*\]  Advance Line by -7 to 5
+  \[0x.*\]  Special opcode 229: advance Address by 16 to 0x10 and Line by 0 to 5
+  \[0x.*\]  Special opcode 6: advance Address by 0 to 0x10 and Line by 1 to 6
+  \[0x.*\]  Advance PC by 5 to 0x15
+  \[0x.*\]  Extended opcode 1: End of Sequence
 
 
 Contents of the .[z]?debug_pubnames section:


More information about the Binutils mailing list