Pretty-printers auto-loading and static libraries

Pierre-Marie de Rodat <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
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
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.