Re: Breakpoint commands in MI mode and "backtrace"

Eli Zaretskii
2017-10-21T08:26:27Z

> Cc: gdb@sourceware.org
> From: Simon Marchi <simark@simark.ca>
> Date: Mon, 9 Oct 2017 08:02:24 -0400
>
> Anyhow, can you try this patch here? It changes the uiout manually instead of
> going through safe_execute_command.

Since this worked for me, in GDB 8.0, can something similar be put in
the current master, so the next GDB release will have this bug fixed?

Thanks.

> diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
> index f1db954a69..b08954132b 100644
> --- a/gdb/cli/cli-script.c
> +++ b/gdb/cli/cli-script.c
> @@ -472,6 +472,8 @@ print_command_trace (const char *cmd)
> printf_filtered ("%s\n", cmd);
> }
>
> +static void restore_interp (void *arg);
> +
> enum command_control_type
> execute_control_command (struct command_line *cmd)
> {
> @@ -491,8 +493,17 @@ execute_control_command (struct command_line *cmd)
> {
> /* A simple command, execute it and return. */
> std::string new_line = insert_user_defined_cmd_args (cmd->line);
> +
> + struct interp *old_interp = interp_set_temp (INTERP_CONSOLE);
> + struct cleanup *old_chain = make_cleanup (restore_interp, old_interp);
> + scoped_restore save_uiout
> + = make_scoped_restore (&current_uiout,
> + current_interpreter ()->interp_ui_out ());
> +
> execute_command (&new_line[0], 0);
> ret = cmd->control_type;
> +
> + do_cleanups (old_chain);
> break;
> }
>
>
>