[Zion] Add a way to unwind the stack and recover from user-space faults.
This commit is contained in:
parent
8ceab2ad23
commit
941d7c8d59
6 changed files with 63 additions and 0 deletions
20
zion/common/stack_unwind.cpp
Normal file
20
zion/common/stack_unwind.cpp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#include "common/stack_unwind.h"
|
||||
|
||||
#include "debug/debug.h"
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsValid(uint64_t* rbp) { return rbp && *rbp != kStackBaseSentinel; }
|
||||
|
||||
} // namespace
|
||||
|
||||
void StackUnwind(uint64_t rbp) {
|
||||
dbgln("-- Begin Stack --");
|
||||
uint64_t* rbp_ptr = reinterpret_cast<uint64_t*>(rbp);
|
||||
while (IsValid(rbp_ptr)) {
|
||||
uint64_t rip = *(rbp_ptr + 1);
|
||||
dbgln("RIP: {x}", rip);
|
||||
rbp_ptr = reinterpret_cast<uint64_t*>(*rbp_ptr);
|
||||
}
|
||||
dbgln("-- End Stack --");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue