Added logic to allow for symbol names to be clicked in Qt debugger ASM viewer.
This commit is contained in:
parent
c8f0649223
commit
242620b782
|
@ -1944,7 +1944,7 @@ void QAsmView::updateAssemblyView(void)
|
|||
size++;
|
||||
}
|
||||
|
||||
DisassembleWithDebug(addr, opcode, asmFlags, asmTxt);
|
||||
DisassembleWithDebug(addr, opcode, asmFlags, asmTxt, &a->sym);
|
||||
|
||||
line.append( asmTxt );
|
||||
}
|
||||
|
@ -3087,6 +3087,7 @@ void QAsmView::mousePressEvent(QMouseEvent * event)
|
|||
if ( line < asmEntry.size() )
|
||||
{
|
||||
int i,j, addr = -1, addrTextLoc = -1, selChar;
|
||||
int symTextStart = -1, symTextEnd = -1;
|
||||
char addrClicked = 0;
|
||||
char stmp[64];
|
||||
|
||||
|
@ -3096,9 +3097,36 @@ void QAsmView::mousePressEvent(QMouseEvent * event)
|
|||
{
|
||||
if ( selChar < (int)asmEntry[line]->text.size() )
|
||||
{
|
||||
|
||||
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;
|
||||
addrTextLoc = i;
|
||||
|
@ -3157,12 +3185,12 @@ void QAsmView::mousePressEvent(QMouseEvent * event)
|
|||
{
|
||||
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 );
|
||||
selAddrText[ sizeof(selAddrText)-1 ] = 0;
|
||||
selAddrText[ selAddrWidth ] = 0;
|
||||
}
|
||||
|
||||
if ( addr < 0 )
|
||||
|
|
|
@ -37,6 +37,7 @@ struct dbg_asm_entry_t
|
|||
int line;
|
||||
uint8 opcode[3];
|
||||
std::string text;
|
||||
debugSymbol_t sym;
|
||||
|
||||
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;
|
||||
|
||||
|
@ -637,23 +637,46 @@ static int replaceSymbols( int flags, int addr, char *str )
|
|||
}
|
||||
|
||||
if ( sym )
|
||||
{
|
||||
if ( flags & ASM_DEBUG_REPLACE )
|
||||
{
|
||||
strcpy( str, sym->name.c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
//sprintf( str, "%04X", addr );
|
||||
str[0] = 0;
|
||||
if ( flags & ASM_DEBUG_ADDR_02X )
|
||||
{
|
||||
sprintf( str, "%02X ", addr );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( str, "%04X ", addr );
|
||||
}
|
||||
strcat( str, sym->name.c_str() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( flags & ASM_DEBUG_ADDR_02X )
|
||||
{
|
||||
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};
|
||||
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
|
||||
#define RX (X.X)
|
||||
|
@ -733,8 +756,8 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
|||
|
||||
if ( flags )
|
||||
{
|
||||
replaceSymbols( flags, tmp, stmp );
|
||||
sprintf(str,"%s ($%02X,X) @ $%04X %s = #$%02X", chr,opcode[1],tmp,stmp,GetMem(tmp));
|
||||
sym = replaceSymbols( flags, tmp, stmp );
|
||||
sprintf(str,"%s ($%02X,X) @ $%s = #$%02X", chr,opcode[1],stmp,GetMem(tmp));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -769,8 +792,8 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
|||
// Change width to %04X // don't!
|
||||
if ( flags )
|
||||
{
|
||||
replaceSymbols( flags, opcode[1], stmp );
|
||||
sprintf(str,"%s $%02X %s = #$%02X", chr,opcode[1],stmp,GetMem(opcode[1]));
|
||||
sym = replaceSymbols( flags | ASM_DEBUG_ADDR_02X, opcode[1], stmp );
|
||||
sprintf(str,"%s $%s = #$%02X", chr,stmp,GetMem(opcode[1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -823,8 +846,8 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
|||
|
||||
if ( flags )
|
||||
{
|
||||
replaceSymbols( flags, tmp, stmp );
|
||||
sprintf(str,"%s $%04X %s = #$%02X", chr,tmp,stmp,GetMem(tmp));
|
||||
sym = replaceSymbols( flags, tmp, stmp );
|
||||
sprintf(str,"%s $%s = #$%02X", chr,stmp,GetMem(tmp));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -846,8 +869,8 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
|||
|
||||
if ( flags )
|
||||
{
|
||||
replaceSymbols( flags, tmp, stmp );
|
||||
sprintf(str,"%s $%04X %s", chr,tmp,stmp);
|
||||
sym = replaceSymbols( flags, tmp, stmp );
|
||||
sprintf(str,"%s $%s", chr,stmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -869,8 +892,8 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
|||
|
||||
if ( flags )
|
||||
{
|
||||
replaceSymbols( flags, tmp, stmp );
|
||||
sprintf(str,"%s ($%02X),Y @ $%04X %s = #$%02X", chr,opcode[1],tmp,stmp,GetMem(tmp));
|
||||
sym = replaceSymbols( flags, tmp, stmp );
|
||||
sprintf(str,"%s ($%02X),Y @ $%s = #$%02X", chr,opcode[1],stmp,GetMem(tmp));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -901,8 +924,8 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
|||
// Change width to %04X // don't!
|
||||
if ( flags )
|
||||
{
|
||||
replaceSymbols( flags, tmp, stmp );
|
||||
sprintf(str,"%s $%02X,X @ $%04X %s = #$%02X", chr,opcode[1],tmp,stmp,GetMem(tmp));
|
||||
sym = replaceSymbols( flags, tmp, stmp );
|
||||
sprintf(str,"%s $%02X,X @ $%s = #$%02X", chr,opcode[1],stmp,GetMem(tmp));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -926,8 +949,9 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
|||
tmp2=(tmp+RY);
|
||||
if ( flags )
|
||||
{
|
||||
replaceSymbols( flags, tmp2, stmp );
|
||||
sprintf(str,"%s $%04X,Y @ $%04X %s = #$%02X", chr,tmp,tmp2,stmp,GetMem(tmp2));
|
||||
sym = replaceSymbols( flags, tmp , stmp );
|
||||
sym2 = replaceSymbols( flags, tmp2, stmp2 );
|
||||
sprintf(str,"%s $%s,Y @ $%s = #$%02X", chr,stmp,stmp2,GetMem(tmp2));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -956,8 +980,9 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
|||
tmp2=(tmp+RX);
|
||||
if ( flags )
|
||||
{
|
||||
replaceSymbols( flags, tmp2, stmp );
|
||||
sprintf(str,"%s $%04X,X @ $%04X %s = #$%02X", chr,tmp,tmp2,stmp,GetMem(tmp2));
|
||||
sym = replaceSymbols( flags, tmp , stmp );
|
||||
sym2 = replaceSymbols( flags, tmp2, stmp2 );
|
||||
sprintf(str,"%s $%s,X @ $%s = #$%02X", chr,stmp,stmp2,GetMem(tmp2));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -974,8 +999,8 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
|||
|
||||
if ( flags )
|
||||
{
|
||||
replaceSymbols( flags, tmp, stmp );
|
||||
sprintf(str,"%s $%04X %s", chr,tmp,stmp);
|
||||
sym = replaceSymbols( flags, tmp, stmp );
|
||||
sprintf(str,"%s $%s", chr,stmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -992,8 +1017,8 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str )
|
|||
// Change width to %04X // don't!
|
||||
if ( flags )
|
||||
{
|
||||
replaceSymbols( flags, tmp, stmp );
|
||||
sprintf(str,"%s $%02X,Y @ $%04X %s = #$%02X", chr,opcode[1],tmp,stmp,GetMem(tmp));
|
||||
sym = replaceSymbols( flags, tmp, stmp );
|
||||
sprintf(str,"%s $%02X,Y @ $%s = #$%02X", chr,opcode[1],stmp,GetMem(tmp));
|
||||
}
|
||||
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;
|
||||
}
|
||||
//--------------------------------------------------------------
|
||||
|
|
|
@ -114,7 +114,9 @@ int generateNLFilenameForAddress(int address, char *NLfilename);
|
|||
|
||||
#define ASM_DEBUG_SYMS 0x0001
|
||||
#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
|
||||
|
|
Loading…
Reference in New Issue