Conversation
Refactor probe_rs::debug::registers Refactor probe_rs::debug::debug_info Improve capstones for disassembly
thefaxman
left a comment
There was a problem hiding this comment.
Overall this is good stuff. I added a few comments here and there, but most of them are in type conversion cleanup and figuring out where to place certain logic. The direction is rock solid.
I did some testing on ARMv8-a / v7-a and not only did it not regress things, it actually got functionality working that wasn't before:
>> bt
Frame 0: cpu_do_idle @ 0xffffffc008b66f2c
/home/rfairfax/linux/arch/arm64/kernel/idle.c:32:2
Frame 0: cpu_do_idle () @ 0xffffffc008b66f2c
This unwind never worked at all previously. It's still not walking the full stack as here's what GDB is getting (one more frame):
#0 cpu_do_idle () at arch/arm64/kernel/idle.c:32
#1 0xffffffc008b66f44 in arch_cpu_idle () at arch/arm64/kernel/idle.c:44
#2 0x0000000100000001 in ?? ()
All that being said this is a clear improvement and I can find no regressions in my testing. It's not surprising to me that there's further work to get ARMv8-a fully working. Ship it.
| /// The group name of a register. | ||
| #[derive(Debug, Clone, Copy, PartialEq)] | ||
| pub enum RegisterGroup { | ||
| /// Core / CPU Registers |
There was a problem hiding this comment.
Should this be Platform to match the other usage?
There was a problem hiding this comment.
I'm open to votes on that. I personally think 'platform' has a broader meaning, and the DWARF spec calls them base registers, so I went with that here, since the debug module is so closely linked with dwarf stuff.
There was a problem hiding this comment.
Fair enough. If we're matching terms from the DWARF spec, which makes sense, a comment may help.
Thanks you for your review and some very valid suggestions. I've added TODO's for things that need work, and I will tackle those as Part 2 ( a follow-up PR) of working on this part of the code. I will be away (off grid) from tomorrow thru Fri, so will synch with you on the the FP support for ARMv8-a you are working on when I get back. |
|
@thefaxman If you are inspired, would you please look at this code I can't explain why it would be necessary to read the N-2 frame's debug info, to get the correct LR value for N-1. If I don't do it, the unwind on Arm doesn't work at all ... and on RISCV it works the way you would expect (only need to read N-1 frame's debug info to the the correct RegisterRule and value for the LR). I'm sure it is a gap in my knowledge somewhere, but have not found any documentation as to why it works like that on Arm. PS. The reason I bring this up here, is because I think there is a risk that it might impact the ARMv8 work you are doing eventually. |
Nothing obvious jumps out to me from a read nor can I think of a reason why you'd need to do this. I do know ARM has a ton of quirks in unwinding, especially for a general purpose unwinder. I'm glad to help spend some cycles debugging this after I finish up the FP work I have in my queue. |
|
bors r+ |
This PR was meant to focus on RISCV debug improvements. However, in the course of fixing RISCV, the extent of changes ballooned, because I discovered some things that needed to be fixed first (my apologies for the large PR)
probe_rs::debug::registersAPI needed changes:probe_rs::RegisterValueto allow support of 32-bit and 64-bit values.This brings RISCV debug functionality that works up to the following:
mainfunction appears mangled in the stacktrace.@MabezDev I would appreciate if you can test some of the 'working' features above on your RISCV use cases.
@thefaxman I would appreciate if you can test to make sure I didn't break any of the ARMv8 (32 and 64-bit) stuff.