* Pretty-printers auto-loading and static libraries
@ 2015-01-13 15:05 Pierre-Marie de Rodat
[not found] ` <201501140221.t0E2LeCl028119@new.toad.com>
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Pierre-Marie de Rodat @ 2015-01-13 15:05 UTC (permalink / raw)
To: GDB
Hi,
I'm trying to write GDB/Python pretty-printers for various data
structures (like standard containers) from the GNAT runtime. My
experiments are going quite well, it's quite hopeful! However GDB
auto-loading features don't seem to be appropriate for this since most
of the time the GNAT runtime is statically linked into programs.
Automatic scripts loading for statically linked libraries in general is
a feature that looks quite hard to support[1]. However the most common
use case for Ada should be fairly easy to catch: if the program contains
the "adainit" symbol, then it is highly likely that it's a program whose
entry point is in Ada, and thus that the GNAT runtime pretty-printers
should be enabled.
I guess my pretty-printers should be temptatively loaded when the
new_objfile event is triggered: if the corresponding Objfile defines an
"adainit" symbol they should be registered in it. Unfortunately I failed
so far to implement this behavior: Objfile do not expose the
corresponding symbol table and Symtab_and_line instances don't even
enable one to perform symbol lookups.
I'm not familiar with GDB internals yet, so what do you think about
this? Would it be reasonable to extend the Python API to enable one to
do so? Or does someone have another idea to load these pretty-printers
only when needed?
Thank you in advance!
[1] And it looks like this is not a recent discovery:
<https://sourceware.org/ml/archer/2008-q4/msg00168.html>
--
Pierre-Marie de Rodat
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Pretty-printers auto-loading and static libraries
[not found] ` <201501140221.t0E2LeCl028119@new.toad.com>
@ 2015-01-14 9:29 ` Pierre-Marie de Rodat
0 siblings, 0 replies; 4+ messages in thread
From: Pierre-Marie de Rodat @ 2015-01-14 9:29 UTC (permalink / raw)
To: John Gilmore; +Cc: GDB
John,
On 01/14/2015 03:21 AM, John Gilmore wrote:
> People who want to debug Ada programs with this pretty-printer can
> create a .gdbinit in their working directory, or in their home
> directory, that loads any pretty-printer that they want.
Yes, I am aware that automatic scripts loading features have security
implications and I don't intend to introduce security breaches into GDB.
The point is that GDB already has such auto loading facilities and ways
to restrict them[1]. As far as I could see, these are even enabled by
default on most distributions.
What I would like to do is to leverage this so that pretty-printers for
Ada work out of the box, otherwise nobody will remember to use them (or
will bother configuring things).
Besides, if I understand correctly, auto-loading pretty-printers, type
printers and so on *only when useful* is important for performance
reasons. If one has to configure GDB to load scripts for all the
runtime/libraries he/she uses, this is going to make GDB's
initialization longer and will likely make regular work longer because
of lookups.
I also guess doing this would pollute the output for "info
pretty-print", making it harder to enable/disable specific
pretty-printers. I don't want to have Ada pretty-printers listed when
I'm debugging some C++ only application. ;-)
[1]
https://sourceware.org/gdb/onlinedocs/gdb/Auto_002dloading-safe-path.html#Auto_002dloading-safe-path
--
Pierre-Marie de Rodat
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Pretty-printers auto-loading and static libraries
2015-01-13 15:05 Pretty-printers auto-loading and static libraries Pierre-Marie de Rodat
[not found] ` <201501140221.t0E2LeCl028119@new.toad.com>
@ 2015-01-19 15:02 ` Pierre-Marie de Rodat
[not found] ` <CAP9bCMTKi6zZCcNaXiYmvVqNbGSam1ovN8-BpjTjL_5+kbQyVg@mail.gmail.com>
2 siblings, 0 replies; 4+ messages in thread
From: Pierre-Marie de Rodat @ 2015-01-19 15:02 UTC (permalink / raw)
To: GDB
On 01/13/2015 04:05 PM, Pierre-Marie de Rodat wrote:
> I guess my pretty-printers should be temptatively loaded when the
> new_objfile event is triggered: if the corresponding Objfile defines an
> "adainit" symbol they should be registered in it. Unfortunately I failed
> so far to implement this behavior: Objfile do not expose the
> corresponding symbol table and Symtab_and_line instances don't even
> enable one to perform symbol lookups.
I dived into the Python API documentation with a fresh mind:
- gdb.lookup_global_symbol returns Symbol instances;
- Symbol instances have a symtab attribute;
- Symtab instances have an objfile attribute.
So it is actually possible to register pretty-printers depending on the
presence of a symbol! I tried it with my setups and it works properly. :-)
Still to be determined: I don't know if performing a global symbol
lookup at each objfile load is acceptable from a performance point of view.
--
Pierre-Marie de Rodat
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Pretty-printers auto-loading and static libraries
[not found] ` <CAP9bCMTKi6zZCcNaXiYmvVqNbGSam1ovN8-BpjTjL_5+kbQyVg@mail.gmail.com>
@ 2015-02-03 14:51 ` Pierre-Marie de Rodat
0 siblings, 0 replies; 4+ messages in thread
From: Pierre-Marie de Rodat @ 2015-02-03 14:51 UTC (permalink / raw)
To: Doug Evans; +Cc: GDB
Doug,
On 01/31/2015 09:15 PM, Doug Evans wrote:
> One thing gdb uses to do auto-loading of files is to look for a special
> section named .debug_gdb_scripts in the executable/shared-library
> and if present then it loads the scripts mentioned there.
> The current release supports listing files to load in .debug_gdb_scripts.
> Top-of-tree now supports putting the script into .debug_gdb_scripts.
That's good to know, thanks!
--
Pierre-Marie de Rodat
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-02-03 14:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-13 15:05 Pretty-printers auto-loading and static libraries Pierre-Marie de Rodat
[not found] ` <201501140221.t0E2LeCl028119@new.toad.com>
2015-01-14 9:29 ` Pierre-Marie de Rodat
2015-01-19 15:02 ` Pierre-Marie de Rodat
[not found] ` <CAP9bCMTKi6zZCcNaXiYmvVqNbGSam1ovN8-BpjTjL_5+kbQyVg@mail.gmail.com>
2015-02-03 14:51 ` Pierre-Marie de Rodat
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).