From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: Lancelot SIX <lsix@lancelotsix.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2 3/4] gdb: Have setter and getter callbacks for settings
Date: Mon, 9 Aug 2021 23:01:10 -0400 [thread overview]
Message-ID: <727ab80a-c72d-960a-6d6e-a731aaa147dd@polymtl.ca> (raw)
In-Reply-To: <20210808192302.3768766-4-lsix@lancelotsix.com>
On 2021-08-08 3:23 p.m., Lancelot SIX via Gdb-patches wrote:
> The main motivation behind this improvement is to help the
> implementation of a patch Simon Marchi is preparing to fix a bug when
> MI or Python try to access parameters that are inferior dependent (see
> PR/28085).
>
> This commit extends the previous one, which introduces the setting
> object to represent a static variable that can be set or shown with the
> appropriate commands. This patch proposes that a setting can either
> contain a pointer to a static variable holding a setting, or pointers to
> a pair of setter and getter callback functions.
>
> The callbacks functions can be used to generate values on the fly when
> the setting is accessed (or set the value in a context dependent way).
> This is useful when the source of truth is not contained in the
> variable pointed to by the setting instance.
>
> Given that the callback function call is hidden within the setting
> abstraction introduced earlier, none of the sites accessing the setting
> needs to be updated. The registered getter or setter is used whatever
> the way to access it is (through MI, Python, Guild, the "with" command
> and the $_gdb_setting / $_gdb_setting_str convenience functions).
>
> All the add_setshow_*_cmd are given a new overload that will accept the
> pair of function pointers (set / get functions) instead of the pointer
> to a global variable.
LGTM, except a small issue I found while rebasing my patch on top of
your series:
> @@ -231,25 +427,50 @@ struct base_setting
> gdb_assert (var_type_uses<T> (this->m_var_type));
> gdb_assert (!this->empty ());
I think this needs to call operator bool, like so:
gdb_assert (*this);
Otherwise, the assert fails when using a getter/setter (empty only
checks for m_var to be non-NULL, which is false when using
getter/setter).
I don't find this notation super clear, it might be clearer if we could
call a named method instead of operator bool. Maybe "empty" could mean
"does not have a buffer nor getter/setter"?
Simon
next prev parent reply other threads:[~2021-08-10 3:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-08 19:22 [PATCH v2 0/4] gdb: Refactor cmd_list_element.var Lancelot SIX via Gdb-patches
2021-08-08 19:22 ` [PATCH v2 1/4] gdb: Add typesafe getter/setter for cmd_list_element.var Lancelot SIX via Gdb-patches
2021-08-10 1:29 ` Simon Marchi via Gdb-patches
2021-08-10 12:22 ` Simon Marchi via Gdb-patches
2021-08-10 21:58 ` Lancelot SIX via Gdb-patches
2021-08-11 0:56 ` Simon Marchi via Gdb-patches
2021-08-08 19:23 ` [PATCH v2 2/4] gdb: make string-like set show commands use std::string variable Lancelot SIX via Gdb-patches
2021-08-08 19:23 ` [PATCH v2 3/4] gdb: Have setter and getter callbacks for settings Lancelot SIX via Gdb-patches
2021-08-10 3:01 ` Simon Marchi via Gdb-patches [this message]
2021-08-10 22:18 ` Lancelot SIX via Gdb-patches
2021-08-11 1:01 ` Simon Marchi via Gdb-patches
2021-08-11 20:00 ` Lancelot SIX via Gdb-patches
2021-08-19 21:03 ` Simon Marchi via Gdb-patches
2021-08-20 7:04 ` Lancelot SIX via Gdb-patches
2021-08-08 19:23 ` [PATCH v2 4/4] gdb: Setting setter return a bool to tell if the value changed Lancelot SIX via Gdb-patches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=727ab80a-c72d-960a-6d6e-a731aaa147dd@polymtl.ca \
--to=gdb-patches@sourceware.org \
--cc=lsix@lancelotsix.com \
--cc=simon.marchi@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox