From: Lancelot SIX <lsix@lancelotsix.com>
To: Tom Tromey <tom@tromey.com>
Cc: Lancelot SIX via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH 15/16] gdb: make cmd_list_element var an optional union
Date: Wed, 28 Jul 2021 20:45:38 +0000 [thread overview]
Message-ID: <20210728204538.z3iqkcfp7yenehms@ubuntu.lan> (raw)
In-Reply-To: <87sfzyci3i.fsf@tromey.com>
On Wed, Jul 28, 2021 at 02:13:21PM -0600, Tom Tromey wrote:
> >>>>> "Lancelot" == Lancelot SIX via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Lancelot> This patch proposes to add an abstraction around the pair of the
> Lancelot> var_type and the void* pointer in order to prevent the user having to
> Lancelot> handle the cast. This is achieved by introducing the setting struct,
> Lancelot> and a set of templated member functions. The template parameter is the
> Lancelot> VAR_TYPES we want to the access the data for. The template ensures the
> Lancelot> return type of the get method and the parameter type of the set method
> Lancelot> matches the data type used to store the actual data.
>
> Seems nice.
>
> Lancelot> int get<var_integer, var_zinteger> ()
>
> It seems to me that it might be better if the get<> template itself knew
> about the storage equivalence between different var_ types and so code
> like this:
>
> Lancelot> + var = cmd->var.get<var_string,
> Lancelot> + var_string_noescape,
> Lancelot> + var_optional_filename,
> Lancelot> + var_filename> ();
>
> ... could be simplified.
>
> Tom
Hi,
Would you prefer to have something like var.get<var_string> () return a
string happily if var is lets say a var_filename but fail if it is a
var_boolean?
I guess it is possible, but I did intentionally went for a very explicit
approach. The idea is to have the user of the class state that he is
aware he will access a data of a given type that can be interpreted in
different ways. This kind of makes more sense when dealing with the
various var_*integer* types where the same value can have different
meaning depending on the effective var_type.
In a way, I guess this is covered by the various fall through of the
switch / case statement where this call is typically used. The
limitation of this is that the switch will not complain if you try to
share a code path for incompatible types, you will need to wait for a
runtime error instead of a compile time error.
Anyway, if you find it more practical, I can try rework the interface
this way.
By the way, I just posted a complete series that contains this proposal,
plus other improvements[1].
I’ll probably wait a bit to see if I get different feedbacks and
come up with something I fill will work for the most.
Thanks,
Lancelot.
[1] https://sourceware.org/pipermail/gdb-patches/2021-July/181183.html
next prev parent reply other threads:[~2021-07-28 20:45 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-14 4:55 [PATCH 00/16] Bunch of commands related cleanups Simon Marchi
2021-07-14 4:55 ` [PATCH 01/16] gdb/testsuite: split gdb.python/py-parameter.exp in procs Simon Marchi
2021-07-14 4:55 ` [PATCH 02/16] gdb.base/setshow.exp: use save_vars to save/restore gdb_prompt Simon Marchi
2021-07-14 4:55 ` [PATCH 03/16] gdb.base/setshow.exp: split in procs Simon Marchi
2021-07-14 4:55 ` [PATCH 04/16] gdb.base/setshow.exp: fix duplicate test name Simon Marchi
2021-07-14 4:55 ` [PATCH 05/16] gdb: un-share set_inferior_cwd declaration Simon Marchi
2021-07-14 4:55 ` [PATCH 06/16] gdb: remove inferior::{argc,argv} Simon Marchi
2021-07-14 4:55 ` [PATCH 07/16] gdb: add setter/getter for inferior arguments Simon Marchi
2021-07-14 4:55 ` [PATCH 08/16] gdb: add setter/getter for inferior cwd Simon Marchi
2021-07-14 4:55 ` [PATCH 09/16] gdb: make inferior::m_args an std::string Simon Marchi
2021-07-14 4:55 ` [PATCH 10/16] gdb: make inferior::m_cwd " Simon Marchi
2021-07-14 4:55 ` [PATCH 11/16] gdb: make inferior::m_terminal " Simon Marchi
2021-07-14 4:55 ` [PATCH 12/16] gdb: rename cfunc to simple_func Simon Marchi
2021-07-14 4:55 ` [PATCH 13/16] gdb: remove cmd_list_element::function::sfunc Simon Marchi
2021-07-28 19:10 ` Tom Tromey
2021-07-28 21:17 ` Simon Marchi
2021-07-29 17:33 ` Tom Tromey
2021-07-14 4:55 ` [PATCH 14/16] gdb/testsuite: test get/set value of unregistered Guile parameter Simon Marchi
2021-07-23 19:42 ` Simon Marchi
2021-07-14 4:55 ` [PATCH 15/16] gdb: make cmd_list_element var an optional union Simon Marchi
2021-07-14 12:08 ` Lancelot SIX
2021-07-14 17:12 ` Lancelot SIX
2021-07-14 19:22 ` Simon Marchi
2021-07-14 23:22 ` Lancelot SIX
2021-07-19 14:32 ` Simon Marchi
2021-07-19 19:52 ` Simon Marchi
2021-07-20 23:03 ` Lancelot SIX
2021-07-23 19:56 ` Simon Marchi
2021-07-23 20:46 ` Lancelot SIX
2021-07-23 21:15 ` Simon Marchi
2021-07-23 22:55 ` Lancelot SIX
2021-07-24 2:04 ` Simon Marchi
2021-07-28 20:13 ` Tom Tromey
2021-07-28 20:45 ` Lancelot SIX [this message]
2021-07-29 17:47 ` Tom Tromey
2021-07-29 20:12 ` Lancelot SIX
2021-07-30 2:09 ` Simon Marchi
2021-07-30 17:47 ` Lancelot SIX
2021-07-18 15:44 ` Lancelot SIX
2021-07-19 14:19 ` Simon Marchi
2021-07-19 20:58 ` Lancelot SIX
2021-07-28 19:47 ` Tom Tromey
2021-07-28 20:59 ` Simon Marchi
2021-07-29 17:41 ` Tom Tromey
2021-07-29 17:44 ` Simon Marchi
2021-07-29 17:49 ` Tom Tromey
2021-07-29 18:00 ` Simon Marchi
2021-07-14 4:55 ` [PATCH 16/16] gdb: make string-like set show commands use std::string variable Simon Marchi
2021-07-28 20:27 ` Tom Tromey
2021-07-28 21:03 ` Simon Marchi
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=20210728204538.z3iqkcfp7yenehms@ubuntu.lan \
--to=lsix@lancelotsix.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.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).