From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id F2E6E3858C50 for ; Tue, 12 Sep 2023 11:35:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F2E6E3858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694518510; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IiFcF1YTpkLsnN4ma3UR/wp8VmuuNz1mLalEajK9cmA=; b=bGFjHfk5j4AB09Nmd8SBaLeeDrUORt5NEj1w30PWoKVFl4CddjjZeKAWBn10BaMNli9REx smbr9wvqSPV8ylC1lC7uUE1v9tJKmSWt5502lUKGwoCxV2J9WuX91j5QJO1+ZQifSpSptj xlt3gsJBMr/RkDws41g7ROqNkSx37DA= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-528-p8TPfbPeNcSS43ggBFkxGg-1; Tue, 12 Sep 2023 07:35:09 -0400 X-MC-Unique: p8TPfbPeNcSS43ggBFkxGg-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-401bdff6bc5so39805575e9.1 for ; Tue, 12 Sep 2023 04:35:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694518508; x=1695123308; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IiFcF1YTpkLsnN4ma3UR/wp8VmuuNz1mLalEajK9cmA=; b=ndEfjvQGx3QDYNxEbsWvL4wr7tyiUyhvR44/xN/JJSCwCJVlLmp5KhaXJemTf/ZDpq qJg8ULDWhs5ombiQDricg8DiGO71zP9FnmCdxOEx5s5R2y8EFOnFZQ4//2a1Wa2KE/0z DBR23Ayz64n3m+AH51/Xy3rLLCaXbfrcga95d4XdsnGcJ+xZQJc4LM0E0zOLxSWWV3hq KVCXD4jqsE/pqG7/xHkOh0QVjibhgqCeAI6AcUIaUx7+yToRUUias02RAB7/GuODMDeY oCk8+cfEyFrML2pG7QNQCNT6oFuNB299AOwkOEwe4ipGwfPk3gUWvqZ7x828phCoI9qz Bhvw== X-Gm-Message-State: AOJu0YzYpM76ukP75gFFvBp9pBXff1ypuJGzkE6SdCVvY/0mEQVL2122 bkT3QiDR+5Ap+RepVv5sOMYjYd3GZlULzjQ2MtGwBdNJWhE/u4dGFnyEn9w2q6+hawMLgDFm6tT i8XsZBan7oU3ABGFa15RegiHzqw9j+tuYm/dgvEaTtCy1mYHW+vmEnRCSizdU44bOxSN2Q7USr1 ujH3BPlw== X-Received: by 2002:a05:600c:2a50:b0:402:bda9:74d1 with SMTP id x16-20020a05600c2a5000b00402bda974d1mr10126380wme.8.1694518507924; Tue, 12 Sep 2023 04:35:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG66RkyD7jhehgXZJG1STW8HLIyqKE1bKoRNMGzCvow8QWc+3mnKE3wySEzEOau5qkR0GzORw== X-Received: by 2002:a05:600c:2a50:b0:402:bda9:74d1 with SMTP id x16-20020a05600c2a5000b00402bda974d1mr10126354wme.8.1694518507353; Tue, 12 Sep 2023 04:35:07 -0700 (PDT) Received: from localhost (197.126.90.146.dyn.plus.net. [146.90.126.197]) by smtp.gmail.com with ESMTPSA id z18-20020a1c4c12000000b003fedcd02e2asm12680573wmf.35.2023.09.12.04.35.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 04:35:06 -0700 (PDT) From: Andrew Burgess To: Simon Marchi via Gdb-patches , gdb-patches@sourceware.org Cc: Simon Marchi Subject: Re: [PATCH 21/21] gdb: make top_level_interpreter a method of struct ui In-Reply-To: <20230908190227.96319-22-simon.marchi@efficios.com> References: <20230908190227.96319-1-simon.marchi@efficios.com> <20230908190227.96319-22-simon.marchi@efficios.com> Date: Tue, 12 Sep 2023 12:35:06 +0100 Message-ID: <87zg1ripzp.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Simon Marchi via Gdb-patches writes: > Rename the field to m_top_level_interpreter and make it private. Adjust > all callers to use `current_ui->top_level_interpreter ()`. > > Change-Id: I6b5461d47d566af5fffc835454c08dd9a1dc9570 > --- > gdb/event-top.c | 2 +- > gdb/infrun.c | 4 ++-- > gdb/interps.c | 8 +------- > gdb/interps.h | 3 --- > gdb/linespec.c | 3 ++- > gdb/main.c | 4 ++-- > gdb/mi/mi-interp.c | 4 ++-- > gdb/solib.c | 4 +++- > gdb/tui/tui.c | 2 +- > gdb/ui.c | 6 +++--- > gdb/ui.h | 8 +++++++- > gdb/utils.c | 5 +++-- > 12 files changed, 27 insertions(+), 26 deletions(-) > > diff --git a/gdb/event-top.c b/gdb/event-top.c > index 54f199d2e393..0dd85cb24d49 100644 > --- a/gdb/event-top.c > +++ b/gdb/event-top.c > @@ -299,7 +299,7 @@ change_line_handler (int editing) > > /* Don't try enabling editing if the interpreter doesn't support it > (e.g., MI). */ > - if (!top_level_interpreter ()->supports_command_editing () > + if (!current_ui->top_level_interpreter ()->supports_command_editing () > || !command_interp ()->supports_command_editing ()) > return; > > diff --git a/gdb/infrun.c b/gdb/infrun.c > index aaa7b2de14cd..9129abba8524 100644 > --- a/gdb/infrun.c > +++ b/gdb/infrun.c > @@ -2916,7 +2916,7 @@ clear_proceed_status_thread (struct thread_info *tp) > static void > notify_about_to_proceed () > { > - top_level_interpreter ()->on_about_to_proceed (); > + current_ui->top_level_interpreter ()->on_about_to_proceed (); > gdb::observers::about_to_proceed.notify (); > } > > @@ -4282,7 +4282,7 @@ check_curr_ui_sync_execution_done (void) > && !gdb_in_secondary_prompt_p (ui)) > { > target_terminal::ours (); > - top_level_interpreter ()->on_sync_execution_done (); > + current_ui->top_level_interpreter ()->on_sync_execution_done (); > ui->register_file_handler (); > } > } > diff --git a/gdb/interps.c b/gdb/interps.c > index f30357405877..0c5afa970651 100644 > --- a/gdb/interps.c > +++ b/gdb/interps.c > @@ -222,12 +222,6 @@ interpreter_completer (struct cmd_list_element *ignore, > } > } > > -struct interp * > -top_level_interpreter (void) > -{ > - return current_ui->top_level_interpreter; > -} > - > /* See interps.h. */ > > struct interp * > @@ -245,7 +239,7 @@ interps_notify (void (interp::*method) (Args...), Args... args) > { > SWITCH_THRU_ALL_UIS () > { > - interp *tli = top_level_interpreter (); > + interp *tli = current_ui->top_level_interpreter (); > if (tli != nullptr) > (tli->*method) (args...); > } > diff --git a/gdb/interps.h b/gdb/interps.h > index 8416d657fb9a..1073d0516cfe 100644 > --- a/gdb/interps.h > +++ b/gdb/interps.h > @@ -258,9 +258,6 @@ extern void current_interp_set_logging (ui_file_up logfile, > bool logging_redirect, > bool debug_redirect); > > -/* Returns the top-level interpreter. */ > -extern struct interp *top_level_interpreter (void); > - > /* Return the current UI's current interpreter. */ > extern struct interp *current_interpreter (void); > > diff --git a/gdb/linespec.c b/gdb/linespec.c > index fa733d880e38..bfee951bef2a 100644 > --- a/gdb/linespec.c > +++ b/gdb/linespec.c > @@ -48,6 +48,7 @@ > #include "gdbsupport/def-vector.h" > #include > #include "inferior.h" > +#include "ui.h" > > /* An enumeration of the various things a user might attempt to > complete for a linespec location. */ > @@ -3168,7 +3169,7 @@ decode_line_full (struct location_spec *locspec, int flags, > > if (select_mode == NULL) > { > - if (top_level_interpreter ()->interp_ui_out ()->is_mi_like_p ()) > + if (current_ui->top_level_interpreter ()->interp_ui_out ()->is_mi_like_p ()) > select_mode = multiple_symbols_all; > else > select_mode = multiple_symbols_select_mode (); > diff --git a/gdb/main.c b/gdb/main.c > index 58a79c518999..c31e28a79a74 100644 > --- a/gdb/main.c > +++ b/gdb/main.c > @@ -430,7 +430,7 @@ start_event_loop () > get around to resetting the prompt, which leaves readline > in a messed-up state. Reset it here. */ > current_ui->prompt_state = PROMPT_NEEDED; > - top_level_interpreter ()->on_command_error (); > + current_ui->top_level_interpreter ()->on_command_error (); > /* This call looks bizarre, but it is required. If the user > entered a command that caused an error, > after_char_processing_hook won't be called from > @@ -470,7 +470,7 @@ captured_command_loop () > > /* Give the interpreter a chance to print a prompt, if necessary */ > if (ui->prompt_state != PROMPT_BLOCKED) > - top_level_interpreter ()->pre_command_loop (); > + current_ui->top_level_interpreter ()->pre_command_loop (); > > /* Now it's time to start the event loop. */ > start_event_loop (); > diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c > index 60a2ed0bcc4c..30ba7a347b48 100644 > --- a/gdb/mi/mi-interp.c > +++ b/gdb/mi/mi-interp.c > @@ -235,7 +235,7 @@ mi_interp::on_sync_execution_done () > static void > mi_execute_command_input_handler (gdb::unique_xmalloc_ptr &&cmd) > { > - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); > + mi_interp *mi = as_mi_interp (current_ui->top_level_interpreter ()); > struct ui *ui = current_ui; > > ui->prompt_state = PROMPT_NEEDED; > @@ -630,7 +630,7 @@ mi_output_running (struct thread_info *thread) > { > SWITCH_THRU_ALL_UIS () > { > - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); > + mi_interp *mi = as_mi_interp (current_ui->top_level_interpreter ()); > > if (mi == NULL) > continue; > diff --git a/gdb/solib.c b/gdb/solib.c > index 4f980e9365c4..e434c7145e4b 100644 > --- a/gdb/solib.c > +++ b/gdb/solib.c > @@ -54,6 +54,7 @@ > #include "source.h" > #include "cli/cli-style.h" > #include "solib-target.h" > +#include "ui.h" > > /* See solib.h. */ > > @@ -1146,7 +1147,8 @@ info_sharedlibrary_command (const char *pattern, int from_tty) > uiout->field_skip ("to"); > } > > - if (! top_level_interpreter ()->interp_ui_out ()->is_mi_like_p () > + if (!(current_ui->top_level_interpreter ()->interp_ui_out () > + ->is_mi_like_p ()) > && so->symbols_loaded > && !objfile_has_symbols (so->objfile)) > { > diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c > index 941c65c970f3..818f5f8a1382 100644 > --- a/gdb/tui/tui.c > +++ b/gdb/tui/tui.c > @@ -399,7 +399,7 @@ tui_enable (void) > > /* If the top level interpreter is not the console/tui (e.g., > MI), enabling curses will certainly lose. */ > - interp = top_level_interpreter ()->name (); > + interp = current_ui->top_level_interpreter ()->name (); > if (strcmp (interp, INTERP_TUI) != 0) > error (_("Cannot enable the TUI when the interpreter is '%s'"), interp); > > diff --git a/gdb/ui.c b/gdb/ui.c > index ec74cc91cd21..e3d4a4765b80 100644 > --- a/gdb/ui.c > +++ b/gdb/ui.c > @@ -180,7 +180,7 @@ ui::set_current_interpreter (interp *interp, bool top_level) > /* If we already have an interpreter, then trying to > set top level interpreter is kinda pointless. */ > gdb_assert (!top_level || !this->current_interpreter); > - gdb_assert (!top_level || !this->top_level_interpreter); > + gdb_assert (!top_level || this->m_top_level_interpreter == nullptr); > > if (old_interp != NULL) > { > @@ -190,7 +190,7 @@ ui::set_current_interpreter (interp *interp, bool top_level) > > this->current_interpreter = interp; > if (top_level) > - this->top_level_interpreter = interp; > + this->m_top_level_interpreter = interp; > > if (interpreter_p != interp->name ()) > interpreter_p = interp->name (); > @@ -295,7 +295,7 @@ new_ui_command (const char *args, int from_tty) > > current_ui->set_top_level_interpreter (interpreter_name); > > - top_level_interpreter ()->pre_command_loop (); > + current_ui->top_level_interpreter ()->pre_command_loop (); > > /* Make sure the file is not closed. */ > stream.release (); > diff --git a/gdb/ui.h b/gdb/ui.h > index cebf112f971c..1ba45760c186 100644 > --- a/gdb/ui.h > +++ b/gdb/ui.h > @@ -86,7 +86,6 @@ struct ui : public intrusive_list_node > /* Each UI has its own independent set of interpreters. */ > intrusive_list interp_list; > interp *current_interpreter = nullptr; > - interp *top_level_interpreter = nullptr; > > /* The interpreter that is active while `interp_exec' is active, NULL > at all other times. */ > @@ -185,6 +184,13 @@ struct ui : public intrusive_list_node > Throws an error if NAME is not a known interpreter or the interpreter fails > to initialize. */ > void set_top_level_interpreter (const char *name); > + > + /* Return this UI's top level interpreter. */ > + interp *top_level_interpreter () > + { return m_top_level_interpreter; } I think this function should be marked const. Thanks, Andrew > + > +private: > + interp *m_top_level_interpreter = nullptr; > }; > > /* The main UI. This is the UI that is bound to stdin/stdout/stderr. > diff --git a/gdb/utils.c b/gdb/utils.c > index cacd6cbd23e6..ef46b6bc292d 100644 > --- a/gdb/utils.c > +++ b/gdb/utils.c > @@ -1606,8 +1606,9 @@ pager_file::puts (const char *linebuffer) > /* Don't do any filtering or wrapping if both are disabled. */ > if (batch_flag > || (lines_per_page == UINT_MAX && chars_per_line == UINT_MAX) > - || top_level_interpreter () == NULL > - || top_level_interpreter ()->interp_ui_out ()->is_mi_like_p ()) > + || current_ui->top_level_interpreter () == NULL > + || (current_ui->top_level_interpreter ()->interp_ui_out () > + ->is_mi_like_p ())) > { > flush_wrap_buffer (); > m_stream->puts (linebuffer); > -- > 2.42.0