Re: Set debug-file-directory from environment variable?

Jan Vrany via Gdb <[email protected]>
Newsgroups gmane.comp.gdb.devel,gmane.comp.gdb.general
Message-ID <[email protected]>
Hi, 
On Thu, 2024-09-05 at 12:17 -0400, Brennan Vincent wrote:
> Hello,
> 
> Would folks be okay with a patch to take debug file directories from
> an
> environment variable, e.g. GDB_DEBUG_FILE_PATH ?
> 
> 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.
> 
> But I'm guessing it would be useful in other situations too.
> 
If I understand you correctly, I think you can use Python to 
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 = os.environ.get('GDB_DEBUG_FILE_PATH')
if path_from_env is not None:
    old = gdb.parameter('debug-file-directory')
    new = old + ":" + path_from_env
    gdb.set_parameter('debug-file-directory', new)

end
---8<----

Jan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.