[Lldb-commits] [lldb] [lldb] Allow fetching of RA register when above fault handler (PR #98566)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Fri Jul 12 04:07:47 PDT 2024


DavidSpickett wrote:

> Without this fix, a frameless function that faults in a firmware environment (that's where we've seen this issue most commonly) hasn't spilled lr to stack, so we need to retrieve it from the fault handler's full-register-context to find the caller of the frameless function that faulted.

So the difference between being interrupted and making a function call is that the latter allows you to store the link register then make the call. A signal may come in at any time, so there may be no saved lr in the frame record at the time the interrupt happens.

And this fix means specifically that if you're inside the function that was interrupted, we will read its lr from the fault handler context?

Sounds good to me.

Testing this is in theory possible, tricky bit is guaranteeing a frameless function. There is the naked attribute but it's not portable https://godbolt.org/z/s9117Gr7a. Or you could write the function in an assembly file, or declare and call it inside an inline assembly block, inside a normal C function. That function would branch to self waiting for SIGALRM for example.

Maybe that has its own problems, I haven't tried it. Maybe it wouldn't generate enough debug info for us to know that the assembly function was there?

https://github.com/llvm/llvm-project/pull/98566


More information about the lldb-commits mailing list