Skip to content

Commit

Permalink
Debugger: When MODE_STEPPING (eg. g or gg mode), prevent ESC from exi…
Browse files Browse the repository at this point in the history
…ting back to the debugger. F7 or Pause keys can still be used. (#217)
  • Loading branch information
tomcw committed Apr 22, 2017
1 parent a5274ca commit 5e6a445
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 33 deletions.
27 changes: 15 additions & 12 deletions source/Debugger/Debug.cpp
Expand Up @@ -8604,6 +8604,18 @@ void DebugContinueStepping ()
}
}

//===========================================================================
void DebugStopStepping(void)
{
_ASSERT(g_nAppMode == MODE_STEPPING);

if (g_nAppMode != MODE_STEPPING)
return;

g_nDebugSteps = 0; // On next DebugContinueStepping(), stop single-stepping and transition to MODE_DEBUG
ClearTempBreakpoints();
}

//===========================================================================
void DebugDestroy ()
{
Expand Down Expand Up @@ -8990,19 +9002,11 @@ void DebugInitialize ()
CmdMOTD(0);
}

// wparam = 0x16
// lparam = 0x002f 0x0001
// insert = VK_INSERT

// Add character to the input line
//===========================================================================
void DebuggerInputConsoleChar( TCHAR ch )
{
if ((g_nAppMode == MODE_STEPPING) && (ch == DEBUG_STEPPING_EXIT_KEY))
{
g_nDebugSteps = 0; // On next DebugContinueStepping(), stop single-stepping and transition to MODE_DEBUG
ClearTempBreakpoints();
}
_ASSERT(g_nAppMode == MODE_DEBUG);

if (g_nAppMode != MODE_DEBUG)
return;
Expand Down Expand Up @@ -9194,7 +9198,6 @@ void ToggleFullScreenConsole()

//===========================================================================
void DebuggerProcessKey( int keycode )
//void DebugProcessCommand (int keycode)
{
if (g_nAppMode != MODE_DEBUG)
return;
Expand Down Expand Up @@ -9293,10 +9296,10 @@ void DebuggerProcessKey( int keycode )
}
else
{
g_nConsoleInputSkip = 0; // VK_OEM_3; // don't pass to DebugProcessChar()
g_nConsoleInputSkip = 0; // VK_OEM_3;
DebuggerInputConsoleChar( '~' );
}
g_nConsoleInputSkip = '~'; // VK_OEM_3; // don't pass to DebugProcessChar()
g_nConsoleInputSkip = '~'; // VK_OEM_3;
}
else
{
Expand Down
10 changes: 2 additions & 8 deletions source/Debugger/Debug.h
Expand Up @@ -161,23 +161,17 @@

// Prototypes _______________________________________________________________

enum
{
DEBUG_STEPPING_EXIT_KEY = 0x1B, // Escape
DEBUG_TOGGLE_KEY = VK_F1 + BTN_DEBUG
};

bool DebugGetVideoMode(UINT* pVideoMode);

void DebugBegin ();
void DebugExitDebugger ();
void DebugContinueStepping ();
void DebugStopStepping(void);
void DebugDestroy ();
void DebugDisplay (BOOL);
void DebugInitialize ();
// void DebugProcessChar (TCHAR);

void DebuggerInputConsoleChar( TCHAR ch );
// void DebugProcessCommand (int);
void DebuggerProcessKey( int keycode );

void DebuggerUpdate();
Expand Down
24 changes: 11 additions & 13 deletions source/Frame.cpp
Expand Up @@ -1012,22 +1012,19 @@ LRESULT CALLBACK FrameWndProc (
break;

case WM_CHAR:
if ((g_nAppMode == MODE_RUNNING) || (g_nAppMode == MODE_LOGO) ||
((g_nAppMode == MODE_STEPPING) && (wparam != TEXT('\x1B'))))
if ((g_nAppMode == MODE_RUNNING) || (g_nAppMode == MODE_STEPPING) || (g_nAppMode == MODE_LOGO))
{
if( !g_bDebuggerEatKey )
{
KeybQueueKeypress((int)wparam,ASCII);
} else {
KeybQueueKeypress((int)wparam, ASCII);
}
else
{
g_bDebuggerEatKey = false;
}
}
else
if ((g_nAppMode == MODE_DEBUG) || (g_nAppMode == MODE_STEPPING))
else if (g_nAppMode == MODE_DEBUG)
{
if (g_nAppMode == MODE_STEPPING && (TCHAR)wparam == DEBUG_STEPPING_EXIT_KEY)
SoundCore_SetFade(FADE_OUT);

DebuggerInputConsoleChar((TCHAR)wparam);
}
break;
Expand Down Expand Up @@ -1303,7 +1300,7 @@ LRESULT CALLBACK FrameWndProc (
break;
case MODE_STEPPING:
SoundCore_SetFade(FADE_OUT);
DebuggerInputConsoleChar( DEBUG_STEPPING_EXIT_KEY );
DebugStopStepping();
break;
}
DrawStatusArea((HDC)0,DRAW_TITLE);
Expand Down Expand Up @@ -1892,17 +1889,18 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/)
case BTN_DEBUG:
if (g_nAppMode == MODE_LOGO && !GetLoadedSaveStateFlag())
{
// FIXME: Why is this needed? Surely when state is MODE_LOGO, then AppleII system will have been reset!
// - Transition to MODE_LOGO when: (a) AppleWin starts, (b) there's a Config change to the AppleII h/w
ResetMachineState();
}

if (g_nAppMode == MODE_STEPPING)
{
// Allow F7 to enter debugger even when not MODE_RUNNING
DebuggerInputConsoleChar( DEBUG_STEPPING_EXIT_KEY );
DebugStopStepping();
bAllowFadeIn = false;
}
else
if (g_nAppMode == MODE_DEBUG)
else if (g_nAppMode == MODE_DEBUG)
{
ProcessButtonClick(BTN_RUN); // Exit debugger, switch to MODE_RUNNING or MODE_STEPPING
}
Expand Down

0 comments on commit 5e6a445

Please sign in to comment.