This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Pretty-printers auto-loading and static libraries


On Tue, Jan 13, 2015 at 7:05 AM, Pierre-Marie de Rodat
<derodat@adacore.com> wrote:
> 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>

Hi.

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.

So, for example, if your runtime includes the script in some .o that
gets linked into the binary, then the scripts mentioned in that .o
will get executed when gdb loads that binary.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]