Skip to content

Commit

Permalink
Merge pull request #80 from AppleWin/master
Browse files Browse the repository at this point in the history
Update from AW.
  • Loading branch information
audetto committed Mar 23, 2023
2 parents e5de6ab + 730c2d8 commit 36be2b5
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 42 deletions.
55 changes: 50 additions & 5 deletions docs/CodingConventions.txt
Expand Up @@ -2,6 +2,15 @@ Coding Conventions for AppleWin
===============================

History:
v7 - 23-Mar-2023 (MP)
. Clarify 2.1 Naming
. Split into sub-section 2.1.1: Simplified prefix names
. Split into sub-section 2.1.2: Loop conters
. Split into sub-section 2.1.3: Out parameters
. Clarify 2.6 Indentation
. Add 2.6.1: Brace placement
. Add 2.6.1.1: Debugger function style
. Clarify b, and n prefix
v6 - 12-Jan-2023 (TC)
. Avoid global vars & provide getter/setter accessor functions.
. Avoid C++11 empty initializer lists. (PR#634)
Expand Down Expand Up @@ -59,10 +68,11 @@ and therefore by extension all header files can be included in any order.
As a general rule and for consistency, adopt the coding convention/style of any module (or function) you are modifying.

2.1: Naming
For functions use upper camel case.
For functions use upper camel case (PascalCase).

For variables use lower camel case.
For variables use lower camel case (camelCase).

2.1.1: Simplified prefix names
And only if applicable, the following simplified prefix (Hungarian) style can be used:

Prefixes:
Expand All @@ -86,8 +96,11 @@ EG:
UINT b;
};

2.1.2: Loop conters
Simple loop counters (i,j,k) don't need to adhere to this style.
NOTE: It would be better to use a better descriptive loop name then a non-descript single character variable name.

2.1.3: Out parameters
Naming for parameters that are being modified (eg. OUT):
It is recommended (but not mandatory) to use a suffix of OUT or '_', eg:
bool Find(int* pFoundOUT);
Expand Down Expand Up @@ -115,7 +128,39 @@ Always use bool instead of BOOL
GPL header, followed by description of module & author.

2.6: Indentation
Tabs favoured over spaces.
Tabs favoured over spaces. (Tabs for indent, spaces for alignment.)

2.6.1: Brace placement
Braces should be formated with Allman Style (opening brace on separate line) and NOT K&R style (opening brace on same indentation level as its header).
EG:
void FindFoo() // GOOD
{
}

void FindFoo() { // BAD
}

See: https://en.wikipedia.org/wiki/Indentation_style

2.6.1.1: Debugger function style
For functions in the debugger, both the

* function declaration,and
* function definition

MUST have a space between the end of the function name and the opening parenthesis.
This makes it trivial to search and jump to the function implementation since every function call _won't_ have that extra space.
EG:
void FindFoo (); // .h

void FindFoo () // .cpp
{
}

void Bar()
{
if (FindFoo() // usage
}

2.7: Expression to be well spaced and parenthesised
It is recommended (but not mandatory):
Expand Down Expand Up @@ -172,12 +217,12 @@ Appendix: Legacy Hungarian notation
dw : DWORD
sz : string (null-terminated)
a : array
b : bool
b : bool or bitmask
e : enum variable
h : handle
i : iterator (eg. UINT, STL-iterator)
m : STL map
n : int
n : int, total, or length
r : reference
s : string
sg_p : singleton
Expand Down
2 changes: 2 additions & 0 deletions docs/Debugger_Changelog.txt
@@ -1,4 +1,6 @@
/*
2.9.1.16 Added: QoL to BPL. Header and colorized address, mem, and symbols.

2.9.1.14 Fix disassembly when in middle of data
Example:
ASC 7D0:7D7
Expand Down
83 changes: 48 additions & 35 deletions source/Debugger/Debug.cpp
Expand Up @@ -1892,43 +1892,39 @@ Update_t CmdBreakpointEnable (int nArgs) {
return UPDATE_BREAKPOINTS;
}


Update_t CmdBreakpointChange (int nArgs) {

// bpchange # <[E e T t S s]>
Update_t CmdBreakpointChange (int nArgs)
{
if (! g_nBreakpoints)
return ConsoleDisplayError("There are no (PC) Breakpoints defined.");
{
ConsolePrintFormat( "There are no " CHC_CATEGORY "PC" CHC_DEFAULT " Breakpoints defined." );
return ConsoleDisplayError( "" );
}

if (nArgs != 2)
if (nArgs < 2)
return Help_Arg_1( CMD_BREAKPOINT_CHANGE );

const int iSlot = g_aArgs[1].nValue;
if (iSlot >= 0 && iSlot < MAX_BREAKPOINTS && g_aBreakpoints[iSlot].bSet)
{
Breakpoint_t & bp = g_aBreakpoints[iSlot];
const char * sArg = g_aArgs[2].sArg;
const int nArgLen = g_aArgs[2].nArgLen;
for (int i = 0; i < nArgLen; ++i)
int iParam;
int iParamArg;

for (iParamArg = 2; iParamArg <= nArgs; ++iParamArg)
{
switch (sArg[i])
int bFound = FindParam( g_aArgs[ iParamArg ].sArg, MATCH_EXACT, iParam, _PARAM_BP_CHANGE_BEGIN, _PARAM_BP_CHANGE_END, true );
if (! bFound)
return Help_Arg_1( CMD_BREAKPOINT_CHANGE );

switch (iParam)
{
case 'E':
bp.bEnabled = true;
break;
case 'e':
bp.bEnabled = false;
break;
case 'T':
bp.bTemp = true;
break;
case 't':
bp.bTemp = false;
break;
case 'S':
bp.bStop = true;
break;
case 's':
bp.bStop = false;
break;
case PARAM_BP_CHANGE_ENABLE : bp.bEnabled = true ; break;
case PARAM_BP_CHANGE_DISABLE : bp.bEnabled = false; break;
case PARAM_BP_CHANGE_TEMP_ON : bp.bTemp = true ; break;
case PARAM_BP_CHANGE_TEMP_OFF: bp.bTemp = false; break;
case PARAM_BP_CHANGE_STOP_ON : bp.bStop = true ; break;
case PARAM_BP_CHANGE_STOP_OFF: bp.bStop = false; break;
}
}
}
Expand All @@ -1946,11 +1942,25 @@ void _BWZ_List( const Breakpoint_t * aBreakWatchZero, const int iBWZ ) //, bool
std::string sAddressBuf;
std::string const& sSymbol = GetSymbol(aBreakWatchZero[iBWZ].nAddress, 2, sAddressBuf);

char cBPM = aBreakWatchZero[iBWZ].eSource == BP_SRC_MEM_READ_ONLY ? 'R'
: aBreakWatchZero[iBWZ].eSource == BP_SRC_MEM_WRITE_ONLY ? 'W'
: ' ';
const char *aMemAccess[4] =
{
"R "
,"W "
,"R/W"
," "
};

ConsoleBufferPushFormat( " #%d %c %c %c %c %08X %04X %c %s",
int iBPM;
switch (aBreakWatchZero[iBWZ].eSource)
{
case BP_SRC_MEM_READ_ONLY : iBPM = 0; break;
case BP_SRC_MEM_WRITE_ONLY: iBPM = 1; break;
case BP_SRC_MEM_RW : iBPM = 2; break;
default : iBPM = 3; break;
}

// ID On Stop Temp HitCounter Addr Mem Symbol
ConsolePrintFormat( " #%X %c %c %c %c %08X " CHC_ADDRESS " %04X " CHC_INFO "%s" CHC_SYMBOL " %s",
// (bZeroBased ? iBWZ + 1 : iBWZ),
iBWZ,
sEnabledFlags[ aBreakWatchZero[ iBWZ ].bEnabled ? 1 : 0 ],
Expand All @@ -1959,13 +1969,15 @@ void _BWZ_List( const Breakpoint_t * aBreakWatchZero, const int iBWZ ) //, bool
sHitFlags [ aBreakWatchZero[ iBWZ ].bHit ? 1 : 0 ],
aBreakWatchZero[ iBWZ ].nHitCount,
aBreakWatchZero[ iBWZ ].nAddress,
cBPM,
aMemAccess[ iBPM ],
sSymbol.c_str()
);
}

void _BWZ_ListAll( const Breakpoint_t * aBreakWatchZero, const int nMax )
{
ConsolePrintFormat( " ID On Stop Temp HitCounter Addr Mem Symbol" );

int iBWZ = 0;
while (iBWZ < nMax) //
{
Expand Down Expand Up @@ -7549,7 +7561,7 @@ Update_t CmdZeroPagePointer (int nArgs)

// Note: Range is [iParamBegin,iParamEnd], not the usually (STL) expected [iParamBegin,iParamEnd)
//===========================================================================
int FindParam(LPCTSTR pLookupName, Match_e eMatch, int & iParam_, int iParamBegin, int iParamEnd )
int FindParam (LPCTSTR pLookupName, Match_e eMatch, int & iParam_, int iParamBegin, int iParamEnd, const bool bCaseSensitive /* false */ )
{
int nFound = 0;
int nLen = _tcslen( pLookupName );
Expand All @@ -7559,7 +7571,8 @@ int FindParam(LPCTSTR pLookupName, Match_e eMatch, int & iParam_, int iParamBegi
return nFound;

#if ALLOW_INPUT_LOWERCASE
eMatch = MATCH_FUZZY;
if (! bCaseSensitive) // HACK: Until We fixup all callers using MATCH_EXACT with MATCH_ANYCASE we need to preserve behavior of ALLOW_INPUT_LOWERCASE always being MATCH_FUZZY
eMatch = MATCH_FUZZY;
#endif

if (eMatch == MATCH_EXACT)
Expand All @@ -7568,7 +7581,7 @@ int FindParam(LPCTSTR pLookupName, Match_e eMatch, int & iParam_, int iParamBegi
for (iParam = iParamBegin; iParam <= iParamEnd; iParam++ )
{
TCHAR *pParamName = g_aParameters[iParam].m_sName;
int eCompare = _tcsicmp(pLookupName, pParamName);
int eCompare = _tcscmp(pLookupName, pParamName);
if (! eCompare) // exact match?
{
nFound++;
Expand Down
7 changes: 7 additions & 0 deletions source/Debugger/Debugger_Commands.cpp
Expand Up @@ -418,6 +418,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{TEXT("W") , NULL, PARAM_BP_WRITE },
{TEXT("@") , NULL, PARAM_BP_WRITE },
{TEXT("*") , NULL, PARAM_BP_READ_WRITE },
// Breakpoint Change, See: CmdBreakpointChange ()
{TEXT("E") , NULL, PARAM_BP_CHANGE_ENABLE },
{TEXT("e") , NULL, PARAM_BP_CHANGE_DISABLE },
{TEXT("T") , NULL, PARAM_BP_CHANGE_TEMP_ON },
{TEXT("t") , NULL, PARAM_BP_CHANGE_TEMP_OFF },
{TEXT("S") , NULL, PARAM_BP_CHANGE_STOP_ON },
{TEXT("s") , NULL, PARAM_BP_CHANGE_STOP_OFF },
// Regs (for PUSH / POP)
{TEXT("A") , NULL, PARAM_REG_A },
{TEXT("X") , NULL, PARAM_REG_X },
Expand Down
2 changes: 1 addition & 1 deletion source/Debugger/Debugger_Help.h
Expand Up @@ -14,7 +14,7 @@

void DisplayAmbigiousCommands ( int nFound );

int FindParam( LPCTSTR pLookupName, Match_e eMatch, int & iParam_, const int iParamBegin = 0, const int iParamEnd = NUM_PARAMS - 1 );
int FindParam( LPCTSTR pLookupName, Match_e eMatch, int & iParam_, const int iParamBegin = 0, const int iParamEnd = NUM_PARAMS - 1, const bool bCaseSensitive = false );
int FindCommand( LPCTSTR pName, CmdFuncPtr_t & pFunction_, int * iCommand_ = NULL );

inline void UnpackVersion( const unsigned int nVersion,
Expand Down
12 changes: 11 additions & 1 deletion source/Debugger/Debugger_Types.h
Expand Up @@ -1366,8 +1366,18 @@ const DisasmData_t* pDisasmData; // If != NULL then bytes are marked up as data

// , PARAM_SIZE // TODO: used by FONT SIZE

, _PARAM_BP_CHANGE_BEGIN = _PARAM_BREAKPOINT_END // Daisy Chain
, PARAM_BP_CHANGE_ENABLE = _PARAM_BP_CHANGE_BEGIN // E
, PARAM_BP_CHANGE_DISABLE // e
, PARAM_BP_CHANGE_TEMP_ON // T
, PARAM_BP_CHANGE_TEMP_OFF // t
, PARAM_BP_CHANGE_STOP_ON // S
, PARAM_BP_CHANGE_STOP_OFF // s
, _PARAM_BP_CHANGE_END
, PARAM_BP_CHANGE_NUM = _PARAM_BP_CHANGE_END - _PARAM_BP_CHANGE_BEGIN

// Note: Order must match BreakpointSource_t
, _PARAM_REGS_BEGIN = _PARAM_BREAKPOINT_END // Daisy Chain
, _PARAM_REGS_BEGIN = _PARAM_BP_CHANGE_END // Daisy Chain
// Regs
, PARAM_REG_A = _PARAM_REGS_BEGIN
, PARAM_REG_X
Expand Down

0 comments on commit 36be2b5

Please sign in to comment.