GUI: "Open Source File" in CPUDisassembly context menu
This commit is contained in:
parent
03b0d8b971
commit
8b6f1b4670
|
|
@ -370,9 +370,9 @@ void Bridge::emitSymbolRefreshCurrent()
|
|||
emit symbolRefreshCurrent();
|
||||
}
|
||||
|
||||
void Bridge::emitLoadSourceFile(const QString path, int line)
|
||||
void Bridge::emitLoadSourceFile(const QString path, int line, int selection)
|
||||
{
|
||||
emit loadSourceFile(path, line);
|
||||
emit loadSourceFile(path, line, selection);
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public:
|
|||
void emitUpdatePatches();
|
||||
void emitUpdateCallStack();
|
||||
void emitSymbolRefreshCurrent();
|
||||
void emitLoadSourceFile(const QString path, int line = 0);
|
||||
void emitLoadSourceFile(const QString path, int line = 0, int selection = 0);
|
||||
|
||||
//Public variables
|
||||
void* winId;
|
||||
|
|
@ -149,7 +149,7 @@ signals:
|
|||
void updatePatches();
|
||||
void updateCallStack();
|
||||
void symbolRefreshCurrent();
|
||||
void loadSourceFile(const QString path, int line);
|
||||
void loadSourceFile(const QString path, int line, int selection);
|
||||
|
||||
private:
|
||||
QMutex* mBridgeMutex;
|
||||
|
|
|
|||
|
|
@ -244,6 +244,8 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event)
|
|||
wMenu->addMenu(mBPMenu);
|
||||
wMenu->addMenu(mFollowMenu);
|
||||
setupFollowReferenceMenu(wVA, mFollowMenu, false);
|
||||
if(DbgFunctions()->GetSourceFromAddr(wVA, 0, 0))
|
||||
wMenu->addAction(mOpenSource);
|
||||
wMenu->addAction(mEnableHighlightingMode);
|
||||
wMenu->addSeparator();
|
||||
|
||||
|
|
@ -501,6 +503,10 @@ void CPUDisassembly::setupRightClickContextMenu()
|
|||
mCopyMenu->addAction(mCopyAddress);
|
||||
mCopyMenu->addAction(mCopyDisassembly);
|
||||
|
||||
// Open Source file
|
||||
mOpenSource = new QAction(QIcon(":/icons/images/source.png"), "Open Source File", this);
|
||||
connect(mOpenSource, SIGNAL(triggered()), this, SLOT(openSource()));
|
||||
|
||||
|
||||
//-------------------- Find references to -----------------------
|
||||
// Menu
|
||||
|
|
@ -1314,3 +1320,13 @@ void CPUDisassembly::findCommand()
|
|||
|
||||
emit displayReferencesWidget();
|
||||
}
|
||||
|
||||
void CPUDisassembly::openSource()
|
||||
{
|
||||
char szSourceFile[MAX_STRING_SIZE] = "";
|
||||
int line = 0;
|
||||
if(!DbgFunctions()->GetSourceFromAddr(rvaToVa(getInitialSelection()), szSourceFile, &line))
|
||||
return;
|
||||
Bridge::getBridge()->emitLoadSourceFile(szSourceFile, 0, line);
|
||||
emit displaySourceManagerWidget();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "Disassembly.h"
|
||||
#include "GotoDialog.h"
|
||||
#include "SourceViewerManager.h"
|
||||
|
||||
class CPUDisassembly : public Disassembly
|
||||
{
|
||||
|
|
@ -25,6 +26,7 @@ public:
|
|||
|
||||
signals:
|
||||
void displayReferencesWidget();
|
||||
void displaySourceManagerWidget();
|
||||
void showPatches();
|
||||
|
||||
public slots:
|
||||
|
|
@ -69,9 +71,9 @@ public slots:
|
|||
void copyAddress();
|
||||
void copyDisassembly();
|
||||
void findCommand();
|
||||
void openSource();
|
||||
|
||||
private:
|
||||
|
||||
// Menus
|
||||
QMenu* mBinaryMenu;
|
||||
QMenu* mGotoMenu;
|
||||
|
|
@ -121,6 +123,7 @@ private:
|
|||
QAction* mCopySelectionNoBytes;
|
||||
QAction* mCopyAddress;
|
||||
QAction* mCopyDisassembly;
|
||||
QAction* mOpenSource;
|
||||
|
||||
GotoDialog* mGoto;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -203,6 +203,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||
connect(ui->actionChangeCommandLine, SIGNAL(triggered()), this, SLOT(changeCommandLine()));
|
||||
|
||||
connect(mCpuWidget->mDisas, SIGNAL(displayReferencesWidget()), this, SLOT(displayReferencesWidget()));
|
||||
connect(mCpuWidget->mDisas, SIGNAL(displaySourceManagerWidget()), this, SLOT(displaySourceViewWidget()));
|
||||
connect(mCpuWidget->mDisas, SIGNAL(showPatches()), this, SLOT(patchWindow()));
|
||||
connect(mCpuWidget->mDump, SIGNAL(displayReferencesWidget()), this, SLOT(displayReferencesWidget()));
|
||||
connect(mCpuWidget->mStack, SIGNAL(displayReferencesWidget()), this, SLOT(displayReferencesWidget()));
|
||||
|
|
|
|||
|
|
@ -36,6 +36,14 @@ void SourceView::setupContextMenu()
|
|||
connect(mFollowInDisasm, SIGNAL(triggered()), this, SLOT(followInDisasmSlot()));
|
||||
}
|
||||
|
||||
void SourceView::setSelection(int line)
|
||||
{
|
||||
int offset = line - 1;
|
||||
if(isValidIndex(offset, 0))
|
||||
setSingleSelection(offset);
|
||||
reloadData(); //repaint
|
||||
}
|
||||
|
||||
void SourceView::setInstructionPointer(int line)
|
||||
{
|
||||
int offset = line - 1;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ public:
|
|||
void setInstructionPointer(int line);
|
||||
QString paintContent(QPainter* painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h);
|
||||
void setupContextMenu();
|
||||
void setSelection(int line);
|
||||
|
||||
signals:
|
||||
void showCpu();
|
||||
|
|
|
|||
|
|
@ -16,19 +16,25 @@ SourceViewerManager::SourceViewerManager(QWidget* parent) : QTabWidget(parent)
|
|||
setCornerWidget(mCloseAllTabs, Qt::TopLeftCorner);
|
||||
|
||||
connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
|
||||
connect(Bridge::getBridge(), SIGNAL(loadSourceFile(QString, int)), this, SLOT(loadSourceFile(QString, int)));
|
||||
connect(Bridge::getBridge(), SIGNAL(loadSourceFile(QString, int, int)), this, SLOT(loadSourceFile(QString, int, int)));
|
||||
}
|
||||
|
||||
void SourceViewerManager::loadSourceFile(QString path, int line)
|
||||
void SourceViewerManager::loadSourceFile(QString path, int line, int selection)
|
||||
{
|
||||
for(int i = 0; i < count(); i++) //remove all other instruction pointers (only one is possible)
|
||||
((SourceView*)this->widget(i))->setInstructionPointer(0);
|
||||
if(!selection)
|
||||
{
|
||||
for(int i = 0; i < count(); i++) //remove all other instruction pointers (only one is possible)
|
||||
((SourceView*)this->widget(i))->setInstructionPointer(0);
|
||||
}
|
||||
for(int i = 0; i < count(); i++)
|
||||
{
|
||||
SourceView* curView = (SourceView*)this->widget(i);
|
||||
if(curView->getSourcePath().compare(path, Qt::CaseInsensitive) == 0) //file already loaded
|
||||
{
|
||||
curView->setInstructionPointer(line);
|
||||
if(selection)
|
||||
curView->setSelection(selection);
|
||||
else
|
||||
curView->setInstructionPointer(line);
|
||||
setCurrentIndex(i); //show that loaded tab
|
||||
return;
|
||||
}
|
||||
|
|
@ -45,6 +51,11 @@ void SourceViewerManager::loadSourceFile(QString path, int line)
|
|||
title = path.mid(idx + 1);
|
||||
SourceView* newView = new SourceView(path, line);
|
||||
connect(newView, SIGNAL(showCpu()), this, SIGNAL(showCpu()));
|
||||
if(selection)
|
||||
{
|
||||
newView->setInstructionPointer(0);
|
||||
newView->setSelection(selection);
|
||||
}
|
||||
addTab(newView, title);
|
||||
setCurrentIndex(count() - 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public:
|
|||
explicit SourceViewerManager(QWidget* parent = 0);
|
||||
|
||||
public slots:
|
||||
void loadSourceFile(QString path, int line);
|
||||
void loadSourceFile(QString path, int line, int selection = 0);
|
||||
void closeTab(int index);
|
||||
void closeAllTabs();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue