-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support nested library calls #141
Comments
@namhyung I really appreciate doing this work! I've tested the branch but found that it's not working as of now. Here is the steps I followed.
Here is the detail log.
Here is cgdb log.
Please take a look at it again. Thanks! |
Hmm.. it works on my machine.
Looking at the log, I found that the a.out was set up twice:
The first was with offset 0 and it's ok. The second was with non-zero offset and caused the crash. I don't know why it does the job twice for the same binary - probably it's actually mapped twice for some reason. Anyway it might work when we skip the second setup, could you please try below patch?
|
Hm.. I has the same problem even if I applied the change above.
|
OK, I set up a container and could reproduce it. It really called the dl_iterate_phdr() call back twice for the main binary (i.e. empty exename). Following patch worked for me (please ignore the above patch).
|
I don't know neither. Maybe need more investigation.. |
Thanks! Now it shows the below trace output:
But still doesn't show |
FYI, here is the log in details.
|
Ah.. there's some more log that shows some error.
|
I looked at the problem, and found the solution! :) It was because the malloc was resolved before we hook the PLTGOT so it didn't call the malloc throughout the PLT0. I restored the PLTGOT of all the resolved entries and could see malloc inside the operator new. The new code is available at review/nest-libcall-v2.
|
OK, it needs to skip special kernel mappings started with '[', thanks! |
@namhyung It works great!
|
One more issue is that I want to see the arguments and retvals of internal library calls. But it crashes when I run the below command.
Even if I use the exact library name, the result is the same.
|
There was a bug on symbol handling. I pushed the fix into review/nest-libcall-v3.
|
@namhyung Thanks! It works fine now.
But I think we need to think about another way rather than explicitly specifying the library name. If there's a lot of libraries, it may be annoying to specify all the libraries to just trace malloc or free in some cases. |
Yes, I feel the same but let's leave it for a different issue. I'll think about it more, thanks. |
@namhyung Thanks a lot for this feature. I would like to suggest one more option with this. Why don't we add an option for tracing only libraries without mcounted functions even if the binary is built with |
One more thing is that I have some symbol problems on the following case running clang distributed in official ubuntu package.
It doesn't have such problem without library names to print arguments and retval.
|
Hmm.. what's the value of tracing library calls only? Anyway, I guess |
The value may be same as |
Sorry for making you busy but there are two more strange things on my Ubuntu 17.04 machine that has
And the other issue is demangling error.
|
I see the same issue - symbol resolution and demangle failure is fixed in review/nest-libcall-v4. But it seems libstdc++ call the
|
It works fine now. Thanks for the quick fix :)
Ah.. It's natural to see |
It's great to see the library calls of prebuilt binaries in depth now. I would also like to see their call graph but it's not easy to see it because there are too many first level calls without Do you think it's okay to add a top level function such as One more value of having |
Do you mean adding a top-level function for the graph command? It's not possible to trace |
I mean we could add |
How would you like to do it? I think we can add an option to uftrace graph command. |
Do you think we better add an option to generate |
Anyway, adding |
@honggyukim suggested to support tracing nested library calls (i.e. libxxx calls a function in libyyy). This can be useful to understand behavior of prebuilt library (or executable). I added
--nest-libcall
option to enable this as it's disabled by default (for performance reason - never profiled though).Some low-level libraries are excluded due to crash. But it seems that PLT in libraries with BIND-NOW have almost nothing. Need to investigate more..
I pushed the code to review/nest-libcall-v1.
Here's an example.
The
lib_a()
andfoo()
are defined in separate libraries which are not built with-pg
. So we cannot see the inside of the functions.But with
--nest-libcall
we can at least see the external function calls they made.The text was updated successfully, but these errors were encountered: