From 42bb6f6037e79e7b869d4b358f59d46261eb69fd Mon Sep 17 00:00:00 2001 From: Steven Frank Date: Wed, 8 Feb 2017 15:47:04 -0800 Subject: [PATCH] Implemented 'dis' (disassemble) command in monitor --- Monitor/TMacMonitor.mm | 4 +++- Monitor/TMonitor.cp | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Monitor/TMacMonitor.mm b/Monitor/TMacMonitor.mm index 904a65d3f..515e2e429 100644 --- a/Monitor/TMacMonitor.mm +++ b/Monitor/TMacMonitor.mm @@ -309,7 +309,9 @@ { if ( controller ) { - [controller addHistoryLine:[NSString stringWithCString:inLine encoding:NSUTF8StringEncoding] type:type]; + NSString *s = [NSString stringWithCString:inLine encoding:NSUTF8StringEncoding]; + s = [s stringByReplacingOccurrencesOfString:@"\t" withString:@" "]; + [controller addHistoryLine:s type:type]; } } diff --git a/Monitor/TMonitor.cp b/Monitor/TMonitor.cp index bb2273db1..2dcb85db7 100644 --- a/Monitor/TMonitor.cp +++ b/Monitor/TMonitor.cp @@ -972,6 +972,30 @@ TMonitor::ExecuteCommand( const char* inCommand ) } theArgInt += 16; } + } else if ( ::sscanf(inCommand, "dis %X", &theArgInt) == 1 ) { + KUInt32 addr = theArgInt; + KUInt32 data; + + for ( int i = 0; i < 16; ++i ) + { + if ( mMemory->Read((TMemory::VAddr) addr, data) ) + { + (void) ::sprintf( + theLine, "Memory error when accessing %.8X [%.8X]", + (unsigned int) theArgInt, + (unsigned int) mMemory->GetFaultStatusRegister() ); + PrintLine(theLine, MONITOR_LOG_ERROR); + break; + } else { + char disasm[256]; + + UDisasm::Disasm(disasm, 256, addr, data); + ::snprintf(theLine, 256, " %08X %s", addr, disasm); + PrintLine(theLine, MONITOR_LOG_INFO); + } + + addr += 4; + } } else if (::sscanf(inCommand, "dm %X", &theArgInt) == 1) { KUInt32 theData[4]; KUInt32 last;