Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor kernel mapping so that symbol table is mapped
- Loading branch information
Showing
6 changed files
with
104 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use core::mem; | ||
|
||
use paging::{ActivePageTable, VirtualAddress}; | ||
|
||
/// Get a stack trace | ||
//TODO: Check for stack being mapped before dereferencing | ||
#[inline(never)] | ||
pub unsafe fn stack_trace() { | ||
let mut rbp: usize; | ||
asm!("" : "={rbp}"(rbp) : : : "intel", "volatile"); | ||
|
||
println!("TRACE: {:>016X}", rbp); | ||
//Maximum 64 frames | ||
let active_table = ActivePageTable::new(); | ||
for _frame in 0..64 { | ||
if let Some(rip_rbp) = rbp.checked_add(mem::size_of::<usize>()) { | ||
if active_table.translate(VirtualAddress::new(rbp)).is_some() && active_table.translate(VirtualAddress::new(rip_rbp)).is_some() { | ||
let rip = *(rip_rbp as *const usize); | ||
if rip == 0 { | ||
println!(" {:>016X}: EMPTY RETURN", rbp); | ||
break; | ||
} | ||
println!(" {:>016X}: {:>016X}", rbp, rip); | ||
rbp = *(rbp as *const usize); | ||
} else { | ||
println!(" {:>016X}: GUARD PAGE", rbp); | ||
break; | ||
} | ||
} else { | ||
println!(" {:>016X}: RBP OVERFLOW", rbp); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters