Open honggyukim opened 3 years ago
The .sym
file of dlopen
ed library is currently created at https://github.com/namhyung/uftrace/blob/v0.10/libmcount/dynamic.c#L644.
The .dbg
file can also be generated at this point. For example,
diff --git a/libmcount/dynamic.c b/libmcount/dynamic.c
index 7d95a61e..43ed6be2 100644
--- a/libmcount/dynamic.c
+++ b/libmcount/dynamic.c
@@ -657,6 +657,8 @@ void mcount_dynamic_dlopen(struct symtabs *symtabs, struct dl_phdr_info *info,
mdi->map = map;
map->mod = load_module_symtab(symtabs, map->libname, map->build_id);
+ prepare_debug_info(symtabs, PATT_REGEX, NULL, NULL, false, true);
+ save_debug_info(symtabs, symtabs->dirname);
mcount_arch_find_module(mdi, &map->mod->symtab);
if (mcount_setup_trampoline(mdi) < 0) {
But filters including arguments can't be applied at this point. We need to find anther way to apply them.
I think it's a duplicate of #842.
Ah, you’re right. But this also shows the module name is missing.
https://github.com/namhyung/uftrace/issues/842#issuecomment-757488907
It turns out to be a non trivial change since it needs to modify the filter/trigger in libmcount at runtime. Currently it initializes them at load time and accesses them in a lock-less way assuming it's not changing. But with dlopen, we need to add or delete some.
Can we inform the program with a special option that the target library will be used so apply filters even before the dlopen
call?
We might be able to provide --dlopen
option for this. For example,
$ uftrace record -a --dlopen libabc_test_lib.so ./t-dlopen
Otherwise, we can also load the dwarf info if we have a library name as a postfix after -A
or -R
as follows.
$ uftrace -A.@libabc_test_lib.so -R.@libabc_test_lib.so t-dlopen
After parsing the command, we can generate and load dwarf info for the library.
When a dlopen
ed library is loaded, we may have to apply filters after acquiring a lock as @gpollo did at https://github.com/namhyung/uftrace/blob/71154aed62c365692ec1f11c4682b64d9691d7b5/libmcount/mcount.c#L902-L908.
Could be. But I'd like to separate the filters/triggers tree for dlopen from the main filters/triggers if possible.
uftrace currently doesn't store
.dbg
info fordlopen
ed libraries. The example is as follows.It shows the module name as
[unknown]
and doesn't set the debug info ofdlopen
-ed librarylibabc_test_lib.so
.