fixups to build & run (mainly reinstating v1.20 Debug.cpp & Debug.h)

This commit is contained in:
wsxyz 2011-03-01 08:12:24 +00:00
parent 2daeebcb01
commit c5cfc49da7
6 changed files with 173 additions and 98 deletions

View File

@ -1,6 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 9.00 
# Visual Studio 2005 Microsoft Visual Studio Solution File, Format Version 11.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppleWin", "Applewin.vcproj", "{C4C93CFD-5B6C-41C5-BF90-17119186120F}" # Visual C++ Express 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Applewin", "Applewin.vcxproj", "{C4C93CFD-5B6C-41C5-BF90-17119186120F}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -42,6 +42,8 @@
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</OutDir> <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</IntDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">C:\Users\Miyeong\Projects\AppleWin-Sheldon\source;C:\Users\Miyeong\Projects\AppleWin-Sheldon\source\CPU;C:\Users\Miyeong\Projects\AppleWin-Sheldon\source\Debugger;C:\Users\Miyeong\Projects\AppleWin-Sheldon\zip_lib;C:\Users\Miyeong\Projects\AppleWin-Sheldon\zlib;$(IncludePath)</IncludePath>
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">C:\Users\Miyeong\Projects\AppleWin-Sheldon\source;C:\Users\Miyeong\Projects\AppleWin-Sheldon\source\CPU;C:\Users\Miyeong\Projects\AppleWin-Sheldon\source\Debugger;C:\Users\Miyeong\Projects\AppleWin-Sheldon\zip_lib;C:\Users\Miyeong\Projects\AppleWin-Sheldon\zlib;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Midl> <Midl>
@ -137,6 +139,7 @@
<ClCompile Include="source\AY8910.cpp" /> <ClCompile Include="source\AY8910.cpp" />
<ClCompile Include="source\CPU.cpp" /> <ClCompile Include="source\CPU.cpp" />
<ClCompile Include="source\cs.cpp" /> <ClCompile Include="source\cs.cpp" />
<ClCompile Include="source\Debugger\Debugger_Commands.cpp" />
<ClCompile Include="source\Disk.cpp" /> <ClCompile Include="source\Disk.cpp" />
<ClCompile Include="source\DiskImage.cpp" /> <ClCompile Include="source\DiskImage.cpp" />
<ClCompile Include="source\DiskImageHelper.cpp" /> <ClCompile Include="source\DiskImageHelper.cpp" />

View File

@ -230,6 +230,9 @@
<ClCompile Include="source\CPU.cpp"> <ClCompile Include="source\CPU.cpp">
<Filter>Source</Filter> <Filter>Source</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="source\Debugger\Debugger_Commands.cpp">
<Filter>Source\Debugger</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="source\6821.h"> <ClInclude Include="source\6821.h">

View File

@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#define ALLOW_INPUT_LOWERCASE 1 #define ALLOW_INPUT_LOWERCASE 1
// See /docs/Debugger_Changelog.txt for full details // See /docs/Debugger_Changelog.txt for full details
const int DEBUGGER_VERSION = MAKE_VERSION(2,7,0,7); const int DEBUGGER_VERSION = MAKE_VERSION(2,7,0,21);
// Public _________________________________________________________________________________________ // Public _________________________________________________________________________________________
@ -46,15 +46,23 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// Bookmarks __________________________________________________________________ // Bookmarks __________________________________________________________________
// vector<int> g_aBookmarks; // vector<int> g_aBookmarks;
int g_nBookmarks; int g_nBookmarks = 0;
Bookmark_t g_aBookmarks[ MAX_BOOKMARKS ]; Bookmark_t g_aBookmarks[ MAX_BOOKMARKS ];
// Breakpoints ________________________________________________________________ // Breakpoints ________________________________________________________________
// Full-Speed debugging
int g_nDebugOnBreakInvalid = 0; // MODE_RUNNING // Normal Speed Breakpoints: Shift-F7 exit debugger, keep breakpoints active, enter run state at NORMAL speed
int g_iDebugOnOpcode = 0; bool g_bDebugNormalSpeedBreakpoints = 0;
bool g_bDebugDelayBreakCheck = false;
// MODE_STEPPING // Full Speed Breakpoints
// Any Speed Breakpoints
int g_nDebugBreakOnInvalid = 0; // Bit Flags of Invalid Opcode to break on: // iOpcodeType = AM_IMPLIED (BRK), AM_1, AM_2, AM_3
int g_iDebugBreakOnOpcode = 0;
bool g_bDebugBreakDelayCheck = false; // If exiting the debugger, allow at least one instruction to execute so we don't trigger on the same invalid opcode
int g_bDebugBreakpointHit = 0; // See: BreakpointHit_t
int g_nBreakpoints = 0; int g_nBreakpoints = 0;
Breakpoint_t g_aBreakpoints[ MAX_BREAKPOINTS ]; Breakpoint_t g_aBreakpoints[ MAX_BREAKPOINTS ];
@ -111,12 +119,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
vector<Command_t> g_vSortedCommands; vector<Command_t> g_vSortedCommands;
// static const char g_aFlagNames[_6502_NUM_FLAGS+1] = TEXT("CZIDBRVN");// Reversed since arrays are from left-to-right // static const char g_aFlagNames[_6502_NUM_FLAGS+1] = TEXT("CZIDBRVN");// Reversed since arrays are from left-to-right
#ifdef WS_VIDEO
Command_t g_aCommands[NUM_COMMANDS];
Command_t g_aParameters[NUM_COMMANDS];
const int NUM_COMMANDS_WITH_ALIASES = sizeof(g_aCommands) / sizeof (Command_t); // Determined at compile-time ;-)
void VerifyDebuggerCommandTable () {}
#endif
// Cursor (Console Input) _____________________________________________________ // Cursor (Console Input) _____________________________________________________
// char g_aInputCursor[] = "\|/-"; // char g_aInputCursor[] = "\|/-";
@ -322,8 +326,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
void _BWZ_ListAll ( const Breakpoint_t * aBreakWatchZero, const int nMax ); void _BWZ_ListAll ( const Breakpoint_t * aBreakWatchZero, const int nMax );
// bool CheckBreakpoint (WORD address, BOOL memory); // bool CheckBreakpoint (WORD address, BOOL memory);
bool CheckBreakpointsIO ();
bool CheckBreakpointsReg ();
bool _CmdBreakpointAddReg ( Breakpoint_t *pBP, BreakpointSource_t iSrc, BreakpointOperator_t iCmp, WORD nAddress, int nLen, bool bIsTempBreakpoint ); bool _CmdBreakpointAddReg ( Breakpoint_t *pBP, BreakpointSource_t iSrc, BreakpointOperator_t iCmp, WORD nAddress, int nLen, bool bIsTempBreakpoint );
int _CmdBreakpointAddCommonArg ( int iArg, int nArg, BreakpointSource_t iSrc, BreakpointOperator_t iCmp, bool bIsTempBreakpoint=false ); int _CmdBreakpointAddCommonArg ( int iArg, int nArg, BreakpointSource_t iSrc, BreakpointOperator_t iCmp, bool bIsTempBreakpoint=false );
void _BWZ_Clear( Breakpoint_t * aBreakWatchZero, int iSlot ); void _BWZ_Clear( Breakpoint_t * aBreakWatchZero, int iSlot );
@ -465,7 +467,7 @@ void _Bookmark_Reset()
//=========================================================================== //===========================================================================
int _Bookmark_Size() int _Bookmark_Size()
{ {
int g_nBookmarks = 0; g_nBookmarks = 0;
int iBookmark; int iBookmark;
for (iBookmark = 0; iBookmark < MAX_BOOKMARKS; iBookmark++ ) for (iBookmark = 0; iBookmark < MAX_BOOKMARKS; iBookmark++ )
@ -711,7 +713,7 @@ Update_t CmdBenchmarkStop (int nArgs)
{ {
g_bBenchmarking = false; g_bBenchmarking = false;
DebugEnd(); DebugEnd();
g_nAppMode = MODE_RUNNING;
FrameRefreshStatus(DRAW_TITLE); FrameRefreshStatus(DRAW_TITLE);
VideoRedrawScreen(); VideoRedrawScreen();
DWORD currtime = GetTickCount(); DWORD currtime = GetTickCount();
@ -811,13 +813,19 @@ _Help:
//=========================================================================== //===========================================================================
Update_t CmdBreakInvalid (int nArgs) // Breakpoint IFF Full-speed! Update_t CmdBreakInvalid (int nArgs) // Breakpoint IFF Full-speed!
{ {
if ((nArgs > 2) || (nArgs == 0)) if (nArgs > 2) // || (nArgs == 0))
goto _Help; goto _Help;
int iType = 0; // default to BRK int iType = AM_IMPLIED; // default to BRK
int nActive = 0; int nActive = 0;
// if (nArgs == 2) if (nArgs == 0)
{
nArgs = 1;
g_aArgs[ 1 ].nValue = AM_IMPLIED;
g_aArgs[ 1 ].sArg[0] = 0;
}
iType = g_aArgs[ 1 ].nValue; iType = g_aArgs[ 1 ].nValue;
// Cases: // Cases:
@ -851,10 +859,10 @@ Update_t CmdBreakInvalid (int nArgs) // Breakpoint IFF Full-speed!
{ {
if (! nFound) // bValidParam) // case 1a or 1c if (! nFound) // bValidParam) // case 1a or 1c
{ {
if ((iType < 0) || (iType > AM_3)) if ((iType < AM_IMPLIED) || (iType > AM_3))
goto _Help; goto _Help;
if (IsDebugBreakOnInvalid( iType )) if ( IsDebugBreakOnInvalid( iType ) )
iParam = PARAM_ON; iParam = PARAM_ON;
else else
iParam = PARAM_OFF; iParam = PARAM_OFF;
@ -914,31 +922,31 @@ Update_t CmdBreakOpcode (int nArgs) // Breakpoint IFF Full-speed!
if (nArgs == 1) if (nArgs == 1)
{ {
int iOpcode = g_aArgs[ 1] .nValue; int iOpcode = g_aArgs[ 1] .nValue;
g_iDebugOnOpcode = iOpcode & 0xFF; g_iDebugBreakOnOpcode = iOpcode & 0xFF;
_tcscpy( sAction, TEXT("Setting") ); _tcscpy( sAction, TEXT("Setting") );
if (iOpcode >= NUM_OPCODES) if (iOpcode >= NUM_OPCODES)
{ {
wsprintf( sText, TEXT("Warning: clamping opcode: %02X"), g_iDebugOnOpcode ); wsprintf( sText, TEXT("Warning: clamping opcode: %02X"), g_iDebugBreakOnOpcode );
ConsoleBufferPush( sText ); ConsoleBufferPush( sText );
return ConsoleUpdate(); return ConsoleUpdate();
} }
} }
if (g_iDebugOnOpcode == 0) if (g_iDebugBreakOnOpcode == 0)
// Show what the current break opcode is // Show what the current break opcode is
wsprintf( sText, TEXT("%s full speed Break on Opcode: None") wsprintf( sText, TEXT("%s full speed Break on Opcode: None")
, sAction , sAction
, g_iDebugOnOpcode , g_iDebugBreakOnOpcode
, g_aOpcodes65C02[ g_iDebugOnOpcode ].sMnemonic , g_aOpcodes65C02[ g_iDebugBreakOnOpcode ].sMnemonic
); );
else else
// Show what the current break opcode is // Show what the current break opcode is
wsprintf( sText, TEXT("%s full speed Break on Opcode: %02X %s") wsprintf( sText, TEXT("%s full speed Break on Opcode: %02X %s")
, sAction , sAction
, g_iDebugOnOpcode , g_iDebugBreakOnOpcode
, g_aOpcodes65C02[ g_iDebugOnOpcode ].sMnemonic , g_aOpcodes65C02[ g_iDebugBreakOnOpcode ].sMnemonic
); );
ConsoleBufferPush( sText ); ConsoleBufferPush( sText );
@ -1035,7 +1043,7 @@ bool _CheckBreakpointValue( Breakpoint_t *pBP, int nVal )
//=========================================================================== //===========================================================================
bool CheckBreakpointsIO () int CheckBreakpointsIO ()
{ {
const int NUM_TARGETS = 2; const int NUM_TARGETS = 2;
@ -1045,7 +1053,7 @@ bool CheckBreakpointsIO ()
NO_6502_TARGET NO_6502_TARGET
}; };
int nBytes; int nBytes;
bool bStatus = false; bool bBreakpointHit = 0;
int iTarget; int iTarget;
int nAddress; int nAddress;
@ -1068,7 +1076,7 @@ bool CheckBreakpointsIO ()
{ {
if (_CheckBreakpointValue( pBP, nAddress )) if (_CheckBreakpointValue( pBP, nAddress ))
{ {
return true; return BP_HIT_MEM;
} }
} }
} }
@ -1076,14 +1084,14 @@ bool CheckBreakpointsIO ()
} }
} }
} }
return bStatus; return bBreakpointHit;
} }
// Returns true if a register breakpoint is triggered // Returns true if a register breakpoint is triggered
//=========================================================================== //===========================================================================
bool CheckBreakpointsReg () int CheckBreakpointsReg ()
{ {
bool bStatus = false; int bBreakpointHit = 0;
for (int iBreakpoint = 0; iBreakpoint < MAX_BREAKPOINTS; iBreakpoint++) for (int iBreakpoint = 0; iBreakpoint < MAX_BREAKPOINTS; iBreakpoint++)
{ {
@ -1094,30 +1102,31 @@ bool CheckBreakpointsReg ()
switch (pBP->eSource) switch (pBP->eSource)
{ {
case BP_SRC_REG_PC: case BP_SRC_REG_PC:
bStatus = _CheckBreakpointValue( pBP, regs.pc ); bBreakpointHit = _CheckBreakpointValue( pBP, regs.pc );
break; break;
case BP_SRC_REG_A: case BP_SRC_REG_A:
bStatus = _CheckBreakpointValue( pBP, regs.a ); bBreakpointHit = _CheckBreakpointValue( pBP, regs.a );
break; break;
case BP_SRC_REG_X: case BP_SRC_REG_X:
bStatus = _CheckBreakpointValue( pBP, regs.x ); bBreakpointHit = _CheckBreakpointValue( pBP, regs.x );
break; break;
case BP_SRC_REG_Y: case BP_SRC_REG_Y:
bStatus = _CheckBreakpointValue( pBP, regs.y ); bBreakpointHit = _CheckBreakpointValue( pBP, regs.y );
break; break;
case BP_SRC_REG_P: case BP_SRC_REG_P:
bStatus = _CheckBreakpointValue( pBP, regs.ps ); bBreakpointHit = _CheckBreakpointValue( pBP, regs.ps );
break; break;
case BP_SRC_REG_S: case BP_SRC_REG_S:
bStatus = _CheckBreakpointValue( pBP, regs.sp ); bBreakpointHit = _CheckBreakpointValue( pBP, regs.sp );
break; break;
default: default:
break; break;
} }
if (bStatus) if (bBreakpointHit)
{ {
bBreakpointHit = BP_HIT_REG;
if (pBP->bTemp) if (pBP->bTemp)
_BWZ_Clear(pBP, iBreakpoint); _BWZ_Clear(pBP, iBreakpoint);
@ -1125,7 +1134,7 @@ bool CheckBreakpointsReg ()
} }
} }
return bStatus; return bBreakpointHit;
} }
void ClearTempBreakpoints () void ClearTempBreakpoints ()
@ -1238,7 +1247,7 @@ Update_t CmdBreakpointAddReg (int nArgs)
} }
} }
if ((! bHaveSrc) && (! bHaveCmp)) if ((! bHaveSrc) && (! bHaveCmp)) // Inverted/Convoluted logic: didn't find BOTH this pass, so we must have already found them.
{ {
int dArgs = _CmdBreakpointAddCommonArg( iArg, nArgs, iSrc, iCmp ); int dArgs = _CmdBreakpointAddCommonArg( iArg, nArgs, iSrc, iCmp );
if (!dArgs) if (!dArgs)
@ -1393,7 +1402,8 @@ Update_t CmdBreakpointAddPC (int nArgs)
//=========================================================================== //===========================================================================
Update_t CmdBreakpointAddIO (int nArgs) Update_t CmdBreakpointAddIO (int nArgs)
{ {
return UPDATE_CONSOLE_DISPLAY; return CmdBreakpointAddMem( nArgs );
// return UPDATE_BREAKPOINTS | UPDATE_CONSOLE_DISPLAY;
} }
@ -1590,7 +1600,7 @@ void _BWZ_List( const Breakpoint_t * aBreakWatchZero, const int iBWZ ) //, bool
void _BWZ_ListAll( const Breakpoint_t * aBreakWatchZero, const int nMax ) void _BWZ_ListAll( const Breakpoint_t * aBreakWatchZero, const int nMax )
{ {
int iBWZ = 0; int iBWZ = 0;
while (iBWZ < MAX_BOOKMARKS) while (iBWZ < nMax) //
{ {
if (aBreakWatchZero[ iBWZ ].bSet) if (aBreakWatchZero[ iBWZ ].bSet)
{ {
@ -1944,7 +1954,7 @@ Update_t CmdTraceFile (int nArgs)
char sFilePath[ MAX_PATH ]; char sFilePath[ MAX_PATH ];
strcpy(sFilePath, g_sCurrentDir); // g_sProgramDir strcpy(sFilePath, g_sCurrentDir); // TODO: g_sDebugDir
strcat(sFilePath, sFileName ); strcat(sFilePath, sFileName );
g_hTraceFile = fopen( sFilePath, "wt" ); g_hTraceFile = fopen( sFilePath, "wt" );
@ -2308,7 +2318,7 @@ void ConfigSave_PrepareHeader ( const Parameters_e eCategory, const Commands_e e
Update_t CmdConfigSave (int nArgs) Update_t CmdConfigSave (int nArgs)
{ {
TCHAR sFilename[ MAX_PATH ]; TCHAR sFilename[ MAX_PATH ];
_tcscpy( sFilename, g_sProgramDir ); // g_sCurrentDir _tcscpy( sFilename, g_sProgramDir ); // TODO: g_sDebugDir
_tcscat( sFilename, g_sFileNameConfig ); _tcscat( sFilename, g_sFileNameConfig );
/* /*
@ -3787,7 +3797,7 @@ static Update_t _CmdMemoryDump (int nArgs, int iWhich, int iView )
g_aMemDump[iWhich].bActive = true; g_aMemDump[iWhich].bActive = true;
g_aMemDump[iWhich].eView = (MemoryView_e) iView; g_aMemDump[iWhich].eView = (MemoryView_e) iView;
return UPDATE_ALL; // TODO: This really needed? Don't think we do any actual ouput return UPDATE_MEM_DUMP; // TODO: This really needed? Don't think we do any actual ouput
} }
//=========================================================================== //===========================================================================
@ -3981,6 +3991,22 @@ Update_t CmdMemoryFill (int nArgs)
static TCHAR g_sMemoryLoadSaveFileName[ MAX_PATH ] = TEXT(""); static TCHAR g_sMemoryLoadSaveFileName[ MAX_PATH ] = TEXT("");
//===========================================================================
Update_t CmdConfigGetDebugDir (int nArgs)
{
TCHAR sPath[ MAX_PATH + 8 ] = "Path: ";
_tcscat( sPath, g_sCurrentDir ); // TODO: debugger dir has no ` CONSOLE_COLOR_ESCAPE_CHAR ?!?!
ConsoleBufferPush( sPath );
return ConsoleUpdate();
}
//===========================================================================
Update_t CmdConfigSetDebugDir (int nArgs)
{
return ConsoleUpdate();
}
//=========================================================================== //===========================================================================
Update_t CmdMemoryLoad (int nArgs) Update_t CmdMemoryLoad (int nArgs)
{ {
@ -4024,7 +4050,7 @@ Update_t CmdMemoryLoad (int nArgs)
return Help_Arg_1( CMD_MEMORY_SAVE ); return Help_Arg_1( CMD_MEMORY_SAVE );
TCHAR sLoadSaveFilePath[ MAX_PATH ]; TCHAR sLoadSaveFilePath[ MAX_PATH ];
_tcscpy( sLoadSaveFilePath, g_sCurrentDir ); // g_sProgramDir _tcscpy( sLoadSaveFilePath, g_sCurrentDir ); // TODO: g_sDebugDir
WORD nAddressStart; WORD nAddressStart;
WORD nAddress2 = 0; WORD nAddress2 = 0;
@ -4088,9 +4114,9 @@ Update_t CmdMemoryLoad (int nArgs)
else else
{ {
ConsoleBufferPush( TEXT( "ERROR: Bad filename" ) ); ConsoleBufferPush( TEXT( "ERROR: Bad filename" ) );
TCHAR sPath[ MAX_PATH + 8 ] = "Path: ";
_tcscat( sPath, g_sCurrentDir ); CmdConfigGetDebugDir( 0 );
ConsoleBufferPush( sPath );
TCHAR sFile[ MAX_PATH + 8 ] = "File: "; TCHAR sFile[ MAX_PATH + 8 ] = "File: ";
_tcscat( sFile, g_sMemoryLoadSaveFileName ); _tcscat( sFile, g_sMemoryLoadSaveFileName );
ConsoleBufferPush( sFile ); ConsoleBufferPush( sFile );
@ -5671,7 +5697,8 @@ Update_t CmdWatchList (int nArgs)
} }
else else
{ {
_BWZ_List( g_aWatches, MAX_WATCHES ); // _BWZ_List( g_aWatches, MAX_WATCHES );
_BWZ_ListAll( g_aWatches, MAX_WATCHES );
} }
return ConsoleUpdate(); return ConsoleUpdate();
} }
@ -7155,13 +7182,13 @@ void DebugContinueStepping ()
{ {
if ((regs.pc >= g_nDebugSkipStart) && (regs.pc < (g_nDebugSkipStart + g_nDebugSkipLen))) if ((regs.pc >= g_nDebugSkipStart) && (regs.pc < (g_nDebugSkipStart + g_nDebugSkipLen)))
{ {
// Enter turbo debugger g_nAppMode -- UI not updated, etc. // Enter turbo debugger mode -- UI not updated, etc.
g_nDebugSteps = -1; g_nDebugSteps = -1;
g_nAppMode = MODE_STEPPING; g_nAppMode = MODE_STEPPING;
} }
else else
{ {
// Enter normal debugger g_nAppMode -- UI updated every instruction, etc. // Enter normal debugger mode -- UI updated every instruction, etc.
g_nDebugSteps = 1; g_nDebugSteps = 1;
g_nAppMode = MODE_STEPPING; g_nAppMode = MODE_STEPPING;
} }
@ -7175,12 +7202,9 @@ void DebugContinueStepping ()
InternalSingleStep(); InternalSingleStep();
bool bBreak = CheckBreakpointsIO(); _IsDebugBreakpointHit(); // Updates g_bDebugBreakpointHit
if (CheckBreakpointsReg()) if ((regs.pc == g_nDebugStepUntil) || g_bDebugBreakpointHit)
bBreak = true;
if ((regs.pc == g_nDebugStepUntil) || bBreak)
g_nDebugSteps = 0; g_nDebugSteps = 0;
else if (g_nDebugSteps > 0) else if (g_nDebugSteps > 0)
g_nDebugSteps--; g_nDebugSteps--;
@ -7190,7 +7214,7 @@ void DebugContinueStepping ()
{ {
if (!((++nStepsTaken) & 0xFFFF)) if (!((++nStepsTaken) & 0xFFFF))
{ {
if (nStepsTaken == 0x10000) if (nStepsTaken == 0x10000) // HACK_MAGIC_NUM
VideoRedrawScreen(); VideoRedrawScreen();
else else
VideoRefreshScreen(); VideoRefreshScreen();
@ -7202,32 +7226,11 @@ void DebugContinueStepping ()
FrameRefreshStatus(DRAW_TITLE); FrameRefreshStatus(DRAW_TITLE);
// BUG: PageUp, Trace - doesn't center cursor // BUG: PageUp, Trace - doesn't center cursor
// if ((g_nDebugStepStart < regs.pc) && (g_nDebugStepStart+3 >= regs.pc)) g_nDisasmCurAddress = regs.pc;
// Still within current disasm "window"?
/*
if ((regs.pc >= g_nDisasmTopAddress) && (regs.pc <= g_nDisasmBotAddress))
{
int eMode = g_aOpcodes[*(mem+g_nDisasmCurAddress)].addrmode;
int nBytes = g_aOpmodes[ eMode ]._nBytes;
g_nDisasmCurAddress += nBytes;
// g_nDisasmTopAddress += nBytes;
// g_nDisasmBotAddress += nBytes;
}
else
*/
{
g_nDisasmCurAddress = regs.pc;
}
DisasmCalcTopBotAddress(); DisasmCalcTopBotAddress();
// g_nDisasmCurAddress += g_aOpmodes[g_aOpcodes[*(mem+g_nDisasmCurAddress)].addrmode]._nBytes;
// DisasmCalcTopBotAddress();
Update_t bUpdate = UPDATE_ALL; Update_t bUpdate = UPDATE_ALL;
// if (nStepsTaken >= 0x10000) // HACK_MAGIC_NUM
// bUpdate = UPDATE_ALL;
UpdateDisplay( bUpdate ); // nStepsTaken >= 0x10000); UpdateDisplay( bUpdate ); // nStepsTaken >= 0x10000);
nStepsTaken = 0; nStepsTaken = 0;
} }
@ -7284,6 +7287,8 @@ void DebugEnd ()
} }
g_vMemorySearchResults.erase( g_vMemorySearchResults.begin(), g_vMemorySearchResults.end() ); g_vMemorySearchResults.erase( g_vMemorySearchResults.begin(), g_vMemorySearchResults.end() );
g_nAppMode = MODE_RUNNING;
} }

View File

@ -30,16 +30,33 @@ using namespace std;
// extern vector<int> g_aBookmarks; // extern vector<int> g_aBookmarks;
// Breakpoints // Breakpoints
enum BreakpointHit_t
{
BP_HIT_NONE = 0
,BP_HIT_INVALID = (1 << 0)
,BP_HIT_OPCODE = (1 << 1)
,BP_HIT_REG = (1 << 2)
,BP_HIT_MEM = (1 << 3)
};
extern int g_nBreakpoints; extern int g_nBreakpoints;
extern Breakpoint_t g_aBreakpoints[ MAX_BREAKPOINTS ]; extern Breakpoint_t g_aBreakpoints[ MAX_BREAKPOINTS ];
extern const char *g_aBreakpointSource [ NUM_BREAKPOINT_SOURCES ]; extern const char *g_aBreakpointSource [ NUM_BREAKPOINT_SOURCES ];
extern const TCHAR *g_aBreakpointSymbols[ NUM_BREAKPOINT_OPERATORS ]; extern const TCHAR *g_aBreakpointSymbols[ NUM_BREAKPOINT_OPERATORS ];
// Full-Speed debugging // MODE_RUNNING // Normal Speed Breakpoints
extern int g_nDebugOnBreakInvalid; extern bool g_bDebugNormalSpeedBreakpoints;
extern int g_iDebugOnOpcode ;
extern bool g_bDebugDelayBreakCheck; // MODE_STEPPING // Full Speed Breakpoints
// Any Speed Breakpoints
extern int g_nDebugBreakOnInvalid ;
extern int g_iDebugBreakOnOpcode ;
// Breakpoint Status
extern bool g_bDebugBreakDelayCheck;
extern int g_bDebugBreakpointHit ;
// Commands // Commands
void VerifyDebuggerCommandTable(); void VerifyDebuggerCommandTable();
@ -133,23 +150,69 @@ using namespace std;
bool Bookmark_Find( const WORD nAddress ); bool Bookmark_Find( const WORD nAddress );
// Breakpoints // Breakpoints
int CheckBreakpointsIO ();
int CheckBreakpointsReg ();
bool GetBreakpointInfo ( WORD nOffset, bool & bBreakpointActive_, bool & bBreakpointEnable_ ); bool GetBreakpointInfo ( WORD nOffset, bool & bBreakpointActive_, bool & bBreakpointEnable_ );
// 0 = Brk, 1 = Invalid1, .. 3 = Invalid 3 inline int _IsDebugBreakpointHit()
inline bool IsDebugBreakOnInvalid( int iOpcodeType )
{ {
bool bActive = (g_nDebugOnBreakInvalid >> iOpcodeType) & 1; g_bDebugBreakpointHit |= CheckBreakpointsIO() || CheckBreakpointsReg();
return bActive; return g_bDebugBreakpointHit;
} }
inline int _IsDebugBreakOnOpcode( int iOpcode )
{
if (g_iDebugBreakOnOpcode == iOpcode)
g_bDebugBreakpointHit |= BP_HIT_OPCODE;
return g_bDebugBreakpointHit;
}
// iOpcodeType = AM_IMPLIED (BRK), AM_1, AM_2, AM_3
inline int IsDebugBreakOnInvalid( int iOpcodeType )
{
g_bDebugBreakpointHit |= ((g_nDebugBreakOnInvalid >> iOpcodeType) & 1) ? BP_HIT_INVALID : 0;
return g_bDebugBreakpointHit;
}
// iOpcodeType = AM_IMPLIED (BRK), AM_1, AM_2, AM_3
inline void SetDebugBreakOnInvalid( int iOpcodeType, int nValue ) inline void SetDebugBreakOnInvalid( int iOpcodeType, int nValue )
{ {
if (iOpcodeType <= AM_3) if (iOpcodeType <= AM_3)
{ {
g_nDebugOnBreakInvalid &= ~ ( 1 << iOpcodeType); g_nDebugBreakOnInvalid &= ~ ( 1 << iOpcodeType);
g_nDebugOnBreakInvalid |= ((nValue & 1) << iOpcodeType); g_nDebugBreakOnInvalid |= ((nValue & 1) << iOpcodeType);
} }
} }
//
// CPU checks the Debugger breakpoints
// a) at opcode fetch
// b) after opcode execution
//
inline int IsDebugBreakOpcode( int iOpcode )
{
if (g_bDebugBreakDelayCheck)
{
g_bDebugBreakDelayCheck = false;
return false;
}
if (! iOpcode )
IsDebugBreakOnInvalid( AM_IMPLIED );
if (g_iDebugBreakOnOpcode ) // User wants to enter debugger on specific opcode?
_IsDebugBreakOnOpcode(iOpcode);
return g_bDebugBreakpointHit;
}
//
inline int IsDebugBreakpointHit()
{
if ( !g_bDebugNormalSpeedBreakpoints )
return false;
return _IsDebugBreakpointHit();
}
// Source Level Debugging // Source Level Debugging
int FindSourceLine( WORD nAddress ); int FindSourceLine( WORD nAddress );

View File

@ -1530,7 +1530,7 @@ void ProcessButtonClick (int button)
else else
if (g_nAppMode == MODE_DEBUG) if (g_nAppMode == MODE_DEBUG)
{ {
g_bDebugDelayBreakCheck = true; //g_bDebugDelayBreakCheck = true;
ProcessButtonClick(BTN_RUN); ProcessButtonClick(BTN_RUN);
// TODO: DD Full-Screen Palette // TODO: DD Full-Screen Palette