[PATCH 0/3] [RFC] Load gdbinit files from a directory

Sergio Durigan Junior sergiodj@redhat.com
Wed Aug 21 18:54:00 GMT 2019

On Wednesday, August 21 2019, Christian Biesinger via gdb-patches wrote:

> On Wed, Aug 21, 2019 at 1:13 PM Pedro Alves <palves@redhat.com> wrote:
>> On 8/20/19 11:17 PM, Christian Biesinger via gdb-patches wrote:
>> > This patch series is some refactoring and then a patch to load gdbinit
>> > files from a directory, instead of only allowing a single file.
>> >
>> > Fedora ships a system gdbinit file that does something similar; this
>> > does this by default and also works if Python is disabled.
>> Note that Fedora won't be able to replace the current mechanism with
>> this, because it also loads Python files from the dir:
>>  python
>>  import glob
>>  # glob.iglob is not available in python-2.4 (RHEL-5).
>>  for f in glob.glob('/etc/gdbinit.d/*.gdb'):
>>    gdb.execute('source %s' % f)
>>  for f in glob.glob('/etc/gdbinit.d/*.py'):
>>    gdb.execute('source %s' % f)
>>  end
>> So we'd need an additional "--with-system-python-scripts-dir"
>> for Python scripts or some such.
> That's a good point. I don't think -with-system-python-scripts-dir
> would really work for Fedora either since the directory there is
> currently the same but I could change the patch to use
> get_ext_lang_of_file/ext_lang_script_sourcer (which is effectively
> pretty similar to the current Fedora gdbinit)

I don't think we need to have separate directories for
Python/Guile/"native" GDB scripts.  I think we should consolidate all of
these scripts inside one directory.

>> Speaking of Python scripts, I guess Fedora's script should be
>> loading Guile scripts as well.

Guile support has been (temporarily?) disabled in Fedora GDB.

> I agree. (Certainly if GDB shipped a default gdbinit like that, it
> should do that)

>> That isn't to say that I object to your patchset, TBC.  I just
>> see it a bit under the "why do it in C when you can script" light.
>> Of course the answer can reasonably be "I need this without Python".
> So there were two reasons why I liked this approach:
> - This ships something with GDB, that will work on all Linux
> distributions the same way, as long as they agree on a directory
> location

I think /etc/gdbinit.d/ is a nice location, and I intend to keep using
it for Fedora GDB and to make Debian GDB use it as well.

I agree that supporting other directories, like ~/.gdbinit.d/, would be

GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible

More information about the Gdb-patches mailing list