[Ltrace-devel] DWARF prototypes: handling symbol aliases

Dima Kogan lists at dima.secretsauce.net
Sun May 25 06:45:42 UTC 2014


Dima Kogan <lists at dima.secretsauce.net> writes:

> As noted in the previous thread, there's an issue with parsing the
> prototypes from the DWARF data caused by multiple symbol names referring
> to the same address.

I looked at this a bit more, and have some working prototype code, and
I'd like some comments before I clean it up for merging.

The previous version would look for aliased names when parsing the
DWARF. This didn't work completely, as described in the last email.
Doing this when looking for exported symbols does work.

The current code parses the exported symbols into struct library{} in
library.h. This is

 struct library {
         ....
         struct library_symbol *symbols;
         struct library_exported_name *exported_names;
         ....
 }

The symbols structure contains names, addresses, etc. This is populated
only for symbols we're explicitly tracing (i.e. not with -l). Currently
breakpoints are set for all entries in this structure.

The exported_names are populated regardless of what we're tracing, and
contains just the export names. This is all done in
populate_this_symtab() in ltrace-elf.c. It's essentially

 populate_this_symtab()
 {
         for(symbols) {
                 populate(exported_names);
                 if (!filter_matches_symbol())
                         continue;
                 populate(symbols);
         }
 }

So to implement the alias-finding here the options are

1. Find the aliases in 'symbols'. This would require the

     if (!filter_matches_symbol())
        continue;

   logic to be removed, and it would require extra logic to not set
   breakpoints for some 'symbols'

2. Find the aliases in 'exported_names'. This requires a fancier data
structure for 'exported_names'.

I have implemented #2, and it works. The code was a bit of a pain to
write, and it needs cleanup if we're to talk about merging it.
Implementing #1 would be a pain too, but a very different pain. Petr, do
you have any preference here?

Please let me know if anything is unclear.

dima



More information about the Ltrace-devel mailing list