Re-enabled the debugger in the command line version (SDL)

This commit is contained in:
skidau 2015-04-19 07:01:41 +00:00
parent dcfeb517dc
commit e07cef142e
5 changed files with 76 additions and 79 deletions

View File

@ -20,6 +20,7 @@ extern "C" {
#include "../gba/agbprint.h" #include "../gba/agbprint.h"
#include "../gba/Flash.h" #include "../gba/Flash.h"
#include "../gba/Cheats.h" #include "../gba/Cheats.h"
#include "../gba/remote.h"
#include "../gba/RTC.h" #include "../gba/RTC.h"
#include "../gba/Sound.h" #include "../gba/Sound.h"
#include "../gb/gb.h" #include "../gb/gb.h"
@ -252,7 +253,9 @@ int ifbType = kIFBNone;
int patchNum = 0; int patchNum = 0;
char *(patchNames[PATCH_MAX_NUM]) = { NULL }; // and so on char *(patchNames[PATCH_MAX_NUM]) = { NULL }; // and so on
void(*dbgMain)() = remoteStubMain;
void(*dbgSignal)(int, int) = remoteStubSignal;
void(*dbgOutput)(const char *, u32) = remoteOutput;
char* homeDir = NULL; char* homeDir = NULL;
char* arg0 = NULL; char* arg0 = NULL;
@ -894,7 +897,7 @@ int ReadOpts(int argc, char ** argv)
log("Missing BIOS file name\n"); log("Missing BIOS file name\n");
break; break;
} }
strcpy(biosFileNameGBA, optarg + 1); strcpy(biosFileNameGBA, optarg);
break; break;
case 'c': case 'c':
{ {
@ -902,13 +905,13 @@ int ReadOpts(int argc, char ** argv)
log("Missing config file name\n"); log("Missing config file name\n");
break; break;
} }
FILE *f = fopen(optarg + 1, "r"); FILE *f = fopen(optarg, "r");
if (f == NULL) { if (f == NULL) {
log("File not found %s\n", optarg + 1); log("File not found %s\n", optarg);
break; break;
} }
preferences = NULL; preferences = NULL;
OpenPreferences(optarg + 1); OpenPreferences(optarg);
fclose(f); fclose(f);
} }
break; break;
@ -924,49 +927,48 @@ int ReadOpts(int argc, char ** argv)
break; break;
} }
if (patchNum >= PATCH_MAX_NUM) { if (patchNum >= PATCH_MAX_NUM) {
log("Too many patches given at %s (max is %d). Ignoring.\n", optarg + 1, PATCH_MAX_NUM); log("Too many patches given at %s (max is %d). Ignoring.\n", optarg, PATCH_MAX_NUM);
} }
else { else {
patchNames[patchNum] = (char *)malloc(1 + strlen(optarg + 1)); patchNames[patchNum] = (char *)malloc(1 + strlen(optarg));
strcpy(patchNames[patchNum], optarg + 1); strcpy(patchNames[patchNum], optarg);
patchNum++; patchNum++;
} }
break; break;
//case 'G': case 'G':
// dbgMain = remoteStubMain; dbgMain = remoteStubMain;
// dbgSignal = remoteStubSignal; dbgSignal = remoteStubSignal;
// dbgOutput = remoteOutput; dbgOutput = remoteOutput;
// debugger = true; debugger = true;
// debuggerStub = true; if (optarg) {
// if (optarg) { char *s = optarg;
// char *s = optarg; if (strncmp(s, "tcp:", 4) == 0) {
// if (strncmp(s, "tcp:", 4) == 0) { s += 4;
// s += 4; int port = atoi(s);
// int port = atoi(s); remoteSetProtocol(0);
// remoteSetProtocol(0); remoteSetPort(port);
// remoteSetPort(port); }
// } else if (strcmp(s, "tcp") == 0) {
// else if (strcmp(s, "tcp") == 0) { remoteSetProtocol(0);
// remoteSetProtocol(0); }
// } else if (strcmp(s, "pipe") == 0) {
// else if (strcmp(s, "pipe") == 0) { remoteSetProtocol(1);
// remoteSetProtocol(1); }
// } else {
// else { log("Unknown protocol %s\n", s);
// log("Unknown protocol %s\n", s); break;
// break; }
// } }
// } else {
// else { remoteSetProtocol(0);
// remoteSetProtocol(0); }
// } break;
// break;
case 'N': case 'N':
parseDebug = false; parseDebug = false;
break; break;
case 'D': case 'D':
if (optarg) { if (optarg) {
systemDebug = atoi(optarg + 1); systemDebug = atoi(optarg);
} }
else { else {
systemDebug = 1; systemDebug = 1;
@ -978,7 +980,7 @@ int ReadOpts(int argc, char ** argv)
break; break;
case 'f': case 'f':
if (optarg) { if (optarg) {
filter = (Filter)atoi(optarg + 1); filter = (Filter)atoi(optarg);
} }
else { else {
filter = kStretch2x; filter = kStretch2x;
@ -986,7 +988,7 @@ int ReadOpts(int argc, char ** argv)
break; break;
case 'I': case 'I':
if (optarg) { if (optarg) {
ifbType = (IFBFilter)atoi(optarg + 1); ifbType = (IFBFilter)atoi(optarg);
} }
else { else {
ifbType = kIFBNone; ifbType = kIFBNone;
@ -1002,13 +1004,13 @@ int ReadOpts(int argc, char ** argv)
#endif #endif
break; break;
case 'S': case 'S':
optFlashSize = atoi(optarg + 1); optFlashSize = atoi(optarg);
if (optFlashSize < 0 || optFlashSize > 1) if (optFlashSize < 0 || optFlashSize > 1)
optFlashSize = 0; optFlashSize = 0;
break; break;
case 's': case 's':
if (optarg) { if (optarg) {
int a = atoi(optarg + 1); int a = atoi(optarg);
if (a >= 0 && a <= 9) { if (a >= 0 && a <= 9) {
gbFrameSkip = a; gbFrameSkip = a;
frameSkip = a; frameSkip = a;
@ -1021,7 +1023,7 @@ int ReadOpts(int argc, char ** argv)
break; break;
case 't': case 't':
if (optarg) { if (optarg) {
int a = atoi(optarg + 1); int a = atoi(optarg);
if (a < 0 || a > 5) if (a < 0 || a > 5)
a = 0; a = 0;
cpuSaveType = a; cpuSaveType = a;
@ -1029,7 +1031,7 @@ int ReadOpts(int argc, char ** argv)
break; break;
case 'v': case 'v':
if (optarg) { if (optarg) {
systemVerbose = atoi(optarg + 1); systemVerbose = atoi(optarg);
} }
else else
systemVerbose = 0; systemVerbose = 0;
@ -1039,7 +1041,7 @@ int ReadOpts(int argc, char ** argv)
break; break;
case 'O': case 'O':
if (optarg) { if (optarg) {
openGL = atoi(optarg + 1); openGL = atoi(optarg);
if (openGL < 0 || openGL > 2) if (openGL < 0 || openGL > 2)
openGL = 1; openGL = 1;
} }

View File

@ -1510,6 +1510,26 @@ void SetMapMasks()
map[10].mask = 0x1FFFFFF; map[10].mask = 0x1FFFFFF;
map[12].mask = 0x1FFFFFF; map[12].mask = 0x1FFFFFF;
map[14].mask = 0xFFFF; map[14].mask = 0xFFFF;
for (int i = 0; i < 16; i++) {
map[i].size = map[i].mask + 1;
if (map[i].size > 0) {
map[i].trace = (u8 *)calloc(map[i].size >> 3, sizeof(u8));
map[i].breakPoints = (u8 *)calloc(map[i].size >> 1, sizeof(u8)); //\\
if (map[i].trace == NULL || map[i].breakPoints == NULL) {
systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"),
"TRACE");
}
}
else {
map[i].trace = NULL;
map[i].breakPoints = NULL; //\\
}
}
clearBreakRegList();
} }
int CPULoadRom(const char *szFile) int CPULoadRom(const char *szFile)
@ -1737,27 +1757,6 @@ int CPULoadRomData(const char *data, int size)
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
SetMapMasks(); SetMapMasks();
for (int i = 0; i < 16; i++) {
map[i].size = map[i].mask + 1;
if (map[i].size > 0) {
map[i].trace = (u8 *)calloc(map[i].size >> 3, sizeof(u8));
map[i].breakPoints = (u8 *)calloc(map[i].size >> 1, sizeof(u8)); //\\
if (map[i].trace == NULL || map[i].breakPoints == NULL) {
systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"),
"TRACE");
}
}
else {
map[i].trace = NULL;
map[i].breakPoints = NULL; //\\
}
}
clearBreakRegList();
#endif #endif
return romSize; return romSize;

View File

@ -76,4 +76,10 @@ void deleteFromBreakRegList(u8 regnum, int location);
void addBreakRegToList(u8 regnum, u8 flags, u32 value); void addBreakRegToList(u8 regnum, u8 flags, u32 value);
void printBreakRegList(bool verbose); void printBreakRegList(bool verbose);
void remoteStubMain();
void remoteStubSignal(int sig, int number);
void remoteOutput(const char *s, u32 addr);
void remoteSetProtocol(int p);
void remoteSetPort(int port);
#endif // REMOTE_H #endif // REMOTE_H

View File

@ -182,18 +182,13 @@ enum VIDEO_SIZE{
u32 throttleLastTime = 0; u32 throttleLastTime = 0;
bool pauseNextFrame = false; bool pauseNextFrame = false;
bool debuggerStub = false;
int sdlMirroringEnable = 0; int sdlMirroringEnable = 0;
static int ignore_first_resize_event = 0; static int ignore_first_resize_event = 0;
void (*dbgMain)();
/* forward */ /* forward */
void systemConsoleMessage(const char*); void systemConsoleMessage(const char*);
void (*dbgSignal)(int,int);
void (*dbgOutput)(const char *, u32);
char* home; char* home;
char screenMessageBuffer[21]; char screenMessageBuffer[21];
@ -1157,7 +1152,6 @@ void sdlPollEvents()
} }
break; break;
case SDLK_F11: case SDLK_F11:
if(dbgMain == remoteStubMain) {
if(armState) { if(armState) {
armNextPC -= 4; armNextPC -= 4;
reg[15].I -= 4; reg[15].I -= 4;
@ -1165,7 +1159,6 @@ void sdlPollEvents()
armNextPC -= 2; armNextPC -= 2;
reg[15].I -= 2; reg[15].I -= 2;
} }
}
debugger = true; debugger = true;
break; break;
case SDLK_F1: case SDLK_F1:
@ -1569,7 +1562,7 @@ int main(int argc, char **argv)
exit(-1); exit(-1);
} }
if (!debuggerStub) { if (!debugger) {
if (optind >= argc) { if (optind >= argc) {
systemMessage(0, "Missing image name"); systemMessage(0, "Missing image name");
usage(argv[0]); usage(argv[0]);
@ -1701,7 +1694,7 @@ int main(int argc, char **argv)
sdlReadBattery(); sdlReadBattery();
if(debuggerStub) if(debugger)
remoteInit(); remoteInit();
int flags = SDL_INIT_VIDEO|SDL_INIT_AUDIO| int flags = SDL_INIT_VIDEO|SDL_INIT_AUDIO|
@ -1810,7 +1803,7 @@ int main(int argc, char **argv)
while(emulating) { while(emulating) {
if(!paused && active) { if(!paused && active) {
if(debugger && emulator.emuHasDebugger) if(debugger && emulator.emuHasDebugger)
dbgMain(); remoteStubMain();
else { else {
emulator.emuMain(emulator.emuCount); emulator.emuMain(emulator.emuCount);
if(rewindSaveNeeded && rewindMemory && emulator.emuWriteMemState) { if(rewindSaveNeeded && rewindMemory && emulator.emuWriteMemState) {

View File

@ -151,9 +151,6 @@ bool soundBufferLow = 0;
void winSignal(int,int); void winSignal(int,int);
void winOutput(const char *, u32); void winOutput(const char *, u32);
void (*dbgSignal)(int,int) = winSignal;
void (*dbgOutput)(const char *, u32) = winOutput;
#ifdef MMX #ifdef MMX
extern "C" bool cpu_mmx; extern "C" bool cpu_mmx;
#endif #endif