WIP, TODO: regenerate debug info from new debug instruction
This commit is contained in:
parent
f9f511013d
commit
bc3392d946
4 changed files with 130 additions and 50 deletions
|
|
@ -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)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue