Add Xrefs to trace disassembler too

This commit is contained in:
torusrxxx 2024-04-20 18:17:31 +08:00
parent a436a4bcc1
commit a461951d07
No known key found for this signature in database
GPG Key ID: A795C73A0F1CFADD
6 changed files with 30 additions and 11 deletions

View File

@ -882,6 +882,11 @@ void TraceBrowser::setupRightClickContextMenu()
});
mMenuBuilder->addMenu(makeMenu(DIcon("goto"), tr("Go to")), gotoMenu);
mMenuBuilder->addAction(makeShortcutAction(DIcon("xrefs"), tr("xrefs..."), SLOT(gotoXrefSlot()), "ActionXrefs"), [this](QMenu*)
{
return !Config()->getBool("Gui", "DisableTraceDump"); // Do not show xrefs when dump is disabled
});
MenuBuilder* searchMenu = new MenuBuilder(this, mTraceFileNotNull);
searchMenu->addAction(makeAction(DIcon("search_for_constant"), tr("Address/Constant"), SLOT(searchConstantSlot())));
searchMenu->addAction(makeAction(DIcon("memory-map"), tr("Memory Reference"), SLOT(searchMemRefSlot())));
@ -940,9 +945,12 @@ void TraceBrowser::setupRightClickContextMenu()
}
return true;
});
mMenuBuilder->addAction(makeAction(DIcon("close"), tr("Close recording"), SLOT(closeFileSlot())), mTraceFileNotNull);
mMenuBuilder->addAction(makeAction(DIcon("delete"), tr("Delete recording"), SLOT(closeDeleteSlot())), mTraceFileNotNull);
mMenuBuilder->addAction(makeShortcutAction(DIcon("browseinexplorer"), tr("Browse in Explorer"), SLOT(browseInExplorerSlot()), "ActionBrowseInExplorer"), mTraceFileNotNull);
mMenuBuilder->addAction(makeAction(DIcon("close"), tr("Close recording"), SLOT(closeFileSlot())), mTraceFileNotNull)
->setStatusTip(tr("Close the trace file tab, and stop recording trace."));
mMenuBuilder->addAction(makeAction(DIcon("delete"), tr("Delete recording"), SLOT(closeDeleteSlot())), mTraceFileNotNull)
->setStatusTip(tr("Delete the trace file from disk, and stop recording trace."));
mMenuBuilder->addAction(makeShortcutAction(DIcon("browseinexplorer"), tr("Browse in Explorer"), SLOT(browseInExplorerSlot()), "ActionBrowseInExplorer"), mTraceFileNotNull)
->setStatusTip(tr("Open the trace file in Explorer."));
mMenuBuilder->loadFromConfig();
}
@ -1393,6 +1401,12 @@ void TraceBrowser::gotoPreviousSlot()
disasm(mHistory.historyPrev(), false);
}
void TraceBrowser::gotoXrefSlot()
{
emit xrefSignal(getTraceFile()->Registers(getInitialSelection()).regcontext.cip);
}
void TraceBrowser::copyCipSlot()
{
QString clipboard;

View File

@ -147,6 +147,7 @@ signals:
void displayReferencesWidget();
void displayLogWidget();
void selectionChanged(unsigned long long selection);
void xrefSignal(duint addr);
void closeFile();
public slots:
@ -164,6 +165,7 @@ public slots:
void rtrSlot();
void gotoPreviousSlot();
void gotoNextSlot();
void gotoXrefSlot();
void enableHighlightingModeSlot();
void mnemonicBriefSlot();
void mnemonicHelpSlot();

View File

@ -67,10 +67,10 @@ void TraceRegisters::displayCustomContextMenuSlot(QPoint pos)
menu.addAction(mDisplayMMX);
}
if((!mNoChange.contains(mSelected)) ||
if(((!mNoChange.contains(mSelected)) ||
mSelected == LastError ||
mSelected == LastStatus ||
mSelected == CIP)
mSelected == CIP) && DbgIsDebugging())
{
menu.addAction(wCM_SetCurrentRegister);
}

View File

@ -69,6 +69,7 @@ TraceWidget::TraceWidget(Architecture* architecture, const QString & fileName, Q
if(mDump)
{
connect(mTraceBrowser, SIGNAL(xrefSignal(duint)), this, SLOT(xrefSlot(duint)));
//dump
ui->mBotLeftFrameLayout->addWidget(mDump);
connect(mDump, SIGNAL(xrefSignal(duint)), this, SLOT(xrefSlot(duint)));

View File

@ -51,25 +51,28 @@ void TraceXrefBrowseDialog::setup(duint index, duint address, TraceFileReader* t
mXrefInfo.reserve(xrefInfo.size());
for(auto & i : xrefInfo)
{
mXrefInfo.emplace_back(TRACE_XREF_RECORD({i, traceFile->Registers(i).regcontext.cip, XREF_DATA}));
mXrefInfo.emplace_back(TRACE_XREF_RECORD({i, traceFile->Registers(i).regcontext.cip}));
}
setWindowTitle(QString(tr("xrefs at <%1>")).arg(GetFunctionSymbol(address)));
for(duint i = 0; i < mXrefInfo.size(); i++)
{
Zydis zydis;
std::string disasm;
QString disasm;
unsigned char data[16] = { 0xCC };
int size;
traceFile->OpCode(mXrefInfo[i].index, data, &size);
zydis.Disassemble(mXrefInfo[i].addr, data);
if(zydis.Success())
{
disasm = zydis.InstructionText();
ui->listWidget->addItem(QString::fromStdString(disasm));
disasm = QString::fromStdString(zydis.InstructionText());
}
else
ui->listWidget->addItem("???");
{
disasm = "???";
}
disasm = traceFile->getIndexText(mXrefInfo[i].index) + ": " + disasm;
ui->listWidget->addItem(disasm);
}
ui->listWidget->setCurrentRow(0);
ui->listWidget->setFocus();

View File

@ -45,7 +45,6 @@ private:
{
unsigned long long index;
duint addr;
XREFTYPE type;
} TRACE_XREF_RECORD;
std::vector<TRACE_XREF_RECORD> mXrefInfo;
duint mAddress;