Forced unwind tables - still bugged
This commit is contained in:
+2
-2
@@ -17,8 +17,8 @@ runner = "scripts/run_debug.sh"
|
|||||||
[target.'cfg(all(target_arch = "x86_64", target_os = "none", not(debug_assertions)))']
|
[target.'cfg(all(target_arch = "x86_64", target_os = "none", not(debug_assertions)))']
|
||||||
runner = "scripts/run_release.sh"
|
runner = "scripts/run_release.sh"
|
||||||
|
|
||||||
# [registry]
|
[target.x86_64-kernel]
|
||||||
# default = "gitea"
|
rustflags = ["-C", "force-unwind-tables"]
|
||||||
|
|
||||||
[registries.gitea]
|
[registries.gitea]
|
||||||
index = "sparse+https://git.zxq5.dev/api/packages/OsDev/cargo/" # Sparse index
|
index = "sparse+https://git.zxq5.dev/api/packages/OsDev/cargo/" # Sparse index
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ use elf::{
|
|||||||
parse::{ParseAt, ParsingTable},
|
parse::{ParseAt, ParsingTable},
|
||||||
section::{SectionHeader, SectionHeaderTable},
|
section::{SectionHeader, SectionHeaderTable},
|
||||||
string_table::StringTable,
|
string_table::StringTable,
|
||||||
|
symbol::SymbolTable,
|
||||||
};
|
};
|
||||||
use limine::request::KernelFileRequest;
|
use limine::request::KernelFileRequest;
|
||||||
|
|
||||||
@@ -83,6 +84,17 @@ impl ElfReader {
|
|||||||
Ok(Self { elf })
|
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.
|
/// Gets the section size of `section_name` in bytes.
|
||||||
pub fn get_section_size(
|
pub fn get_section_size(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -45,7 +45,19 @@ pub fn panic_handler(info: &PanicInfo<'_>) -> ! {
|
|||||||
eprintln!("{:?}", err);
|
eprintln!("{:?}", err);
|
||||||
hcf()
|
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()
|
crate::hcf()
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ impl FallibleIterator for Unwinder {
|
|||||||
if self.is_first {
|
if self.is_first {
|
||||||
self.is_first = false;
|
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
|
// 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).
|
// the caller function).
|
||||||
self.regs.set_stack_ptr(self.cfa);
|
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>> {}
|
// fn next(&mut self) -> Option<Result<Option<CallFrame>, UnwinderError>> {}
|
||||||
}
|
}
|
||||||
@@ -209,6 +209,8 @@ impl RegisterSet {
|
|||||||
pub struct CallFrame {
|
pub struct CallFrame {
|
||||||
/// The current instruction pointer.
|
/// The current instruction pointer.
|
||||||
pub pc: u64,
|
pub pc: u64,
|
||||||
|
/// The symbol of the function.
|
||||||
|
pub symbol: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|||||||
Reference in New Issue
Block a user