Hi all, I'm running into an issue with unw_get_reg where I'm getting
incorrect values back, since I am calling it later than it expects to get
called. In particular, I'm doing something like:
unw_cursor_t* getCursorForFrame(int depth);
int64_t getR12(unw_cursor_t*);
void foo() {
unw_cursor_t* cursor = getCursorForFrame(1);
int64_t r12 = getR12(cursor);
}
The issue is that foo() doesn't spill r12, but both getCursorForFrame() and
getR12() do. Things fail since they spill r12 to different locations, but
the cursor we get from getCursorForFrame() only saves the memory location
that r12 was spilled to, which in this case is a stack slot for the
getCursorForFrame() stack frame. Then getR12 spills something else to that
stack slot, and then calls unw_get_reg, which returns an invalid value.
I can work around this for now (I'm saving all the registers in
getCursorForFrame), but is there any straightforward set of restrictions on
when one can call unw_get_reg? Maybe something like "cursors are only
valid for the duration of the last stack frame that called unw_init_local
or unw_step". But I'm not sure if that's even enough, since what if
unw_step + unw_get_reg themselves have this issue?
This issue has only cropped up when we run in a very optimized mode, where
there are very few stack frames between the one that we want to investigate
and the one doing the investigation.
kmod
_______________________________________________
Libunwind-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/libunwind-devel