Mon Jan 7 12:22:18 2002 Jeffrey A Law (law@redhat.com)
+ * 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.
+
* gdb.base/selftest.exp (backtrace through signal handler): Remove
hppa*-*-hpux* expected failure.
* gdb.base/structs.exp (do_function_calls): Similarly.
#else /* ! vxworks */
# include <stdio.h>
+# include <stdlib.h>
#endif /* ! vxworks */
/*
* of gcc have or have had problems with this).
*/
+#ifdef PROTOTYPES
+int marker1 (void) { return (0); }
+int marker2 (int a) { return (1); }
+void marker3 (char *a, char *b) {}
+void marker4 (long d) {}
+#else
int marker1 () { return (0); }
int marker2 (a) int a; { return (1); }
void marker3 (a, b) char *a, *b; {}
void marker4 (d) long d; {}
+#endif
/*
* This simple classical example of recursion is useful for
* testing stack backtraces and such.
*/
+#ifdef PROTOTYPES
+int factorial(int);
+
+int
+main (int argc, char **argv, char **envp)
+#else
int
main (argc, argv, envp)
int argc;
char *argv[], **envp;
+#endif
{
#ifdef usestubs
set_debug_traps();
breakpoint();
#endif
- if (argc == 123456) {
+ if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */
fprintf (stderr, "usage: factorial <number>\n");
return 1;
}
marker2 (43);
marker3 ("stack", "trace");
marker4 (177601976L);
- return 0;
+ argc = (argc == 12345); /* This is silly, but we can step off of it */
+ return argc;
}
+#ifdef PROTOTYPES
+int factorial (int value)
+#else
int factorial (value)
int value;
+#endif
{
if (value > 1) {
value *= factorial (value - 1);
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;
+}
#
+# 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] {
\[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 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"