Use console uiout when executing breakpoint commands
As reported here https://sourceware.org/ml/gdb/2017-10/msg00020.html the output of certain commands, like backtrace, doesn't appear anywhere when it is run as a breakpoint command and when using MI. The reason is that the current_uiout is set to the mi_ui_out while these commands run, whereas we want the output as CLI output. Some commands like "print" work, because they use printf_filtered (gdb_stdout, ...) directly, bypassing the current ui_out. The fix I did is to force setting the cli_uiout as the current_uiout when calling execute_control_command. I am not sure if this is the right way to fix the problem, comments about the approach would be appreciated. I enhanced gdb.mi/mi-break.exp to test the backtrace command. Regtested on the buildbot. gdb/ChangeLog: * cli/cli-script.c (execute_control_command): Rename to ... (execute_control_command_1): ... this. (execute_control_command): New function. gdb/testsuite/ChangeLog: * gdb.mi/mi-break.exp (test_breakpoint_commands): Test backtrace as a breakpoint command.
This commit is contained in:
parent
4d01dee480
commit
3a87ae656c
4 changed files with 31 additions and 6 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2017-10-31 Simon Marchi <simon.marchi@polymtl.ca>
|
||||||
|
|
||||||
|
* cli/cli-script.c (execute_control_command): Rename to ...
|
||||||
|
(execute_control_command_1): ... this.
|
||||||
|
(execute_control_command): New function.
|
||||||
|
|
||||||
2017-10-31 Simon Marchi <simon.marchi@ericsson.com>
|
2017-10-31 Simon Marchi <simon.marchi@ericsson.com>
|
||||||
|
|
||||||
* tracepoint.c (tfind_command): Remove const_cast.
|
* tracepoint.c (tfind_command): Remove const_cast.
|
||||||
|
|
|
@ -463,8 +463,10 @@ print_command_trace (const char *cmd)
|
||||||
printf_filtered ("%s\n", cmd);
|
printf_filtered ("%s\n", cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum command_control_type
|
/* Helper for execute_control_command. */
|
||||||
execute_control_command (struct command_line *cmd)
|
|
||||||
|
static enum command_control_type
|
||||||
|
execute_control_command_1 (struct command_line *cmd)
|
||||||
{
|
{
|
||||||
struct command_line *current;
|
struct command_line *current;
|
||||||
struct value *val;
|
struct value *val;
|
||||||
|
@ -541,7 +543,7 @@ execute_control_command (struct command_line *cmd)
|
||||||
{
|
{
|
||||||
scoped_restore save_nesting
|
scoped_restore save_nesting
|
||||||
= make_scoped_restore (&command_nest_depth, command_nest_depth + 1);
|
= make_scoped_restore (&command_nest_depth, command_nest_depth + 1);
|
||||||
ret = execute_control_command (current);
|
ret = execute_control_command_1 (current);
|
||||||
|
|
||||||
/* If we got an error, or a "break" command, then stop
|
/* If we got an error, or a "break" command, then stop
|
||||||
looping. */
|
looping. */
|
||||||
|
@ -600,7 +602,7 @@ execute_control_command (struct command_line *cmd)
|
||||||
{
|
{
|
||||||
scoped_restore save_nesting
|
scoped_restore save_nesting
|
||||||
= make_scoped_restore (&command_nest_depth, command_nest_depth + 1);
|
= make_scoped_restore (&command_nest_depth, command_nest_depth + 1);
|
||||||
ret = execute_control_command (current);
|
ret = execute_control_command_1 (current);
|
||||||
|
|
||||||
/* If we got an error, get out. */
|
/* If we got an error, get out. */
|
||||||
if (ret != simple_control)
|
if (ret != simple_control)
|
||||||
|
@ -644,6 +646,18 @@ execute_control_command (struct command_line *cmd)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum command_control_type
|
||||||
|
execute_control_command (struct command_line *cmd)
|
||||||
|
{
|
||||||
|
/* Make sure we use the console uiout. It's possible that we are executing
|
||||||
|
breakpoint commands while running the MI interpreter. */
|
||||||
|
interp *console = interp_lookup (current_ui, INTERP_CONSOLE);
|
||||||
|
scoped_restore save_uiout
|
||||||
|
= make_scoped_restore (¤t_uiout, interp_ui_out (console));
|
||||||
|
|
||||||
|
return execute_control_command_1 (cmd);
|
||||||
|
}
|
||||||
|
|
||||||
/* Like execute_control_command, but first set
|
/* Like execute_control_command, but first set
|
||||||
suppress_next_print_command_trace. */
|
suppress_next_print_command_trace. */
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2017-10-31 Simon Marchi <simon.marchi@polymtl.ca>
|
||||||
|
|
||||||
|
* gdb.mi/mi-break.exp (test_breakpoint_commands): Test backtrace
|
||||||
|
as a breakpoint command.
|
||||||
|
|
||||||
2017-10-28 Maksim Dzabraev <dzabraew@gmail.com>
|
2017-10-28 Maksim Dzabraev <dzabraew@gmail.com>
|
||||||
|
|
||||||
PR python/21213
|
PR python/21213
|
||||||
|
|
|
@ -277,7 +277,7 @@ proc test_breakpoint_commands {} {
|
||||||
-number 9 -disp keep -func callee2 -file ".*basics.c" \
|
-number 9 -disp keep -func callee2 -file ".*basics.c" \
|
||||||
-line $line_callee2_body
|
-line $line_callee2_body
|
||||||
|
|
||||||
mi_gdb_test "-break-commands 9 \"set \$i=0\" \"while \$i<10\" \"print \$i\" \"set \$i=\$i+1\" \"end\" \"continue\" " \
|
mi_gdb_test "-break-commands 9 \"bt\" \"set \$i=0\" \"while \$i<10\" \"print \$i\" \"set \$i=\$i+1\" \"end\" \"continue\" " \
|
||||||
"\\^done" \
|
"\\^done" \
|
||||||
"breakpoint commands: set commands"
|
"breakpoint commands: set commands"
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ proc test_breakpoint_commands {} {
|
||||||
set test "intermediate stop and continue, bp commands"
|
set test "intermediate stop and continue, bp commands"
|
||||||
gdb_expect {
|
gdb_expect {
|
||||||
-i $gdb_main_spawn_id
|
-i $gdb_main_spawn_id
|
||||||
-re ".*\\\$1 = 0.*\\\$10 = 9" {
|
-re ".*callee2.*callee1.*main.*\\\$1 = 0.*\\\$10 = 9" {
|
||||||
pass $test
|
pass $test
|
||||||
}
|
}
|
||||||
timeout {
|
timeout {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue