Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 2/5] powerpc64-aix processing xlC generated line table
@ 2013-08-01 11:07 Raunaq 12
  0 siblings, 0 replies; 12+ messages in thread
From: Raunaq 12 @ 2013-08-01 11:07 UTC (permalink / raw)
  To: gdb-patches


xlc generated binaries have a line table which is not the same as GCC.
GCC compiled binaries have an extra line entry in the line table to
signify start of a function whereas xlc does not have this entry.

Due to this difference, commands like break <function name> and
list <function name> give wrong results.

To fix this issue I have written a function modify_xlc_linenos
which will add a line table entry at the function start points
if there is no extra entry in the line table as in the case of xlc.

Hence,
breakpoints and listing functions will work as expected even for xlc
compiled binaries.

---
ChangeLog :-
* xcoffread.c (modify_xlc_linenos): New function to modify xlc
generated linetables.
(process_linenos): make calls to the 'modify_xlc_linenos' to correctly
process linenos is case of xlc compiled binaries.
---
./gdb/xcoffread.c
===================================================================
--- ./gdb.orig/xcoffread.c
+++ ./gdb/xcoffread.c
@@ -241,6 +241,8 @@

 static struct linetable *arrange_linetable (struct linetable *);

+static struct linetable *modify_xlc_linenos (struct linetable *);
+
 static void record_include_end (struct coff_symbol *);

 static void process_linenos (CORE_ADDR, CORE_ADDR);
@@ -589,6 +591,24 @@
     }
 }

+/* xlc compiled binaries have one less entry in the line table.
+   So the function entry lines marked as line number equal to 0
+   will be retained in the line table with line numbers equal
+   to its succeeding line table entry.	*/
+
+static struct linetable *
+modify_xlc_linenos (struct linetable *lineTb)
+{
+ int jj;
+ for (jj = 0; jj < lineTb->nitems; jj++)
+  {
+   if (lineTb->item[jj].line == 0 && (lineTb->item[jj].pc
+                                    != lineTb->item[jj + 1].pc))
+        lineTb->item[jj].line = lineTb->item[jj + 1].line;
+  }
+ return lineTb;
+}
+
 /* Global variable to pass the psymtab down to all the routines involved
    in psymtab to symtab processing.  */
 static struct partial_symtab *this_symtab_psymtab;
@@ -698,10 +718,14 @@

       lv = main_subfile.line_vector;

+      /* Add extra line entry in case of xlc compiled binaries.	*/
+
+      lineTb = modify_xlc_linenos (lv);
+
       /* Line numbers are not necessarily ordered.  xlc compilation will
          put static function to the end.  */

-      lineTb = arrange_linetable (lv);
+      lineTb = arrange_linetable (lineTb);
       if (lv == lineTb)
 	{
 	  current_subfile->line_vector = (struct linetable *)
@@ -730,10 +754,14 @@

 	  lv = (inclTable[ii].subfile)->line_vector;

+          /* Add extra line entry in case of xlc compiled binaries */
+
+          lineTb = modify_xlc_linenos (lv);
+
 	  /* Line numbers are not necessarily ordered.  xlc compilation will
 	     put static function to the end.  */

-	  lineTb = arrange_linetable (lv);
+	  lineTb = arrange_linetable (lineTb);

 	  push_subfile ();

---


^ permalink raw reply	[flat|nested] 12+ messages in thread
* [PATCH 2/5] powerpc64-aix processing xlC generated line table
@ 2013-07-29  6:15 Raunaq 12
  2013-07-29 16:58 ` Pedro Alves
  0 siblings, 1 reply; 12+ messages in thread
From: Raunaq 12 @ 2013-07-29  6:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: tromey, Mark Kettenis


powerpc-ibm-aix: Fix line number handling for xlc compiled binaries.

xlc compiled binaries have a line table which is different from gcc
compiled ones.
It does not contain 1 extra entry which indicates the function start PC.

Because of this, listing functions, eg: 'list main' or
breaking at functions, eg: 'break function1' give wrong line numbers.

To fix this, we check if the function entry point has an entry in the
line table (in case of gcc, it does). If it does not have this entry, then
we retain
the function entry lines marked as line number equal to 0 and assign the
line number
equal to the succeeding line table entry.
---

ChangeLog :-
* xcoffread.c (process_linenos): Add fix to correctly process linenos in
case of xlc compiled binaries.

---
Index: ./gdb/xcoffread.c
===================================================================
--- ./gdb.orig/xcoffread.c
+++ ./gdb/xcoffread.c
@@ -602,7 +602,7 @@
 static void
 process_linenos (CORE_ADDR start, CORE_ADDR end)
 {
-  int offset, ii;
+ int offset, ii, jj;
   file_ptr max_offset
     = XCOFF_DATA (this_symtab_objfile)->max_lineno_offset;

@@ -698,10 +698,24 @@

       lv = main_subfile.line_vector;

+      /* xlc compiled binaries have one less entry in the line table.
+         So the function entry lines marked as line number equal to 0
+         will be retained in the line table with line numbers equal
+         to its succeeding line table entry. */
+
+      lineTb = lv;
+
+      for (jj = 0; jj < lineTb->nitems; jj++)
+        {
+          if (lineTb->item[jj].line == 0 && (lineTb->item[jj].pc
+			             != lineTb->item[jj + 1].pc))
+                    lineTb->item[jj].line = lineTb->item[jj + 1].line;
+        }
+
       /* Line numbers are not necessarily ordered.  xlc compilation will
          put static function to the end.  */

-      lineTb = arrange_linetable (lv);
+     lineTb = arrange_linetable (lineTb);
       if (lv == lineTb)
        {
          current_subfile->line_vector = (struct linetable *)
@@ -730,10 +744,24 @@

          lv = (inclTable[ii].subfile)->line_vector;

+          /* xlc compiled binaries have one less entry in the line table.
+             So the function entry lines marked as line number equal to 0
+             will be retained in the line table with line numbers equal
+             to its succeeding line table entry. */
+
+          lineTb = lv;
+
+          for (jj = 0; jj < lineTb->nitems; jj++)
+            {
+              if (lineTb->item[jj].line == 0 && (lineTb->item[jj].pc
+				 != lineTb->item[jj + 1].pc))
+                    lineTb->item[jj].line = lineTb->item[jj + 1].line;
+            }
+
          /* Line numbers are not necessarily ordered.  xlc compilation
will
             put static function to the end.  */

-         lineTb = arrange_linetable (lv);
+        lineTb = arrange_linetable (lineTb);

          push_subfile ();

---


^ permalink raw reply	[flat|nested] 12+ messages in thread
* [PATCH 2/5] powerpc64-aix processing xlC generated line table
@ 2013-07-24 12:37 Raunaq 12
  0 siblings, 0 replies; 12+ messages in thread
From: Raunaq 12 @ 2013-07-24 12:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: tromey


powerpc-ibm-aix: Fix line number handling for xlc compiled binaries.

xlc compiled binaries have a line table which is different from gcc
compiled ones.
It does not contain 1 extra entry which indicates the function start PC.

Because of this, listing functions, eg: 'list main' or
breaking at functions, eg: 'break function1' give wrong line numbers.

To fix this, we check if the function entry point has an entry in the
line table (in case of gcc, it does). If it does not have this entry, then
we retain
the function entry lines marked as line number equal to 0 and assign the
line number
equal to the succeeding line table entry.
---

ChangeLog :-
* xcoffread.c (process_linenos): Add fix to correctly process linenos in
case of xlc compiled binaries.

---
Index: ./gdb/xcoffread.c
===================================================================
--- ./gdb.orig/xcoffread.c
+++ ./gdb/xcoffread.c
@@ -602,7 +602,7 @@
 static void
 process_linenos (CORE_ADDR start, CORE_ADDR end)
 {
-  int offset, ii;
+ int offset, ii, jj;
   file_ptr max_offset
     = XCOFF_DATA (this_symtab_objfile)->max_lineno_offset;

@@ -698,10 +698,24 @@

       lv = main_subfile.line_vector;

+      /* xlc compiled binaries have one less entry in the line table.
+         So the function entry lines marked as line number equal to 0
+         will be retained in the line table with line numbers equal
+         to its succeeding line table entry. */
+
+      lineTb = lv;
+
+      for (jj = 0; jj < lineTb->nitems; jj++)
+        {
+          if (lineTb->item[jj].line == 0 && (lineTb->item[jj].pc
+			             != lineTb->item[jj + 1].pc))
+                    lineTb->item[jj].line = lineTb->item[jj + 1].line;
+        }
+
       /* Line numbers are not necessarily ordered.  xlc compilation will
          put static function to the end.  */

-      lineTb = arrange_linetable (lv);
+     lineTb = arrange_linetable (lineTb);
       if (lv == lineTb)
        {
          current_subfile->line_vector = (struct linetable *)
@@ -730,10 +744,24 @@

          lv = (inclTable[ii].subfile)->line_vector;

+          /* xlc compiled binaries have one less entry in the line table.
+             So the function entry lines marked as line number equal to 0
+             will be retained in the line table with line numbers equal
+             to its succeeding line table entry. */
+
+          lineTb = lv;
+
+          for (jj = 0; jj < lineTb->nitems; jj++)
+            {
+              if (lineTb->item[jj].line == 0 && (lineTb->item[jj].pc
+				 != lineTb->item[jj + 1].pc))
+                    lineTb->item[jj].line = lineTb->item[jj + 1].line;
+            }
+
          /* Line numbers are not necessarily ordered.  xlc compilation
will
             put static function to the end.  */

-         lineTb = arrange_linetable (lv);
+        lineTb = arrange_linetable (lineTb);

          push_subfile ();

---


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-08-26 15:30 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <OF1EDEDB55.9DF54135-ON65257BBA.003B42B8-65257BBA.003D0F4D@LocalDomain>
2013-08-07 11:37 ` [PATCH 2/5] powerpc64-aix processing xlC generated line table Raunaq 12
2013-08-07 15:23   ` Ulrich Weigand
2013-08-08 12:04     ` Raunaq 12
2013-08-08 22:01       ` Ulrich Weigand
2013-08-12  7:50         ` Raunaq 12
2013-08-26 15:30           ` Ulrich Weigand
2013-08-01 11:07 Raunaq 12
  -- strict thread matches above, loose matches on Subject: below --
2013-07-29  6:15 Raunaq 12
2013-07-29 16:58 ` Pedro Alves
2013-07-31  9:57   ` Raunaq 12
     [not found]   ` <OF668B9A7A.5414653D-ON65257BB9.00351B5A-65257BB9.003675D7@LocalDomain>
2013-07-31 10:03     ` Raunaq 12
2013-07-24 12:37 Raunaq 12

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox