Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Fix breakpoints when several source files have the same name
@ 2009-10-01 21:05 Sébastien Granjoux
  2009-10-01 21:45 ` Joel Brobecker
  0 siblings, 1 reply; 13+ messages in thread
From: Sébastien Granjoux @ 2009-10-01 21:05 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 516 bytes --]

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

[-- Attachment #2: ChangeLog.txt --]
[-- Type: text/plain, Size: 155 bytes --]

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

[-- Attachment #3: fix_multiple_breakpoint.patch --]
[-- Type: text/x-patch, Size: 2526 bytes --]

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

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

* Re: Fix breakpoints when several source files have the same name
  2009-10-01 21:05 Fix breakpoints when several source files have the same name Sébastien Granjoux
@ 2009-10-01 21:45 ` Joel Brobecker
  2009-10-02 20:28   ` Sébastien Granjoux
  0 siblings, 1 reply; 13+ messages in thread
From: Joel Brobecker @ 2009-10-01 21:45 UTC (permalink / raw)
  To: S?bastien Granjoux; +Cc: gdb-patches

Sebastien,

Do you have a copyright assignment on file with the FSF? I cannot
seem to be able to find you in our records, at least not by using
your name. If you don't, then I am afraid that we cannot accept this
contribution until you do. This is a bit of a lengthy process, so
let me know if you need the request forms.

> 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

Overall, this looks OK to me (good catch on the FILENAME_CMP!).
I just have a few comments, little nits:

> +      /* Get symbol full file name if possible */

All comments should be full sentences, meaning that they should start
with capital letter, and end with a period.  The period should also
be followed by 2 spaces, so:

  /* Get symbol full file name if possible.  */

> +	if ((symtab->fullname != NULL)
> +	    && (symtab_to_fullname (s) != NULL)
> +	    && (FILENAME_CMP (symtab->fullname, s->fullname) != 0))

You have unecessary parenthesis, and we avoid that in GDB (we find
that this makes the code harder to read - if only because it uses
a different style than usual).

	if (symtab->fullname != NULL
	    && symtab_to_fullname (s) != NULL
	    && FILENAME_CMP (symtab->fullname, s->fullname) != 0)

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

The function comment needs to be updated. Can you also put all first
3 arguments on the same line. The line break is unnecessary.

> +	  if ((fullname != NULL)
> +	      && (symtab_to_fullname (symtab) != NULL)
> +    	      && (FILENAME_CMP (fullname, symtab->fullname) != 0))
> +    	    continue;		  

Same as above with the extra parens.


-- 
Joel


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

* Re: Fix breakpoints when several source files have the same name
  2009-10-01 21:45 ` Joel Brobecker
@ 2009-10-02 20:28   ` Sébastien Granjoux
  0 siblings, 0 replies; 13+ messages in thread
From: Sébastien Granjoux @ 2009-10-02 20:28 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

Hi Joel,

Joel Brobecker a écrit :
> Do you have a copyright assignment on file with the FSF?

No.

> I cannot
> seem to be able to find you in our records, at least not by using
> your name. If you don't, then I am afraid that we cannot accept this
> contribution until you do. This is a bit of a lengthy process, so
> let me know if you need the request forms.

Then I need it, please send me the form.

> All comments should....

Ok, thanks for your detailed review, I will fix all this.

Regards,

Sébastien


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

* Re: Fix breakpoints when several source files have the same name
  2009-11-09 22:05     ` Joel Brobecker
@ 2009-11-10 18:46       ` Sébastien Granjoux
  0 siblings, 0 replies; 13+ messages in thread
From: Sébastien Granjoux @ 2009-11-10 18:46 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

Hi Joel,

Joel Brobecker a écrit :
> I have now checked that patch in for you.  Just one tiny little nit
> that I corrected: 2 spaces before your email address.

Thank you.

> You are now eligible for "Write After Approval". See gdb/MAINTAINERS
> for more details.  If you think you'll be contributing more patches
> to GDB, it would be a good idea for you to have write access to the GDB
> repository.  Let me know if this is something you're interested in.

I don't think I will write more patches for the moment. I'm working on 
another project but I have planned to go back to the gdb front end so 
perhaps next year.

Regards,

Sébastien


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

* Re: Fix breakpoints when several source files have the same name
  2009-11-09 21:38   ` Sébastien Granjoux
@ 2009-11-09 22:05     ` Joel Brobecker
  2009-11-10 18:46       ` Sébastien Granjoux
  0 siblings, 1 reply; 13+ messages in thread
From: Joel Brobecker @ 2009-11-09 22:05 UTC (permalink / raw)
  To: S?bastien Granjoux; +Cc: gdb-patches

> 2009-11-09  Sebastien Granjoux <seb.sfo@free.fr>
> 
> 	PR mi/9583:
> 	* symtab.c (find_line_symtab, append_exact_match_to_sals)
> 	(expand_line_sal): Use full filename when setting breakpoints if
> 	available

I have now checked that patch in for you.  Just one tiny little nit
that I corrected: 2 spaces before your email address.

You are now eligible for "Write After Approval". See gdb/MAINTAINERS
for more details.  If you think you'll be contributing more patches
to GDB, it would be a good idea for you to have write access to the GDB
repository.  Let me know if this is something you're interested in.

-- 
Joel


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

* Re: Fix breakpoints when several source files have the same name
  2009-11-09 21:09 ` Joel Brobecker
@ 2009-11-09 21:38   ` Sébastien Granjoux
  2009-11-09 22:05     ` Joel Brobecker
  0 siblings, 1 reply; 13+ messages in thread
From: Sébastien Granjoux @ 2009-11-09 21:38 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 621 bytes --]

Hi Joel,

Joel Brobecker a écrit :
> Would you mind sending unified diffs, next time.  There seems to be
> a preference of unified diffs over context diffs.

No, problem.


> Periods need to be followed by 2 spaces (GNU Coding Standards). I realize
> that the text you started with had the problem too!  Also, I believe there
> is a typo "symbol has no full name" -> "symtab has no full name"?

I have fixed all this in the attached patch.


> Pre-approved with the changes above.  Have your assignment request
> come through, yet?

Yes, I have received the confirmation a week ago.

Thanks for your review.

Sébastien

[-- Attachment #2: ChangeLog.txt --]
[-- Type: text/plain, Size: 200 bytes --]

2009-11-09  Sebastien Granjoux <seb.sfo@free.fr>

	PR mi/9583:
	* symtab.c (find_line_symtab, append_exact_match_to_sals)
	(expand_line_sal): Use full filename when setting breakpoints if
	available


[-- Attachment #3: fix_multiple_breakpoint4.path --]
[-- Type: text/plain, Size: 3358 bytes --]

Index: gdb/symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.216
diff -U3 -r1.216 symtab.c
--- gdb/symtab.c	19 Oct 2009 09:51:42 -0000	1.216
+++ gdb/symtab.c	9 Nov 2009 21:29:00 -0000
@@ -2416,18 +2416,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)
@@ -4591,12 +4598,14 @@
 }
 
 /* Helper to expand_line_sal below.  Search in the symtabs for any
-   linetable entry that exactly matches FILENAME and LINENO and append
-   them to RET. If there is at least one match, return 1; otherwise,
-   return 0, and return the best choice in BEST_ITEM and BEST_SYMTAB.  */
+   linetable entry that exactly matches FULLNAME and LINENO and append
+   them to RET.  If FULLNAME is NULL or if a symtab has no full name,
+   use FILENAME and LINENO instead.  If there is at least one match,
+   return 1; otherwise, 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)
@@ -4612,10 +4621,14 @@
   ALL_PSPACES (pspace)
     ALL_PSPACE_SYMTABS (pspace, 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;
@@ -4700,7 +4713,7 @@
       ALL_PSPACES (pspace)
 	ALL_PSPACE_PSYMTABS (pspace, objfile, psymtab)
 	{
-	  if (strcmp (match_filename, psymtab->filename) == 0)
+	  if (FILENAME_CMP (match_filename, psymtab->filename) == 0)
 	    {
 	      set_current_program_space (pspace);
 
@@ -4712,10 +4725,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 (match_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);
     }
 

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

* Re: Fix breakpoints when several source files have the same name
  2009-11-09 20:31 Sébastien Granjoux
@ 2009-11-09 21:09 ` Joel Brobecker
  2009-11-09 21:38   ` Sébastien Granjoux
  0 siblings, 1 reply; 13+ messages in thread
From: Joel Brobecker @ 2009-11-09 21:09 UTC (permalink / raw)
  To: S?bastien Granjoux; +Cc: gdb-patches

Sebastien,

Would you mind sending unified diffs, next time.  There seems to be
a preference of unified diffs over context diffs.  (thank you!)

2009-10-29  Sebastien Granjoux <seb.sfo@free.fr>

	PR mi/9583:
	* symtab.c (find_line_symtab, append_exact_match_to_sals)
	(expand_line_sal): Use full filename when setting breakpoints if
	available

This is OK with one minor comment:

>   /* Helper to expand_line_sal below.  Search in the symtabs for any
> !    linetable entry that exactly matches FILENAME and LINENO and append
> !    them to RET. If there is at least one match, return 1; otherwise,
> !    return 0, and return the best choice in BEST_ITEM and BEST_SYMTAB.  */
>   
>   static int
> ! append_exact_match_to_sals (char *filename, int lineno,
>   			    struct symtabs_and_lines *ret,
>   			    struct linetable_entry **best_item,
>   			    struct symtab **best_symtab)
> --- 4598,4611 ----
>   }
>   
>   /* Helper to expand_line_sal below.  Search in the symtabs for any
> !    linetable entry that exactly matches FULLNAME and LINENO and append
> !    them to RET. If FULLNAME is NULL or if a symbol has no full name,
> !    use FILENAME and LINENO instead. If there is at least one match,
> !    return 1; otherwise, return 0, and return the best choice in BEST_ITEM
> !    and BEST_SYMTAB.  */

Periods need to be followed by 2 spaces (GNU Coding Standards). I realize
that the text you started with had the problem too!  Also, I believe there
is a typo "symbol has no full name" -> "symtab has no full name"?

Pre-approved with the changes above.  Have your assignment request
come through, yet?

-- 
Joel


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

* Re: Fix breakpoints when several source files have the same name
@ 2009-11-09 20:31 Sébastien Granjoux
  2009-11-09 21:09 ` Joel Brobecker
  0 siblings, 1 reply; 13+ messages in thread
From: Sébastien Granjoux @ 2009-11-09 20:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Joel Brobecker

[-- Attachment #1: Type: text/plain, Size: 101 bytes --]

Hi,

I have sent an updated patch to fix bug 9583, it is waiting for a review.

Regards,

Sébastien

[-- Attachment #2: fix_multiple_breakpoint3.path --]
[-- Type: text/plain, Size: 6319 bytes --]

? .deps
? .gdbinit
? Makefile
? ada-exp.c
? ada-lex.c
? c-exp.c
? config.cache
? config.h
? config.log
? config.status
? cp-name-parser.c
? f-exp.c
? gdb
? gdbtui
? init.c
? jv-exp.c
? m2-exp.c
? objc-exp.c
? observer.h
? observer.inc
? p-exp.c
? stamp-h
? stamp-h1
? stamp-xml
? toto
? toto2
? version.c
? xml-builtin.c
? doc/Makefile
? doc/config.log
? doc/config.status
? gdbserver/Makefile
? gdbserver/config.h
? gdbserver/config.log
? gdbserver/config.status
? gdbserver/gdbreplay
? gdbserver/gdbserver
? gdbserver/reg-i386-linux.c
? gdbserver/stamp-h
? gdbserver/version.c
? gnulib/.deps
? gnulib/Makefile
? gnulib/string.h
? testsuite/Makefile
? testsuite/config.log
? testsuite/config.status
? testsuite/gdb.ada/Makefile
? testsuite/gdb.arch/Makefile
? testsuite/gdb.asm/Makefile
? testsuite/gdb.base/Makefile
? testsuite/gdb.cp/Makefile
? testsuite/gdb.disasm/Makefile
? testsuite/gdb.dwarf2/Makefile
? testsuite/gdb.fortran/Makefile
? testsuite/gdb.java/Makefile
? testsuite/gdb.mi/Makefile
? testsuite/gdb.modula2/Makefile
? testsuite/gdb.objc/Makefile
? testsuite/gdb.opt/Makefile
? testsuite/gdb.pascal/Makefile
? testsuite/gdb.python/Makefile
? testsuite/gdb.reverse/Makefile
? testsuite/gdb.server/Makefile
? testsuite/gdb.stabs/Makefile
? testsuite/gdb.stabs/config.log
? testsuite/gdb.stabs/config.status
? testsuite/gdb.threads/Makefile
? testsuite/gdb.trace/Makefile
? testsuite/gdb.xml/Makefile
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.216
diff -c -p -r1.216 symtab.c
*** symtab.c	19 Oct 2009 09:51:42 -0000	1.216
--- symtab.c	29 Oct 2009 21:39:30 -0000
*************** find_line_symtab (struct symtab *symtab,
*** 2416,2433 ****
  
        ALL_PSYMTABS (objfile, p)
        {
!         if (strcmp (symtab->filename, p->filename) != 0)
            continue;
          PSYMTAB_TO_SYMTAB (p);
        }
  
        ALL_SYMTABS (objfile, s)
        {
  	struct linetable *l;
  	int ind;
  
! 	if (strcmp (symtab->filename, s->filename) != 0)
  	  continue;
  	l = LINETABLE (s);
  	ind = find_line_common (l, line, &exact);
  	if (ind >= 0)
--- 2416,2440 ----
  
        ALL_PSYMTABS (objfile, p)
        {
!         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 (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)
*************** append_expanded_sal (struct symtabs_and_
*** 4591,4602 ****
  }
  
  /* Helper to expand_line_sal below.  Search in the symtabs for any
!    linetable entry that exactly matches FILENAME and LINENO and append
!    them to RET. If there is at least one match, return 1; otherwise,
!    return 0, and return the best choice in BEST_ITEM and BEST_SYMTAB.  */
  
  static int
! append_exact_match_to_sals (char *filename, int lineno,
  			    struct symtabs_and_lines *ret,
  			    struct linetable_entry **best_item,
  			    struct symtab **best_symtab)
--- 4598,4611 ----
  }
  
  /* Helper to expand_line_sal below.  Search in the symtabs for any
!    linetable entry that exactly matches FULLNAME and LINENO and append
!    them to RET. If FULLNAME is NULL or if a symbol has no full name,
!    use FILENAME and LINENO instead. If there is at least one match,
!    return 1; otherwise, return 0, and return the best choice in BEST_ITEM
!    and BEST_SYMTAB.  */
  
  static int
! 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)
*************** append_exact_match_to_sals (char *filena
*** 4612,4621 ****
    ALL_PSPACES (pspace)
      ALL_PSPACE_SYMTABS (pspace, objfile, symtab)
      {
!       if (strcmp (filename, symtab->filename) == 0)
  	{
  	  struct linetable *l;
  	  int len;
  	  l = LINETABLE (symtab);
  	  if (!l)
  	    continue;
--- 4621,4634 ----
    ALL_PSPACES (pspace)
      ALL_PSPACE_SYMTABS (pspace, objfile, symtab)
      {
!       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;
*************** expand_line_sal (struct symtab_and_line 
*** 4700,4706 ****
        ALL_PSPACES (pspace)
  	ALL_PSPACE_PSYMTABS (pspace, objfile, psymtab)
  	{
! 	  if (strcmp (match_filename, psymtab->filename) == 0)
  	    {
  	      set_current_program_space (pspace);
  
--- 4713,4719 ----
        ALL_PSPACES (pspace)
  	ALL_PSPACE_PSYMTABS (pspace, objfile, psymtab)
  	{
! 	  if (FILENAME_CMP (match_filename, psymtab->filename) == 0)
  	    {
  	      set_current_program_space (pspace);
  
*************** expand_line_sal (struct symtab_and_line 
*** 4712,4721 ****
        /* 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 (match_filename, lineno,
  					  &ret, &best_item, &best_symtab);
        if (!exact && best_item)
! 	append_exact_match_to_sals (best_symtab->filename, best_item->line,
  				    &ret, &best_item, &best_symtab);
      }
  
--- 4725,4737 ----
        /* Now search the symtab for exact matches and append them.  If
  	 none is found, append the best_item and all its exact
  	 matches.  */
!       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_symtab->fullname, best_item->line,
  				    &ret, &best_item, &best_symtab);
      }
  


[-- Attachment #3: ChangeLog.txt --]
[-- Type: text/plain, Size: 200 bytes --]

2009-10-29  Sebastien Granjoux <seb.sfo@free.fr>

	PR mi/9583:
	* symtab.c (find_line_symtab, append_exact_match_to_sals)
	(expand_line_sal): Use full filename when setting breakpoints if
	available


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

* Re: Fix breakpoints when several source files have the same name
@ 2009-10-29 21:55 Sébastien Granjoux
  0 siblings, 0 replies; 13+ messages in thread
From: Sébastien Granjoux @ 2009-10-29 21:55 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 481 bytes --]

Hi,

I have updated my patch to fix a bug which appears 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 updated my fix to work on the latest development version, the 
code has changed a bit. I have signed a copyright assignment with the 
FSF for gdb.

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

Regards,

Sébastien

[-- Attachment #2: fix_multiple_breakpoint3.path --]
[-- Type: text/plain, Size: 6318 bytes --]

? .deps
? .gdbinit
? Makefile
? ada-exp.c
? ada-lex.c
? c-exp.c
? config.cache
? config.h
? config.log
? config.status
? cp-name-parser.c
? f-exp.c
? gdb
? gdbtui
? init.c
? jv-exp.c
? m2-exp.c
? objc-exp.c
? observer.h
? observer.inc
? p-exp.c
? stamp-h
? stamp-h1
? stamp-xml
? toto
? toto2
? version.c
? xml-builtin.c
? doc/Makefile
? doc/config.log
? doc/config.status
? gdbserver/Makefile
? gdbserver/config.h
? gdbserver/config.log
? gdbserver/config.status
? gdbserver/gdbreplay
? gdbserver/gdbserver
? gdbserver/reg-i386-linux.c
? gdbserver/stamp-h
? gdbserver/version.c
? gnulib/.deps
? gnulib/Makefile
? gnulib/string.h
? testsuite/Makefile
? testsuite/config.log
? testsuite/config.status
? testsuite/gdb.ada/Makefile
? testsuite/gdb.arch/Makefile
? testsuite/gdb.asm/Makefile
? testsuite/gdb.base/Makefile
? testsuite/gdb.cp/Makefile
? testsuite/gdb.disasm/Makefile
? testsuite/gdb.dwarf2/Makefile
? testsuite/gdb.fortran/Makefile
? testsuite/gdb.java/Makefile
? testsuite/gdb.mi/Makefile
? testsuite/gdb.modula2/Makefile
? testsuite/gdb.objc/Makefile
? testsuite/gdb.opt/Makefile
? testsuite/gdb.pascal/Makefile
? testsuite/gdb.python/Makefile
? testsuite/gdb.reverse/Makefile
? testsuite/gdb.server/Makefile
? testsuite/gdb.stabs/Makefile
? testsuite/gdb.stabs/config.log
? testsuite/gdb.stabs/config.status
? testsuite/gdb.threads/Makefile
? testsuite/gdb.trace/Makefile
? testsuite/gdb.xml/Makefile
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.216
diff -c -p -r1.216 symtab.c
*** symtab.c	19 Oct 2009 09:51:42 -0000	1.216
--- symtab.c	29 Oct 2009 21:39:30 -0000
*************** find_line_symtab (struct symtab *symtab,
*** 2416,2433 ****
  
        ALL_PSYMTABS (objfile, p)
        {
!         if (strcmp (symtab->filename, p->filename) != 0)
            continue;
          PSYMTAB_TO_SYMTAB (p);
        }
  
        ALL_SYMTABS (objfile, s)
        {
  	struct linetable *l;
  	int ind;
  
! 	if (strcmp (symtab->filename, s->filename) != 0)
  	  continue;
  	l = LINETABLE (s);
  	ind = find_line_common (l, line, &exact);
  	if (ind >= 0)
--- 2416,2440 ----
  
        ALL_PSYMTABS (objfile, p)
        {
!         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 (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)
*************** append_expanded_sal (struct symtabs_and_
*** 4591,4602 ****
  }
  
  /* Helper to expand_line_sal below.  Search in the symtabs for any
!    linetable entry that exactly matches FILENAME and LINENO and append
!    them to RET. If there is at least one match, return 1; otherwise,
!    return 0, and return the best choice in BEST_ITEM and BEST_SYMTAB.  */
  
  static int
! append_exact_match_to_sals (char *filename, int lineno,
  			    struct symtabs_and_lines *ret,
  			    struct linetable_entry **best_item,
  			    struct symtab **best_symtab)
--- 4598,4611 ----
  }
  
  /* Helper to expand_line_sal below.  Search in the symtabs for any
!    linetable entry that exactly matches FULLNAME and LINENO and append
!    them to RET. If FULLNAME is NULL or if a symbol has no full name,
!    use FILENAME and LINENO instead. If there is at least one match,
!    return 1; otherwise, return 0, and return the best choice in BEST_ITEM
!    and BEST_SYMTAB.  */
  
  static int
! 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)
*************** append_exact_match_to_sals (char *filena
*** 4612,4621 ****
    ALL_PSPACES (pspace)
      ALL_PSPACE_SYMTABS (pspace, objfile, symtab)
      {
!       if (strcmp (filename, symtab->filename) == 0)
  	{
  	  struct linetable *l;
  	  int len;
  	  l = LINETABLE (symtab);
  	  if (!l)
  	    continue;
--- 4621,4634 ----
    ALL_PSPACES (pspace)
      ALL_PSPACE_SYMTABS (pspace, objfile, symtab)
      {
!       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;
*************** expand_line_sal (struct symtab_and_line 
*** 4700,4706 ****
        ALL_PSPACES (pspace)
  	ALL_PSPACE_PSYMTABS (pspace, objfile, psymtab)
  	{
! 	  if (strcmp (match_filename, psymtab->filename) == 0)
  	    {
  	      set_current_program_space (pspace);
  
--- 4713,4719 ----
        ALL_PSPACES (pspace)
  	ALL_PSPACE_PSYMTABS (pspace, objfile, psymtab)
  	{
! 	  if (FILENAME_CMP (match_filename, psymtab->filename) == 0)
  	    {
  	      set_current_program_space (pspace);
  
*************** expand_line_sal (struct symtab_and_line 
*** 4712,4721 ****
        /* 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 (match_filename, lineno,
  					  &ret, &best_item, &best_symtab);
        if (!exact && best_item)
! 	append_exact_match_to_sals (best_symtab->filename, best_item->line,
  				    &ret, &best_item, &best_symtab);
      }
  
--- 4725,4737 ----
        /* Now search the symtab for exact matches and append them.  If
  	 none is found, append the best_item and all its exact
  	 matches.  */
!       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_symtab->fullname, best_item->line,
  				    &ret, &best_item, &best_symtab);
      }
  

[-- Attachment #3: ChangeLog.txt --]
[-- Type: text/plain, Size: 199 bytes --]

2009-10-29  Sebastien Granjoux <seb.sfo@free.fr>

	PR mi/9583:
	* symtab.c (find_line_symtab, append_exact_match_to_sals)
	(expand_line_sal): Use full filename when setting breakpoints if
	available

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

* Re: Fix breakpoints when several source files have the same name
  2009-09-30 18:53   ` Sébastien Granjoux
@ 2009-09-30 19:07     ` Jan Kratochvil
  0 siblings, 0 replies; 13+ messages in thread
From: Jan Kratochvil @ 2009-09-30 19:07 UTC (permalink / raw)
  To: Sébastien Granjoux; +Cc: Joel Brobecker, gdb-patches

On Wed, 30 Sep 2009 20:53:27 +0200, Sébastien Granjoux wrote:
> That's fine for me but months ago I get an email offlist from Jan
> Kratochvil who has fixed this bug with another patch.
[...]
> Anyway, I would really like to get this bug fixed, so if you think
> it's ok, I can update my own patch.

yes, some fix of your would be great, not sure when I can get to the patch of
mine.  I can later rebase it on yours.


Thanks,
Jan


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

* Re: Fix breakpoints when several source files have the same name
  2009-09-29 22:20 ` Joel Brobecker
@ 2009-09-30 18:53   ` Sébastien Granjoux
  2009-09-30 19:07     ` Jan Kratochvil
  0 siblings, 1 reply; 13+ messages in thread
From: Sébastien Granjoux @ 2009-09-30 18:53 UTC (permalink / raw)
  To: Joel Brobecker, Jan Kratochvil; +Cc: gdb-patches

Hi Joel,

Joel Brobecker a écrit :
> Really really sorry for taking so long before reviewing this patch.
> Please don't hesitate to send pings on the list to remind us of a patch
> that is sitting unreviewed for more than a week or two.

Ok, I haven't been very pushy on this patch neither but I'm really glad 
to make some progress on it as it is still a problem with no real work 
around.

> How about changing the patch to only do the fullname matching iff
> (if and only iff) the simple filename matches first.  In other words,
> compute the symtab/psymtab fullname only if the filename matches.

That's fine for me but months ago I get an email offlist from Jan 
Kratochvil who has fixed this bug with another patch.

I think his patch is better than mine. Instead of adding another 
particular case, he has rewritten some functions and add a test case. 
The drawback is that it is more difficult to be sure that there is no 
regression and I have understood that Jan wants to work a bit more or it.

Anyway, I would really like to get this bug fixed, so if you think it's 
ok, I can update my own patch.

Regards,

Sébastien


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

* Re: Fix breakpoints when several source files have the same name
  2009-05-24 10:49 Sébastien Granjoux
@ 2009-09-29 22:20 ` Joel Brobecker
  2009-09-30 18:53   ` Sébastien Granjoux
  0 siblings, 1 reply; 13+ messages in thread
From: Joel Brobecker @ 2009-09-29 22:20 UTC (permalink / raw)
  To: S?bastien Granjoux; +Cc: gdb-patches

Sebastien,

Really really sorry for taking so long before reviewing this patch.
Please don't hesitate to send pings on the list to remind us of a patch
that is sitting unreviewed for more than a week or two.

> There is in gdb 6.8 a new bug that makes breakpoints inserted at the  
> wrong place when a program has several files with the same base name (in  
> different directories).
[...]
> I have found it using the mi interface but it appears in the same way  
> with the other commands.

For the record, here is how I reproduced the issue on my side:
I have two small files a/foo.c and b/foo.c, each containing an empty
function called foo_a and foo_b (resp). Then a file main.c:

     extern void foo_a (void);
     extern void foo_b (void);
     
     int
     main (void)
     {
       foo_a ();
       foo_b ();
     
       return 0;
     }

To build, I did:

    % (cd a && gcc -c -g foo.c)
    % (cd b && gcc -c -g foo.c)
    % gcc -o main main.c a/foo.o b/foo.o

The important part here, is to compile both foo.c files from
within the directory where these files are located, at least
with GCC.

Trying to break on either location, using the filename's fullname,
results in 2 breakpoints being inserted instead of just one:

    (gdb) b /t.a/brobecke/ex/break/a/foo.c:3
    Breakpoint 1 at 0x400480: file foo.c, line 4. (2 locations)
    (gdb) b /t.a/brobecke/ex/break/b/foo.c:3
    Note: breakpoint 1 also set at pc 0x400480.
    Note: breakpoint 1 also set at pc 0x400478.
    Breakpoint 2 at 0x400480: file foo.c, line 4. (2 locations)

> 2009-05-24  Sebastien Granjoux <seb.sfo@free.fr>
> 
> 	PR mi/9583:
> 	* symtab.c (find_line_symtab): Use full filename if available

My concern with your approach is with performance: symtab_to_fullname
and psymtab_to_fullname are actually a bit expensive to call, as they
involve locating the file on the local host disk, taking into account
debugging info as well as the source path (see the "dir" command) and
then opening/closing that file if found.

How about changing the patch to only do the fullname matching iff
(if and only iff) the simple filename matches first.  In other words,
compute the symtab/psymtab fullname only if the filename matches.

-- 
Joel


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

* Fix breakpoints when several source files have the same name
@ 2009-05-24 10:49 Sébastien Granjoux
  2009-09-29 22:20 ` Joel Brobecker
  0 siblings, 1 reply; 13+ messages in thread
From: Sébastien Granjoux @ 2009-05-24 10:49 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 649 bytes --]

Hi All,

There is in gdb 6.8 a new bug that makes breakpoints inserted at the 
wrong place when a program has several files with the same base name (in 
different directories).

In some place, gdb checks only the base name of the file and so doesn't 
find the right place for the breakpoints.

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

I have found it using the mi interface but it appears in the same way 
with the other commands.


Here is a fix attached for this bug. It checks if a full name is 
available and if yes uses it instead of comparing only the base name.


Regards,

Sébastien


[-- Attachment #2: ChangeLog.txt --]
[-- Type: text/plain, Size: 126 bytes --]

2009-05-24  Sebastien Granjoux <seb.sfo@free.fr>

	PR mi/9583:
	* symtab.c (find_line_symtab): Use full filename if available

[-- Attachment #3: fix_9583.diff --]
[-- Type: text/x-patch, Size: 1323 bytes --]

Index: gdb/symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.208
diff -u -r1.208 symtab.c
--- gdb/symtab.c	23 May 2009 10:11:42 -0000	1.208
+++ gdb/symtab.c	24 May 2009 10:24:13 -0000
@@ -2408,9 +2408,19 @@
       else
 	best = 0;
 
+      /* Get symbol full file name if possible */
+      symtab_to_fullname (symtab);
+
       ALL_PSYMTABS (objfile, p)
       {
-        if (strcmp (symtab->filename, p->filename) != 0)
+        const char *fullname;
+
+        if (symtab->fullname && (fullname = psymtab_to_fullname (p)))
+          {
+            if (FILENAME_CMP (symtab->fullname, fullname) != 0)
+              continue;
+          }
+        else if (FILENAME_CMP (symtab->filename, p->filename) != 0)
           continue;
         PSYMTAB_TO_SYMTAB (p);
       }
@@ -2419,8 +2429,14 @@
       {
 	struct linetable *l;
 	int ind;
+	const char *fullname;
 
-	if (strcmp (symtab->filename, s->filename) != 0)
+	if (symtab->fullname && (fullname = symtab_to_fullname (s)))
+	  {
+            if (FILENAME_CMP (symtab->fullname, fullname) != 0)
+              continue;
+          }
+       	else if (FILENAME_CMP (symtab->filename, s->filename) != 0)
 	  continue;
 	l = LINETABLE (s);
 	ind = find_line_common (l, line, &exact);

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

end of thread, other threads:[~2009-11-10 18:46 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-01 21:05 Fix breakpoints when several source files have the same name Sébastien Granjoux
2009-10-01 21:45 ` Joel Brobecker
2009-10-02 20:28   ` Sébastien Granjoux
  -- strict thread matches above, loose matches on Subject: below --
2009-11-09 20:31 Sébastien Granjoux
2009-11-09 21:09 ` Joel Brobecker
2009-11-09 21:38   ` Sébastien Granjoux
2009-11-09 22:05     ` Joel Brobecker
2009-11-10 18:46       ` Sébastien Granjoux
2009-10-29 21:55 Sébastien Granjoux
2009-05-24 10:49 Sébastien Granjoux
2009-09-29 22:20 ` Joel Brobecker
2009-09-30 18:53   ` Sébastien Granjoux
2009-09-30 19:07     ` Jan Kratochvil

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