diff options
author | Dima Kogan <dima@secretsauce.net> | 2014-07-09 01:09:33 -0700 |
---|---|---|
committer | Chanho Park <chanho61.park@samsung.com> | 2014-08-22 20:38:26 +0900 |
commit | 070dc5826c9015cf8d8bfa04c429f419fd9d08ff (patch) | |
tree | 39c356ad730607b5684edf394d35b23a650349f0 /library.h | |
parent | ac6502b964595e8eb8d5268ed9d79824cacaba91 (diff) | |
download | ltrace-070dc5826c9015cf8d8bfa04c429f419fd9d08ff.tar.gz ltrace-070dc5826c9015cf8d8bfa04c429f419fd9d08ff.tar.bz2 ltrace-070dc5826c9015cf8d8bfa04c429f419fd9d08ff.zip |
Made activate_latent_in() iterations much more efficient
Previously activate_latent_in() iterations looked like
for(export names in lib1) // hash table iteration
{
for(symbol names in lib2) // list iteration
{
if(names equal && libsym->latent)
{
proc_activate_latent_symbol(proc, libsym)
}
}
}
This is inefficient both due to the double iteration but also since iterating
over a hash table in slow (have to look through all cells, even empty ones).
This patch turns this logic into
for(symbol names in lib2) // list iteration
{
if(name in lib1 export names && libsym->latent) // hash table lookup
{
proc_activate_latent_symbol(proc, libsym)
}
}
So there's no more double iteration, and the hash iteration was turned into a
hash lookup. Much better.
Diffstat (limited to 'library.h')
-rw-r--r-- | library.h | 25 |
1 files changed, 5 insertions, 20 deletions
@@ -262,26 +262,6 @@ int library_exported_names_push(struct library_exported_names *names, uint64_t addr, const char *name, int own_name ); -/* Iterates through the a library's export list. The callback is called for - * every symbol a library exports. Symbol aliases do not apply here. If multiple - * symbols are defined at the same address, each is reported here. - * - * If we want to iterate through the whole list, set name_start_after=NULL. If - * we want to start iterating immediately past a particular symbol name, pass a - * pointer to this symbol name in name_start_after. This must be a pointer in - * the internal dict, preferably returned by an earlier call to this function - * - * If the callback fails at any point, a pointer to the failing key is returned. - * On success, returns NULL. The returned pointer can be passed back to this - * function in name_start_after to resume skipping this element - */ -const char** library_exported_names_each( - const struct library_exported_names *names, - const char **name_start_after, - enum callback_status (*cb)(const char *, - void *), - void *data); - /* Iterates through the a library's export list, reporting each symbol that is * an alias of the given 'aliasname' symbol. This 'aliasname' symbol itself is * NOT reported, so if this symbol is unique, the callback is not called at all. @@ -304,4 +284,9 @@ const char** library_exported_names_each_alias( void *), void *data); +/* Returns 0 if the exported names list does not contain a given name, or 1 if + * it does */ +int library_exported_names_contains(const struct library_exported_names* names, + const char* queryname); + #endif /* _LIBRARY_H_ */ |