Re: [PATCH 00/16] Add styling to the gdb CLI and TUI

Matt Rice
2019-03-03T16:16:44Z

On Sun, Mar 3, 2019 at 7:53 AM Eli Zaretskii <eliz@gnu.org> wrote:
>
> A few minor comments and questions related to this feature:
>
> And one more issue, only tangentially related: if I put on my
> ~/.gdbinit settings that customize style, older versions of GDB
> complain when they start up, because they don't know about styles. Is
> there any way of conditioning scripting commands on the GDB version,
> or some other way of avoiding such problems?

I didn't see a easy way to get the gdb version from python,
except parsing the output of "show version", perhaps I missed it.

but I have added stuff conditional on the inferior binary name before..
py
def on_bin_echo(): gdb.execute("set arg -d")
exec_funcs = {"/bin/echo" : on_bin_echo}
map(lambda x: exec_funcs[x.filename]() if
exec_funcs.has_key(x.filename) else None, gdb.objfiles())
end

You should be able to do the same by parsing the output of 'show version',
However, given that, I think it'd be better in this case to just try
and use the gdb.parameter API from python to set the setting,
and handling any exception which should be thrown for old gdb without
the appropriate parameter.

If the gdb in question python or guile, I really have no idea, but i
hope that helps.