From 9ef3e205b04d7fe356189341da3b639a2df2b095 Mon Sep 17 00:00:00 2001 From: skidau Date: Sun, 19 Apr 2015 10:13:53 +0000 Subject: [PATCH] Fixed the debug printf feature in the case where a debugger is not attached. --- src/common/ConfigManager.cpp | 2 +- src/gba/remote.cpp | 17 +++++++++++++++++ src/gba/remote.h | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/common/ConfigManager.cpp b/src/common/ConfigManager.cpp index 023d726c..4b5a6319 100644 --- a/src/common/ConfigManager.cpp +++ b/src/common/ConfigManager.cpp @@ -255,7 +255,7 @@ char *(patchNames[PATCH_MAX_NUM]) = { NULL }; // and so on void(*dbgMain)() = remoteStubMain; void(*dbgSignal)(int, int) = remoteStubSignal; -void(*dbgOutput)(const char *, u32) = remoteOutput; +void(*dbgOutput)(const char *, u32) = debuggerOutput; char* homeDir = NULL; char* arg0 = NULL; diff --git a/src/gba/remote.cpp b/src/gba/remote.cpp index 44f74dba..83c289ce 100644 --- a/src/gba/remote.cpp +++ b/src/gba/remote.cpp @@ -273,6 +273,23 @@ void printBreakRegList(bool verbose){ } +void debuggerOutput(const char *s, u32 addr) +{ + if (s) + printf("%s", s); + else { + char c; + + c = debuggerReadByte(addr); + addr++; + while (c) { + putchar(c); + c = debuggerReadByte(addr); + addr++; + } + } +} + // checks that the given address is in the DB list bool debuggerInDB(u32 address) { diff --git a/src/gba/remote.h b/src/gba/remote.h index 7d210337..97e4ce02 100644 --- a/src/gba/remote.h +++ b/src/gba/remote.h @@ -43,6 +43,8 @@ extern void dexp_listVars(); extern void dexp_saveVars(char *); extern void dexp_loadVars(char *); +void debuggerOutput(const char *s, u32 addr); + bool debuggerBreakOnExecution(u32 address, u8 state); bool debuggerBreakOnWrite(u32 address, u32 value, int size); void debuggerBreakOnWrite(u32 address, u32 oldvalue, u32 value, int size, int t);