Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Simon Marchi via Gdb <gdb@sourceware.org>
To: Basile Starynkevitch <basile@starynkevitch.net>, gdb@sourceware.org
Subject: Re: seeking open source examples of GDB scripting
Date: Mon, 26 Jan 2026 11:52:28 -0500	[thread overview]
Message-ID: <22882514-250f-42c9-8b6e-771966e9c3b9@simark.ca> (raw)
In-Reply-To: <631f016aca22712c52b3718cb2cd43c496a3e9f7.camel@starynkevitch.net>

On 1/18/26 2:01 PM, Basile Starynkevitch wrote:
> Hello all,
> 
> I am seeking open source examples (or tutorials, given that I am unfamiliar with Python) of GDB scripting.
> 
> Since I have a naughty bug : https://github.com/RefPerSys/RefPerSys/issues/30
> 
> The scripting could be in GNU guile (I much prefer that language).

I'm sure there are good examples of real-world scripting out there, on
github or otherwise, but I don't have good examples in mind.  The Guile
API is unfortunately not as maintained as the Python one, so it's
missing features compared to the Python one.  And even the Python API is
missing some key things, people just add whatever they need.

> For example, I would like to automatically add a breakpoint to every line calling the RPS_POSSIBLE_BREAKPOINT() macro
> That macro is nearly a no-op one defined in https://github.com/RefPerSys/RefPerSys/blob/19f01d3783c9f727980f21fc2c66db4837745b61/refpersys.hh#L1335

I don't think it's possible for GDB by itself to figure out the "call
sites" of a macro.

But you could perhaps modify your RPS_POSSIBLE_BREAKPOINT_AT macro to
include a call to a dummy/empty function, and put a breakpoint on that.
That wouldn't require using the Python or Guile API.

Otherwise, I see that your macro defines some symbols of the form:

  "__" RPS_BASENAME "_brk_" #Lin

You could try the rbreak command to try to put a breakpoint on all
symbols matching a given regex pattern.  But that only works if the
symbol is visible to gdb, I'm not sure it will be.  You might need to
make it ".global", I don't know.

Simon

      reply	other threads:[~2026-01-26 16:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-18 19:01 Basile Starynkevitch
2026-01-26 16:52 ` Simon Marchi via Gdb [this message]

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=22882514-250f-42c9-8b6e-771966e9c3b9@simark.ca \
    --to=gdb@sourceware.org \
    --cc=basile@starynkevitch.net \
    --cc=simark@simark.ca \
    /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