mirror of
https://github.com/transistorfet/moa.git
synced 2024-12-25 00:30:50 +00:00
Added tracing mode to debugger
This commit is contained in:
parent
2cb21d7b8d
commit
8ba506cc11
@ -130,7 +130,7 @@ impl M68k {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn exception(&mut self, system: &System, number: u8, is_interrupt: bool) -> Result<(), Error> {
|
pub fn exception(&mut self, system: &System, number: u8, is_interrupt: bool) -> Result<(), Error> {
|
||||||
info!("{}: raising exception {}", DEV_NAME, number);
|
debug!("{}: raising exception {}", DEV_NAME, number);
|
||||||
let offset = (number as u16) << 2;
|
let offset = (number as u16) << 2;
|
||||||
if self.cputype >= M68kType::MC68010 {
|
if self.cputype >= M68kType::MC68010 {
|
||||||
self.push_word(system, offset)?;
|
self.push_word(system, offset)?;
|
||||||
@ -231,28 +231,28 @@ impl M68k {
|
|||||||
self.state.pc = (self.decoder.start + 2).wrapping_add(offset as u32);
|
self.state.pc = (self.decoder.start + 2).wrapping_add(offset as u32);
|
||||||
},
|
},
|
||||||
Instruction::BCHG(bitnum, target, size) => {
|
Instruction::BCHG(bitnum, target, size) => {
|
||||||
let bitnum = self.get_target_value(system, bitnum, Size::Byte)? % get_bit_op_max(size);
|
let bitnum = self.get_target_value(system, bitnum, Size::Byte)?;
|
||||||
let mut value = self.get_target_value(system, target, size)?;
|
let mut value = self.get_target_value(system, target, size)?;
|
||||||
let mask = self.set_bit_test_flags(value, bitnum, size);
|
let mask = self.set_bit_test_flags(value, bitnum, size);
|
||||||
value = (value & !mask) | (!(value & mask) & mask);
|
value = (value & !mask) | (!(value & mask) & mask);
|
||||||
self.set_target_value(system, target, value, size)?;
|
self.set_target_value(system, target, value, size)?;
|
||||||
},
|
},
|
||||||
Instruction::BCLR(bitnum, target, size) => {
|
Instruction::BCLR(bitnum, target, size) => {
|
||||||
let bitnum = self.get_target_value(system, bitnum, Size::Byte)? % get_bit_op_max(size);
|
let bitnum = self.get_target_value(system, bitnum, Size::Byte)?;
|
||||||
let mut value = self.get_target_value(system, target, size)?;
|
let mut value = self.get_target_value(system, target, size)?;
|
||||||
let mask = self.set_bit_test_flags(value, bitnum, size);
|
let mask = self.set_bit_test_flags(value, bitnum, size);
|
||||||
value = value & !mask;
|
value = value & !mask;
|
||||||
self.set_target_value(system, target, value, size)?;
|
self.set_target_value(system, target, value, size)?;
|
||||||
},
|
},
|
||||||
Instruction::BSET(bitnum, target, size) => {
|
Instruction::BSET(bitnum, target, size) => {
|
||||||
let bitnum = self.get_target_value(system, bitnum, Size::Byte)? % get_bit_op_max(size);
|
let bitnum = self.get_target_value(system, bitnum, Size::Byte)?;
|
||||||
let mut value = self.get_target_value(system, target, size)?;
|
let mut value = self.get_target_value(system, target, size)?;
|
||||||
let mask = self.set_bit_test_flags(value, bitnum, size);
|
let mask = self.set_bit_test_flags(value, bitnum, size);
|
||||||
value = value | mask;
|
value = value | mask;
|
||||||
self.set_target_value(system, target, value, size)?;
|
self.set_target_value(system, target, value, size)?;
|
||||||
},
|
},
|
||||||
Instruction::BTST(bitnum, target, size) => {
|
Instruction::BTST(bitnum, target, size) => {
|
||||||
let bitnum = self.get_target_value(system, bitnum, Size::Byte)? % get_bit_op_max(size);
|
let bitnum = self.get_target_value(system, bitnum, Size::Byte)?;
|
||||||
let value = self.get_target_value(system, target, size)?;
|
let value = self.get_target_value(system, target, size)?;
|
||||||
self.set_bit_test_flags(value, bitnum, size);
|
self.set_bit_test_flags(value, bitnum, size);
|
||||||
},
|
},
|
||||||
@ -415,7 +415,7 @@ impl M68k {
|
|||||||
self.set_target_value(system, target2, value1, Size::Long)?;
|
self.set_target_value(system, target2, value1, Size::Long)?;
|
||||||
},
|
},
|
||||||
Instruction::EXT(reg, from_size, to_size) => {
|
Instruction::EXT(reg, from_size, to_size) => {
|
||||||
let input = self.state.d_reg[reg as usize];
|
let input = get_value_sized(self.state.d_reg[reg as usize], from_size);
|
||||||
let result = match (from_size, to_size) {
|
let result = match (from_size, to_size) {
|
||||||
(Size::Byte, Size::Word) => ((((input as u8) as i8) as i16) as u16) as u32,
|
(Size::Byte, Size::Word) => ((((input as u8) as i8) as i16) as u16) as u32,
|
||||||
(Size::Word, Size::Long) => (((input as u16) as i16) as i32) as u32,
|
(Size::Word, Size::Long) => (((input as u16) as i16) as i32) as u32,
|
||||||
@ -503,7 +503,7 @@ impl M68k {
|
|||||||
Instruction::MOVEM(target, size, dir, mask) => {
|
Instruction::MOVEM(target, size, dir, mask) => {
|
||||||
self.execute_movem(system, target, size, dir, mask)?;
|
self.execute_movem(system, target, size, dir, mask)?;
|
||||||
},
|
},
|
||||||
//Instruction::MOVEP(Register, Target, Size, Direction) => {
|
//Instruction::MOVEP(reg, target, size, dir) => {
|
||||||
//},
|
//},
|
||||||
Instruction::MOVEQ(data, reg) => {
|
Instruction::MOVEQ(data, reg) => {
|
||||||
let value = sign_extend_to_long(data as u32, Size::Byte) as u32;
|
let value = sign_extend_to_long(data as u32, Size::Byte) as u32;
|
||||||
@ -1170,14 +1170,6 @@ fn get_msb_mask(value: u32, size: Size) -> u32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_bit_op_max(size: Size) -> u32 {
|
|
||||||
match size {
|
|
||||||
Size::Byte => 8,
|
|
||||||
Size::Long => 32,
|
|
||||||
Size::Word => panic!("bit ops cannot be word size"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_bit_field_mask(offset: u32, width: u32) -> u32 {
|
fn get_bit_field_mask(offset: u32, width: u32) -> u32 {
|
||||||
let mut mask = 0;
|
let mut mask = 0;
|
||||||
for _ in 0..width {
|
for _ in 0..width {
|
||||||
|
@ -31,6 +31,7 @@ impl StackTracer {
|
|||||||
pub struct Debugger {
|
pub struct Debugger {
|
||||||
pub last_command: Option<String>,
|
pub last_command: Option<String>,
|
||||||
pub repeat: u32,
|
pub repeat: u32,
|
||||||
|
pub trace_only: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -39,14 +40,23 @@ impl Debugger {
|
|||||||
Self {
|
Self {
|
||||||
last_command: None,
|
last_command: None,
|
||||||
repeat: 0,
|
repeat: 0,
|
||||||
|
trace_only: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn breakpoint_occurred(&mut self) {
|
||||||
|
self.trace_only = false;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn run_debugger(&mut self, system: &System, target: TransmutableBox) -> Result<(), Error> {
|
pub fn run_debugger(&mut self, system: &System, target: TransmutableBox) -> Result<(), Error> {
|
||||||
let mut target = target.borrow_mut();
|
let mut target = target.borrow_mut();
|
||||||
let debug_obj = target.as_debuggable().unwrap();
|
let debug_obj = target.as_debuggable().unwrap();
|
||||||
debug_obj.print_current_step(system)?;
|
debug_obj.print_current_step(system)?;
|
||||||
|
|
||||||
|
if self.trace_only {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
if self.repeat > 0 {
|
if self.repeat > 0 {
|
||||||
self.repeat -= 1;
|
self.repeat -= 1;
|
||||||
let last_command = self.last_command.clone().unwrap();
|
let last_command = self.last_command.clone().unwrap();
|
||||||
@ -116,6 +126,10 @@ impl Debugger {
|
|||||||
self.check_repeat_arg(args)?;
|
self.check_repeat_arg(args)?;
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
},
|
},
|
||||||
|
"t" | "trace" => {
|
||||||
|
self.trace_only = true;
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
//"ds" | "stack" | "dumpstack" => {
|
//"ds" | "stack" | "dumpstack" => {
|
||||||
// println!("Stack:");
|
// println!("Stack:");
|
||||||
// for addr in &self.debugger.stack_tracer.calls {
|
// for addr in &self.debugger.stack_tracer.calls {
|
||||||
|
@ -62,6 +62,7 @@ impl System {
|
|||||||
|
|
||||||
pub fn enable_debugging(&self) {
|
pub fn enable_debugging(&self) {
|
||||||
self.debug_enabled.set(true);
|
self.debug_enabled.set(true);
|
||||||
|
self.debugger.borrow_mut().breakpoint_occurred();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn disable_debugging(&self) {
|
pub fn disable_debugging(&self) {
|
||||||
|
Loading…
Reference in New Issue
Block a user