Merge pull request #235 from mjbudd77/master
Added logic to allow for symbol names to be clicked in Qt debugger AS…
This commit is contained in:
commit
93bfc01b34
|
@ -1944,7 +1944,7 @@ void QAsmView::updateAssemblyView(void)
|
||||||
size++;
|
size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisassembleWithDebug(addr, opcode, asmFlags, asmTxt);
|
DisassembleWithDebug(addr, opcode, asmFlags, asmTxt, &a->sym);
|
||||||
|
|
||||||
line.append( asmTxt );
|
line.append( asmTxt );
|
||||||
}
|
}
|
||||||
|
@ -3087,6 +3087,7 @@ void QAsmView::mousePressEvent(QMouseEvent * event)
|
||||||
if ( line < asmEntry.size() )
|
if ( line < asmEntry.size() )
|
||||||
{
|
{
|
||||||
int i,j, addr = -1, addrTextLoc = -1, selChar;
|
int i,j, addr = -1, addrTextLoc = -1, selChar;
|
||||||
|
int symTextStart = -1, symTextEnd = -1;
|
||||||
char addrClicked = 0;
|
char addrClicked = 0;
|
||||||
char stmp[64];
|
char stmp[64];
|
||||||
|
|
||||||
|
@ -3096,9 +3097,36 @@ void QAsmView::mousePressEvent(QMouseEvent * event)
|
||||||
{
|
{
|
||||||
if ( selChar < (int)asmEntry[line]->text.size() )
|
if ( selChar < (int)asmEntry[line]->text.size() )
|
||||||
{
|
{
|
||||||
|
|
||||||
i = selChar;
|
i = selChar;
|
||||||
|
|
||||||
if ( isxdigit( asmEntry[line]->text[i] ) )
|
if ( asmEntry[line]->sym.name.size() > 0 )
|
||||||
|
{
|
||||||
|
size_t subStrLoc = asmEntry[line]->text.find( asmEntry[line]->sym.name, 22 );
|
||||||
|
|
||||||
|
if ( (subStrLoc != std::string::npos) && (subStrLoc > 22) )
|
||||||
|
{
|
||||||
|
//printf("Line:%i asmEntry DB Sym: %zi '%s'\n", line, subStrLoc, asmEntry[line]->sym.name.c_str() );
|
||||||
|
symTextStart = subStrLoc;
|
||||||
|
symTextEnd = subStrLoc + asmEntry[line]->sym.name.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (i >= symTextStart) && (i < symTextEnd) )
|
||||||
|
{
|
||||||
|
selAddrLine = line;
|
||||||
|
selAddrChar = symTextStart;
|
||||||
|
selAddrWidth = symTextEnd - symTextStart;
|
||||||
|
selAddrValue = addr = asmEntry[line]->sym.ofs;
|
||||||
|
|
||||||
|
if ( selAddrWidth >= (int)sizeof(selAddrText) )
|
||||||
|
{
|
||||||
|
selAddrWidth = sizeof(selAddrText)-1;
|
||||||
|
}
|
||||||
|
strncpy( selAddrText, asmEntry[line]->sym.name.c_str(), selAddrWidth );
|
||||||
|
selAddrText[ selAddrWidth ] = 0;
|
||||||
|
}
|
||||||
|
else if ( isxdigit( asmEntry[line]->text[i] ) )
|
||||||
{
|
{
|
||||||
addrClicked = 1;
|
addrClicked = 1;
|
||||||
addrTextLoc = i;
|
addrTextLoc = i;
|
||||||
|
@ -3157,12 +3185,12 @@ void QAsmView::mousePressEvent(QMouseEvent * event)
|
||||||
{
|
{
|
||||||
selAddrWidth = 0;
|
selAddrWidth = 0;
|
||||||
}
|
}
|
||||||
if ( selAddrWidth > (int)sizeof(selAddrText) )
|
if ( selAddrWidth >= (int)sizeof(selAddrText) )
|
||||||
{
|
{
|
||||||
selAddrWidth = sizeof(selAddrText);
|
selAddrWidth = sizeof(selAddrText)-1;
|
||||||
}
|
}
|
||||||
strncpy( selAddrText, asmEntry[line]->text.c_str(), selAddrWidth );
|
strncpy( selAddrText, asmEntry[line]->text.c_str(), selAddrWidth );
|
||||||
selAddrText[ sizeof(selAddrText)-1 ] = 0;
|
selAddrText[ selAddrWidth ] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( addr < 0 )
|
if ( addr < 0 )
|
||||||
|
|
|
@ -37,6 +37,7 @@ struct dbg_asm_entry_t
|
||||||
int line;
|
int line;
|
||||||
uint8 opcode[3];
|
uint8 opcode[3];
|
||||||
std::string text;
|
std::string text;
|
||||||
|
debugSymbol_t sym;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
|
@ -616,7 +616,7 @@ void debugSymbolTable_t::print(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
static int replaceSymbols( int flags, int addr, char *str )
|
debugSymbol_t *replaceSymbols( int flags, int addr, char *str )
|
||||||
{
|
{
|
||||||
debugSymbol_t *sym;
|
debugSymbol_t *sym;
|
||||||
|
|
||||||
|
@ -638,22 +638,45 @@ static int replaceSymbols( int flags, int addr, char *str )
|
||||||
|
|
||||||
if ( sym )
|
if ( sym )
|
||||||
{
|
{
|
||||||
strcpy( str, sym->name.c_str() );
|
if ( flags & ASM_DEBUG_REPLACE )
|
||||||
|
{
|
||||||
|
strcpy( str, sym->name.c_str() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( flags & ASM_DEBUG_ADDR_02X )
|
||||||
|
{
|
||||||
|
sprintf( str, "%02X ", addr );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf( str, "%04X ", addr );
|
||||||
|
}
|
||||||
|
strcat( str, sym->name.c_str() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//sprintf( str, "%04X", addr );
|
if ( flags & ASM_DEBUG_ADDR_02X )
|
||||||
str[0] = 0;
|
{
|
||||||
|
sprintf( str, "%02X", addr );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf( str, "%04X", addr );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return sym;
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str, debugSymbol_t *symOut, debugSymbol_t *symOut2 )
|
||||||
{
|
{
|
||||||
|
debugSymbol_t *sym = NULL;
|
||||||
|
debugSymbol_t *sym2 = NULL;
|
||||||
static char chr[8]={0};
|
static char chr[8]={0};
|
||||||
uint16_t tmp,tmp2;
|
uint16_t tmp,tmp2;
|
||||||
char stmp[128];
|
char stmp[128], stmp2[128];
|
||||||
|
|
||||||
//these may be replaced later with passed-in values to make a lighter-weight disassembly mode that may not query the referenced values
|
//these may be replaced later with passed-in values to make a lighter-weight disassembly mode that may not query the referenced values
|
||||||
#define RX (X.X)
|
#define RX (X.X)
|
||||||
|
@ -733,8 +756,8 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
||||||
|
|
||||||
if ( flags )
|
if ( flags )
|
||||||
{
|
{
|
||||||
replaceSymbols( flags, tmp, stmp );
|
sym = replaceSymbols( flags, tmp, stmp );
|
||||||
sprintf(str,"%s ($%02X,X) @ $%04X %s = #$%02X", chr,opcode[1],tmp,stmp,GetMem(tmp));
|
sprintf(str,"%s ($%02X,X) @ $%s = #$%02X", chr,opcode[1],stmp,GetMem(tmp));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -769,8 +792,8 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
||||||
// Change width to %04X // don't!
|
// Change width to %04X // don't!
|
||||||
if ( flags )
|
if ( flags )
|
||||||
{
|
{
|
||||||
replaceSymbols( flags, opcode[1], stmp );
|
sym = replaceSymbols( flags | ASM_DEBUG_ADDR_02X, opcode[1], stmp );
|
||||||
sprintf(str,"%s $%02X %s = #$%02X", chr,opcode[1],stmp,GetMem(opcode[1]));
|
sprintf(str,"%s $%s = #$%02X", chr,stmp,GetMem(opcode[1]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -823,8 +846,8 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
||||||
|
|
||||||
if ( flags )
|
if ( flags )
|
||||||
{
|
{
|
||||||
replaceSymbols( flags, tmp, stmp );
|
sym = replaceSymbols( flags, tmp, stmp );
|
||||||
sprintf(str,"%s $%04X %s = #$%02X", chr,tmp,stmp,GetMem(tmp));
|
sprintf(str,"%s $%s = #$%02X", chr,stmp,GetMem(tmp));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -846,8 +869,8 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
||||||
|
|
||||||
if ( flags )
|
if ( flags )
|
||||||
{
|
{
|
||||||
replaceSymbols( flags, tmp, stmp );
|
sym = replaceSymbols( flags, tmp, stmp );
|
||||||
sprintf(str,"%s $%04X %s", chr,tmp,stmp);
|
sprintf(str,"%s $%s", chr,stmp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -869,8 +892,8 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
||||||
|
|
||||||
if ( flags )
|
if ( flags )
|
||||||
{
|
{
|
||||||
replaceSymbols( flags, tmp, stmp );
|
sym = replaceSymbols( flags, tmp, stmp );
|
||||||
sprintf(str,"%s ($%02X),Y @ $%04X %s = #$%02X", chr,opcode[1],tmp,stmp,GetMem(tmp));
|
sprintf(str,"%s ($%02X),Y @ $%s = #$%02X", chr,opcode[1],stmp,GetMem(tmp));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -901,8 +924,8 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
||||||
// Change width to %04X // don't!
|
// Change width to %04X // don't!
|
||||||
if ( flags )
|
if ( flags )
|
||||||
{
|
{
|
||||||
replaceSymbols( flags, tmp, stmp );
|
sym = replaceSymbols( flags, tmp, stmp );
|
||||||
sprintf(str,"%s $%02X,X @ $%04X %s = #$%02X", chr,opcode[1],tmp,stmp,GetMem(tmp));
|
sprintf(str,"%s $%02X,X @ $%s = #$%02X", chr,opcode[1],stmp,GetMem(tmp));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -926,8 +949,9 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
||||||
tmp2=(tmp+RY);
|
tmp2=(tmp+RY);
|
||||||
if ( flags )
|
if ( flags )
|
||||||
{
|
{
|
||||||
replaceSymbols( flags, tmp2, stmp );
|
sym = replaceSymbols( flags, tmp , stmp );
|
||||||
sprintf(str,"%s $%04X,Y @ $%04X %s = #$%02X", chr,tmp,tmp2,stmp,GetMem(tmp2));
|
sym2 = replaceSymbols( flags, tmp2, stmp2 );
|
||||||
|
sprintf(str,"%s $%s,Y @ $%s = #$%02X", chr,stmp,stmp2,GetMem(tmp2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -956,8 +980,9 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
||||||
tmp2=(tmp+RX);
|
tmp2=(tmp+RX);
|
||||||
if ( flags )
|
if ( flags )
|
||||||
{
|
{
|
||||||
replaceSymbols( flags, tmp2, stmp );
|
sym = replaceSymbols( flags, tmp , stmp );
|
||||||
sprintf(str,"%s $%04X,X @ $%04X %s = #$%02X", chr,tmp,tmp2,stmp,GetMem(tmp2));
|
sym2 = replaceSymbols( flags, tmp2, stmp2 );
|
||||||
|
sprintf(str,"%s $%s,X @ $%s = #$%02X", chr,stmp,stmp2,GetMem(tmp2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -974,8 +999,8 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
||||||
|
|
||||||
if ( flags )
|
if ( flags )
|
||||||
{
|
{
|
||||||
replaceSymbols( flags, tmp, stmp );
|
sym = replaceSymbols( flags, tmp, stmp );
|
||||||
sprintf(str,"%s $%04X %s", chr,tmp,stmp);
|
sprintf(str,"%s $%s", chr,stmp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -992,8 +1017,8 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
||||||
// Change width to %04X // don't!
|
// Change width to %04X // don't!
|
||||||
if ( flags )
|
if ( flags )
|
||||||
{
|
{
|
||||||
replaceSymbols( flags, tmp, stmp );
|
sym = replaceSymbols( flags, tmp, stmp );
|
||||||
sprintf(str,"%s $%02X,Y @ $%04X %s = #$%02X", chr,opcode[1],tmp,stmp,GetMem(tmp));
|
sprintf(str,"%s $%02X,Y @ $%s = #$%02X", chr,opcode[1],stmp,GetMem(tmp));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1007,6 +1032,25 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( symOut )
|
||||||
|
{
|
||||||
|
if ( sym )
|
||||||
|
{
|
||||||
|
*symOut = *sym;
|
||||||
|
}
|
||||||
|
else if ( sym2 )
|
||||||
|
{
|
||||||
|
*symOut = *sym2; sym2 = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( symOut2 )
|
||||||
|
{
|
||||||
|
if ( sym2 )
|
||||||
|
{
|
||||||
|
*symOut2 = *sym2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
|
|
|
@ -112,9 +112,11 @@ extern debugSymbolTable_t debugSymbolTable;
|
||||||
int generateNLFilenameForBank(int bank, char *NLfilename);
|
int generateNLFilenameForBank(int bank, char *NLfilename);
|
||||||
int generateNLFilenameForAddress(int address, char *NLfilename);
|
int generateNLFilenameForAddress(int address, char *NLfilename);
|
||||||
|
|
||||||
#define ASM_DEBUG_SYMS 0x0001
|
#define ASM_DEBUG_SYMS 0x0001
|
||||||
#define ASM_DEBUG_REGS 0x0002
|
#define ASM_DEBUG_REGS 0x0002
|
||||||
|
#define ASM_DEBUG_REPLACE 0x0004
|
||||||
|
#define ASM_DEBUG_ADDR_02X 0x0008
|
||||||
|
|
||||||
int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str );
|
int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str, debugSymbol_t *symOut = NULL, debugSymbol_t *symOut2 = NULL );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue