Skip to content
This repository was archived by the owner on Mar 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[unstable]
build-std = ["core", "compiler_builtins", "alloc"]
build-std-features = ["compiler-builtins-mem"]
panic-abort-tests = true # Or remove this from Cargo.toml: `panic = "abort"`
panic-abort-tests = true # Or remove this from Cargo.toml: `panic = "abort"`

[build]
target = "x86_64-infinity_os.json"
rustflags = ["-C", "force-frame-pointers=yes"]

[target.'cfg(target_os = "none")']
runner = "bootimage runner"
runner = "bootimage runner"
1 change: 1 addition & 0 deletions src/kernel/debug/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod stack_trace;
20 changes: 20 additions & 0 deletions src/kernel/debug/stack_trace.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use crate::print;
use core::arch::asm;

#[repr(C)]
struct StackFrame {
rbp: *const StackFrame,
rip: usize,
}

pub fn walk_stack() {
let mut frame: *const StackFrame;
unsafe {
asm!("mov {}, rbp", out(reg) frame);
}

while let Some(stack_frame) = unsafe { frame.as_ref() } {
print!("Function address: {:#x}\n", stack_frame.rip);
frame = stack_frame.rbp;
}
}
1 change: 1 addition & 0 deletions src/kernel/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod allocator;
pub mod clock;
pub mod debug;
pub mod gdt;
pub mod interrupts;
pub mod memory;
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ pub fn kernel_main(boot_info: &'static BootInfo) -> ! {
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
print!("{}\n", info);
kernel::debug::stack_trace::walk_stack();
infinity_os::hlt_loop();
}