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]

Fix breakpoints when several source files have the same name


Hi All,

I have updated my patch to fix a bug in gdb 6.8 that makes breakpoints inserted at the wrong place when a program has several files with the same base name (in different directories).

I have checked my fix on the latest development version and updated it because the bug has moved a bit. Moreover I have reduced the number of calls of the symtab_to_fullname function as requested.

There is a bug report opened about this here:
http://sourceware.org/bugzilla/show_bug.cgi?id=9583

Regards,

Sébastien
2009-10-01  Sebastien Granjoux <seb.sfo@free.fr>

	PR mi/9583:
	* symtab.c (find_line_symtab, append_exact_match_to_sals):
	Use full filename if available
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.215
diff -U3 -r1.215 symtab.c
--- symtab.c	24 Aug 2009 22:00:55 -0000	1.215
+++ symtab.c	1 Oct 2009 20:42:07 -0000
@@ -2410,18 +2410,25 @@
 
       ALL_PSYMTABS (objfile, p)
       {
-        if (strcmp (symtab->filename, p->filename) != 0)
+        if (FILENAME_CMP (symtab->filename, p->filename) != 0)
           continue;
         PSYMTAB_TO_SYMTAB (p);
       }
 
+      /* Get symbol full file name if possible */
+      symtab_to_fullname (symtab);
+
       ALL_SYMTABS (objfile, s)
       {
 	struct linetable *l;
 	int ind;
 
-	if (strcmp (symtab->filename, s->filename) != 0)
+	if (FILENAME_CMP (symtab->filename, s->filename) != 0)
 	  continue;
+	if ((symtab->fullname != NULL)
+	    && (symtab_to_fullname (s) != NULL)
+	    && (FILENAME_CMP (symtab->fullname, s->fullname) != 0))
+	  continue;	
 	l = LINETABLE (s);
 	ind = find_line_common (l, line, &exact);
 	if (ind >= 0)
@@ -4581,7 +4588,8 @@
    return 0, and return the best choice in BEST_ITEM and BEST_SYMTAB.  */
 
 static int
-append_exact_match_to_sals (char *filename, int lineno,
+append_exact_match_to_sals (char *filename,
+			    char *fullname, int lineno,
 			    struct symtabs_and_lines *ret,
 			    struct linetable_entry **best_item,
 			    struct symtab **best_symtab)
@@ -4595,10 +4603,14 @@
   
   ALL_SYMTABS (objfile, symtab)
     {
-      if (strcmp (filename, symtab->filename) == 0)
+      if (FILENAME_CMP (filename, symtab->filename) == 0)
 	{
 	  struct linetable *l;
 	  int len;
+	  if ((fullname != NULL)
+	      && (symtab_to_fullname (symtab) != NULL)
+    	      && (FILENAME_CMP (fullname, symtab->fullname) != 0))
+    	    continue;		  
 	  l = LINETABLE (symtab);
 	  if (!l)
 	    continue;
@@ -4684,10 +4696,13 @@
       /* Now search the symtab for exact matches and append them.  If
 	 none is found, append the best_item and all its exact
 	 matches.  */
-      exact = append_exact_match_to_sals (sal.symtab->filename, lineno,
+      symtab_to_fullname (sal.symtab);
+      exact = append_exact_match_to_sals (sal.symtab->filename,
+					  sal.symtab->fullname, lineno,
 					  &ret, &best_item, &best_symtab);
       if (!exact && best_item)
-	append_exact_match_to_sals (best_symtab->filename, best_item->line,
+	append_exact_match_to_sals (best_symtab->filename,
+				    best_symtab->fullname, best_item->line,
 				    &ret, &best_item, &best_symtab);
     }
 

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