Index: breakpoint.c =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.c,v retrieving revision 1.78 diff -c -3 -p -r1.78 breakpoint.c *** breakpoint.c 26 Jun 2002 05:20:04 -0000 1.78 --- breakpoint.c 31 Jul 2002 20:08:35 -0000 *************** top: *** 1882,1888 **** breakpoint_proceeded = 0; for (; bs != NULL; bs = bs->next) { ! cmd = bs->commands; while (cmd != NULL) { execute_control_command (cmd); --- 1882,1892 ---- breakpoint_proceeded = 0; for (; bs != NULL; bs = bs->next) { ! /* Use a temporary copy of the commands, as one command in the list ! may cause this breakpoint and its commands to be deleted. */ ! cmd = copy_command_lines (bs->commands); ! make_cleanup_free_command_lines (&cmd); ! while (cmd != NULL) { execute_control_command (cmd); *************** breakpoint_auto_delete (bpstat bs) *** 6575,6590 **** { struct breakpoint *b, *temp; - for (; bs; bs = bs->next) - if (bs->breakpoint_at && bs->breakpoint_at->disposition == disp_del - && bs->stop) - delete_breakpoint (bs->breakpoint_at); - ALL_BREAKPOINTS_SAFE (b, temp) { if (b->disposition == disp_del_at_next_stop) delete_breakpoint (b); } } /* Delete a breakpoint and clean up all traces of it in the data --- 6579,6607 ---- { struct breakpoint *b, *temp; ALL_BREAKPOINTS_SAFE (b, temp) { if (b->disposition == disp_del_at_next_stop) delete_breakpoint (b); } + + for (; bs; bs = bs->next) + if (bs->breakpoint_at && bs->breakpoint_at->disposition == disp_del + && bs->stop) + { + if (bs->commands) + { + /* Don't delete this breakpoint yet, as there are some + commands associated to this temporary breakpoint that + need to be executed before. Mark this breakpoint for + deletion at the next stop, and also disable this breakpoint + to avoid hitting it later on. */ + bs->breakpoint_at->disposition = disp_del_at_next_stop; + disable_breakpoint (bs->breakpoint_at); + } + else + delete_breakpoint (bs->breakpoint_at); + } } /* Delete a breakpoint and clean up all traces of it in the data Index: testsuite/gdb.base/commands.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/commands.exp,v retrieving revision 1.10 diff -c -3 -p -r1.10 commands.exp *** testsuite/gdb.base/commands.exp 13 Dec 2001 22:42:23 -0000 1.10 --- testsuite/gdb.base/commands.exp 31 Jul 2002 20:08:36 -0000 *************** proc deprecated_command_test {} { *** 440,445 **** --- 440,498 ---- "deprecate with no arguments" } + 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. + gdb_test "tbreak factorial" \ + "Breakpoint \[0-9\]+ at .*: file .*/run.c, line \[0-9\]+\." \ + "breakpoint in temporary_breakpoint_commands" + + send_gdb "commands\n" + gdb_expect { + -re "Type commands for when breakpoint .* is hit, one per line.*>" { + pass "begin commands in bp_deleted_in_command_test" + } + -re "$gdb_prompt $" {fail "begin commands in bp_deleted_in_command_test"} + timeout {fail "(timeout) begin commands bp_deleted_in_command_test"} + } + send_gdb "silent\n" + gdb_expect { + -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" } + } + + } gdbvar_simple_if_test gdbvar_simple_while_test *************** user_defined_command_test *** 454,456 **** --- 507,510 ---- watchpoint_command_test test_command_prompt_position deprecated_command_test + temporary_breakpoint_commands