diff --git a/Changes.txt b/Changes.txt index 27825e1cf..64da360cb 100644 --- a/Changes.txt +++ b/Changes.txt @@ -23,6 +23,9 @@ then back again would pass a 'Tab' key event to the app, which in most cases would navigate to the next UI element. + * Fixed possible lockups when entering the debugger under certain + circumstances. + * Reverted joystick changes for Decathlon ROMs from last release, as it was added by mistake. diff --git a/src/debugger/DiStella.cxx b/src/debugger/DiStella.cxx index a96fef2f7..3e5dd4488 100644 --- a/src/debugger/DiStella.cxx +++ b/src/debugger/DiStella.cxx @@ -103,9 +103,16 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list, // use all access points determined by Stella during emulation int codeAccessPoint = 0; - while(!myAddressQueue.empty()) + // Sometimes we get a circular reference, in that processing a certain + // PC address leads us to a sequence of addresses that end up trying + // to process the same address again. We detect such consecutive PC + // addresses and only process the first one + uInt16 lastPC = 0; + bool duplicateFound = false; + while(!(myAddressQueue.empty() || duplicateFound)) { - myPC = myAddressQueue.front(); + myPC = lastPC = myAddressQueue.front(); + uInt16 pcBeg = myPC; myAddressQueue.pop(); disasm(myPC, 1); @@ -174,6 +181,7 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list, ++codeAccessPoint; } } + duplicateFound = (myAddressQueue.front() == lastPC); } for (int k = 0; k <= myAppData.end; k++) {