Following the previous patch, I thought it would make sense to make
current_token a field of mi_interp. This variable contains the token of
the currently handled MI command, like the 222 in:
222-exec-continue
I didn't find any bug related to that, it's just a "that seems nicer"
cleanup, since the current token is a fundamentally per-interp thing.
There should be no user-visible change.
Change-Id: Ib52b3c0cba4b7c9d805b432c809692a86e4945ad
---
gdb/mi/mi-interp.c | 2 +-
gdb/mi/mi-interp.h | 2 ++
gdb/mi/mi-main.c | 17 ++++++++---------
gdb/mi/mi-main.h | 2 --
4 files changed, 11 insertions(+), 12 deletions(-)
On Tue, May 2, 2023 at 10:50 PM Simon Marchi via Gdb-patches <
gdb-patches@sourceware.org> wrote:
> Following the previous patch, I thought it would make sense to make
> current_token a field of mi_interp. This variable contains the token of
> the currently handled MI command, like the 222 in:
>
> 222-exec-continue
>
> I didn't find any bug related to that, it's just a "that seems nicer"
> cleanup, since the current token is a fundamentally per-interp thing.
> There should be no user-visible change.
>
> Change-Id: Ib52b3c0cba4b7c9d805b432c809692a86e4945ad
>
>
I do agree the change feels nicer and I can confirm this causes no
regressions when tested on Fedora Rawhide, ppc64le.
@@ -968,7 +968,7 @@ mi_on_resume_1 (struct mi_interp *mi,
if (!mi->running_result_record_printed && mi->mi_proceeded)
{
gdb_printf (mi->raw_stdout, "%s^running\n",
- current_token ? current_token : "");
+ mi->current_token ? mi->current_token : "");
}
/* Backwards compatibility. If doing a wildcard resume and there's
@@ -70,6 +70,8 @@ class mi_interp final : public interp
/* Flag indicating that the target has proceeded since the last
command was issued. */
int mi_proceeded;
+
+ const char *current_token;
};
/* Output the shared object attributes to UIOUT. */
@@ -78,7 +78,6 @@ static struct mi_timestamp *current_command_ts;
static int do_timings = 0;
-char *current_token;
/* Few commands would like to know if options like --thread-group were
explicitly specified. This variable keeps the current parsed
command including all option, and make it possible. */
@@ -147,8 +146,8 @@ mi_cmd_gdb_exit (const char *command, char **argv, int argc)
struct mi_interp *mi = (struct mi_interp *) current_interpreter ();
/* We have to print everything right here because we never return. */
- if (current_token)
- gdb_puts (current_token, mi->raw_stdout);
+ if (mi->current_token)
+ gdb_puts (mi->current_token, mi->raw_stdout);
gdb_puts ("^exit\n", mi->raw_stdout);
mi_out_put (current_uiout, mi->raw_stdout);
gdb_flush (mi->raw_stdout);
@@ -1794,8 +1793,8 @@ captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context)
if (do_timings)
current_command_ts = context->cmd_start;
- scoped_restore save_token = make_scoped_restore (¤t_token,
- context->token);
+ scoped_restore save_token
+ = make_scoped_restore (&mi->current_token, context->token);
mi->running_result_record_printed = 0;
mi->mi_proceeded = 0;
@@ -2178,8 +2177,8 @@ mi_load_progress (const char *section_name,
xfree (previous_sect_name);
previous_sect_name = xstrdup (section_name);
- if (current_token)
- gdb_puts (current_token, mi->raw_stdout);
+ if (mi->current_token)
+ gdb_puts (mi->current_token, mi->raw_stdout);
gdb_puts ("+download", mi->raw_stdout);
{
ui_out_emit_tuple tuple_emitter (uiout.get (), NULL);
@@ -2196,8 +2195,8 @@ mi_load_progress (const char *section_name,
if (time_now - last_update > milliseconds (500))
{
last_update = time_now;
- if (current_token)
- gdb_puts (current_token, mi->raw_stdout);
+ if (mi->current_token)
+ gdb_puts (mi->current_token, mi->raw_stdout);
gdb_puts ("+download", mi->raw_stdout);
{
ui_out_emit_tuple tuple_emitter (uiout.get (), NULL);
@@ -34,8 +34,6 @@ extern void mi_print_timing_maybe (struct ui_file *file);
extern int mi_async_p (void);
-extern char *current_token;
-
struct mi_suppress_notification
{
/* Breakpoint notification suppressed? */