[PATCH 1/2] gdb: add set/show commands for managing debuginfod

Simon Marchi simon.marchi@polymtl.ca
Sun Oct 31 02:43:06 GMT 2021


On 2021-10-29 21:54, Simon Marchi via Gdb-patches wrote:
> On 2021-10-29 21:09, Aaron Merey wrote:
>> Changed to use add_setshow_prefix_cmd. Because this function
>> doesn't have a parameter for a custom show function I added
>> a 'show debuginfod status' command so that the user can check
>> whether debuginfod is set to 'on', 'off' or 'ask'.
> 
> Ah, I had not realized that, sorry.  Well, you could have left it
> as-is then :/.

Hi Aaron,

I re-visited how I suggested you to do "set debuginfod", which were
based on how I designed "set index-cache", and I think it's not right
after all.

I don't think it was good idea to overload "set index-cache" as a
boolean setting and a prefix command.  First, I had to add the
information of whether index-cache is enabled as custom message:


    (gdb) show index-cache 
    index-cache directory:  The directory of the index cache is "/home/simark/.cache/gdb".
    index-cache stats:  
        Cache hits (this session): 0
      Cache misses (this session): 0

    The index cache is currently disabled.  <---

This is not good, because in "info set" it looks like this:

    (gdb) info set
    ...
    host-charset:  The host character set is "auto; currently UTF-8".
    index-cache directory:  The directory of the index cache is "/home/simark/.cache/gdb".
    index-cache stats:    Cache hits (this session): 0
    Cache misses (this session): 0
    inferior-tty:  Terminal for future runs of program being debugged is "".
    ...

This just looks weird.  Also, because the index-cache on/off knob isn't
a proper setting, it doesn't appear in MI, a frontend can't know if
index-cache is enabled or not:

    -gdb-show index-cache 
    ~"\n"
    ~"    Cache hits (this session): 0\n"
    ~"  Cache misses (this session): 0\n"
    ~"\n"
    ~"The index cache is currently disabled.\n"
    ^done,showlist={option={name="directory",value="/home/simark/.cache/gdb"},option={name="stats"}}

You solved this by adding "set debuginfod status", which is a bit
better, but also not ideal.  It's weird for the set command used to toggle
debuginfod on and off to not mirror the show command used to show the
state.

So, I think that having dedicated commands "set/show index-cache enabled
on/off" and "set/show debuginfod enabled on/off" is better, in the end.
What do you think?

Another mistake I think I did with the index-cache is "show index-cache
stats".  Set/show commands are supposed to be for settings.  This is
just printing some information, not a setting value.  Using a show
command for this means that the index-cache stats are printed when
doing "info set", which makes no sense.  Also, printing the "setting" in
MI is useless:

    -gdb-show index-cache stats
    ~"  Cache hits (this session): 0\n"
    ~"Cache misses (this session): 0\n"
    ^done

I think that this should have been an info command, "info index-cache
stats" maybe.

I'm considering fixing this for the index-cache (deprecating the old
commands, but keeping them as aliases of the new ones).  If you agree, I
could do the same with "set debuginfo" too.

Simon



More information about the Gdb-patches mailing list