From: Simon Marchi <simon.marchi@polymtl.ca>
To: Lancelot SIX <lsix@lancelotsix.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v4 3/4] gdb: Have setter and getter callbacks for settings
Date: Thu, 30 Sep 2021 08:42:04 -0400 [thread overview]
Message-ID: <e76da67a-692c-8ac4-2695-2e32620c132e@polymtl.ca> (raw)
In-Reply-To: <20210929215011.1489639-4-lsix@lancelotsix.com>
Just some nits:
> @@ -475,6 +479,7 @@ add_set_or_show_cmd (const char *name,
>
> gdb_assert (type == set_cmd || type == show_cmd);
> c->type = type;
> +
> c->var.emplace (var_type, arg);
Spurious new line added.
> @@ -219,18 +249,42 @@ struct setting
> (see VAR_TYPE_USES). */
> setting (var_types var_type, const erased_args &args)
> : m_var_type (var_type),
> - m_var (args.var)
> + m_var (args.var),
> + m_getter (args.getter),
> + m_setter (args.setter)
> {
> }
>
> - /* Access the type of the current setting. */
> - var_types type () const
> + /* Create a setting backed by setter and getter functions.
> +
> + Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */
> + template<typename T>
> + setting (var_types var_type,
> + setting_setter_ftype<T> setter,
> + setting_getter_ftype<T> getter)
> + : m_var_type (var_type)
> {
> - return m_var_type;
> + gdb_assert (var_type_uses<T> (var_type));
> +
> + /* Getters and setters are cast to and from the arbitrary `void (*) ()`
> + function pointer type. Make sure that the two types are really of the
> + same size. */
> + gdb_static_assert (sizeof (m_getter) == sizeof (getter));
> + gdb_static_assert (sizeof (m_setter) == sizeof (setter));
> +
> + m_getter = reinterpret_cast<erased_func> (getter);
> + m_setter = reinterpret_cast<erased_func> (setter);
> }
>
> + /* Access the type of the current setting. */
> + var_types type () const
> + { return m_var_type; }
> +
> /* Return the current value.
>
> + Calling this method is only valid if the current setting is stored in a
> + variable referenced by m_var (i.e. 'storage () == storage::variable').
That part of the comment seems false.
Simon
next prev parent reply other threads:[~2021-09-30 12:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-29 21:50 [PATCH v4 0/4] Refactor cmd_list_element.var Lancelot SIX
2021-09-29 21:50 ` [PATCH v4 1/4] gdb: Introduce setting construct within cmd_list_element Lancelot SIX
2021-09-30 12:12 ` Simon Marchi
2021-09-30 12:30 ` Simon Marchi
2021-09-30 23:15 ` Lancelot SIX
2021-10-01 1:16 ` Simon Marchi
2021-09-30 12:39 ` Simon Marchi
2021-09-29 21:50 ` [PATCH v4 2/4] gdb: make string-like set show commands use std::string variable Lancelot SIX
2021-09-29 21:50 ` [PATCH v4 3/4] gdb: Have setter and getter callbacks for settings Lancelot SIX
2021-09-30 12:42 ` Simon Marchi [this message]
2021-10-05 19:10 ` Simon Marchi
2021-10-05 20:27 ` Lancelot SIX
2021-10-05 20:39 ` Simon Marchi
2021-10-05 22:21 ` Lancelot SIX
2021-09-29 21:50 ` [PATCH v4 4/4] gdb: Setting setter return a bool to tell if the value changed Lancelot SIX
2021-09-30 12:43 ` Simon Marchi
2021-09-30 12:44 ` [PATCH v4 0/4] Refactor cmd_list_element.var Simon Marchi
2021-10-03 19:22 ` Lancelot SIX
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=e76da67a-692c-8ac4-2695-2e32620c132e@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=lsix@lancelotsix.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).