This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/5] powerpc64-aix- Processing XLC generated line tables


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.

i.e,

if (lineTb->item[jj].line == 0 && (lineTb->item[jj].pc != lineTb->item[jj
+1].pc))
                    lineTb->item[jj].line = lineTb->item[jj+1].line;

--------------------

Index: ./gdb/xcoffread.c
===================================================================
--- ./gdb.orig/xcoffread.c
+++ ./gdb/xcoffread.c
@@ -605,7 +605,7 @@ static struct objfile *this_symtab_objfi
 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;

@@ -701,10 +701,23 @@ process_linenos (CORE_ADDR start, CORE_A

       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 *)
@@ -733,10 +746,23 @@ process_linenos (CORE_ADDR start, CORE_A

 	  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 ();



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]