Skip to content

Commit

Permalink
Fix RUN and RUNWATCH commands [#4484]
Browse files Browse the repository at this point in the history
  • Loading branch information
joncampbell123 committed Sep 26, 2023
1 parent 841d684 commit 293e27d
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 57 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Next version:
- Updated build tool for MinGW lowend builds required for the updated SDL2
library. As a result, MinGW lowend builds are now able to enable debugger
features. (maron2000)
- Debugger RUN and RUNWATCH commands were broken, fix. Make sure debugger
shortcut triggers execution to stop whether in RUN or RUNWATCH mode.

2023.09.01
- Disable by default message confirmation after snapshot and AVI video
Expand Down
117 changes: 60 additions & 57 deletions src/debug/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1855,6 +1855,7 @@ bool lookslikefloat(char* str) {

void VGA_DumpFontRamBIN(const char *filename);
void VGA_DumpFontRamBMP(const char *filename);
int32_t DEBUG_Run(int32_t amount,bool quickexit);

bool ParseCommand(char* str) {
std::string copy_str = str;
Expand Down Expand Up @@ -2197,47 +2198,48 @@ bool ParseCommand(char* str) {
return true;
}

if (command == "RUN") {
DrawRegistersUpdateOld();
debugging = false;
runnormal = true;

logBuffSuppressConsole = false;
if (logBuffSuppressConsoleNeedUpdate) {
logBuffSuppressConsoleNeedUpdate = false;
DEBUG_RefreshPage(0);
}

Bits DEBUG_NullCPUCore(void);

CPU_Cycles = 1;
inhibit_int_breakpoint = true;
if (cpudecoder != DEBUG_NullCPUCore)
(*cpudecoder)();
if (command == "RUN") {
DrawRegistersUpdateOld();
debug_running = false;
debugging=false;
DrawCode();
DrawInput();
logBuffSuppressConsole = false;
if (logBuffSuppressConsoleNeedUpdate) {
logBuffSuppressConsoleNeedUpdate = false;
DEBUG_RefreshPage(0);
}

inhibit_int_breakpoint = false;
Bits DEBUG_NullCPUCore(void);

void DEBUG_DrawScreen(void);
DEBUG_DrawScreen();
inhibit_int_breakpoint = true;
DEBUG_Run(1,false);
inhibit_int_breakpoint = false;
mainMenu.get_item("debugger_rundebug").check(false).refresh_item(mainMenu);
mainMenu.get_item("debugger_runnormal").check(true).refresh_item(mainMenu);
mainMenu.get_item("debugger_runwatch").check(false).refresh_item(mainMenu);

CBreakpoint::ActivateBreakpointsExceptAt(SegPhys(cs)+reg_eip);
mainMenu.get_item("debugger_rundebug").check(false).refresh_item(mainMenu);
mainMenu.get_item("debugger_runnormal").check(true).refresh_item(mainMenu);
mainMenu.get_item("debugger_runwatch").check(false).refresh_item(mainMenu);
DOSBOX_SetNormalLoop();
GFX_SetTitle(-1,-1,-1,is_paused);
return true;
}
DOSBOX_SetNormalLoop();
GFX_SetTitle(-1,-1,-1,is_paused);
return true;
}

if (command == "RUNWATCH") {
debug_running = true;
runnormal = false;
mainMenu.get_item("debugger_rundebug").check(false).refresh_item(mainMenu);
mainMenu.get_item("debugger_runnormal").check(false).refresh_item(mainMenu);
mainMenu.get_item("debugger_runwatch").check(true).refresh_item(mainMenu);
DEBUG_DrawScreen();
return true;
}
if (command == "RUNWATCH") {
auto oldcore = cpudecoder;
runnormal = false;
inhibit_int_breakpoint = true;
DEBUG_Run(1,true);
inhibit_int_breakpoint = false;
cpudecoder = oldcore;
debug_running = true;
debugging = true;
CBreakpoint::ActivateBreakpoints();
mainMenu.get_item("debugger_rundebug").check(false).refresh_item(mainMenu);
mainMenu.get_item("debugger_runnormal").check(false).refresh_item(mainMenu);
mainMenu.get_item("debugger_runwatch").check(true).refresh_item(mainMenu);
DEBUG_DrawScreen();
return true;
}

if (command == "A20") {
void MEM_A20_Enable(bool enabled);
Expand Down Expand Up @@ -4147,26 +4149,26 @@ uint32_t DEBUG_CheckKeys(void) {
codeViewData.inputPos = (int)strlen(codeViewData.inputStr);
break;
case KEY_F(5): // Run Program
DrawRegistersUpdateOld();
DrawRegistersUpdateOld();
debugging=false;
DrawCode();
DrawInput();
logBuffSuppressConsole = false;
if (logBuffSuppressConsoleNeedUpdate) {
logBuffSuppressConsoleNeedUpdate = false;
DEBUG_RefreshPage(0);
}
DrawInput();
logBuffSuppressConsole = false;
if (logBuffSuppressConsoleNeedUpdate) {
logBuffSuppressConsoleNeedUpdate = false;
DEBUG_RefreshPage(0);
}

Bits DEBUG_NullCPUCore(void);
Bits DEBUG_NullCPUCore(void);

inhibit_int_breakpoint = true;
inhibit_int_breakpoint = true;
ret = DEBUG_Run(1,false);
if(cpudecoder == DEBUG_NullCPUCore)
ret = -1; /* DEBUG_Loop() must exit */
inhibit_int_breakpoint = false;
mainMenu.get_item("debugger_rundebug").check(false).refresh_item(mainMenu);
mainMenu.get_item("debugger_runnormal").check(true).refresh_item(mainMenu);
mainMenu.get_item("debugger_runwatch").check(false).refresh_item(mainMenu);
if(cpudecoder == DEBUG_NullCPUCore)
ret = -1; /* DEBUG_Loop() must exit */
inhibit_int_breakpoint = false;
mainMenu.get_item("debugger_rundebug").check(false).refresh_item(mainMenu);
mainMenu.get_item("debugger_runnormal").check(true).refresh_item(mainMenu);
mainMenu.get_item("debugger_runwatch").check(false).refresh_item(mainMenu);

skipDraw = true; // don't update screen after this instruction
break;
Expand All @@ -4186,20 +4188,20 @@ uint32_t DEBUG_CheckKeys(void) {
}
break;
case KEY_F(10): // Step over inst
DrawRegistersUpdateOld();
DrawRegistersUpdateOld();
if (StepOver()) {
mustCompleteInstruction = true;
inhibit_int_breakpoint = true;
ret = DEBUG_Run(1,false);
inhibit_int_breakpoint = false;
inhibit_int_breakpoint = false;
mustCompleteInstruction = false;
skipDraw = true;
break;
}
// If we aren't stepping over something, do a normal step.
/* FALLTHROUGH */
case KEY_F(11): // trace into
DrawRegistersUpdateOld();
DrawRegistersUpdateOld();
exitLoop = false;
mustCompleteInstruction = true;
ret = DEBUG_Run(1,true);
Expand Down Expand Up @@ -4425,6 +4427,7 @@ void DEBUG_Enable_Handler(bool pressed) {
DEBUG_DrawScreen();
if (tohide&&!debugging) return;
}

if (debugging) {
DrawRegistersUpdateOld();
debugging=false;
Expand All @@ -4440,7 +4443,7 @@ void DEBUG_Enable_Handler(bool pressed) {
CBreakpoint::ActivateBreakpointsExceptAt(SegPhys(cs)+reg_eip);
DOSBOX_SetNormalLoop();
GFX_SetTitle(-1,-1,-1,is_paused);
if (tohide) return;
// if (tohide) return;
}

static bool showhelp=false;
Expand Down Expand Up @@ -5119,7 +5122,7 @@ Bitu DEBUG_EnableDebugger(void)
{
exitLoop = true;

if (!debugging)
if (!debugging || (debugging && debug_running))
DEBUG_Enable_Handler(true);

CPU_Cycles=CPU_CycleLeft=0;
Expand Down

0 comments on commit 293e27d

Please sign in to comment.