1
0
Fork 0

Improve the trace tab UX

This commit is contained in:
Duncan Ogilvie 2022-08-20 00:00:33 +02:00
parent eb2f4776e3
commit 117dd32a06
11 changed files with 54 additions and 5 deletions

View File

@ -1773,6 +1773,16 @@ BRIDGE_IMPEXP void GuiSelectInSymbolsTab(duint addr)
_gui_sendmessage(GUI_SELECT_IN_SYMBOLS_TAB, (void*)addr, nullptr);
}
BRIDGE_IMPEXP void GuiGotoTrace(duint index)
{
_gui_sendmessage(GUI_GOTO_TRACE, (void*)index, nullptr);
}
BRIDGE_IMPEXP void GuiShowTrace()
{
_gui_sendmessage(GUI_SHOW_TRACE, nullptr, nullptr);
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
hInst = hinstDLL;

View File

@ -1205,6 +1205,8 @@ typedef enum
GUI_GET_CURRENT_GRAPH, // param1=BridgeCFGraphList*, param2=unused
GUI_SHOW_REF, // param1=unused, param2=unused
GUI_SELECT_IN_SYMBOLS_TAB, // param1=duint addr, param2=unused
GUI_GOTO_TRACE, // param1=duint index, param2=unused
GUI_SHOW_TRACE, // param1=unused, param2=unused
} GUIMSG;
//GUI Typedefs
@ -1388,6 +1390,8 @@ BRIDGE_IMPEXP void GuiExecuteOnGuiThreadEx(GUICALLBACKEX cbGuiThread, void* user
BRIDGE_IMPEXP void GuiGetCurrentGraph(BridgeCFGraphList* graphList);
BRIDGE_IMPEXP void GuiShowReferences();
BRIDGE_IMPEXP void GuiSelectInSymbolsTab(duint addr);
BRIDGE_IMPEXP void GuiGotoTrace(duint index);
BRIDGE_IMPEXP void GuiShowTrace();
#ifdef __cplusplus
}

View File

@ -327,3 +327,13 @@ bool cbSymbolsFollow(int argc, char* argv[])
GuiFocusView(GUI_SYMMOD);
return true;
}
bool cbGotoTrace(int argc, char* argv[])
{
duint index = 0;
if(IsArgumentsLessThan(argc, 2) || !valfromstring(argv[1], &index, false))
return false;
GuiGotoTrace(index);
GuiShowTrace();
}

View File

@ -22,3 +22,4 @@ bool cbInstrFoldDisassembly(int argc, char* argv[]);
bool cbDebugUpdateTitle(int argc, char* argv[]);
bool cbShowReferences(int argc, char* argv[]);
bool cbSymbolsFollow(int argc, char* argv[]);
bool cbGotoTrace(int argc, char* argv[]);

View File

@ -407,6 +407,7 @@ static void registercommands()
dbgcmdnew("guiupdatetitle", cbDebugUpdateTitle, true); // set relevant disassembly title
dbgcmdnew("showref", cbShowReferences, false); // show references window
dbgcmdnew("symfollow", cbSymbolsFollow, false); // follow address in symbols tab
dbgcmdnew("gototrace,tracegoto", cbGotoTrace, false); // goto index in trace tab
//misc
dbgcmdnew("chd", cbInstrChd, false); //Change directory

View File

@ -890,6 +890,14 @@ void* Bridge::processMessage(GUIMSG type, void* param1, void* param2)
case GUI_SELECT_IN_SYMBOLS_TAB:
emit symbolSelectModule(duint(param1));
break;
case GUI_GOTO_TRACE:
emit gotoTraceIndex(duint(param1));
break;
case GUI_SHOW_TRACE:
emit showTraceBrowser();
break;
}
return nullptr;

View File

@ -163,6 +163,8 @@ signals:
void symbolSelectModule(duint base);
void getCurrentGraph(BridgeCFGraphList* graphList);
void showReferences();
void gotoTraceIndex(duint index);
void showTraceBrowser();
private:
CRITICAL_SECTION csBridge;

View File

@ -113,6 +113,7 @@ MainWindow::MainWindow(QWidget* parent)
connect(Bridge::getBridge(), SIGNAL(selectInMemoryMap(duint)), this, SLOT(displayMemMapWidget()));
connect(Bridge::getBridge(), SIGNAL(symbolSelectModule(duint)), this, SLOT(displaySymbolWidget()));
connect(Bridge::getBridge(), SIGNAL(closeApplication()), this, SLOT(close()));
connect(Bridge::getBridge(), SIGNAL(showTraceBrowser()), this, SLOT(displayTraceWidget()));
// Setup menu API
initMenuApi();

View File

@ -50,6 +50,7 @@ TraceBrowser::TraceBrowser(QWidget* parent) : AbstractTableView(parent)
connect(Bridge::getBridge(), SIGNAL(updateTraceBrowser()), this, SLOT(updateSlot()));
connect(Bridge::getBridge(), SIGNAL(openTraceFile(const QString &)), this, SLOT(openSlot(const QString &)));
connect(Bridge::getBridge(), SIGNAL(gotoTraceIndex(duint)), this, SLOT(gotoIndexSlot(duint)));
connect(Config(), SIGNAL(tokenizerConfigUpdated()), this, SLOT(tokenizerConfigUpdatedSlot()));
}
@ -917,7 +918,7 @@ void TraceBrowser::setupRightClickContextMenu()
return true;
});
MenuBuilder* gotoMenu = new MenuBuilder(this, isValid);
gotoMenu->addAction(makeShortcutAction(DIcon("goto"), tr("Expression"), SLOT(gotoSlot()), "ActionGotoExpression"), isValid);
gotoMenu->addAction(makeShortcutAction(DIcon("goto"), tr("Index"), SLOT(gotoSlot()), "ActionGotoExpression"), isValid);
gotoMenu->addAction(makeAction(DIcon("arrow-step-rtr"), tr("Function return"), SLOT(rtrSlot())), isValid);
gotoMenu->addAction(makeShortcutAction(DIcon("previous"), tr("Previous"), SLOT(gotoPreviousSlot()), "ActionGotoPrevious"), [this](QMenu*)
{
@ -930,7 +931,7 @@ void TraceBrowser::setupRightClickContextMenu()
mMenuBuilder->addMenu(makeMenu(DIcon("goto"), tr("Go to")), gotoMenu);
MenuBuilder* searchMenu = new MenuBuilder(this, isValid);
searchMenu->addAction(makeAction(DIcon("search_for_constant"), tr("Constant"), SLOT(searchConstantSlot())));
searchMenu->addAction(makeAction(DIcon("search_for_constant"), tr("Address/Constant"), SLOT(searchConstantSlot())));
searchMenu->addAction(makeAction(DIcon("memory-map"), tr("Memory Reference"), SLOT(searchMemRefSlot())));
mMenuBuilder->addMenu(makeMenu(DIcon("search"), tr("&Search")), searchMenu);
@ -1831,7 +1832,10 @@ void TraceBrowser::enableHighlightingModeSlot()
void TraceBrowser::searchConstantSlot()
{
WordEditDialog constantDlg(this);
constantDlg.setup(tr("Constant"), 0, sizeof(duint));
duint initialConstant = 0;
if(mTraceFile && mTraceFile->Progress() == 100)
initialConstant = mTraceFile->Registers(getInitialSelection()).regcontext.cip;
constantDlg.setup(tr("Constant"), initialConstant, sizeof(duint));
if(constantDlg.exec() == QDialog::Accepted)
{
TraceFileSearchConstantRange(mTraceFile, constantDlg.getVal(), constantDlg.getVal());
@ -1869,3 +1873,8 @@ void TraceBrowser::toggleAutoDisassemblyFollowSelectionSlot()
{
mAutoDisassemblyFollowSelection = !mAutoDisassemblyFollowSelection;
}
void TraceBrowser::gotoIndexSlot(duint index)
{
disasm(index, false);
}

View File

@ -185,6 +185,7 @@ public slots:
void updateSlot();
void toggleAutoDisassemblyFollowSelectionSlot();
void gotoIndexSlot(duint index);
protected:
void disasm(unsigned long long index, bool history = true);

View File

@ -20,8 +20,9 @@ int TraceFileSearchConstantRange(TraceFileReader* file, duint start, duint end)
title = QCoreApplication::translate("TraceFileSearch", "Range: %1-%2").arg(ToPtrString(start)).arg(ToPtrString(end));
GuiReferenceInitialize(title.toUtf8().constData());
GuiReferenceAddColumn(sizeof(duint) * 2, QCoreApplication::translate("TraceFileSearch", "Address").toUtf8().constData());
GuiReferenceAddColumn(sizeof(duint) * 2, QCoreApplication::translate("TraceFileSearch", "Index").toUtf8().constData());
GuiReferenceAddColumn(5, QCoreApplication::translate("TraceFileSearch", "Index").toUtf8().constData());
GuiReferenceAddColumn(100, QCoreApplication::translate("TraceFileSearch", "Disassembly").toUtf8().constData());
GuiReferenceAddCommand(QCoreApplication::translate("TraceFileSearch", "Follow index in trace").toUtf8().constData(), "gototrace 0x$1");
GuiReferenceSetRowCount(0);
REGISTERCONTEXT regcontext;
@ -92,8 +93,9 @@ int TraceFileSearchMemReference(TraceFileReader* file, duint address)
Zydis zy;
GuiReferenceInitialize(QCoreApplication::translate("TraceFileSearch", "Reference").toUtf8().constData());
GuiReferenceAddColumn(sizeof(duint) * 2, QCoreApplication::translate("TraceFileSearch", "Address").toUtf8().constData());
GuiReferenceAddColumn(sizeof(duint) * 2, QCoreApplication::translate("TraceFileSearch", "Index").toUtf8().constData());
GuiReferenceAddColumn(5, QCoreApplication::translate("TraceFileSearch", "Index").toUtf8().constData());
GuiReferenceAddColumn(100, QCoreApplication::translate("TraceFileSearch", "Disassembly").toUtf8().constData());
GuiReferenceAddCommand(QCoreApplication::translate("TraceFileSearch", "Follow index in trace").toUtf8().constData(), "gototrace 0x$1");
GuiReferenceSetRowCount(0);
for(unsigned long long index = 0; index < file->Length(); index++)