Merge pull request #231 from mjbudd77/master
Qt Debugger Assembly View Selected Address Logic Update
This commit is contained in:
commit
d2f543b094
|
@ -2811,6 +2811,12 @@ QAsmView::QAsmView(QWidget *parent)
|
|||
maxLineOffset = 0;
|
||||
ctxMenuAddr = -1;
|
||||
|
||||
selAddrLine = -1;
|
||||
selAddrChar = 0;
|
||||
selAddrWidth = 0;
|
||||
selAddrValue = -1;
|
||||
memset( selAddrText, 0, sizeof(selAddrText) );
|
||||
|
||||
//setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
|
@ -2938,6 +2944,27 @@ void QAsmView::resizeEvent(QResizeEvent *event)
|
|||
void QAsmView::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
//printf("Debug ASM Window Key Press: 0x%x \n", event->key() );
|
||||
if ( selAddrValue >= 0 )
|
||||
{
|
||||
ctxMenuAddr = selAddrValue;
|
||||
|
||||
if ( event->key() == Qt::Key_B )
|
||||
{
|
||||
parent->asmViewCtxMenuAddBP();
|
||||
}
|
||||
else if ( event->key() == Qt::Key_S )
|
||||
{
|
||||
parent->asmViewCtxMenuAddSym();
|
||||
}
|
||||
else if ( event->key() == Qt::Key_M )
|
||||
{
|
||||
parent->asmViewCtxMenuAddBM();
|
||||
}
|
||||
else if ( event->key() == Qt::Key_H )
|
||||
{
|
||||
parent->asmViewCtxMenuOpenHexEdit();
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void QAsmView::keyReleaseEvent(QKeyEvent *event)
|
||||
|
@ -3047,11 +3074,68 @@ void QAsmView::mousePressEvent(QMouseEvent * event)
|
|||
|
||||
if ( line < asmEntry.size() )
|
||||
{
|
||||
int addr;
|
||||
int i,j, addr = -1, addrTextLoc = -1, selChar;
|
||||
char addrClicked = 0;
|
||||
char stmp[64];
|
||||
|
||||
addr = asmEntry[line]->addr;
|
||||
selChar = c.x();
|
||||
|
||||
if ( selChar < (int)asmEntry[line]->text.size() )
|
||||
{
|
||||
i = selChar;
|
||||
|
||||
if ( isxdigit( asmEntry[line]->text[i] ) )
|
||||
{
|
||||
addrClicked = 1;
|
||||
addrTextLoc = i;
|
||||
|
||||
while ( isxdigit( asmEntry[line]->text[i] ) )
|
||||
{
|
||||
addrTextLoc = i;
|
||||
i--;
|
||||
}
|
||||
if ( asmEntry[line]->text[i] == '$' || asmEntry[line]->text[i] == ':' )
|
||||
{
|
||||
i--;
|
||||
}
|
||||
else
|
||||
{
|
||||
addrClicked = 0;
|
||||
}
|
||||
if ( asmEntry[line]->text[i] == '#' )
|
||||
{
|
||||
addrClicked = 0;
|
||||
}
|
||||
if ( addrClicked )
|
||||
{
|
||||
j=0; i = addrTextLoc;
|
||||
|
||||
while ( isxdigit( asmEntry[line]->text[i] ) )
|
||||
{
|
||||
stmp[j] = asmEntry[line]->text[i]; i++; j++;
|
||||
}
|
||||
stmp[j] = 0;
|
||||
|
||||
//printf("Addr: '%s'\n", stmp );
|
||||
|
||||
addr = strtol( stmp, NULL, 16 );
|
||||
|
||||
selAddrLine = line;
|
||||
selAddrChar = addrTextLoc;
|
||||
selAddrWidth = j;
|
||||
selAddrValue = addr;
|
||||
strcpy( selAddrText, stmp );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//printf("Line: '%s'\n", asmEntry[line]->text.c_str() );
|
||||
|
||||
if ( addr >= 0 )
|
||||
{
|
||||
parent->setBookmarkSelectedAddress( addr );
|
||||
}
|
||||
|
||||
parent->setBookmarkSelectedAddress( addr );
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -3070,22 +3154,33 @@ void QAsmView::contextMenuEvent(QContextMenuEvent *event)
|
|||
{
|
||||
int addr;
|
||||
|
||||
ctxMenuAddr = addr = asmEntry[line]->addr;
|
||||
if ( selAddrValue < 0 )
|
||||
{
|
||||
ctxMenuAddr = addr = asmEntry[line]->addr;
|
||||
}
|
||||
else
|
||||
{
|
||||
ctxMenuAddr = addr = selAddrValue;
|
||||
}
|
||||
|
||||
act = new QAction(tr("Add Breakpoint"), &menu);
|
||||
menu.addAction(act);
|
||||
act->setShortcut( QKeySequence(tr("B")));
|
||||
connect( act, SIGNAL(triggered(void)), parent, SLOT(asmViewCtxMenuAddBP(void)) );
|
||||
|
||||
act = new QAction(tr("Add Symbolic Debug Marker"), &menu);
|
||||
menu.addAction(act);
|
||||
act->setShortcut( QKeySequence(tr("S")));
|
||||
connect( act, SIGNAL(triggered(void)), parent, SLOT(asmViewCtxMenuAddSym(void)) );
|
||||
|
||||
act = new QAction(tr("Add Bookmark"), &menu);
|
||||
menu.addAction(act);
|
||||
act->setShortcut( QKeySequence(tr("M")));
|
||||
connect( act, SIGNAL(triggered(void)), parent, SLOT(asmViewCtxMenuAddBM(void)) );
|
||||
|
||||
act = new QAction(tr("Open Hex Editor"), &menu);
|
||||
menu.addAction(act);
|
||||
act->setShortcut( QKeySequence(tr("H")));
|
||||
connect( act, SIGNAL(triggered(void)), parent, SLOT(asmViewCtxMenuOpenHexEdit(void)) );
|
||||
|
||||
menu.exec(event->globalPos());
|
||||
|
@ -3168,22 +3263,20 @@ void QAsmView::paintEvent(QPaintEvent *event)
|
|||
}
|
||||
painter.drawText( x, y, tr(asmEntry[l]->text.c_str()) );
|
||||
|
||||
if ( selAddr == asmEntry[l]->addr )
|
||||
if ( (selAddrLine == l) )
|
||||
{ // Highlight ASM line for selected address.
|
||||
if ( !displayROMoffsets && (asmEntry[l]->type == dbg_asm_entry_t::ASM_TEXT) )
|
||||
if ( (selAddr == selAddrValue) && (asmEntry[l]->type == dbg_asm_entry_t::ASM_TEXT) &&
|
||||
( asmEntry[l]->text.compare( selAddrChar, selAddrWidth, selAddrText ) == 0 ) )
|
||||
{
|
||||
int ax;
|
||||
char addrString[16];
|
||||
|
||||
ax = 4*pxCharWidth;
|
||||
ax = selAddrChar*pxCharWidth;
|
||||
|
||||
painter.fillRect( ax, y - pxLineSpacing + pxLineLead, 4*pxCharWidth, pxLineSpacing, QColor("blue") );
|
||||
painter.fillRect( ax, y - pxLineSpacing + pxLineLead, selAddrWidth*pxCharWidth, pxLineSpacing, QColor("blue") );
|
||||
|
||||
sprintf( addrString, "%04X", selAddr );
|
||||
painter.setPen( QColor("white"));
|
||||
|
||||
painter.setPen( this->palette().color(QPalette::Background));
|
||||
|
||||
painter.drawText( ax, y, tr(addrString) );
|
||||
painter.drawText( ax, y, tr(selAddrText) );
|
||||
|
||||
painter.setPen( this->palette().color(QPalette::WindowText));
|
||||
}
|
||||
|
|
|
@ -145,6 +145,12 @@ class QAsmView : public QWidget
|
|||
int cursorPosX;
|
||||
int cursorPosY;
|
||||
|
||||
int selAddrLine;
|
||||
int selAddrChar;
|
||||
int selAddrWidth;
|
||||
int selAddrValue;
|
||||
char selAddrText[16];
|
||||
|
||||
dbg_asm_entry_t *asmPC;
|
||||
std::vector <dbg_asm_entry_t*> asmEntry;
|
||||
|
||||
|
|
Loading…
Reference in New Issue