AppleWin/source/Debug.h

157 lines
4.4 KiB
C
Raw Normal View History

2006-02-25 20:50:29 +00:00
#pragma once
#include <vector>
#include <algorithm> // sort
#include <map>
using namespace std;
2006-02-26 06:26:56 +00:00
#include "Debugger_Types.h"
#include "Debugger_Parser.h"
#include "Debugger_Console.h"
#include "Debugger_Assembler.h"
#include "Debugger_Help.h"
#include "Debugger_Display.h"
#include "Util_MemoryTextFile.h"
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
// Globals __________________________________________________________________
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
// Benchmarking
extern DWORD extbench;
2006-02-25 20:50:29 +00:00
// Breakpoints
2006-02-26 06:26:56 +00:00
extern int g_nBreakpoints;
extern Breakpoint_t g_aBreakpoints[ MAX_BREAKPOINTS ];
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
extern const TCHAR *g_aBreakpointSource [ NUM_BREAKPOINT_SOURCES ];
extern const TCHAR *g_aBreakpointSymbols[ NUM_BREAKPOINT_OPERATORS ];
2006-02-25 20:50:29 +00:00
// Full-Speed debugging
extern int g_nDebugOnBreakInvalid;
extern int g_iDebugOnOpcode ;
extern bool g_bDebugDelayBreakCheck;
2006-02-26 06:26:56 +00:00
// Commands
extern const int NUM_COMMANDS_WITH_ALIASES; // = sizeof(g_aCommands) / sizeof (Command_t); // Determined at compile-time ;-)
extern int g_iCommand; // last command
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
extern Command_t g_aCommands[];
extern Command_t g_aParameters[];
2006-02-25 20:50:29 +00:00
// Cursor
2006-02-26 06:26:56 +00:00
extern WORD g_nDisasmTopAddress ;
extern WORD g_nDisasmBotAddress ;
extern WORD g_nDisasmCurAddress ;
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
extern bool g_bDisasmCurBad ;
extern int g_nDisasmCurLine ; // Aligned to Top or Center
extern int g_iDisasmCurState ;
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
extern int g_nDisasmWinHeight;
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
extern const int WINDOW_DATA_BYTES_PER_LINE;
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
// Disassembly
extern bool g_bConfigDisasmAddressColon ;
extern bool g_bConfigDisasmOpcodesView ;
extern bool g_bConfigDisasmOpcodeSpaces ;
extern int g_iConfigDisasmTargets ;
extern int g_iConfigDisasmBranchType ;
extern int g_bConfigDisasmImmediateChar;
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
// Display
extern bool g_bDebuggerViewingAppleOutput;
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
// Font
extern int g_nFontHeight;
extern int g_iFontSpacing;
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
// Memory
extern MemoryDump_t g_aMemDump[ NUM_MEM_DUMPS ];
2006-02-25 20:50:29 +00:00
// extern MemorySearchArray_t g_vMemSearchMatches;
extern vector<int> g_vMemorySearchResults;
2006-02-26 06:26:56 +00:00
// Source Level Debugging
extern TCHAR g_aSourceFileName[ MAX_PATH ];
extern MemoryTextFile_t g_AssemblerSourceBuffer;
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
extern int g_iSourceDisplayStart ;
extern int g_nSourceAssembleBytes ;
extern int g_nSourceAssemblySymbols;
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
// Version
extern const int DEBUGGER_VERSION;
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
// Watches
extern int g_nWatches;
extern Watches_t g_aWatches[ MAX_WATCHES ];
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
// Window
extern int g_iWindowLast;
extern int g_iWindowThis;
extern WindowSplit_t g_aWindowConfig[ NUM_WINDOWS ];
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
// Zero Page
extern int g_nZeroPagePointers;
extern ZeroPagePointers_t g_aZeroPagePointers[ MAX_ZEROPAGE_POINTERS ]; // TODO: use vector<> ?
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
// Prototypes _______________________________________________________________
2006-02-25 20:50:29 +00:00
// Bookmarks
bool Bookmark_Find( const WORD nAddress );
2006-02-26 06:26:56 +00:00
// Breakpoints
bool GetBreakpointInfo ( WORD nOffset, bool & bBreakpointActive_, bool & bBreakpointEnable_ );
2006-02-25 20:50:29 +00:00
// 0 = Brk, 1 = Invalid1, .. 3 = Invalid 3
inline bool IsDebugBreakOnInvalid( int iOpcodeType )
{
bool bActive = (g_nDebugOnBreakInvalid >> iOpcodeType) & 1;
return bActive;
}
inline void SetDebugBreakOnInvalid( int iOpcodeType, int nValue )
{
if (iOpcodeType <= AM_3)
{
g_nDebugOnBreakInvalid &= ~ ( 1 << iOpcodeType);
g_nDebugOnBreakInvalid |= ((nValue & 1) << iOpcodeType);
}
}
2006-02-26 06:26:56 +00:00
// Color
inline COLORREF DebuggerGetColor( int iColor );
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
// Source Level Debugging
int FindSourceLine( WORD nAddress );
LPCTSTR FormatAddress( WORD nAddress, int nBytes );
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
// Symbol Table / Memory
bool FindAddressFromSymbol( LPCSTR pSymbol, WORD * pAddress_ = NULL, int * iTable_ = NULL );
WORD GetAddressFromSymbol (LPCTSTR symbol); // HACK: returns 0 if symbol not found
void SymbolUpdate( Symbols_e eSymbolTable, char *pSymbolName, WORD nAddrss, bool bRemoveSymbol, bool bUpdateSymbol );
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
LPCTSTR FindSymbolFromAddress (WORD nAdress, int * iTable_ = NULL );
LPCTSTR GetSymbol (WORD nAddress, int nBytes);
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
Update_t DebuggerProcessCommand( const bool bEchoConsoleInput );
2006-02-25 20:50:29 +00:00
2006-02-26 06:26:56 +00:00
// Prototypes _______________________________________________________________
2006-02-25 20:50:29 +00:00
enum
{
DEBUG_EXIT_KEY = 0x1B, // Escape
DEBUG_TOGGLE_KEY = VK_F1 + BTN_DEBUG
};
2006-02-26 06:26:56 +00:00
void DebugBegin ();
void DebugContinueStepping ();
void DebugDestroy ();
void DebugDisplay (BOOL);
void DebugEnd ();
void DebugInitialize ();
// void DebugProcessChar (TCHAR);
void DebuggerInputConsoleChar( TCHAR ch );
// void DebugProcessCommand (int);
void DebuggerProcessKey( int keycode );