Forced unwind tables - still bugged

This commit is contained in:
2025-03-06 01:01:04 +00:00
parent bc51f3ec43
commit f197149d80
4 changed files with 31 additions and 5 deletions
+2 -2
View File
@@ -17,8 +17,8 @@ runner = "scripts/run_debug.sh"
[target.'cfg(all(target_arch = "x86_64", target_os = "none", not(debug_assertions)))']
runner = "scripts/run_release.sh"
# [registry]
# default = "gitea"
[target.x86_64-kernel]
rustflags = ["-C", "force-unwind-tables"]
[registries.gitea]
index = "sparse+https://git.zxq5.dev/api/packages/OsDev/cargo/" # Sparse index
+12
View File
@@ -18,6 +18,7 @@ use elf::{
parse::{ParseAt, ParsingTable},
section::{SectionHeader, SectionHeaderTable},
string_table::StringTable,
symbol::SymbolTable,
};
use limine::request::KernelFileRequest;
@@ -83,6 +84,17 @@ impl ElfReader {
Ok(Self { elf })
}
#[warn(clippy::unwrap_used)]
pub fn get_symbol_table(
&self,
) -> Result<
Option<(SymbolTable<'static, LittleEndian>, StringTable<'static>)>,
ElfError,
> {
// TODO: Remove .unwrap().
Ok(self.elf.symbol_table().unwrap())
}
/// Gets the section size of `section_name` in bytes.
pub fn get_section_size(
&self,
+13 -1
View File
@@ -45,7 +45,19 @@ pub fn panic_handler(info: &PanicInfo<'_>) -> ! {
eprintln!("{:?}", err);
hcf()
}) {
eprintln!("Frame: {:x?}", call_frame);
serial_println!("Got frame: {:x?}", call_frame);
let Some((symtab, strtab)) =
ELF.get_symbol_table().unwrap_or_else(|e| {
serial_println!("{:?}", e);
hcf()
})
else {
// TODO: Omit symbol names but just print addresses.
serial_println!("Didn't find symtab and strtab!");
hcf()
};
// let sym_name = symtab.get(call_frame.pc as usize).unwrap();
}
crate::hcf()
+4 -2
View File
@@ -50,7 +50,7 @@ impl FallibleIterator for Unwinder {
if self.is_first {
self.is_first = false;
return Ok(Some(CallFrame { pc }));
return Ok(Some(CallFrame { pc, symbol: 0 }));
}
// This is a row in the virtual unwind table AKA the CFI which will help
@@ -121,7 +121,7 @@ impl FallibleIterator for Unwinder {
// the caller function).
self.regs.set_stack_ptr(self.cfa);
Ok(Some(CallFrame { pc }))
Ok(Some(CallFrame { pc, symbol: 0 }))
}
// fn next(&mut self) -> Option<Result<Option<CallFrame>, UnwinderError>> {}
}
@@ -209,6 +209,8 @@ impl RegisterSet {
pub struct CallFrame {
/// The current instruction pointer.
pub pc: u64,
/// The symbol of the function.
pub symbol: usize,
}
#[derive(Debug)]