Re: Set debug-file-directory from environment variable?
Jan Vrany via Gdb <[email protected]> Fri, 06 Sep 2024 10:25:06 +0000
| Newsgroups | gmane.comp.gdb.devel,gmane.comp.gdb.general |
|---|---|
| Message-ID | <[email protected]> |
Hi,=20
On Thu, 2024-09-05 at 12:17 -0400, Brennan Vincent wrote:
> Hello,
>=20
> Would folks be okay with a patch to take debug file directories from
> an
> environment variable, e.g. GDB_DEBUG_FILE_PATH ?
>=20
> An example of when this is could be useful is for Guix users: the
> variable could be automatically set up when spawning a Guix shell
> that
> contains debug packages.
>=20
> But I'm guessing it would be useful in other situations too.
>=20
If I understand you correctly, I think you can use Python to=C2=A0
do it (if your GDB has Python support).
Something like putting following your .gdbinit (or to system-wide
init script):
---8<----
python
import os
path_from_env =3D os.environ.get('GDB_DEBUG_FILE_PATH')
if path_from_env is not None:
old =3D gdb.parameter('debug-file-directory')
new =3D old + ":" + path_from_env
gdb.set_parameter('debug-file-directory', new)
end
---8<----
Jan