RE: Using GDB as a Python interpreter

"Aktemur, Tankut Baris via Gdb" <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <DM4PR11MB7303D5468357169E45FDC69AC429A@DM4PR11MB7303.namprd11.prod.outlook.com>
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.

-Baris

 
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
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.