GUI: added Goto -> File offset
This commit is contained in:
parent
1de5fb533f
commit
7353c57278
|
|
@ -262,6 +262,9 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event)
|
|||
if(historyHasNext())
|
||||
mGotoMenu->addAction(mGotoNext);
|
||||
mGotoMenu->addAction(mGotoExpression);
|
||||
char modname[MAX_MODULE_SIZE] = "";
|
||||
if(DbgGetModuleAt(wVA, modname))
|
||||
mGotoMenu->addAction(mGotoFileOffset);
|
||||
wMenu->addMenu(mGotoMenu);
|
||||
wMenu->addSeparator();
|
||||
|
||||
|
|
@ -436,6 +439,10 @@ void CPUDisassembly::setupRightClickContextMenu()
|
|||
this->addAction(mGotoExpression);
|
||||
connect(mGotoExpression, SIGNAL(triggered()), this, SLOT(gotoExpression()));
|
||||
|
||||
// File offset action
|
||||
mGotoFileOffset = new QAction("File Offset", this);
|
||||
connect(mGotoFileOffset, SIGNAL(triggered()), this, SLOT(gotoFileOffset()));
|
||||
|
||||
//-------------------- Follow in Dump ----------------------------
|
||||
// Menu
|
||||
mFollowMenu = new QMenu("&Follow in Dump", this);
|
||||
|
|
@ -889,6 +896,27 @@ void CPUDisassembly::gotoExpression()
|
|||
}
|
||||
}
|
||||
|
||||
void CPUDisassembly::gotoFileOffset()
|
||||
{
|
||||
if(!DbgIsDebugging())
|
||||
return;
|
||||
char modname[MAX_MODULE_SIZE] = "";
|
||||
if(!DbgFunctions()->ModNameFromAddr(rvaToVa(getInitialSelection()), modname, true))
|
||||
{
|
||||
QMessageBox::critical(this, "Error!", "Not inside a module...");
|
||||
return;
|
||||
}
|
||||
GotoDialog mGotoDialog(this);
|
||||
mGotoDialog.fileOffset = true;
|
||||
mGotoDialog.modName = QString(modname);
|
||||
mGotoDialog.setWindowTitle("Goto File Offset in " + QString(modname));
|
||||
if(mGotoDialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
uint_t value = DbgValFromString(mGotoDialog.expressionText.toUtf8().constData());
|
||||
value = DbgFunctions()->FileOffsetToVa(modname, value);
|
||||
DbgCmdExec(QString().sprintf("disasm \"%p\"", value).toUtf8().constData());
|
||||
}
|
||||
|
||||
void CPUDisassembly::followActionSlot()
|
||||
{
|
||||
QAction* action = qobject_cast<QAction*>(sender());
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ public slots:
|
|||
void toggleFunction();
|
||||
void assembleAt();
|
||||
void gotoExpression();
|
||||
void gotoFileOffset();
|
||||
void followActionSlot();
|
||||
void gotoPrevious();
|
||||
void gotoNext();
|
||||
|
|
@ -102,6 +103,7 @@ private:
|
|||
QAction* msetHwBPOnSlot2Action;
|
||||
QAction* msetHwBPOnSlot3Action;
|
||||
QAction* mGotoExpression;
|
||||
QAction* mGotoFileOffset;
|
||||
QAction* mGotoPrevious;
|
||||
QAction* mGotoNext;
|
||||
QAction* mReferenceSelectedAddress;
|
||||
|
|
|
|||
|
|
@ -246,6 +246,11 @@ void CPUDump::setupContextMenu()
|
|||
connect(mGotoExpression, SIGNAL(triggered()), this, SLOT(gotoExpressionSlot()));
|
||||
mGotoMenu->addAction(mGotoExpression);
|
||||
|
||||
// Goto->File offset
|
||||
mGotoFileOffset = new QAction("File Offset", this);
|
||||
connect(mGotoFileOffset, SIGNAL(triggered()), this, SLOT(gotoFileOffsetSlot()));
|
||||
mGotoMenu->addAction(mGotoFileOffset);
|
||||
|
||||
//Hex menu
|
||||
mHexMenu = new QMenu("&Hex", this);
|
||||
//Hex->Ascii
|
||||
|
|
@ -559,6 +564,27 @@ void CPUDump::gotoExpressionSlot()
|
|||
}
|
||||
}
|
||||
|
||||
void CPUDump::gotoFileOffsetSlot()
|
||||
{
|
||||
if(!DbgIsDebugging())
|
||||
return;
|
||||
char modname[MAX_MODULE_SIZE] = "";
|
||||
if(!DbgFunctions()->ModNameFromAddr(rvaToVa(getInitialSelection()), modname, true))
|
||||
{
|
||||
QMessageBox::critical(this, "Error!", "Not inside a module...");
|
||||
return;
|
||||
}
|
||||
GotoDialog mGotoDialog(this);
|
||||
mGotoDialog.fileOffset = true;
|
||||
mGotoDialog.modName = QString(modname);
|
||||
mGotoDialog.setWindowTitle("Goto File Offset in " + QString(modname));
|
||||
if(mGotoDialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
uint_t value = DbgValFromString(mGotoDialog.expressionText.toUtf8().constData());
|
||||
value = DbgFunctions()->FileOffsetToVa(modname, value);
|
||||
DbgCmdExec(QString().sprintf("dump \"%p\"", value).toUtf8().constData());
|
||||
}
|
||||
|
||||
void CPUDump::hexAsciiSlot()
|
||||
{
|
||||
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewHexAscii);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ public slots:
|
|||
|
||||
void setLabelSlot();
|
||||
void gotoExpressionSlot();
|
||||
void gotoFileOffsetSlot();
|
||||
|
||||
void hexAsciiSlot();
|
||||
void hexUnicodeSlot();
|
||||
|
|
@ -110,6 +111,7 @@ private:
|
|||
|
||||
QMenu* mGotoMenu;
|
||||
QAction* mGotoExpression;
|
||||
QAction* mGotoFileOffset;
|
||||
|
||||
QMenu* mHexMenu;
|
||||
QAction* mHexAsciiAction;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ GotoDialog::GotoDialog(QWidget* parent) : QDialog(parent), ui(new Ui::GotoDialog
|
|||
ui->editExpression->setFocus();
|
||||
validRangeStart = 0;
|
||||
validRangeEnd = 0;
|
||||
fileOffset = false;
|
||||
mValidateThread = new GotoDialogValidateThread(this);
|
||||
connect(this, SIGNAL(finished(int)), this, SLOT(finishedSlot(int)));
|
||||
}
|
||||
|
|
@ -57,6 +58,24 @@ void GotoDialog::validateExpression()
|
|||
ui->buttonOk->setEnabled(false);
|
||||
expressionText.clear();
|
||||
}
|
||||
else if(fileOffset)
|
||||
{
|
||||
uint_t offset = DbgValFromString(expression.toUtf8().constData());
|
||||
uint_t va = DbgFunctions()->FileOffsetToVa(modName.toUtf8().constData(), offset);
|
||||
if(va)
|
||||
{
|
||||
QString addrText = QString("%1").arg(va, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
|
||||
ui->labelError->setText(QString("<font color='#00DD00'><b>Correct expression! -> </b></font>" + addrText));
|
||||
ui->buttonOk->setEnabled(true);
|
||||
expressionText = expression;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->labelError->setText("<font color='red'><b>Invalid file offset...</b></font>");
|
||||
ui->buttonOk->setEnabled(false);
|
||||
expressionText.clear();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uint_t addr = DbgValFromString(expression.toUtf8().constData());
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ public:
|
|||
QString expressionText;
|
||||
uint_t validRangeStart;
|
||||
uint_t validRangeEnd;
|
||||
bool fileOffset;
|
||||
QString modName;
|
||||
void showEvent(QShowEvent* event);
|
||||
void hideEvent(QHideEvent* event);
|
||||
void validateExpression();
|
||||
|
|
|
|||
Loading…
Reference in New Issue