This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 2/5] powerpc64-aix processing xlC generated line table
- From: Raunaq 12 <raunaq12 at in dot ibm dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: gdb-patches at sourceware dot org, Mark Kettenis <mark dot kettenis at xs4all dot nl>, tromey at redhat dot com
- Date: Wed, 31 Jul 2013 15:24:51 +0530
- Subject: Re: [PATCH 2/5] powerpc64-aix processing xlC generated line table
- References: <OF2681EF63 dot 7B9300E1-ON65257BB7 dot 002254BD-65257BB7 dot 00225FAB at in dot ibm dot com> <51F69F1E dot 40808 at redhat dot com>
> > + 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;
> > + }
>
> Seems to me this duplicate code could/should be factored out to a helper
> function.
Agreed. Implementation looks much cleaner after using a function for the
duplicate code. Here is the modified patch and changelog.
---
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.
---
Index: ./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 ();
---
this is ok?
Note :- without this patch we are not able to break into functions at the
entry
point and we are not able to list functions by their name. eg :- list main
Regards,
Raunaq