public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Nagmat Nazar <nagmat@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: What are the procedures to use self declared convenience functions in GDB?
Date: Wed, 18 Nov 2020 15:39:15 -0500	[thread overview]
Message-ID: <8477dd9d-5952-ca65-3b11-386259f27e61@simark.ca> (raw)
In-Reply-To: <CAJnvuZ_UEox9FvcNVS2rUC+=5P8_g=_hLOG13FdQBP-2x_e+pg@mail.gmail.com>

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

  parent reply	other threads:[~2020-11-18 20:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-17  9:03 Nagmat Nazar
2020-11-17 14:34 ` Simon Marchi
     [not found]   ` <CAJnvuZ_UEox9FvcNVS2rUC+=5P8_g=_hLOG13FdQBP-2x_e+pg@mail.gmail.com>
2020-11-18 20:39     ` Simon Marchi [this message]
2020-11-19  7:48       ` Aktemur, Tankut Baris
2020-11-19  8:34         ` Nagmat Nazar
2020-11-19 10:39           ` Christian Biesinger
2020-11-19 10:59             ` Aktemur, Tankut Baris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8477dd9d-5952-ca65-3b11-386259f27e61@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb@sourceware.org \
    --cc=nagmat@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).