[Ltrace-devel] DWARF prototypes: handling symbol aliases

Dima Kogan lists at dima.secretsauce.net
Tue May 27 09:01:44 UTC 2014


Petr Machata <pmachata at redhat.com> writes:

> Dima Kogan <lists at dima.secretsauce.net> writes:
>
>> 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?
>
> I'll check out your patches hopefully later this week.  Your №2 seems
> reasonable, but I'll need to check out the code and think about it for a
> bit.

Hi. This code wasn't pushed anywhere, but if you want to look at it,
it's here:

 https://github.com/dkogan/ltrace/tree/libsym_aliases_inexportlist

Note that this code is extremely rough, and you don't need to even
bother reviewing it. I'm only posting it here so you could see the main
logic, and see that this does indeed work.

Notes:

1. This patch extends the exported_names (in struct library) data
structure to contain both an address and a name for each symbol, so that
it can be used to find aliases. The intent was to eventually make this
structure efficient, but currently it's a just dumb linear list search
for all access operations.

2. This data structure is populated in populate_this_symtab() as before.

3. Then, in library_get_prototype() we go through every prototype we have
(from DWARF or from the config files), we find aliased symbols, and we
add a prototype for the aliases. This is done in a sloppy way, so ltrace
crashes on exit(). Yeah.



The implementation of #1 and #2 above could use the symbols member of
struct library, as I said before. #3 is a bit separate. It'd be nice to
not duplicate the prototypes, to find the duplicates when we need them.

I can make all this reasonable, but I await comments before proceeding.


Oh. The test program I'm using is this:

 #include <unistd.h>
 #include <time.h>
 int main(void)
 {
         usleep(33);
         nanosleep(&(struct timespec){.tv_nsec = 44}, NULL);
 }

The test ltrace invocations are

 ./ltrace -x '*sleep' -L ./tst
 ./ltrace -l 'libc*' ./tst

Thanks.

dima



More information about the Ltrace-devel mailing list