Retrieve stack pointer in _Unwind_Backtrace's callback
Categories
(Core :: mozglue, enhancement)
Tracking
()
People
(Reporter: mozbugz, Unassigned)
Details
Attachments
(1 obsolete file)
There is a TODO in unwind_callback (called from _unwind_Backtrace in MozStackWalk used on some platforms) :
// TODO Use something like '_Unwind_GetGR()' to get the stack pointer.
Discussing with :glandium recently, https://phabricator.services.mozilla.com/D110899#inline-619854 :
we don't actually have the stack pointers while walking the stack with _Unwind_Backtrace (there's a TODO that says to use something like _Unwind_GetGR, which I tried, but it actually crashes on a null deref because the registers data doesn't necessary contain the info).
Coincidentally, as part of bug 1635987 I had just touched that _Unwind_Backtrace code, and I had managed to get a stack pointer by using _Unwind_GetCFA() (which is not documented everywhere _Unwind_Backtrace is, so it's easy to miss!), it Worked For Me™ in a prototype mac test: Try, macos test output with SPs (the "sp" values would have been null otherwise).
I've found some positive information in a post titled "cfa == rsp on x86_64":
uint64 _Unwind_GetCFA(struct _Unwind_Context *context);
This function returns the 64-bit Canonical Frame Address which is defined as the value of %rsp at the call site in the previous frame.
Also opensource.apple.com and linuxbase.org.
Mike, feel free to comment here, or in the upcoming patch, if you have thoughts for/against.
| Reporter | ||
Comment 1•5 years ago
|
||
Updated•5 years ago
|
| Reporter | ||
Comment 2•5 years ago
|
||
Comment on attachment 9217294 [details]
Bug 1706528 - Retrieve stack pointer in _Unwind_Backtrace's callback - r?glandium
Abandoning patch, as it could crash on some platforms.
| Reporter | ||
Comment 3•5 years ago
|
||
I won't work on this anymore (I don't really need it).
I'll leave the bug open, in case someone finds a good solution.
Description
•