[Zion] Add a max depth to stack unwinds.

This commit is contained in:
Drew Galbraith 2023-11-24 15:04:19 -08:00
parent cb590c96b8
commit 8bedc80caf
1 changed files with 3 additions and 1 deletions

View File

@ -9,12 +9,14 @@ bool IsValid(uint64_t* rbp) { return rbp && *rbp != kStackBaseSentinel; }
} // namespace
void StackUnwind(uint64_t rbp) {
uint64_t depth_limit = 10;
dbgln("-- Begin Stack --");
uint64_t* rbp_ptr = reinterpret_cast<uint64_t*>(rbp);
while (IsValid(rbp_ptr)) {
while (IsValid(rbp_ptr) && depth_limit > 0) {
uint64_t rip = *(rbp_ptr + 1);
dbgln("RIP: {x}", rip);
rbp_ptr = reinterpret_cast<uint64_t*>(*rbp_ptr);
depth_limit--;
}
dbgln("-- End Stack --");
}