Skip to content

Commit

Permalink
Merge pull request #108 from ThorstenBr/debuggerUPSTREAM
Browse files Browse the repository at this point in the history
Ported AppleWin debugger to LinApple
  • Loading branch information
ghedger committed Mar 31, 2020
2 parents 61eece9 + 4926abc commit f59ee9b
Show file tree
Hide file tree
Showing 44 changed files with 24,777 additions and 632 deletions.
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ DEPEXT := d
OBJEXT := o
IMGEXT := png
XPMEXT := xpm
SYMEXT := SYM

# FIXME: Make this go away!
INSTDIR := $(PREFIX)/lib/$(PACKAGE)
Expand Down Expand Up @@ -59,7 +60,7 @@ ifdef DEBUG
CFLAGS := -Wall -O0 -ggdb -ansi -c -finstrument-functions -std=c++11
endif

CFLAGS += -DASSET_DIR=\"$(ASSET_DIR)\" -DRESOURCE_INIT_DIR=\"$(RESOURCE_INIT_DIR)\"
CFLAGS += -DASSET_DIR=\"$(ASSET_DIR)\" -DRESOURCE_INIT_DIR=\"$(RESOURCE_INIT_DIR)\" -DVERSIONSTRING=\"$(VERSION)\"
CFLAGS += $(SDL_CFLAGS)
CFLAGS += $(CURL_CFLAGS)
# Do not complain about XPMs
Expand All @@ -80,9 +81,11 @@ CONFFILES := \
linapple.conf
SRCIMGFILES := $(foreach dir,$(RESDIR),$(wildcard $(dir)/*.$(IMGEXT)))
DSTIMGFILES := $(addprefix src/../,$(SRCIMGFILES:.$(IMGEXT)=.$(XPMEXT)))
SRCSYMFILES := $(wildcard $(RESDIR)/*.$(SYMEXT))
DSTSYMFILES := $(patsubst $(RESDIR)/%,$(TARGETDIR)/%,$(SRCSYMFILES))

#Default Make
all: images directories $(TARGETDIR)/$(TARGET)
all: images directories $(TARGETDIR)/$(TARGET) symbolfiles

#Remake
remake: cleaner all
Expand All @@ -93,6 +96,9 @@ images: $(DSTIMGFILES)
resources: directories
@cp $(RESDIR)/* $(TARGETDIR)/

# Copy symbol files to target directory
symbolfiles: $(DSTSYMFILES)

#Make the Directories
directories:
@mkdir -p $(TARGETDIR)
Expand Down Expand Up @@ -187,6 +193,9 @@ $(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT)
convert -flatten "$<" "$@"
@sed -i 's/$(notdir $(basename $@))\[\]/$(notdir $(basename $@))_xpm[]/g' "$@"

$(TARGETDIR)/%.$(SYMEXT): $(RESDIR)/%.$(SYMEXT)
cp $< $@

#Non-File Targets
.PHONY: all remake clean cleaner resources package install uninstall images directories
.PHONY: all remake clean cleaner resources package install uninstall images directories symbolfiles

2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ currently resides.
| F6 | Toggle fullscreen mode. See Warning below. |
| Shift+F6 | Toggle character set (keyboard/video ROM rocker switch for |
| | Apple IIe/enhanced with international keyboards/video ROMs) |
| F7 | Reserved for debugger. |
| F7 | Show debugger. |
| F8 | Save screenshot as a bitmap. |
| Shift+F8 | Save runtime changes to configuration to the configuration file. |
| F9 | Cycle through video modes. |
Expand Down
5 changes: 3 additions & 2 deletions inc/AppleWin.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

#include <curl/curl.h>

extern char VERSIONSTRING[]; // Contructed in WinMain()

extern TCHAR *g_pAppTitle;

extern eApple2Type g_Apple2Type;
Expand All @@ -30,6 +28,7 @@ extern UINT g_ScreenWidth;
extern UINT g_ScreenHeight;

extern DWORD needsprecision;
extern TCHAR g_sProgramDir[MAX_PATH];
extern TCHAR g_sCurrentDir[MAX_PATH];
extern TCHAR g_sHDDDir[MAX_PATH];
extern TCHAR g_sSaveStateDir[MAX_PATH];
Expand Down Expand Up @@ -62,3 +61,5 @@ void SetBudgetVideo(bool);
bool GetBudgetVideo();

void SetCurrentCLK6502();

void SingleStep(bool bReinit);
64 changes: 40 additions & 24 deletions inc/Debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
using namespace std;

#include "Debugger_Types.h"
#include "Util_MemoryTextFile.h"

// Globals
extern bool g_bDebuggerEatKey;

// Benchmarking
extern DWORD extbench;
Expand All @@ -19,6 +21,18 @@ extern int g_nBookmarks;
extern Bookmark_t g_aBookmarks[MAX_BOOKMARKS];

// 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),
BP_HIT_MEMR = (1 << 4),
BP_HIT_MEMW = (1 << 5),
BP_HIT_PC_READ_FLOATING_BUS_OR_IO_MEM = (1 << 6)
};

extern int g_nBreakpoints;
extern Breakpoint_t g_aBreakpoints[MAX_BREAKPOINTS];

Expand All @@ -27,8 +41,7 @@ extern const TCHAR *g_aBreakpointSymbols[NUM_BREAKPOINT_OPERATORS];

// Full-Speed debugging
extern int g_nDebugOnBreakInvalid;
extern int g_iDebugOnOpcode;
extern bool g_bDebugDelayBreakCheck;
extern int g_iDebugBreakOnOpcode;

// Commands
extern const int NUM_COMMANDS_WITH_ALIASES; // = sizeof(g_aCommands) / sizeof (Command_t); // Determined at compile-time ;-)
Expand All @@ -37,8 +50,18 @@ extern int g_iCommand; // last command
extern Command_t g_aCommands[];
extern Command_t g_aParameters[];

class commands_functor_compare
{
public:
bool operator() ( const Command_t & rLHS, const Command_t & rRHS ) const
{
// return true if lhs<rhs
return (_tcscmp( rLHS.m_sName, rRHS.m_sName ) <= 0) ? true : false;
}
};

// Config - FileName
extern char g_sFileNameConfig[];
extern std::string g_sFileNameConfig;

// Cursor
extern WORD g_nDisasmTopAddress;
Expand All @@ -54,6 +77,8 @@ extern int g_nDisasmWinHeight;
extern const int WINDOW_DATA_BYTES_PER_LINE;

// Config - Disassembly
extern bool g_bConfigDisasmAddressView;
extern int g_bConfigDisasmClick; // GH#462
extern bool g_bConfigDisasmAddressColon;
extern bool g_bConfigDisasmOpcodesView;
extern bool g_bConfigDisasmOpcodeSpaces;
Expand All @@ -64,9 +89,6 @@ extern int g_bConfigDisasmImmediateChar;
// Config - Info
extern bool g_bConfigInfoTargetPointer;

// Display
extern bool g_bDebuggerViewingAppleOutput;

// Font
extern int g_nFontHeight;
extern int g_iFontSpacing;
Expand All @@ -77,7 +99,8 @@ extern MemoryDump_t g_aMemDump[NUM_MEM_DUMPS];
extern vector<int> g_vMemorySearchResults;

// Source Level Debugging
extern TCHAR g_aSourceFileName[MAX_PATH];
extern std::string g_aSourceFileName;
extern MemoryTextFile_t g_AssemblerSourceBuffer;

extern int g_iSourceDisplayStart;
extern int g_nSourceAssembleBytes;
Expand Down Expand Up @@ -107,21 +130,8 @@ bool Bookmark_Find(const WORD nAddress);
// Breakpoints
bool GetBreakpointInfo(WORD nOffset, bool &bBreakpointActive_, bool &bBreakpointEnable_);

// 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);
}
}

// Color
inline COLORREF DebuggerGetColor(int iColor);
COLORREF DebuggerGetColor(int iColor);

// Source Level Debugging
int FindSourceLine(WORD nAddress);
Expand All @@ -132,7 +142,7 @@ LPCTSTR FormatAddress(WORD nAddress, int nBytes);
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);
void SymbolUpdate(SymbolTable_Index_e eSymbolTable, char *pSymbolName, WORD nAddrss, bool bRemoveSymbol, bool bUpdateSymbol);

LPCTSTR FindSymbolFromAddress(WORD nAdress, int *iTable_ = NULL);

Expand All @@ -149,11 +159,11 @@ enum {

void DebugBegin();

void DebugContinueStepping();
void DebugContinueStepping(const bool bCallerWillUpdateDisplay=false);

void DebugDestroy();

void DebugDisplay(BOOL);
void DebugDisplay(BOOL bInitDisasm=FALSE);

void DebugEnd();

Expand All @@ -168,3 +178,9 @@ void DebuggerUpdate();
void DebuggerCursorNext();

void DebuggerMouseClick(int x, int y);

void VerifyDebuggerCommandTable();

bool IsDebugSteppingAtFullSpeed(void);

bool DebugGetVideoMode(UINT* pVideoMode);
Loading

0 comments on commit f59ee9b

Please sign in to comment.