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 BEE8C3858430 for ; Tue, 12 Sep 2023 10:58:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BEE8C3858430 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=1694516328; 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=KUqEqsiIrFcELqvyrtULNmFGVn1tTc3qObtJmTcWd5Q=; b=dU7vKzc91BXuC9cc+pKxXgh2mH/C1EvJUU8bw1McRRlGj7E4a6DXgB1xYMUYg66Nxba0D/ sgz1mgrwd5I5kg+Jq+6+b+JkR2sezfnCvavBvo3JLYiSomZab7xdG+GjSHhbCHA8WJDdWE cq9o9i2sCQwkTzE15iUday8Ppind7DQ= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-412-a41TWkO5O8aOfvfhvZjP-g-1; Tue, 12 Sep 2023 06:58:47 -0400 X-MC-Unique: a41TWkO5O8aOfvfhvZjP-g-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-30932d15a30so3877943f8f.1 for ; Tue, 12 Sep 2023 03:58:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694516326; x=1695121126; 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=KUqEqsiIrFcELqvyrtULNmFGVn1tTc3qObtJmTcWd5Q=; b=VPEufi4+pCLjcNB4qlU535ds2oh2lFraHPk2Fru/TEM5Au0VS3Ag4QQQWgp0E4yi2C 4iOQF2B6ZqaqMrZhp81uFTPUdbKbFg17jyMwQNps2yXFwTwYc6EJa20/iSlWSkt9KlVn yHC669YfgsNj2e1SfGpGvWU0KqPe11pz6Yu63y7MVvCx5IICMaxqMvxrA3chw6liEkhm gsdLX6vXRy+meBdgVfwBkhE0LaJwycRGb0S513ltBlE1OA0mqbdqlFDBk/k3BwYDWPlp f6U/vucgPwXz3SceUDMiQiWymdvbtjmLWC3r7DOuJwyrSKh3vzl92kIyWCH0LFo/hY/4 Yu4g== X-Gm-Message-State: AOJu0YwRKGhu7seGvMfhVJA7BncBFkvvtN89W9vjfvDeOwY9rxUIk8Te wQI0eSbxuxp5tgJIWIbGniYiZQFckZP7KxwOPRzB7WKe0pVTgUzhmQIv+f2SKZnDX7PWvsEVw07 6/gXgM30VeGsXc1Q4QCVgbtvKYJ1TSVvBwDmzRFyyL4wWpjeqw075AtF3e34CMfQfgMPTQJPx2X kImiioeg== X-Received: by 2002:adf:ce89:0:b0:31a:d4d0:6e98 with SMTP id r9-20020adfce89000000b0031ad4d06e98mr9367343wrn.8.1694516325918; Tue, 12 Sep 2023 03:58:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUKz/yzV2aZPOUbQfO5pba5kb5bfReHo9B7eMHJgLYbtpiXcBVplZ7g7zLxJHFQWfNiaFVMg== X-Received: by 2002:adf:ce89:0:b0:31a:d4d0:6e98 with SMTP id r9-20020adfce89000000b0031ad4d06e98mr9367329wrn.8.1694516325381; Tue, 12 Sep 2023 03:58:45 -0700 (PDT) Received: from localhost (197.126.90.146.dyn.plus.net. [146.90.126.197]) by smtp.gmail.com with ESMTPSA id y11-20020adfd08b000000b003140fff4f75sm12444869wrh.17.2023.09.12.03.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 03:58:44 -0700 (PDT) From: Andrew Burgess To: Simon Marchi via Gdb-patches , gdb-patches@sourceware.org Cc: Simon Marchi Subject: Re: [PATCH 18/21] gdb: make interp_set a method of struct ui In-Reply-To: <20230908190227.96319-19-simon.marchi@efficios.com> References: <20230908190227.96319-1-simon.marchi@efficios.com> <20230908190227.96319-19-simon.marchi@efficios.com> Date: Tue, 12 Sep 2023 11:58:44 +0100 Message-ID: <875y4fk68r.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: > Move interp_set to ui::set_current_interpreter. > > Change-Id: I7e83ca7732bb6229a1e61dc0e3832f54c20c3f52 > --- > gdb/interps.c | 66 +++------------------------------------------------ > gdb/ui.c | 51 +++++++++++++++++++++++++++++++++++++++ > gdb/ui.h | 12 ++++++++++ > 3 files changed, 66 insertions(+), 63 deletions(-) > > diff --git a/gdb/interps.c b/gdb/interps.c > index 18758f1f7af6..465c174ea794 100644 > --- a/gdb/interps.c > +++ b/gdb/interps.c > @@ -80,66 +80,6 @@ find_interp_factory (const char *name) > return nullptr; > } > > -/* This sets the current interpreter to be INTERP. If INTERP has not > - been initialized, then this will also run the init method. > - > - The TOP_LEVEL parameter tells if this new interpreter is > - the top-level one. The top-level is what is requested > - on the command line, and is responsible for reporting general > - notification about target state changes. For example, if > - MI is the top-level interpreter, then it will always report > - events such as target stops and new thread creation, even if they > - are caused by CLI commands. */ > - > -static void > -interp_set (ui *ui, struct interp *interp, bool top_level) > -{ > - struct interp *old_interp = ui->current_interpreter; > - > - /* If we already have an interpreter, then trying to > - set top level interpreter is kinda pointless. */ > - gdb_assert (!top_level || !ui->current_interpreter); > - gdb_assert (!top_level || !ui->top_level_interpreter); > - > - if (old_interp != NULL) > - { > - ui->m_current_uiout->flush (); > - old_interp->suspend (); > - } > - > - ui->current_interpreter = interp; > - if (top_level) > - ui->top_level_interpreter = interp; > - > - if (interpreter_p != interp->name ()) > - interpreter_p = interp->name (); > - > - bool warn_about_mi1 = false; > - > - /* Run the init proc. */ > - if (!interp->inited) > - { > - interp->init (top_level); > - interp->inited = true; > - > - if (streq (interp->name (), "mi1")) > - warn_about_mi1 = true; > - } > - > - /* Do this only after the interpreter is initialized. */ > - ui->m_current_uiout = interp->interp_ui_out (); > - > - /* Clear out any installed interpreter hooks/event handlers. */ > - clear_interpreter_hooks (); > - > - interp->resume (); > - > - if (warn_about_mi1) > - warning (_("MI version 1 is deprecated in GDB 13 and " > - "will be removed in GDB 14. Please upgrade " > - "to a newer version of MI.")); > -} > - > /* See interps.h. */ > > void > @@ -151,7 +91,7 @@ set_top_level_interpreter (const char *name) > if (interp == NULL) > error (_("Interpreter `%s' unrecognized"), name); > /* Install it. */ > - interp_set (current_ui, interp, true); > + current_ui->set_current_interpreter (interp, true); > } > > void > @@ -267,10 +207,10 @@ interpreter_exec_cmd (const char *args, int from_tty) > if (interp_to_use == NULL) > error (_("Could not find interpreter \"%s\"."), prules[0]); > > - interp_set (current_ui, interp_to_use, false); > + current_ui->set_current_interpreter (interp_to_use, false); > SCOPE_EXIT > { > - interp_set (current_ui, old_interp, false); > + current_ui->set_current_interpreter (old_interp, false); > }; > > for (i = 1; i < nrules; i++) > diff --git a/gdb/ui.c b/gdb/ui.c > index 8c04dc92b89e..2db899eb9c31 100644 > --- a/gdb/ui.c > +++ b/gdb/ui.c > @@ -172,6 +172,57 @@ ui::lookup_interp (const char *name) > > /* See ui.h. */ > > +void > +ui::set_current_interpreter (interp *interp, bool top_level) > +{ > + struct interp *old_interp = this->current_interpreter; Is there any way that we can assert something like: gdb_assert (this == interp->m_ui); we maybe need an interp::mi() accessor function. > + > + /* 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); > + > + if (old_interp != NULL) > + { > + m_current_uiout->flush (); > + old_interp->suspend (); > + } > + > + this->current_interpreter = interp; > + if (top_level) > + this->top_level_interpreter = interp; > + > + if (interpreter_p != interp->name ()) > + interpreter_p = interp->name (); > + > + bool warn_about_mi1 = false; > + > + /* Run the init proc. */ > + if (!interp->inited) > + { > + interp->init (top_level); > + interp->inited = true; > + > + if (streq (interp->name (), "mi1")) > + warn_about_mi1 = true; > + } > + > + /* Do this only after the interpreter is initialized. */ > + m_current_uiout = interp->interp_ui_out (); > + > + /* Clear out any installed interpreter hooks/event handlers. */ > + clear_interpreter_hooks (); > + > + interp->resume (); > + > + if (warn_about_mi1) > + warning (_("MI version 1 is deprecated in GDB 13 and " > + "will be removed in GDB 14. Please upgrade " > + "to a newer version of MI.")); > +} > + > +/* See ui.h. */ > + > void > ui::unregister_file_handler () > { > diff --git a/gdb/ui.h b/gdb/ui.h > index be89ab3d6848..4f6a32991d6d 100644 > --- a/gdb/ui.h > +++ b/gdb/ui.h > @@ -167,6 +167,18 @@ struct ui : public intrusive_list_node > interp_factory_register, return nullptr; otherwise return a pointer to > the interpreter. */ > interp *lookup_interp (const char *name); > + > + /* This sets the current interpreter of this UI to be INTERP. If INTERP has > + not been initialized, then this will also run the init method. > + > + The TOP_LEVEL parameter tells if this new interpreter is I know these aren't your words, but could we take this chance to update this text to: The TOP_LEVEL parameter is true if this new interpreter is which reads much nicer. Thanks, Andrew > + the top-level one. The top-level is what is requested > + on the command line, and is responsible for reporting general > + notification about target state changes. For example, if > + MI is the top-level interpreter, then it will always report > + events such as target stops and new thread creation, even if they > + are caused by CLI commands. */ > + void set_current_interpreter (interp *interp, bool top_level); > }; > > /* The main UI. This is the UI that is bound to stdin/stdout/stderr. > -- > 2.42.0