public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Lancelot SIX <lsix@lancelotsix.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 15/16] gdb: make cmd_list_element var an optional union
Date: Fri, 23 Jul 2021 20:46:29 +0000	[thread overview]
Message-ID: <20210723204613.ud6kkhnt46dz4bq3@ubuntu.lan> (raw)
In-Reply-To: <f3ae4240-ffb5-3150-9b8f-4e0d78d0a83f@polymtl.ca>

Hi,

I plan on spending some more time on it this week end hopefully.

If you do not mind waiting a bit for my patch to be finalized, and want
to go with my approach, there is indeed no point merging yours now.  The
main thing I try to avoid is having both of us working at the same time
on different solutions of the same problem.  Your approach has the
advantage of being almost ready, I can wait for it to be stabilized
before I adapt my work on top on it.  If you are fine waiting for my
approach, I’ll proceed!

My plan is to:

- Improve slightly
  https://sourceware.org/pipermail/gdb-patches/2021-July/180991.html
  (use gdb::Requires instead of static assert, include the python
  binding I forgot because I did not build it, add some selftests of
  the runtime checks introduced by the getters and getters, and ensure
  the documentation is adequate).
- Adapt your patch using std::string on top on my architecture
  (https://sourceware.org/pipermail/gdb-patches/2021-July/180921.html).
- Add a new patch that allows the use of setter / getter (based on what
  was is drafted in
  https://sourceware.org/pipermail/gdb-patches/2021-July/181037.html).
  As a side note, the storage of user provided getter / setter functions
  is done using a unions (void* is not an appropriate for that).  It is
  possible to use the same approach to create getters and setters around
  the union of pointers you provide in your patch (but this would require
  some work, obviously).

Does that makes sense?

Best,
Lancelot.

On Fri, Jul 23, 2021 at 03:56:57PM -0400, Simon Marchi wrote:
> > Hi,
> > 
> > I reworked a bit my previous implementation to see to what extent it can
> > support what you are looking for.  Short answer: it can (and it is
> > completely transparent to the caller).
> > 
> > In the previous draft version[1], I introduced a struct that groups
> > together the var_type and the pointer to the actual data in order to
> > abstract a setting (i.e. a value with a type that can be SET or SHOWn).
> > This struct provides getters and setters in order to enforce that we
> > cast the pointer to the adequate type.  I have modified this data
> > structure so we can register user-provided callbacks.  If those
> > functions are provided, the getter and setters will call them to
> > generate retrieve the value instead of trying to dereference the
> > pointer.
> > 
> > For the moment, I just made sure that this compiles and I played with
> > dummy settings in my local tree.  It is not yet finalized nor fully
> > operational because do_set_command will try to free the pointer returned
> > by the getter when dealing with char* data.  With user provided
> > callbacks memory should probably not be managed at that level but by the
> > getter / setter.  Nothing worrying, you have a commit that plans to
> > change the char* with std::string, this should solve the issue quite
> > nicely.
> > 
> > As for the previous version, this adds a significant amount of templated
> > code that can make the implementation appear quite complex.
> > 
> > I think I’ll wait for your series to land before I finalize this
> > proposal (this is just a POC for the moment) unless you want to build on
> > top of this approach to introduce user provided callbacks.
> 
> Do you suggest I merge my patch that makes it a union first?  Won't that
> be counter productive if you plan to make it a void* again?  I'm a bit
> lost now, so I am not sure what's the best order for doing things.
> 
> Simon

  reply	other threads:[~2021-07-23 20:46 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 [this message]
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
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=20210723204613.ud6kkhnt46dz4bq3@ubuntu.lan \
    --to=lsix@lancelotsix.com \
    --cc=gdb-patches@sourceware.org \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).