This is the mail archive of the gdb-patches@sources.redhat.com 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]

Test for GCC debug symbol bug



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"
  
  



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