Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Test for GCC debug symbol bug
@ 2002-01-04 14:17 law
  2002-01-04 17:55 ` Daniel Jacobowitz
  0 siblings, 1 reply; 2+ messages in thread
From: law @ 2002-01-04 14:17 UTC (permalink / raw)
  To: gdb-patches


This patch adds a test for a GCC bug in its line number output.

Basically if we have a multi-line IF or WHILE conditional, GCC will
emit incorrect line numbers for the IF/WHILE statement.

The incorrect line numbers (of course) make debugging multi-line 
IF/WHILE statements a PITA.

To help ensure the GCC team doesn't break this again, I'd like to 
add this relatively simple test to the GDB testsuite.


	* gdb.base/break.c (multi_line_if_conditional): New function.
	(multi_ilne_while_conditional): Likewise.
	* gdb.base/break.exp: Verify that a breakpoint on a multi-line
	IF or WHILE condition puts the breakpoint at the start of
	the condition.

Index: break.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/testsuite/gdb.base/break.c,v
retrieving revision 1.7
diff -c -3 -p -r1.7 break.c
*** break.c	1999/10/02 00:24:35	1.7
--- break.c	2002/01/04 21:56:33
*************** int value;
*** 99,101 ****
--- 99,131 ----
      return (value);
  }
  
+ #ifdef PROTOTYPES
+ int multi_line_if_conditional (int a, int b, int c)
+ #else
+ int multi_line_if_conditional (a, b, c)
+   int a, b, c;
+ #endif
+ {
+   if (a
+       && b
+       && c)
+     return 0;
+   else
+     return 1;
+ }
+ 
+ #ifdef PROTOTYPES
+ int multi_line_while_conditional (int a, int b, int c)
+ #else
+ int multi_line_while_conditional (a, b, c)
+   int a, b, c;
+ #endif
+ {
+   while (a
+       && b
+       && c)
+     {
+       a--, b--, c--;
+     }
+   return 0;
+ }
Index: break.exp
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/testsuite/gdb.base/break.exp,v
retrieving revision 1.62.80.1
diff -c -3 -p -r1.62.80.1 break.exp
*** break.exp	2001/12/19 20:39:46	1.62.80.1
--- break.exp	2002/01/04 21:56:33
*************** gdb_test "break $srcfile:85" \
*** 122,127 ****
--- 122,139 ----
  
  
  #
+ # Test putting a break at the start of a multi-line if conditional.
+ # Verify the breakpoint was put at the start of the conditional.
+ #
+ gdb_test "break multi_line_if_conditional" \
+     "Breakpoint.*at.* file .*$srcfile, line 109\\." \
+     "breakpoint at start of multi line if conditional"
+ 
+ gdb_test "break multi_line_while_conditional" \
+     "Breakpoint.*at.* file .*$srcfile, line 124\\." \
+     "breakpoint at start of multi line while conditional"
+ 
+ #
  # check to see what breakpoints are set
  #
  if [target_info exists gdb_stub] {
*************** gdb_test "info break" \
*** 141,147 ****
  \[0-9\]+\[\t \]+breakpoint     keep y.* in factorial$proto at .*$srcfile:96.*
  \[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:79.*
  \[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:79.*
! \[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:85" \
      "breakpoint info"
  
  
--- 153,161 ----
  \[0-9\]+\[\t \]+breakpoint     keep y.* in factorial$proto at .*$srcfile:96.*
  \[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:79.*
  \[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:79.*
! \[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:85.*
! \[0-9\]+\[\t \]+breakpoint     keep y.* in multi_line_if_conditional at .*$srcfile:109.*
! \[0-9\]+\[\t \]+breakpoint     keep y.* in multi_line_while_conditional at .*$srcfile:124" \
      "breakpoint info"
  
  



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

* Re: Test for GCC debug symbol bug
  2002-01-04 14:17 Test for GCC debug symbol bug law
@ 2002-01-04 17:55 ` Daniel Jacobowitz
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Jacobowitz @ 2002-01-04 17:55 UTC (permalink / raw)
  To: law; +Cc: gdb-patches

On Fri, Jan 04, 2002 at 03:14:59PM -0700, law@redhat.com wrote:
> 
> This patch adds a test for a GCC bug in its line number output.
> 
> Basically if we have a multi-line IF or WHILE conditional, GCC will
> emit incorrect line numbers for the IF/WHILE statement.
> 
> The incorrect line numbers (of course) make debugging multi-line 
> IF/WHILE statements a PITA.
> 
> To help ensure the GCC team doesn't break this again, I'd like to 
> add this relatively simple test to the GDB testsuite.
> 
> 
> 	* gdb.base/break.c (multi_line_if_conditional): New function.
> 	(multi_ilne_while_conditional): Likewise.
> 	* gdb.base/break.exp: Verify that a breakpoint on a multi-line
> 	IF or WHILE condition puts the breakpoint at the start of
> 	the condition.

<Andrew Cagney Hat On, apologies to Andrew>

This is obvious; please do commit it.  I'm all in favor of debug info
tests.

Of course, we may want to mark it XFAIL if we end up stopping where
broken GCC's would have; I really dislike FAILs that GDB can do nothing
about, although in some cases they're unavoidable.  Do we have a
documented policy for what all the DejaGNU result codes mean in the GDB
testsuite?  If not, should I propose one?

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


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

end of thread, other threads:[~2002-01-05  1:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-04 14:17 Test for GCC debug symbol bug law
2002-01-04 17:55 ` Daniel Jacobowitz

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