- Sponsor
-
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
kcov hanging on arm64 #267
Comments
Thanks for the report! I believe you're the first one who's actually tried it on ARM64. It was implemented blindly since I don't have access to the actual hardware. Anyway, it's almost certainly an error with how breakpoints are set, or how the PC is read out. I believe it's the latter since it looks for address 0x0. It's really just a constant, which you can find in If you feel like it, feel free to experiment a bit with it and see if it works better. |
I think excerpt from
I also tested with a simple test case which crashed initially but when I specified |
Unfortunately, ptrace isn't recursive, so kcov won't work at all when run
under strace since it uses ptrace.
Anyway, very good progress! Looking forward to a pull request in the future
:-)
|
Could you have a look at the debug log, if something is obvious from the crash? |
Hmm... It does look pretty good:
Can you disassemble and look what's at 0x7fb7fe071c? You can also try to limit collection a bit by running with |
@vielmetti may be able to get you an aarch64 box if you want to test yourself @SimonKagstrom via worksonarm. |
Thanks @mmlb . Are these tests running in a VM or on bare metal? |
I'm not sure how @kannaiah ran it, but I don't think it really matters if it runs in a (full system) VM or on hardware. A qemu installation should be enough, so I can probably set that up myself sometime, unless someone else does it first :-) |
I built My minimum reproduction of a problem is this: when I try to trace the system
|
Well, the system ls doesn't contain debug information, so it can't be traced by kcov. What you can do is to run kcov against itself, i.e.,
although I believe it will behave in the same way as @kannaiah reported above, so it needs debugging. |
Hi @SimonKagstrom ! I am wondering if this arm64 support stuff is still on going. Referencing cargo-kcov#40, when I tried to run the coverage test on arm64, a warning popped out like this and the test hanged: However I did installed the required library. Using GDB for debugging this issue, it turns out the code hanged in the infinite loop of collector.cc: Full backtrace log:
Also I checked out the line 92 of CMakeList.txt, it seems that aarch64 is not supported? Got really confused... Therefore I am wondering if you can give some helps or suggestions. Thanks so much! |
Well, I've never tried it personally on Aarch64, but there is some code for it. Could you run it with some high value passed to Clearing a breakpoint still sounds like it's started to do something, but the address is perhaps not quite right here. |
Hi, @SimonKagstrom, @MrXinWang I tried PT continuing 60 with signal 0 |
After changing PT stopped PID 561 0x0000057f |
Agree with @kannaiah and my colleague @michael2012z about the value of A comparison of debug logs from arm64 and x86_64 after changing Seems kcov on arm64 is stuck in endless looking for instructions however never progresses at some point, even if the instruction is hit; and the child process never exits (
|
Thanks a lot for the debugging! Hmmm... Do you have a toy example to run this on (i.e., a main() which just exits or something similar). Does that work? Also, you could perhaps try to kill the child process, like
and then debug the core dump in gdb to see if the child get's stuck on some destroyed instruction (since kcov overwrites the actual instructions). |
Hi @SimonKagstrom ! Thanks so much for the suggestion! Following what you have suggested, I built a binary as:
then using
Using
while using static build ( Wondering any methods to see/print the instructions modified by kcov? |
You can run "disassemble" in GDB to see the instructions. However, it seems to crash in glibc, which is somewhat surprising. I've been putting off setting up a Aarch64 qemu system, but I guess I should get around to it sometime soon :-) As for the PC adjustment, it depends on how the architecture handles the breakpoints. x86 steps the instruction pointer, so needs adjustment to continue on the instruction where the BP was set (after clearing). At least PPC and ARM does not do this, I'm not sure bout Aarch64. Also worth checking is if the breakpoint setup replacement (arch_setupBreakpoint, which replaces the instruction with 0xd4200000) is correct. On ARM, breakpoints are really illegal instructions, so kcov uses SIGILL to detect hits. Maybe that's not correct on Aarch64? |
Hi @SimonKagstrom ! I think somehow me and my colleague found a method to fix this (for now we don't think the setup breakpoints function will setup all correct breakpoints on arm64, which lead to this strange behaviour that some of the instructions in the beginning will be hit correctly while later some instructions will not be hit). We did a very brief test on our arm64 machine and it works. However we probably need some time to propose a PR as contributing will need some legal approval. Thanks so much about the kindly instruction and help with the debugging! |
Woho! Great work, both of you! Looking forward to a pull request! Don't thank me, I didn't do any of this work :-) |
Hi, @SimonKagstrom , do you mind adding 2 files in this repo: |
@michael2012z the license is present in the COPYING file in the root directory, which was sort of standard when the kcov project started. I don't know enough legal matters to really know how to write a CONTRIBUTING.md file though, perhaps someone else here has a better knowledge about it? |
Yes, COPYING contains the text for LICENSE. 👍 |
Hi @SimonKagstrom ! We are really sorry to make this PR-proposing process complex. It is just because as employees, we are not allowed to (freely) post code changes unless we have the legal approval from the opensource project (probably the company as well, I really dont know....), which probably would involve some other department/colleagues from the company and we need to satisfy their requests...... As far as I am concerned, if we need to apply a legal approval, we need both inbound and outbound license of the project, which are namely the LICENSE/COPYING file and the CONTRIBUTING.md file. For this project I think any kind of CONTRIBUTING.md file is fine? I think you can easily find a proper template at: Again really sorry for the inconvenience.....we dont want to make things complicated too.... |
I pushed a CONTRIBUTING.md file as well now. |
Tried kcov built for source and it is hanging.
Below is debug log using max level 31
The text was updated successfully, but these errors were encountered: