Made debugger able to break on and distinguish Stack reads/writes, regardless of the source of the stack change. Addresses bug 2809881, which asked for the address push from an NMI/IRQ to cause a break

This commit is contained in:
ugetab 2010-05-27 17:01:29 +00:00
parent ed2a319661
commit ff284dd29c
2 changed files with 39 additions and 2 deletions

View File

@ -1,3 +1,4 @@
27-may-2010 - ugetab - Win32 - Debugger - Made debugger able to break on and distinguish Stack reads/writes
24-may-2010 - adelikat - Win32 - Memwatch - ignore spaces at the beginnign of an address in the address boxes
24-may-2010 - mart0258 - Disable auto-savestates during turbo
24-may-2010 - mart0258 - Prevent .zip files containing no recognized files from causing crash

View File

@ -494,15 +494,17 @@ void BreakHit(bool force = false) {
FCEUD_DebugBreakpoint();
}
uint8 StackAddrBackup = X.S;
///fires a breakpoint
void breakpoint() {
int i;
int i,j;
uint16 A=0;
uint8 brk_type,opcode[3] = {0};
//inspect the current opcode
opcode[0] = GetMem(_PC);
//if the current instruction is bad, and we are breaking on bad opcodes, then hit the breakpoint
if(dbgstate.badopbreak && (opsize[opcode[0]] == 0)) BreakHit(true);
@ -593,12 +595,46 @@ void breakpoint() {
}
else if (((watchpoint[i].flags & (WP_R | WP_W)) && (watchpoint[i].address == A)) ||
((watchpoint[i].flags & WP_X) && (watchpoint[i].address == _PC))) BreakHit();
} else if (watchpoint[i].flags & WP_E) {
//brk_type independant coding
//Stack mem breaks
if (X.S < StackAddrBackup) {
//Pushes to stack
if (watchpoint[i].flags & WP_W) {
for (j = (X.S|0x0100); j < (StackAddrBackup|0x0100); j++) {
if (watchpoint[i].endaddress) {
if ((watchpoint[i].address <= j) && (watchpoint[i].endaddress >= j))
BreakHit();
}
else if (watchpoint[i].address == j)
BreakHit();
}
}
}
else if (StackAddrBackup < X.S) {
//Pulls from stack
if (watchpoint[i].flags & WP_R) {
for (j = (StackAddrBackup|0x0100); j < (X.S|0x0100); j++) {
if (watchpoint[i].endaddress) {
if ((watchpoint[i].address <= j) && (watchpoint[i].endaddress >= j))
BreakHit();
}
else if (watchpoint[i].address == j)
BreakHit();
}
}
}
}
}
// ################################## Start of SP CODE ###########################
}
// ################################## End of SP CODE ###########################
}
//Update the stack address with the current one, now that changes have registered.
StackAddrBackup = X.S;
}
//bbit edited: this is the end of the inserted code