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]

[commit/xcoffread] unexpected breakpoint choice on AIX


Hello,

This is a change that Jerome Guitton made a while back in our tree,
and we forgot to contribute. The upside is that it means that it got
field-tested for over a year :).

Here is Jerome's description of the problem, as he filed it in our
tracking system:

> In the testcase of the customer, we have a package Pack, which
> instanciate a generic function defined in a package Gen. So the line
> numbers generated for this package look like:
> 
> ----------------------------------------------------------------
> .file   "pack.adb"
> 
> [...] # code generated from Pack
> 
> .bi     "gen.adb"
> .bf     3
> .line   1
> 
> [...] #code from Gen
> 
> .ei     "gen.adb"
> .bi     "pack.adb"
> .line 17
> 
> [...] #some code from Pack
> [...] #(basically some code expansion from the gen instanciation)
> 
> .ei     "pack.adb"
> .bi     "gen.adb"
> .line   5
> 
> [...]
> ----------------------------------------------------------------
> 
> So, what does it mean? Well, this debug format have support for C include
> files. The corresping assembler directive are:
> .bi <name>: beginning of the include file named "name"
> .ei <name>: end of this include file
> 
> .line are used to associate a set of instruction to a line number. So
> far, so good. The use of these directive is reasonable in our case
> (generic instantiation).
> 
> Now, the problem is that GDB supposes that these .bi/.ei does not
> refer to the current file (that is to say pack.adb). It would not make
> much sense in C (why would anyone #include a file into itself?)... but
> in our Ada case this supposition is not valid anymore.
> 
> Because of this supposition, GDB ends up with two file named "pack.adb"
> in its symbol table, the second one containing all the .bi/.ei line
> entries...

2009-03-12  Jerome Guitton  <guitton@adacore.com>

        * xcoffread.c (process_linenos): Check if the line in the
        include table refers to the main source file and, if so,
        add them to the main subfile.

Checked in.

-- 
Joel
Index: xcoffread.c
===================================================================
RCS file: /cvs/src/src/gdb/xcoffread.c,v
retrieving revision 1.66
diff -u -p -r1.66 xcoffread.c
--- xcoffread.c	22 Feb 2009 01:02:20 -0000	1.66
+++ xcoffread.c	12 Mar 2009 17:54:19 -0000
@@ -600,17 +600,32 @@ process_linenos (CORE_ADDR start, CORE_A
 		 start, 0, &main_source_baseline);
 	    }
 
-	  /* Have a new subfile for the include file.  */
+	  if (strcmp (inclTable[ii].name, last_source_file) == 0)
+	    {
+              /* The entry in the include table refers to the main source
+                 file. Add the lines to the main subfile.  */
 
-	  tmpSubfile = inclTable[ii].subfile =
-	    (struct subfile *) xmalloc (sizeof (struct subfile));
+	      main_source_baseline = inclTable[ii].funStartLine;
+	      enter_line_range
+		(&main_subfile, inclTable[ii].begin, inclTable[ii].end,
+		 start, 0, &main_source_baseline);
+	      inclTable[ii].subfile = &main_subfile;
+	    }
+	  else
+	    {
 
-	  memset (tmpSubfile, '\0', sizeof (struct subfile));
-	  firstLine = &(inclTable[ii].funStartLine);
+	      /* Have a new subfile for the include file.  */
 
-	  /* Enter include file's lines now.  */
-	  enter_line_range (tmpSubfile, inclTable[ii].begin,
-			    inclTable[ii].end, start, 0, firstLine);
+	      tmpSubfile = inclTable[ii].subfile =
+		(struct subfile *) xmalloc (sizeof (struct subfile));
+
+	      memset (tmpSubfile, '\0', sizeof (struct subfile));
+	      firstLine = &(inclTable[ii].funStartLine);
+
+	      /* Enter include file's lines now.  */
+	      enter_line_range (tmpSubfile, inclTable[ii].begin,
+				inclTable[ii].end, start, 0, firstLine);
+	    }
 
 	  if (offset <= inclTable[ii].end)
 	    offset = inclTable[ii].end + linesz;
@@ -656,7 +671,8 @@ process_linenos (CORE_ADDR start, CORE_A
 
   for (ii = 0; ii < inclIndx; ++ii)
     {
-      if ((inclTable[ii].subfile)->line_vector)		/* Useless if!!! FIXMEmgo */
+      if (inclTable[ii].subfile != ((struct subfile *) &main_subfile)
+          && (inclTable[ii].subfile)->line_vector)		/* Useless if!!! FIXMEmgo */
 	{
 	  struct linetable *lineTb, *lv;
 

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