diff options
author | Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> | 2020-12-07 09:03:24 +0100 |
---|---|---|
committer | Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> | 2020-12-07 09:10:51 +0100 |
commit | 21e051b3d666bcd614391142a936a8a8cccfa3cb (patch) | |
tree | c22b5f525e6b89afe9a57755f966fd1a29cedcb7 /gdb/testsuite/gdb.gdb/python-interrupts.exp | |
parent | f51f9f1d0300029d33ecb73976f5d2be9b63553e (diff) | |
download | gdb-21e051b3d666bcd614391142a936a8a8cccfa3cb.zip gdb-21e051b3d666bcd614391142a936a8a8cccfa3cb.tar.gz gdb-21e051b3d666bcd614391142a936a8a8cccfa3cb.tar.bz2 |
gdb/main: execute breakpoint commands for '-iex' and '-ex' commands
Suppose we have the script file below:
break main
commands
print 123
end
run
If started with this script file, GDB executes the breakpoint command:
$ gdb -q -x myscript --args ./test
Reading symbols from ./test...
Breakpoint 1 at 0x114e: file test.c, line 2.
Breakpoint 1, main () at test.c:2
2 return 0;
$1 = 123
(gdb)
However, if we remove the "run" line from the script and pass it with
the '-ex' option instead, the command is not executed:
$ gdb -q -x myscript_no_run --args ./test
Reading symbols from ./test...
Breakpoint 1 at 0x114e: file test.c, line 2.
Starting program: /path/to/test
Breakpoint 1, main () at test.c:2
2 return 0;
(gdb)
If the user enters a command at this point, the breakpoint command
is executed, yielding weird output:
$ gdb -q -x myscript_no_run --args ./test
Reading symbols from ./test...
Breakpoint 1 at 0x114e: file test.c, line 2.
Starting program: /path/to/test
Breakpoint 1, main () at test.c:2
2 return 0;
(gdb) print "a"
$1 = "a"
$2 = 123
When consuming script files, GDB runs bp actions after executing a
command. See `command_handler` in event-top.c:
if (c[0] != '#')
{
execute_command (command, ui->instream == ui->stdin_stream);
/* Do any commands attached to breakpoint we stopped at. */
bpstat_do_actions ();
}
However, for '-ex' commands, `bpstat_do_actions` is not invoked.
Hence, the misaligned output explained above occurs. To fix the
problem, add a call to `bpstat_do_actions` after executing a command.
gdb/ChangeLog:
2020-12-07 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* main.c (catch_command_errors): Add a flag parameter; invoke
`bpstat_do_actions` if the flag is set.
(execute_cmdargs): Update a call to `catch_command_errors`.
gdb/testsuite/ChangeLog:
2020-12-07 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.base/bp-cmds-run-with-ex.c: New file.
* gdb.base/bp-cmds-run-with-ex.exp: New file.
* gdb.base/bp-cmds-run-with-ex.gdb: New file.
* gdb.gdb/python-interrupts.exp: Update the call to
'catch_command_errors' with the new argument.
* gdb.gdb/python-selftest.exp: Ditto.
Diffstat (limited to 'gdb/testsuite/gdb.gdb/python-interrupts.exp')
-rw-r--r-- | gdb/testsuite/gdb.gdb/python-interrupts.exp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.gdb/python-interrupts.exp b/gdb/testsuite/gdb.gdb/python-interrupts.exp index 6e5ce6e..b99b23e 100644 --- a/gdb/testsuite/gdb.gdb/python-interrupts.exp +++ b/gdb/testsuite/gdb.gdb/python-interrupts.exp @@ -25,7 +25,7 @@ proc test_python_interrupts {} { } gdb_breakpoint set_active_ext_lang temporary - gdb_test "call catch_command_errors(execute_command, \"python print(5)\", 0)" \ + gdb_test "call catch_command_errors(execute_command, \"python print(5)\", 0, true)" \ "Temporary breakpoint.*silently stop." gdb_test "signal SIGINT" \ "KeyboardInterrupt.*Error while executing Python code." |