add read and step out

This commit is contained in:
Jorj Bauer 2020-07-04 14:46:55 -04:00
parent 1da4817e86
commit 06211c9933

View File

@ -91,10 +91,19 @@ bool getAddress(const char *buf, unsigned int *addrOut)
#define HEXCHAR(x) ((x>='0'&&x<='9')?x-'0':(x>='a'&&x<='f')?x-'a'+10:(x>='A'&&x<='F')?x-'A'+10:(x=='i' || x=='I')?1:(x=='o' || x=='O')?0:0) #define HEXCHAR(x) ((x>='0'&&x<='9')?x-'0':(x>='a'&&x<='f')?x-'a'+10:(x>='A'&&x<='F')?x-'A'+10:(x=='i' || x=='I')?1:(x=='o' || x=='O')?0:0)
#define FROMHEXP(p) ((HEXCHAR(*p) << 4) | HEXCHAR(*(p+1))) #define FROMHEXP(p) ((HEXCHAR(*p) << 4) | HEXCHAR(*(p+1)))
bool steppingOut = false;
void Debugger::step() void Debugger::step()
{ {
static char buf[256]; static char buf[256];
// FIXME: add more than just RTS(0x60) here
if (steppingOut &&
g_vm->getMMU()->read(g_cpu->pc) != 0x60) {
return;
}
steppingOut = false;
if (cd != -1) { if (cd != -1) {
// Print the status back out the socket // Print the status back out the socket
uint8_t p = g_cpu->flags; uint8_t p = g_cpu->flags;
@ -147,6 +156,11 @@ void Debugger::step()
printf("Closing debugging socket\n"); printf("Closing debugging socket\n");
close(cd); cd=-1; close(cd); cd=-1;
break; break;
case 'S':
steppingOut = true;
break;
case 'b': // Set breakpoint case 'b': // Set breakpoint
GETLN; GETLN;
if (getAddress(buf, &val)) { if (getAddress(buf, &val)) {
@ -186,6 +200,22 @@ void Debugger::step()
} }
break; break;
case '*': // read 1 byte of memory. Use '* 0x<address>'
{
GETLN;
if (getAddress(buf, &val)) {
sprintf(buf, "Memory location 0x%X: ", val);
write(cd, buf, strlen(buf));
val = g_vm->getMMU()->read(val);
sprintf(buf, "0x%.2X\012\015", val);
write(cd, buf, strlen(buf));
} else {
sprintf(buf, "Invalid read\012\015");
write(cd, buf, strlen(buf));
}
}
break;
case 'G': // Goto (set PC) case 'G': // Goto (set PC)
GETLN; GETLN;
if (getAddress(buf, &val)) { if (getAddress(buf, &val)) {