core: Fix broken debugger build
Former-commit-id: 0dcdb6d758e463eecc02faf5a0e7eff6c8c08899 Former-commit-id: 5e9d842158d573b10dc1ddb4c3621056282351ed
This commit is contained in:
parent
2ec52fb722
commit
f140e0f83b
|
@ -87,20 +87,20 @@ pub struct SavedCpuState {
|
|||
|
||||
#[derive(Clone, Debug)]
|
||||
#[cfg(feature = "debugger")]
|
||||
struct DebuggerInfo {
|
||||
last_executed: Option<DecodedInstruction>,
|
||||
pub struct DebuggerState {
|
||||
pub last_executed: Option<DecodedInstruction>,
|
||||
/// store the gpr before executing an instruction to show diff in the Display impl
|
||||
gpr_previous: [u32; 15],
|
||||
breakpoints: Vec<u32>,
|
||||
verbose: bool,
|
||||
trace_opcodes: bool,
|
||||
trace_exceptions: bool,
|
||||
pub gpr_previous: [u32; 15],
|
||||
pub breakpoints: Vec<u32>,
|
||||
pub verbose: bool,
|
||||
pub trace_opcodes: bool,
|
||||
pub trace_exceptions: bool,
|
||||
}
|
||||
|
||||
#[cfg(feature = "debugger")]
|
||||
impl Default for DebuggerInfo {
|
||||
fn default() -> DebuggerInfo {
|
||||
DebuggerInfo {
|
||||
impl Default for DebuggerState {
|
||||
fn default() -> DebuggerState {
|
||||
DebuggerState {
|
||||
last_executed: None,
|
||||
gpr_previous: [0; 15],
|
||||
breakpoints: Vec::new(),
|
||||
|
@ -126,7 +126,7 @@ pub struct Core<I: MemoryInterface> {
|
|||
pub(super) banks: BankedRegisters,
|
||||
|
||||
#[cfg(feature = "debugger")]
|
||||
pub dbg_info: DebuggerInfo,
|
||||
pub dbg: DebuggerState,
|
||||
}
|
||||
|
||||
impl<I: MemoryInterface> Core<I> {
|
||||
|
@ -143,7 +143,7 @@ impl<I: MemoryInterface> Core<I> {
|
|||
banks: BankedRegisters::default(),
|
||||
|
||||
#[cfg(feature = "debugger")]
|
||||
dbg_info: DebuggerInfo::default(),
|
||||
dbg: DebuggerState::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ impl<I: MemoryInterface> Core<I> {
|
|||
|
||||
// savestate does not keep debugger related information, so just reinitialize to default
|
||||
#[cfg(feature = "debugger")]
|
||||
dbg_info: DebuggerInfo::default(),
|
||||
dbg: DebuggerState::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,7 @@ impl<I: MemoryInterface> Core<I> {
|
|||
|
||||
#[cfg(feature = "debugger")]
|
||||
pub fn set_verbose(&mut self, v: bool) {
|
||||
self.verbose = v;
|
||||
self.dbg.verbose = v;
|
||||
}
|
||||
|
||||
pub fn get_reg(&self, r: usize) -> u32 {
|
||||
|
@ -360,8 +360,8 @@ impl<I: MemoryInterface> Core<I> {
|
|||
|
||||
#[cfg(feature = "debugger")]
|
||||
fn debugger_record_step(&mut self, d: DecodedInstruction) {
|
||||
self.gpr_previous = self.get_registers();
|
||||
self.last_executed = Some(d);
|
||||
self.dbg.gpr_previous = self.get_registers();
|
||||
self.dbg.last_executed = Some(d);
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
|
@ -538,7 +538,7 @@ impl<I: MemoryInterface> fmt::Display for Core<I> {
|
|||
let mut reg_name = reg_string(i).to_string();
|
||||
reg_name.make_ascii_uppercase();
|
||||
|
||||
let style = if gpr[i] != self.gpr_previous[i] {
|
||||
let style = if gpr[i] != self.dbg.gpr_previous[i] {
|
||||
®_dirty_style
|
||||
} else {
|
||||
®_normal_style
|
||||
|
|
|
@ -114,10 +114,10 @@ impl Debugger {
|
|||
Step(count) => {
|
||||
for _ in 0..count {
|
||||
self.gba.step_debugger();
|
||||
while self.gba.cpu.last_executed.is_none() {
|
||||
while self.gba.cpu.dbg.last_executed.is_none() {
|
||||
self.gba.step_debugger();
|
||||
}
|
||||
if let Some(last_executed) = &self.gba.cpu.last_executed {
|
||||
if let Some(last_executed) = &self.gba.cpu.dbg.last_executed {
|
||||
let pc = last_executed.get_pc();
|
||||
let symbol =
|
||||
self.symbols
|
||||
|
@ -208,10 +208,10 @@ impl Debugger {
|
|||
None => println!("Breakpint already exists."),
|
||||
},
|
||||
DelBreakpoint(addr) => self.delete_breakpoint(addr),
|
||||
ClearBreakpoints => self.gba.cpu.breakpoints.clear(),
|
||||
ClearBreakpoints => self.gba.cpu.dbg.breakpoints.clear(),
|
||||
ListBreakpoints => {
|
||||
println!("breakpoint list:");
|
||||
for (i, b) in self.gba.cpu.breakpoints.iter().enumerate() {
|
||||
for (i, b) in self.gba.cpu.dbg.breakpoints.iter().enumerate() {
|
||||
println!("[{}] 0x{:08x}", i, b)
|
||||
}
|
||||
}
|
||||
|
@ -224,10 +224,10 @@ impl Debugger {
|
|||
}
|
||||
TraceToggle(flags) => {
|
||||
if flags.contains(TraceFlags::TRACE_OPCODE) {
|
||||
self.gba.cpu.trace_opcodes = !self.gba.cpu.trace_opcodes;
|
||||
self.gba.cpu.dbg.trace_opcodes = !self.gba.cpu.dbg.trace_opcodes;
|
||||
println!(
|
||||
"[*] opcode tracing {}",
|
||||
if self.gba.cpu.trace_opcodes {
|
||||
if self.gba.cpu.dbg.trace_opcodes {
|
||||
"on"
|
||||
} else {
|
||||
"off"
|
||||
|
@ -235,10 +235,10 @@ impl Debugger {
|
|||
)
|
||||
}
|
||||
if flags.contains(TraceFlags::TRACE_EXCEPTIONS) {
|
||||
self.gba.cpu.trace_exceptions = !self.gba.cpu.trace_exceptions;
|
||||
self.gba.cpu.dbg.trace_exceptions = !self.gba.cpu.dbg.trace_exceptions;
|
||||
println!(
|
||||
"[*] exception tracing {}",
|
||||
if self.gba.cpu.trace_exceptions {
|
||||
if self.gba.cpu.dbg.trace_exceptions {
|
||||
"on"
|
||||
} else {
|
||||
"off"
|
||||
|
|
|
@ -55,7 +55,7 @@ impl Debugger {
|
|||
|
||||
pub fn check_breakpoint(&self) -> Option<u32> {
|
||||
let next_pc = self.gba.cpu.get_next_pc();
|
||||
for bp in &self.gba.cpu.breakpoints {
|
||||
for bp in &self.gba.cpu.dbg.breakpoints {
|
||||
if *bp == next_pc {
|
||||
return Some(next_pc);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ impl Debugger {
|
|||
}
|
||||
|
||||
pub fn delete_breakpoint(&mut self, addr: u32) {
|
||||
self.gba.cpu.breakpoints.retain(|&a| a != addr);
|
||||
self.gba.cpu.dbg.breakpoints.retain(|&a| a != addr);
|
||||
}
|
||||
|
||||
fn decode_reg(&self, s: &str) -> DebuggerResult<usize> {
|
||||
|
|
|
@ -325,9 +325,10 @@ impl GameBoyAdvance {
|
|||
|
||||
#[cfg(feature = "debugger")]
|
||||
pub fn add_breakpoint(&mut self, addr: u32) -> Option<usize> {
|
||||
if !self.cpu.breakpoints.contains(&addr) {
|
||||
let new_index = self.cpu.breakpoints.len();
|
||||
self.cpu.breakpoints.push(addr);
|
||||
let breakpoints = &mut self.cpu.dbg.breakpoints;
|
||||
if !breakpoints.contains(&addr) {
|
||||
let new_index = breakpoints.len();
|
||||
breakpoints.push(addr);
|
||||
Some(new_index)
|
||||
} else {
|
||||
None
|
||||
|
@ -337,7 +338,7 @@ impl GameBoyAdvance {
|
|||
#[cfg(feature = "debugger")]
|
||||
pub fn check_breakpoint(&self) -> Option<u32> {
|
||||
let next_pc = self.cpu.get_next_pc();
|
||||
for bp in &self.cpu.breakpoints {
|
||||
for bp in &self.cpu.dbg.breakpoints {
|
||||
if (*bp & !1) == next_pc {
|
||||
return Some(*bp);
|
||||
}
|
||||
|
|
Reference in a new issue