Re: Using GDB as a Python interpreter

Florian Weimer via Gdb <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
* Tankut Baris via Gdb Aktemur:

> On Saturday, July 1, 2023 10:53 AM, Florian Weimer wrote:
>> I want to run a Python script with GDB, from the shell command line,
>> without having to create two files.
>> 
>> I came up with the hack included below, but it's not particularly nice.
>> The downside is that the script file name must end in “.py”, which would
>> not allow to install the script in /usr/bin for most distributions.  I
>> don't see a way to override that.
>
> Based on this comment, I assume you have write access to /usr.
> Would you then consider wrapping your script in a Python function
> and then installing it in GDB's data directory
> (e.g. /usr/share/gdb/python/gdb/function/)?  The file would be loaded
> automatically by GDB at startup.  You can then invoke the Python function
> with a single-line GDB command.

I was aiming for a one-file solution (and something that could be
installed as-is into /usr/bin eventually).  Two-file solutions are sort
of easy. 8-)

Thanks,
Florian
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.