This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFAv3 0/3] Convenience functions $_gdb_setting/$_gdb_int_setting
- From: Pedro Alves <palves at redhat dot com>
- To: Philippe Waroquiers <philippe dot waroquiers at skynet dot be>, gdb-patches at sourceware dot org
- Date: Mon, 8 Jul 2019 17:34:49 +0100
- Subject: Re: [RFAv3 0/3] Convenience functions $_gdb_setting/$_gdb_int_setting
- References: <20190706104947.30301-1-philippe.waroquiers@skynet.be>
Hi Philippe,
Some overall design comments below.
On 7/6/19 11:49 AM, Philippe Waroquiers wrote:
> As part of the discussion of 'show | set may-call-functions [on|off]',
> Eli suggested to have a way to access the GDB settings from
> user defined commands.
>
As I had mentioned back then:
https://sourceware.org/ml/gdb-patches/2019-04/msg00562.html
we can already access the settings via Python. E.g. see it
done here from a gdbinit script:
https://gcc.gnu.org/ml/gcc-patches/2019-01/msg00135.html
Copied here for convenience:
python __gcc_prev_pagination=gdb.parameter("pagination")
set pagination off
...
python if __gcc_prev_pagination: gdb.execute("set pagination on")
Given that, and the existence of the "with" command now for the
common case, I'd like to at least see some mention/rationale/argument
in the commit logs about why this is worth having/maintaining
over just using gdb.parameter.
BTW, did you look into how gdb.parameter is implemented, see if
anything could be shared?
BTW², kind of unfortunate that Python used a different naming
here (settings vs parameters).
> So, this patch series implements this.
>
> 2 functions are provided:
> * $_gdb_setting that gives access to all settings, giving back a string value.
> * $_gdb_int_setting, giving access to boolean, auto-boolean and integers.
> This is easier to use for such types than the string version.
The naming of the functions kind of seems a bit reversed to me. Off hand, I'd
expect $_gdb_setting to give me the setting in its native type, and then
something like $_gdb_setting_str to give me a string version/representation.
Also, it seems like a design issue that settings that are unsigned
internally get their values exposed as signed.
I guess it could be even better if the setting's types were some new built-in
types specific for the settings, and then if you wanted to get a string
representation, you'd use '$_as_string($_gdb_setting(...))'. (*)
(*) this made me wonder about a special $_python convenience function,
which would take some python code as argument, and return a value, so you
could write:
if $_python(gdb.parameter ("pagination"))
...
end
etc.
> This is v3.
> Compared to v1, it rebases to a recent master, and handles the comments
> of Eli about the documentation.
>
> (there was in fact no changes between v2 and v1, because I forgot to
> commit the changes before sending the RFAv2 mail).
Thanks,
Pedro Alves