Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Kevin Pouget <kevin.pouget@gmail.com>
To: gdb@sourceware.org
Subject: Re: Python objfile-gdb.py file -- how to handle reloading properly ?
Date: Wed, 23 Mar 2011 09:06:00 -0000	[thread overview]
Message-ID: <AANLkTinsRrJefA4iNuNu8usHV8yEi=V-TSHYB_M43g-g@mail.gmail.com> (raw)
In-Reply-To: <AANLkTi=XEP8x27_BNr6NwS09Ra=nNu=CA6qrrpUJ5N8Z@mail.gmail.com>

Hello,

I'm not writing a pretty-printer, but something quite similar to
thread-event notification (eg, thread creation/death, where some
special locations are breakpointed, and an action is trigger upon
hitting the bp).

So in this case, maybe the autoloading discussed before is not
actually the best solution. What I would like to do is:

> (at gdb startup) Load the process-independent part of my --python-- module
> (at application startup/shared library loading) Set my breakpoint, resolve addresses and enable process-dependent commands

-- AFAIU, that's more or less what was done with linux-thread-db.c and
libpthread.so --

whereas currently, I just load everything from the objfile-gdb.py hook


Cordially,

Kevin


On Tue, Mar 22, 2011 at 1:00 PM, Tom Tromey <tromey@redhat.com> wrote:
>
> >>>>> "Kevin" == Kevin Pouget <kevin.pouget@gmail.com> writes:
>
> Kevin> I'm playing with the objfile-gdb.py loading, and I can't manage to
> Kevin> support the reloading efficiently:
> [...]
> Kevin> which looks like a ugly hack! Did you find any better solution?
>
> Yeah, have your hook file be very small and have it import the real
> printers.  The documentation lays out the best approach:
>
>       We recommend that you put your core pretty-printers into a Python
>    package.  If your pretty-printers are for use with a library, we
>    further recommend embedding a version number into the package name.
>    This practice will enable GDB to load multiple versions of your
>    pretty-printers at the same time, because they will have different
>    names.
>
>       You should write auto-loaded code (*note Auto-loading::) such that it
>    can be evaluated multiple times without changing its meaning.  An ideal
>    auto-load file will consist solely of `import's of your printer
>    modules, followed by a call to a register pretty-printers with the
>    current objfile.
>
>       Taken as a whole, this approach will scale nicely to multiple
>    inferiors, each potentially using a different library version.
>    Embedding a version number in the Python package name will ensure that
>    GDB is able to load both sets of printers simultaneously.  Then,
>    because the search for pretty-printers is done by objfile, and because
>    your auto-loaded code took care to register your library's printers
>    with a specific objfile, GDB will find the correct printers for the
>    specific version of the library used by each inferior.
>
> Tom


  parent reply	other threads:[~2011-03-23  9:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-22 14:07 Kevin Pouget
     [not found] ` <AANLkTikZX2JvZF4bNYh8ZQR-e-bqLS=+zZq_m_b2Y+an@mail.gmail.com>
2011-03-22 15:00   ` Kevin Pouget
2011-03-22 17:00 ` Tom Tromey
     [not found]   ` <AANLkTi=XEP8x27_BNr6NwS09Ra=nNu=CA6qrrpUJ5N8Z@mail.gmail.com>
2011-03-23  9:06     ` Kevin Pouget [this message]
     [not found]       ` <AANLkTikp_m_zwsUPmmEvgHiEKxBidNd-MNY4cTrprynU@mail.gmail.com>
     [not found]         ` <AANLkTi=66tRSet6UgrtBpZzEU5o_PmTdazdkB-NnWEVZ@mail.gmail.com>
2011-03-23 10:46           ` Kevin Pouget
2011-03-23 18:26     ` Tom Tromey

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='AANLkTinsRrJefA4iNuNu8usHV8yEi=V-TSHYB_M43g-g@mail.gmail.com' \
    --to=kevin.pouget@gmail.com \
    --cc=gdb@sourceware.org \
    /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