* [RFA] Fix inferior restart problem in gdb.base/commands.exp
@ 2002-09-07 7:05 Fred Fish
2002-09-07 7:11 ` Fred Fish
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Fred Fish @ 2002-09-07 7:05 UTC (permalink / raw)
To: gdb-patches; +Cc: fnf
When running the gdb testsuite with an external simulator like "sid", if the
inferior is allowed to run to completion and exit, a simple gdb_run_cmd may
have problems rerunning the inferior since it doesn't do a complete restart.
An alternative to gdb_run_cmd is to do the following prior to setting up
the test and then later do just a continue instead of gdb_run_cmd:
gdb_exit
gdb_start
delete_breakpoints
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
but that is much more expensive. It is sufficient to just not allow the
inferior to run to completion. This patch does that.
Also, to avoid having to specifically test for noinferiorio we don't
check for output from the test case, it is not relevant to the given
test anyway.
-Fred
2002-09-07 Fred Fish <fnf@intrinsity.com>
* gdb.base/run.c (all_done): Add function and call it at end of main.
* gdb.base/commands.exp (bp_deleted_in_command_test): Set breakpoint
at all_done so we don't exit, which makes restarting more difficult.
Adjust expected success results to match stopping at all_done.
(temporary_breakpoint_commands): Ditto.
Index: gdb.base/commands.exp
===================================================================
RCS file: /mips/newtools/fsf/gdb/gdb/testsuite/gdb.base/commands.exp,v
retrieving revision 1.1.1.2
diff -c -p -r1.1.1.2 commands.exp
*** gdb.base/commands.exp 2002/08/31 02:49:15 1.1.1.2
--- gdb.base/commands.exp 2002/09/07 13:52:31
*************** proc bp_deleted_in_command_test {} {
*** 446,451 ****
--- 446,459 ----
gdb_test "set args 1" "" "set args in bp_deleted_in_command_test"
delete_breakpoints
+ # Set a breakpoint that will prevent us from running to completion and exiting.
+ # If we allow the inferior to exit, gdb_run_cmd may not be sufficient to get us
+ # going again in a future test without a full restart, when using a gdb stub.
+
+ gdb_test "break all_done" \
+ "Breakpoint \[0-9\]+ at .*: file .*/run.c, line \[0-9\]+\." \
+ "breakpoint at all_done"
+
# Create a breakpoint, and associate a command-list to it, with
# one command that deletes this breakpoint.
gdb_test "break factorial" \
*************** proc bp_deleted_in_command_test {} {
*** 489,496 ****
}
gdb_run_cmd
gdb_expect {
! -re ".*factorial command-list executed.*1.*Program exited normally.*$gdb_prompt $" {
pass "run factorial until breakpoint"
}
-re ".*$gdb_prompt $" {
--- 497,507 ----
}
gdb_run_cmd
+ # Note that we specifically don't check that the inferior printed any output
+ # since it is immaterial to the test results and we don't want to have to check
+ # whether or not "noinferiorio" is set.
gdb_expect {
! -re ".*factorial command-list executed.*Breakpoint \[0-9\]+, all_done.*$gdb_prompt $" {
pass "run factorial until breakpoint"
}
-re ".*$gdb_prompt $" {
*************** proc temporary_breakpoint_commands {} {
*** 507,512 ****
--- 518,531 ----
gdb_test "set args 1" "" "set args in temporary_breakpoint_commands"
delete_breakpoints
+ # Set a breakpoint that will prevent us from running to completion and exiting.
+ # If we allow the inferior to exit, gdb_run_cmd may not be sufficient to get us
+ # going again in a future test without a full restart, when using a gdb stub.
+
+ gdb_test "break all_done" \
+ "Breakpoint \[0-9\]+ at .*: file .*/run.c, line \[0-9\]+\." \
+ "breakpoint at all_done"
+
# Create a temporary breakpoint, and associate a commands list to it.
# This test will verify that this commands list is executed when the
# breakpoint is hit.
*************** proc temporary_breakpoint_commands {} {
*** 546,555 ****
}
gdb_run_cmd
gdb_expect {
! -re ".*factorial tbreak commands executed.*1.*Program exited normally.*" {
pass "run factorial until temporary breakpoint"
}
timeout { fail "(timeout) run factorial until temporary breakpoint" }
}
}
--- 565,581 ----
}
gdb_run_cmd
+ # Note that we specifically don't check that the inferior printed any output
+ # since it is immaterial to the test results and we don't want to have to check
+ # whether or not "noinferiorio" is set.
gdb_expect {
! -re ".*factorial tbreak commands executed.*Breakpoint \[0-9\]+, all_done.*$gdb_prompt $" {
pass "run factorial until temporary breakpoint"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "run factorial until temporary breakpoint"
}
+ default { fail "(timeout) run factorial until temporary breakpoint" }
timeout { fail "(timeout) run factorial until temporary breakpoint" }
}
}
Index: gdb.base/run.c
===================================================================
RCS file: /mips/newtools/fsf/gdb/gdb/testsuite/gdb.base/run.c,v
retrieving revision 1.1.1.1
diff -c -p -r1.1.1.1 run.c
*** gdb.base/run.c 2002/07/03 16:56:33 1.1.1.1
--- gdb.base/run.c 2002/09/07 13:52:31
*************** char *arg;
*** 37,42 ****
--- 37,45 ----
# include <stdlib.h>
#endif /* ! vxworks */
+ /* Someplace we can set a breakpoint to avoid running to completion when needed */
+ void all_done () {};
+
#ifdef PROTOTYPES
int factorial (int);
*************** char *argv[], **envp;
*** 63,68 ****
--- 66,72 ----
printf ("%d\n", factorial (atoi (argv[1])));
}
#endif
+ all_done ();
return 0;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] Fix inferior restart problem in gdb.base/commands.exp
2002-09-07 7:05 [RFA] Fix inferior restart problem in gdb.base/commands.exp Fred Fish
@ 2002-09-07 7:11 ` Fred Fish
2002-09-07 9:07 ` Fred Fish
2002-09-07 10:11 ` Daniel Jacobowitz
2 siblings, 0 replies; 4+ messages in thread
From: Fred Fish @ 2002-09-07 7:11 UTC (permalink / raw)
To: gdb-patches; +Cc: fnf
> Also, to avoid having to specifically test for noinferiorio we don't
> check for output from the test case, it is not relevant to the given
> test anyway.
Hmm, I just realized that this may not be true since we probably want
to ensure that the breakpoint at factorial really does get cleared
and only hit once. More likely what we should do is call factorial
with 2 instead of 1, and in the command list print the value, and
in the expected results look for that printout from the command
excuted when the breakpoint is hit and cleared. I'll tweak it and
resubmit.
Assuming that change is made, do I have approval for the patch?
-Fred
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] Fix inferior restart problem in gdb.base/commands.exp
2002-09-07 7:05 [RFA] Fix inferior restart problem in gdb.base/commands.exp Fred Fish
2002-09-07 7:11 ` Fred Fish
@ 2002-09-07 9:07 ` Fred Fish
2002-09-07 10:11 ` Daniel Jacobowitz
2 siblings, 0 replies; 4+ messages in thread
From: Fred Fish @ 2002-09-07 9:07 UTC (permalink / raw)
To: gdb-patches; +Cc: Fred Fish
Here is an updated patch that checks that the right breakpoint is
getting hit, and only that breakpoint. It also has some format tweaks
for consistency.
-Fred
2002-09-07 Fred Fish <fnf@intrinsity.com>
* gdb.base/run.c (all_done): Add function and call it at end of main.
* gdb.base/commands.exp (bp_deleted_in_command_test): Set breakpoint
at all_done so we don't exit, which makes restarting more difficult.
Call factorial with 2 instead of 1 to check breakpoint cleared.
Adjust expected success results to match stopping at all_done.
(temporary_breakpoint_commands): Ditto.
(watchpoint_command_test): Adjust hardcoded line number to match.
Index: gdb.base/commands.exp
===================================================================
RCS file: /mips/newtools/fsf/gdb/gdb/testsuite/gdb.base/commands.exp,v
retrieving revision 1.1.1.2
diff -c -p -r1.1.1.2 commands.exp
*** gdb.base/commands.exp 2002/08/31 02:49:15 1.1.1.2
--- gdb.base/commands.exp 2002/09/07 15:12:05
*************** proc watchpoint_command_test {} {
*** 331,337 ****
}
send_gdb "continue\n"
gdb_expect {
! -re "Continuing.*\[Ww\]atchpoint $wp_id deleted because the program has left the block in.*which its expression is valid.*run.c:57.*$gdb_prompt $" {
pass "continue with watch"
}
-re "$gdb_prompt $" {fail "continue with watch"}
--- 331,337 ----
}
send_gdb "continue\n"
gdb_expect {
! -re "Continuing.*\[Ww\]atchpoint $wp_id deleted because the program has left the block in.*which its expression is valid.*run.c:60.*$gdb_prompt $" {
pass "continue with watch"
}
-re "$gdb_prompt $" {fail "continue with watch"}
*************** proc deprecated_command_test {} {
*** 443,451 ****
proc bp_deleted_in_command_test {} {
global gdb_prompt
! gdb_test "set args 1" "" "set args in bp_deleted_in_command_test"
delete_breakpoints
# Create a breakpoint, and associate a command-list to it, with
# one command that deletes this breakpoint.
gdb_test "break factorial" \
--- 443,459 ----
proc bp_deleted_in_command_test {} {
global gdb_prompt
! gdb_test "set args 2" "" "set args in bp_deleted_in_command_test"
delete_breakpoints
+ # Set a breakpoint that will prevent us from running to completion and exiting.
+ # If we allow the inferior to exit, gdb_run_cmd may not be sufficient to get us
+ # going again in a future test without a full restart, when using a gdb stub.
+
+ gdb_test "break all_done" \
+ "Breakpoint \[0-9\]+ at .*: file .*/run.c, line \[0-9\]+\." \
+ "breakpoint at all_done"
+
# Create a breakpoint, and associate a command-list to it, with
# one command that deletes this breakpoint.
gdb_test "break factorial" \
*************** proc bp_deleted_in_command_test {} {
*** 470,487 ****
gdb_expect {
-re ">" {pass "add clear command"}
-re "$gdb_prompt $" {fail "add clear command"}
! timeout {fail "(timeout) add clear command"} }
send_gdb "printf \"factorial command-list executed\\n\"\n"
gdb_expect {
-re ">" {pass "add printf command"}
-re "$gdb_prompt $" {fail "add printf command"}
timeout {fail "(timeout) add printf command"}
}
send_gdb "cont\n"
gdb_expect {
-re ">" {pass "add cont command"}
-re "$gdb_prompt $" {fail "add cont command"}
! timeout {fail "(timeout) add cont command"} }
send_gdb "end\n"
gdb_expect {
-re "$gdb_prompt $" {pass "end commands"}
--- 478,503 ----
gdb_expect {
-re ">" {pass "add clear command"}
-re "$gdb_prompt $" {fail "add clear command"}
! timeout {fail "(timeout) add clear command"}
! }
send_gdb "printf \"factorial command-list executed\\n\"\n"
gdb_expect {
-re ">" {pass "add printf command"}
-re "$gdb_prompt $" {fail "add printf command"}
timeout {fail "(timeout) add printf command"}
}
+ send_gdb "print value\n"
+ gdb_expect {
+ -re ">" {pass "add print value command"}
+ -re "$gdb_prompt $" {fail "add print value command"}
+ timeout {fail "(timeout) add print value command"}
+ }
send_gdb "cont\n"
gdb_expect {
-re ">" {pass "add cont command"}
-re "$gdb_prompt $" {fail "add cont command"}
! timeout {fail "(timeout) add cont command"}
! }
send_gdb "end\n"
gdb_expect {
-re "$gdb_prompt $" {pass "end commands"}
*************** proc bp_deleted_in_command_test {} {
*** 489,496 ****
}
gdb_run_cmd
gdb_expect {
! -re ".*factorial command-list executed.*1.*Program exited normally.*$gdb_prompt $" {
pass "run factorial until breakpoint"
}
-re ".*$gdb_prompt $" {
--- 505,515 ----
}
gdb_run_cmd
+ # Note that we specifically don't check that the inferior printed any output
+ # since it is immaterial to the test results and we don't want to have to check
+ # whether or not "noinferiorio" is set.
gdb_expect {
! -re ".*factorial command-list executed.*\\$\[0-9\]* = 2\[ \r\n\]+.*Breakpoint \[0-9\]+, all_done.*$gdb_prompt $" {
pass "run factorial until breakpoint"
}
-re ".*$gdb_prompt $" {
*************** proc bp_deleted_in_command_test {} {
*** 504,512 ****
proc temporary_breakpoint_commands {} {
global gdb_prompt
! gdb_test "set args 1" "" "set args in temporary_breakpoint_commands"
delete_breakpoints
# Create a temporary breakpoint, and associate a commands list to it.
# This test will verify that this commands list is executed when the
# breakpoint is hit.
--- 523,539 ----
proc temporary_breakpoint_commands {} {
global gdb_prompt
! gdb_test "set args 2" "" "set args in temporary_breakpoint_commands"
delete_breakpoints
+ # Set a breakpoint that will prevent us from running to completion and exiting.
+ # If we allow the inferior to exit, gdb_run_cmd may not be sufficient to get us
+ # going again in a future test without a full restart, when using a gdb stub.
+
+ gdb_test "break all_done" \
+ "Breakpoint \[0-9\]+ at .*: file .*/run.c, line \[0-9\]+\." \
+ "breakpoint at all_done"
+
# Create a temporary breakpoint, and associate a commands list to it.
# This test will verify that this commands list is executed when the
# breakpoint is hit.
*************** proc temporary_breakpoint_commands {} {
*** 527,555 ****
-re ">" {pass "add silent tbreak command"}
-re "$gdb_prompt $" {fail "add silent tbreak command"}
timeout {fail "(timeout) add silent tbreak command"}
! }
send_gdb "printf \"factorial tbreak commands executed\\n\"\n"
gdb_expect {
-re ">" {pass "add printf tbreak command"}
-re "$gdb_prompt $" {fail "add printf tbreak command"}
timeout {fail "(timeout) add printf tbreak command"}
! }
send_gdb "cont\n"
gdb_expect {
-re ">" {pass "add cont tbreak command"}
-re "$gdb_prompt $" {fail "add cont tbreak command"}
! timeout {fail "(timeout) add cont tbreak command"} }
send_gdb "end\n"
gdb_expect {
-re "$gdb_prompt $" {pass "end tbreak commands"}
timeout {fail "(timeout) end tbreak commands"}
! }
gdb_run_cmd
gdb_expect {
! -re ".*factorial tbreak commands executed.*1.*Program exited normally.*" {
pass "run factorial until temporary breakpoint"
}
timeout { fail "(timeout) run factorial until temporary breakpoint" }
}
}
--- 554,596 ----
-re ">" {pass "add silent tbreak command"}
-re "$gdb_prompt $" {fail "add silent tbreak command"}
timeout {fail "(timeout) add silent tbreak command"}
! }
send_gdb "printf \"factorial tbreak commands executed\\n\"\n"
gdb_expect {
-re ">" {pass "add printf tbreak command"}
-re "$gdb_prompt $" {fail "add printf tbreak command"}
timeout {fail "(timeout) add printf tbreak command"}
! }
! send_gdb "print value\n"
! gdb_expect {
! -re ">" {pass "add print value tbreak command"}
! -re "$gdb_prompt $" {fail "add print value tbreak command"}
! timeout {fail "(timeout) add print value tbreak command"}
! }
send_gdb "cont\n"
gdb_expect {
-re ">" {pass "add cont tbreak command"}
-re "$gdb_prompt $" {fail "add cont tbreak command"}
! timeout {fail "(timeout) add cont tbreak command"}
! }
send_gdb "end\n"
gdb_expect {
-re "$gdb_prompt $" {pass "end tbreak commands"}
timeout {fail "(timeout) end tbreak commands"}
! }
gdb_run_cmd
+ # Note that we specifically don't check that the inferior printed any output
+ # since it is immaterial to the test results and we don't want to have to check
+ # whether or not "noinferiorio" is set.
gdb_expect {
! -re ".*factorial tbreak commands executed.*\\$\[0-9\]* = 2\[ \r\n\]+.*Breakpoint \[0-9\]+, all_done.*$gdb_prompt $" {
pass "run factorial until temporary breakpoint"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "run factorial until temporary breakpoint"
}
+ default { fail "(timeout) run factorial until temporary breakpoint" }
timeout { fail "(timeout) run factorial until temporary breakpoint" }
}
}
Index: gdb.base/run.c
===================================================================
RCS file: /mips/newtools/fsf/gdb/gdb/testsuite/gdb.base/run.c,v
retrieving revision 1.1.1.1
diff -c -p -r1.1.1.1 run.c
*** gdb.base/run.c 2002/07/03 16:56:33 1.1.1.1
--- gdb.base/run.c 2002/09/07 15:12:05
*************** char *arg;
*** 37,42 ****
--- 37,45 ----
# include <stdlib.h>
#endif /* ! vxworks */
+ /* Someplace we can set a breakpoint to avoid running to completion when needed */
+ void all_done () {};
+
#ifdef PROTOTYPES
int factorial (int);
*************** char *argv[], **envp;
*** 54,60 ****
breakpoint();
#endif
#ifdef FAKEARGV
! printf ("%d\n", factorial (1));
#else
if (argc != 2) {
printf ("usage: factorial <number>\n");
--- 57,63 ----
breakpoint();
#endif
#ifdef FAKEARGV
! printf ("%d\n", factorial (2));
#else
if (argc != 2) {
printf ("usage: factorial <number>\n");
*************** char *argv[], **envp;
*** 63,68 ****
--- 66,72 ----
printf ("%d\n", factorial (atoi (argv[1])));
}
#endif
+ all_done ();
return 0;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] Fix inferior restart problem in gdb.base/commands.exp
2002-09-07 7:05 [RFA] Fix inferior restart problem in gdb.base/commands.exp Fred Fish
2002-09-07 7:11 ` Fred Fish
2002-09-07 9:07 ` Fred Fish
@ 2002-09-07 10:11 ` Daniel Jacobowitz
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2002-09-07 10:11 UTC (permalink / raw)
To: Fred Fish; +Cc: gdb-patches
On Sat, Sep 07, 2002 at 09:04:45AM -0500, Fred Fish wrote:
> When running the gdb testsuite with an external simulator like "sid", if the
> inferior is allowed to run to completion and exit, a simple gdb_run_cmd may
> have problems rerunning the inferior since it doesn't do a complete restart.
>
> An alternative to gdb_run_cmd is to do the following prior to setting up
> the test and then later do just a continue instead of gdb_run_cmd:
>
> gdb_exit
> gdb_start
> delete_breakpoints
> gdb_reinitialize_dir $srcdir/$subdir
> gdb_load ${binfile}
>
> but that is much more expensive. It is sufficient to just not allow the
> inferior to run to completion. This patch does that.
>
> Also, to avoid having to specifically test for noinferiorio we don't
> check for output from the test case, it is not relevant to the given
> test anyway.
I don't really like this. Isn't there some way you can make re-issuing
gdb_run_cmd work for sid? It works for gdbserver, I believe, though I
have to play some games to do it. (The test itself fails but due to a
bad regular expression construct, I think - not sure why. The desired
behavior is indeed there.) I don't like having to work around all
sorts of targets in the testsuite more than necessary.
I've had a kernel bug this week that only showed up when GDB ran a
program multiple times. Is there anywhere else in the testsuite that
continues to cover that?
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-09-07 17:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-07 7:05 [RFA] Fix inferior restart problem in gdb.base/commands.exp Fred Fish
2002-09-07 7:11 ` Fred Fish
2002-09-07 9:07 ` Fred Fish
2002-09-07 10:11 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox