RE: What are the procedures to use self declared convenience functions in GDB?
"Aktemur, Tankut Baris via Gdb" <[email protected]>
| Newsgroups | gmane.comp.gdb.devel |
|---|---|
| Message-ID | <SN6PR11MB2893B29380034B5FE56491A8C4E00@SN6PR11MB2893.namprd11.prod.outlook.com> |
On Wednesday, November 18, 2020 9:39 PM, Simon Marchi wrote:
> On 2020-11-18 12:18 a.m., Nagmat Nazar wrote:
> > Dear Simon,
> >
> > I have written convenience function as on explanation:
> > https://sourceware.org/gdb/onlinedocs/gdb/Functions-In-Python.html
> > greet.py
> > ```
> >
> > class Greet (gdb.Function):
> > """Return string to greet someone.
> > Takes a name as argument."""
> >
> > def __init__ (self):
> > super (Greet, self).__init__ ("greet")
> >
> > def invoke (self, name):
> > return "Hello, %s!" % name.string ()
> >
> > Greet ()
> >
> > ```
> > image.png
> >
> > I have placed greet.py into ~/gdb/python/lib/gdb/function/, but as you see on the picture
> it still gives error. What else shall I do in order to use this function?
> >
> > Kind regards
> > Nagmat
>
> Just putting the file in ~/gdb/python/lib/gdb/function/ won't magically load it.
>
> You should either use the source command inside GDB (or in a .gdbinit) or the -x switch when
> starting GDB.
>
> Simon
If you list the file name in gdb/data-directory/Makefile.in's PYTHON_FILE_LIST, I believe
it's loaded automatically at GDB startup time.
-Baris
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928