Re: What are the procedures to use self declared convenience functions in GDB?

Nagmat Nazar via Gdb <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <CAJnvuZ8vHxZ=CJhRPsVtLZe4t-pBbuiNQz_forxDK2D0PGShiQ@mail.gmail.com>
Dear Mr. Baris,

Thanks for your response, I have added it to Makefile.in as you told me,
but it is not functioning. How can I check If it was loaded or not?

Kind regards,
Nagmat

On Thu, Nov 19, 2020 at 4:48 PM Aktemur, Tankut Baris <
[email protected]> wrote:

> 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
>
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.