-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
When attaching with --pid=, shared libraries are not covered #109
Comments
Sorry, I've completely missed this bug report. It might have something to do with shared library support I think, which perhaps isn't working well together with the --pid= option. Shared libraries are handled via a LD_PRELOAD override, but for an already started process, the LD_PRELOAD wasn't set at startup time. Therefore kcov doesn't detect the loaded libraries when it starts. You should still get hits from snmpd itself, but not from the other libraries loaded by it. |
It makes sense, I will try with a static binary to confirm your analysis. |
I just tested with a static version of busybox and it worked well so it seems you guessed right. |
Great, thanks for testing! I think I'll resolve this issue by adding a few lines to the documentation - I don't think it will be very easy to fix the core issue. |
You may probably retrieve the list of loaded shared libraries by the process through /proc//maps (sadly it is Linux specific) but I don't know if it is sufficient to trace them. |
Yes, maybe that's a possibility. I'll keep the bug report open for further investigation. |
I took a look at this bug again, and I believe it should be doable to parse /proc//maps for the shared library-when-tracing-via-pid case. It will still not cover all cases since it will be difficult to detect dlopen():ing shared libraries this way (which is done via the LD_PRELOAD stuff above as well). Anyway, it will be Linux-only, but the shared library handling depends on dl_iterate_phdr() as it is today, so it's already Linux-specific. |
Hi (again),
When I use kcov with the
--pid
flag, I don't manage to get coverage results.Environment
/usr/sbin/snmpd
from net-snmp-5.5 compiled using-g -O0
(snmpd binary is not stripped, debug symbols are not in a separate build id).Steps to reproduce
Launch the snmpd daemon
Attach kcov to the running snmpd instance
Make sure snmpd does something and kill it
Coverage results generated by kcov are void
Additional information
If the snmp daemon is executed directly by kcov, coverage results are correctly generated.
This issue also occurs when snmpd is launched using
-f
flag which prevents snmpd from forking.When running kcov with
--debug=15
, the following message appears:What does it mean ? Maybe some debug information are missing on my system ?
The text was updated successfully, but these errors were encountered: