This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH] Outwit compiler dead code elimination in break.exp test
- From: Fred Fish <fnf at public dot ninemoons dot com>
- To: gdb-patches at sources dot redhat dot com
- Cc: fnf at ninemoons dot com
- Date: Sat, 29 Nov 2003 16:05:01 -0700 (MST)
- Subject: [PATCH] Outwit compiler dead code elimination in break.exp test
- Reply-to: fnf at ninemoons dot com
2003-11-29 Fred Fish <fnf@redhat.com>
* gdb.base/break.c (globalvar): Add.
(marker1, marker2, marker3, marker4): Set globalvar.
Index: gdb.base/break.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/break.c,v
retrieving revision 1.3
diff -c -p -r1.3 break.c
*** gdb.base/break.c 13 Nov 2003 15:34:39 -0000 1.3
--- gdb.base/break.c 29 Nov 2003 22:57:41 -0000
*************** char *arg;
*** 37,54 ****
* as places to try setting breakpoints at. They are explicitly
* "one-line functions" to verify that this case works (some versions
* of gcc have or have had problems with this).
*/
#ifdef PROTOTYPES
! int marker1 (void) { return (0); }
! int marker2 (int a) { return (1); } /* set breakpoint 8 here */
! void marker3 (char *a, char *b) {}
! void marker4 (long d) {} /* set breakpoint 14 here */
#else
! int marker1 () { return (0); }
! int marker2 (a) int a; { return (1); } /* set breakpoint 9 here */
! void marker3 (a, b) char *a, *b; {}
! void marker4 (d) long d; {} /* set breakpoint 13 here */
#endif
/*
--- 37,58 ----
* as places to try setting breakpoints at. They are explicitly
* "one-line functions" to verify that this case works (some versions
* of gcc have or have had problems with this).
+ * Recent versions of gcc have gotten smart enough that they will not
+ * call functions that have no use or visible side effect, so use
+ * globalvar to outwit the compiler for a while longer.
*/
+ int globalvar;
#ifdef PROTOTYPES
! int marker1 (void) { globalvar = 1; return (0); }
! int marker2 (int a) { globalvar = 2; return (1); } /* set breakpoint 8 here */
! void marker3 (char *a, char *b) {globalvar = 3;}
! void marker4 (long d) {globalvar = 4;} /* set breakpoint 14 here */
#else
! int marker1 () { globalvar = 1; return (0); }
! int marker2 (a) int a; { globalvar = 2; return (1); } /* set breakpoint 9 here */
! void marker3 (a, b) char *a, *b; {globalvar = 3;}
! void marker4 (d) long d; {globalvar = 4;} /* set breakpoint 13 here */
#endif
/*