diff options
author | Ben Bridle <ben@derelict.engineering> | 2024-10-31 18:08:19 +1300 |
---|---|---|
committer | Ben Bridle <ben@derelict.engineering> | 2024-10-31 18:08:19 +1300 |
commit | dafa39853a6fc43f6a803ff6436b0f6d25373368 (patch) | |
tree | a11f6760fd2f485bd76b57ab0102add7a1e5a7c6 | |
parent | 825a023c2cd77716ee54a0ecfeb65618e0940a71 (diff) | |
download | bedrock-pc-dafa39853a6fc43f6a803ff6436b0f6d25373368.zip |
Only print stack debug information in debug mode
The stack state when halting was previously being printed even outside
of debug mode.
-rw-r--r-- | src/debug.rs | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/debug.rs b/src/debug.rs index d7e7f67..8be5bb9 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -34,20 +34,26 @@ impl DebugState { } pub fn debug_summary(&mut self, core: &BedrockCore) { - eprintln!("\n PC: 0x{:04x} Cycles: {} (+{} in {:.2?})", - core.mem.pc, core.cycle, - core.cycle.saturating_sub(self.last_cycle), - self.last_mark.elapsed(), - ); - eprint!("WST: "); - debug_stack(&core.wst, 0x10); - eprint!("RST: "); - debug_stack(&core.rst, 0x10); - // Print information about the current symbol. - if let Some(symbol) = self.symbols.for_address(core.mem.pc) { - eprint!("SYM: {BLUE}@{}{NORMAL} 0x{:04x}", symbol.name, symbol.address); - if let Some(location) = &symbol.location { eprint!(" {DIM}{location}{NORMAL}"); } - eprintln!(); + if self.enabled { + eprintln!("\n PC: 0x{:04x} Cycles: {} (+{} in {:.2?})", + core.mem.pc, core.cycle, + core.cycle.saturating_sub(self.last_cycle), + self.last_mark.elapsed(), + ); + eprint!("WST: "); + debug_stack(&core.wst, 0x10); + eprint!("RST: "); + debug_stack(&core.rst, 0x10); + // Print information about the closest symbol. + if let Some(symbol) = self.symbols.for_address(core.mem.pc) { + let name = &symbol.name; + let address = &symbol.address; + eprint!("SYM: {BLUE}@{name}{NORMAL} 0x{address:04x}"); + if let Some(location) = &symbol.location { + eprint!(" {DIM}{location}{NORMAL}"); + } + eprintln!(); + } } self.last_cycle = core.cycle; self.last_mark = Instant::now(); |