WIP, TODO: regenerate debug info from new debug instruction

This commit is contained in:
Jean-Marie Mineau 2025-01-10 17:45:00 +01:00
parent f9f511013d
commit bc3392d946
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
4 changed files with 130 additions and 50 deletions

View file

@ -300,6 +300,20 @@ pub enum DebugInfo {
EndOfData,
}
impl DebugInfo {
pub fn get_addr(&self) -> u32 {
match self {
Self::DefLocal { addr, .. } => *addr,
Self::EndLocal { addr, .. } => *addr,
Self::PrologueEnd { addr } => *addr,
Self::EpilogueBegin { addr } => *addr,
Self::SetSourceFile { addr, .. } => *addr,
Self::SetLineNumber { addr, .. } => *addr,
Self::EndOfData => u32::MAX, // TODO should be an Option::None?
}
}
}
/// A state machine that interpret a [`DebugInfoItem`].
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct DebugStateMachine<'a> {
@ -344,7 +358,7 @@ impl<'a> DebugStateMachine<'a> {
pub fn get_ins(&self) -> Result<DbgBytecode> {
if self.pc >= self.debug_info.bytecode.len() {
return Err(Error::OutOfBound(
"Try to read an instruction out of bound, maybe after the enf of the debug sequence."
"Try to read an instruction out of bound, maybe after the end of the debug sequence."
.into()
));
}
@ -513,6 +527,14 @@ impl<'a> DebugStateMachine<'a> {
}
}
}
pub fn next_info(&mut self) -> DebugInfo {
loop {
if let Some(info) = self.tick() {
return info;
}
}
}
}
#[cfg(test)]