DBG: added test commands "refinit" and "refadd" (maybe for a reference searching script?)
GUI: more generic searching in SearchListView GUI: ReferenceView now uses signals GUI: added ReferenceView menu entry (+shortcut)
This commit is contained in:
parent
a3eed0f80d
commit
e813969f72
|
@ -10,6 +10,8 @@
|
|||
#include "memory.h"
|
||||
#include "x64_dbg.h"
|
||||
|
||||
static bool bRefinit=false;
|
||||
|
||||
CMDRESULT cbBadCmd(int argc, char* argv[])
|
||||
{
|
||||
uint value=0;
|
||||
|
@ -702,3 +704,35 @@ CMDRESULT cbInstrXor(int argc, char* argv[])
|
|||
return cmddirectexec(dbggetcommandlist(), newcmd);
|
||||
}
|
||||
|
||||
CMDRESULT cbInstrRefinit(int argc, char* argv[])
|
||||
{
|
||||
GuiReferenceDeleteAllColumns();
|
||||
GuiReferenceAddColumn(sizeof(uint)*2, "Address");
|
||||
GuiReferenceAddColumn(0, "Data");
|
||||
GuiReferenceSetRowCount(0);
|
||||
GuiReferenceReloadData();
|
||||
bRefinit=true;
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
CMDRESULT cbInstrRefadd(int argc, char* argv[])
|
||||
{
|
||||
if(argc<3)
|
||||
{
|
||||
dputs("not enough arguments!");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
uint addr=0;
|
||||
if(!valfromstring(argv[1], &addr, false))
|
||||
return STATUS_ERROR;
|
||||
if(!bRefinit)
|
||||
cbInstrRefinit(argc, argv);
|
||||
int index=GuiReferenceGetRowCount();
|
||||
GuiReferenceSetRowCount(index+1);
|
||||
char addr_text[deflen]="";
|
||||
sprintf(addr_text, fhex, addr);
|
||||
GuiReferenceSetCellContent(index, 0, addr_text);
|
||||
GuiReferenceSetCellContent(index, 1, argv[2]);
|
||||
GuiReferenceReloadData();
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
|
|
@ -41,4 +41,7 @@ CMDRESULT cbInstrShr(int argc, char* argv[]);
|
|||
CMDRESULT cbInstrSub(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrTest(int argc, char* argv[]);
|
||||
|
||||
CMDRESULT cbInstrRefinit(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrRefadd(int argc, char* argv[]);
|
||||
|
||||
#endif // _INSTRUCTIONS_H
|
||||
|
|
|
@ -139,6 +139,9 @@ static void registercommands()
|
|||
|
||||
cmdnew(cmd, "dump", cbDebugDump, true); //dump at address
|
||||
cmdnew(cmd, "printf", cbPrintf, false); //printf
|
||||
|
||||
cmdnew(cmd, "refinit", cbInstrRefinit, false);
|
||||
cmdnew(cmd, "refadd", cbInstrRefadd, false);
|
||||
}
|
||||
|
||||
static bool cbCommandProvider(char* cmd, int maxlen)
|
||||
|
|
|
@ -2,17 +2,8 @@
|
|||
|
||||
ReferenceView::ReferenceView()
|
||||
{
|
||||
// Get font information
|
||||
QFont wFont("Monospace", 8);
|
||||
wFont.setStyleHint(QFont::Monospace);
|
||||
wFont.setFixedPitch(true);
|
||||
int charwidth=QFontMetrics(wFont).width(QChar(' '));
|
||||
|
||||
// Setup example list
|
||||
mList->addColumnAt(charwidth*2*sizeof(int_t)+8, "Address", true);
|
||||
mList->addColumnAt(0, "Data", true);
|
||||
mSearchList->addColumnAt(charwidth*2*sizeof(int_t)+8, "Address", true);
|
||||
mSearchList->addColumnAt(0, "Data", true);
|
||||
// Setup SearchListView settings
|
||||
mSearchStartCol = 1;
|
||||
|
||||
// Create search progress bar
|
||||
mSearchProgress = new QProgressBar();
|
||||
|
@ -22,4 +13,58 @@ ReferenceView::ReferenceView()
|
|||
|
||||
// Add the progress bar to the main layout
|
||||
mMainLayout->addWidget(mSearchProgress);
|
||||
|
||||
// Setup signals
|
||||
connect(Bridge::getBridge(), SIGNAL(referenceAddColumnAt(int,QString)), this, SLOT(addColumnAt(int,QString)));
|
||||
connect(Bridge::getBridge(), SIGNAL(referenceSetRowCount(int_t)), this, SLOT(setRowCount(int_t)));
|
||||
connect(Bridge::getBridge(), SIGNAL(referenceDeleteAllColumns()), this, SLOT(deleteAllColumns()));
|
||||
connect(Bridge::getBridge(), SIGNAL(referenceSetCellContent(int,int,QString)), this, SLOT(setCellContent(int,int,QString)));
|
||||
connect(Bridge::getBridge(), SIGNAL(referenceReloadData()), this, SLOT(reloadData()));
|
||||
connect(Bridge::getBridge(), SIGNAL(referenceSetSingleSelection(int,bool)), this, SLOT(setSingleSelection(int,bool)));
|
||||
}
|
||||
|
||||
void ReferenceView::addColumnAt(int width, QString title)
|
||||
{
|
||||
QFont wFont("Monospace", 8);
|
||||
wFont.setStyleHint(QFont::Monospace);
|
||||
wFont.setFixedPitch(true);
|
||||
int charwidth=QFontMetrics(wFont).width(QChar(' '));
|
||||
if(width)
|
||||
width=charwidth*width+8;
|
||||
else
|
||||
width=0;
|
||||
mSearchBox->setText("");
|
||||
mList->addColumnAt(width, title, true);
|
||||
mSearchList->addColumnAt(width, title, true);
|
||||
}
|
||||
|
||||
void ReferenceView::setRowCount(int_t count)
|
||||
{
|
||||
mSearchBox->setText("");
|
||||
mList->setRowCount(count);
|
||||
}
|
||||
|
||||
void ReferenceView::deleteAllColumns()
|
||||
{
|
||||
mList->deleteAllColumns();
|
||||
}
|
||||
|
||||
void ReferenceView::setCellContent(int r, int c, QString s)
|
||||
{
|
||||
mSearchBox->setText("");
|
||||
mList->setCellContent(r, c, s);
|
||||
}
|
||||
|
||||
void ReferenceView::reloadData()
|
||||
{
|
||||
mSearchBox->setText("");
|
||||
mList->reloadData();
|
||||
}
|
||||
|
||||
void ReferenceView::setSingleSelection(int index, bool scroll)
|
||||
{
|
||||
mSearchBox->setText("");
|
||||
mList->setSingleSelection(index);
|
||||
if(scroll) //TODO: better scrolling
|
||||
mList->setTableOffset(index);
|
||||
}
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
#ifndef REFERENCEVIEW_H
|
||||
#define REFERENCEVIEW_H
|
||||
|
||||
#include "SearchListView.h"
|
||||
#include <QProgressBar>
|
||||
#include "SearchListView.h"
|
||||
#include "Bridge.h"
|
||||
|
||||
class ReferenceView : public SearchListView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ReferenceView();
|
||||
|
||||
private slots:
|
||||
void addColumnAt(int width, QString title);
|
||||
void setRowCount(int_t count);
|
||||
void deleteAllColumns();
|
||||
void setCellContent(int r, int c, QString s);
|
||||
void reloadData();
|
||||
void setSingleSelection(int index, bool scroll);
|
||||
|
||||
private:
|
||||
QProgressBar* mSearchProgress;
|
||||
};
|
||||
|
|
|
@ -19,6 +19,7 @@ SearchListView::SearchListView(QWidget *parent) :
|
|||
// Set global variables
|
||||
mSearchBox = ui->searchBox;
|
||||
mCurList = mList;
|
||||
mSearchStartCol = 0;
|
||||
|
||||
// Create list layout
|
||||
mListLayout = new QVBoxLayout();
|
||||
|
@ -82,6 +83,26 @@ void SearchListView::listKeyPressed(QKeyEvent* event)
|
|||
emit enterPressedSignal();
|
||||
}
|
||||
|
||||
bool SearchListView::findTextInList(StdTable* list, QString text, int row, int startcol, bool startswith)
|
||||
{
|
||||
int count=list->getColumnCount();
|
||||
if(startcol+1>count)
|
||||
return false;
|
||||
if(startswith)
|
||||
{
|
||||
for(int i=startcol; i<count; i++)
|
||||
if(list->getCellContent(row, i).startsWith(text, Qt::CaseInsensitive))
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i=startcol; i<count; i++)
|
||||
if(list->getCellContent(row, i).contains(text, Qt::CaseInsensitive))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SearchListView::searchTextChanged(const QString &arg1)
|
||||
{
|
||||
if(arg1.length())
|
||||
|
@ -101,7 +122,8 @@ void SearchListView::searchTextChanged(const QString &arg1)
|
|||
int count=mList->getRowCount();
|
||||
for(int i=0,j=0; i<count; i++)
|
||||
{
|
||||
if(mList->getCellContent(i, 1).contains(arg1, Qt::CaseInsensitive) || mList->getCellContent(i, 2).contains(arg1, Qt::CaseInsensitive))
|
||||
if(findTextInList(mList, arg1, i, mSearchStartCol, false))
|
||||
//if(mList->getCellContent(i, 1).contains(arg1, Qt::CaseInsensitive) || mList->getCellContent(i, 2).contains(arg1, Qt::CaseInsensitive))
|
||||
{
|
||||
mSearchList->setRowCount(j+1);
|
||||
mSearchList->setCellContent(j, 0, mList->getCellContent(i, 0));
|
||||
|
@ -114,7 +136,8 @@ void SearchListView::searchTextChanged(const QString &arg1)
|
|||
mSearchList->setTableOffset(0);
|
||||
for(int i=0; i<count; i++)
|
||||
{
|
||||
if(mSearchList->getCellContent(i, 1).startsWith(arg1, Qt::CaseInsensitive) || mSearchList->getCellContent(i, 2).startsWith(arg1, Qt::CaseInsensitive))
|
||||
if(findTextInList(mSearchList, arg1, i, mSearchStartCol, true))
|
||||
//if(mSearchList->getCellContent(i, 1).startsWith(arg1, Qt::CaseInsensitive) || mSearchList->getCellContent(i, 2).startsWith(arg1, Qt::CaseInsensitive))
|
||||
{
|
||||
if(count>mSearchList->getViewableRowsCount())
|
||||
{
|
||||
|
|
|
@ -23,6 +23,9 @@ public:
|
|||
StdTable* mSearchList;
|
||||
StdTable* mCurList;
|
||||
QLineEdit* mSearchBox;
|
||||
int mSearchStartCol;
|
||||
|
||||
bool findTextInList(StdTable* list, QString text, int row, int startcol, bool startswith);
|
||||
|
||||
private slots:
|
||||
void searchTextChanged(const QString &arg1);
|
||||
|
|
|
@ -15,6 +15,7 @@ SymbolView::SymbolView(QWidget *parent) :
|
|||
|
||||
// Create reference view
|
||||
mSearchListView = new SearchListView();
|
||||
mSearchListView->mSearchStartCol = 1;
|
||||
|
||||
// Get font information
|
||||
QFont wFont("Monospace", 8);
|
||||
|
|
|
@ -170,91 +170,34 @@ void Bridge::emitSetSymbolProgress(int progress)
|
|||
emit setSymbolProgress(progress);
|
||||
}
|
||||
|
||||
void Bridge::emitAddColumnAt(StdTable* table, int width, QString title, bool isClickable)
|
||||
{
|
||||
table->addColumnAt(width, title, isClickable);
|
||||
}
|
||||
|
||||
void Bridge::emitSetRowCount(StdTable* table, int_t count)
|
||||
{
|
||||
table->setRowCount(count);
|
||||
}
|
||||
|
||||
int_t Bridge::emitGetRowCount(StdTable* table)
|
||||
{
|
||||
return table->getRowCount();
|
||||
}
|
||||
|
||||
void Bridge::emitDeleteAllColumns(StdTable* table)
|
||||
{
|
||||
table->deleteAllColumns();
|
||||
}
|
||||
|
||||
void Bridge::emitSetCellContent(StdTable* table, int r, int c, QString s)
|
||||
{
|
||||
table->setCellContent(r, c, s);
|
||||
}
|
||||
|
||||
const char* Bridge::emitGetCellContent(StdTable* table, int r, int c)
|
||||
{
|
||||
return table->getCellContent(r, c).toUtf8().constData(); //TODO: fix this
|
||||
}
|
||||
|
||||
void Bridge::emitReloadData(StdTable* table)
|
||||
{
|
||||
table->reloadData();
|
||||
}
|
||||
|
||||
void Bridge::emitSetSingleSelection(StdTable* table, int index, bool scroll)
|
||||
{
|
||||
table->setSingleSelection(index);
|
||||
if(scroll) //TODO: better scrolling
|
||||
table->setTableOffset(index);
|
||||
}
|
||||
|
||||
void Bridge::emitReferenceAddColumnAt(int width, QString title)
|
||||
{
|
||||
referenceView->mSearchBox->setText("");
|
||||
emitAddColumnAt(referenceView->mList, width, title, true);
|
||||
emit referenceAddColumnAt(width, title);
|
||||
}
|
||||
|
||||
void Bridge::emitReferenceSetRowCount(int_t count)
|
||||
{
|
||||
referenceView->mSearchBox->setText("");
|
||||
emitSetRowCount(referenceView->mList, count);
|
||||
}
|
||||
|
||||
int_t Bridge::emitReferenceGetRowCount()
|
||||
{
|
||||
return emitGetRowCount(referenceView->mList);
|
||||
emit referenceSetRowCount(count);
|
||||
}
|
||||
|
||||
void Bridge::emitReferenceDeleteAllColumns()
|
||||
{
|
||||
referenceView->mSearchBox->setText("");
|
||||
emitDeleteAllColumns(referenceView->mList);
|
||||
emit referenceDeleteAllColumns();
|
||||
}
|
||||
|
||||
void Bridge::emitReferenceSetCellContent(int r, int c, QString s)
|
||||
{
|
||||
referenceView->mSearchBox->setText("");
|
||||
emitSetCellContent(referenceView->mList, r, c, s);
|
||||
}
|
||||
|
||||
const char* Bridge::emitReferenceGetCellContent(int r, int c)
|
||||
{
|
||||
return emitGetCellContent(referenceView->mList, r, c);
|
||||
emit referenceSetCellContent(r, c, s);
|
||||
}
|
||||
|
||||
void Bridge::emitReferenceReloadData()
|
||||
{
|
||||
emitReloadData(referenceView->mList);
|
||||
emit referenceReloadData();
|
||||
}
|
||||
|
||||
void Bridge::emitReferenceSetSingleSelection(int index, bool scroll)
|
||||
{
|
||||
referenceView->mSearchBox->setText("");
|
||||
emitSetSingleSelection(referenceView->mList, index, scroll);
|
||||
emit referenceSetSingleSelection(index, scroll);
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
|
@ -441,7 +384,7 @@ __declspec(dllexport) void* _gui_sendmessage(GUIMSG type, void* param1, void* pa
|
|||
|
||||
case GUI_REF_GETROWCOUNT:
|
||||
{
|
||||
return (void*)Bridge::getBridge()->emitReferenceGetRowCount();
|
||||
return (void*)Bridge::getBridge()->referenceView->mList->getRowCount();
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -460,7 +403,7 @@ __declspec(dllexport) void* _gui_sendmessage(GUIMSG type, void* param1, void* pa
|
|||
|
||||
case GUI_REF_GETCELLCONTENT:
|
||||
{
|
||||
return (void*)Bridge::getBridge()->emitReferenceGetCellContent((int)(int_t)param1, (int)(int_t)param2);
|
||||
return (void*)Bridge::getBridge()->referenceView->mList->getCellContent((int)(int_t)param1, (int)(int_t)param2).toUtf8().constData();
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -51,21 +51,10 @@ public:
|
|||
void emitClearSymbolLog();
|
||||
void emitSetSymbolProgress(int progress);
|
||||
|
||||
void emitAddColumnAt(StdTable* table, int width, QString title, bool isClickable);
|
||||
void emitSetRowCount(StdTable* table, int_t count);
|
||||
int_t emitGetRowCount(StdTable* table);
|
||||
void emitDeleteAllColumns(StdTable* table);
|
||||
void emitSetCellContent(StdTable* table, int r, int c, QString s);
|
||||
const char* emitGetCellContent(StdTable* table, int r, int c);
|
||||
void emitReloadData(StdTable* table);
|
||||
void emitSetSingleSelection(StdTable* table, int index, bool scroll);
|
||||
|
||||
void emitReferenceAddColumnAt(int width, QString title);
|
||||
void emitReferenceSetRowCount(int_t count);
|
||||
int_t emitReferenceGetRowCount();
|
||||
void emitReferenceDeleteAllColumns();
|
||||
void emitReferenceSetCellContent(int r, int c, QString s);
|
||||
const char* emitReferenceGetCellContent(int r, int c);
|
||||
void emitReferenceReloadData();
|
||||
void emitReferenceSetSingleSelection(int index, bool scroll);
|
||||
|
||||
|
@ -102,6 +91,13 @@ signals:
|
|||
void clearSymbolLog();
|
||||
void setSymbolProgress(int progress);
|
||||
|
||||
void referenceAddColumnAt(int width, QString title);
|
||||
void referenceSetRowCount(int_t count);
|
||||
void referenceDeleteAllColumns();
|
||||
void referenceSetCellContent(int r, int c, QString s);
|
||||
void referenceReloadData();
|
||||
void referenceSetSingleSelection(int index, bool scroll);
|
||||
|
||||
private:
|
||||
QMutex mBridgeMutex;
|
||||
|
||||
|
|
|
@ -118,6 +118,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||
connect(ui->actionCpu,SIGNAL(triggered()),this,SLOT(displayCpuWidget()));
|
||||
connect(ui->actionSymbolInfo,SIGNAL(triggered()),this,SLOT(displaySymbolWidget()));
|
||||
connect(mSymbolView,SIGNAL(showCpu()),this,SLOT(displayCpuWidget()));
|
||||
connect(ui->actionReferences,SIGNAL(triggered()),this,SLOT(displayReferencesWidget()));
|
||||
|
||||
connect(Bridge::getBridge(), SIGNAL(updateWindowTitle(QString)), this, SLOT(updateWindowTitleSlot(QString)));
|
||||
connect(Bridge::getBridge(), SIGNAL(updateCPUTitle(QString)), this, SLOT(updateCPUTitleSlot(QString)));
|
||||
|
@ -493,3 +494,10 @@ void MainWindow::displaySymbolWidget()
|
|||
mSymbolView->setFocus();
|
||||
setTab(mSymbolView);
|
||||
}
|
||||
|
||||
void MainWindow::displayReferencesWidget()
|
||||
{
|
||||
mReferenceView->show();
|
||||
mReferenceView->setFocus();
|
||||
setTab(mReferenceView);
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ public slots:
|
|||
void execeRtr();
|
||||
void displayCpuWidget();
|
||||
void displaySymbolWidget();
|
||||
void displayReferencesWidget();
|
||||
|
||||
private slots:
|
||||
void on_actionGoto_triggered();
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
<addaction name="actionBreakpoints"/>
|
||||
<addaction name="actionScript"/>
|
||||
<addaction name="actionSymbolInfo"/>
|
||||
<addaction name="actionReferences"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuDebug">
|
||||
<property name="title">
|
||||
|
@ -123,6 +124,7 @@
|
|||
<addaction name="actionMemoryMap"/>
|
||||
<addaction name="actionScript"/>
|
||||
<addaction name="actionSymbolInfo"/>
|
||||
<addaction name="actionReferences"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionScylla"/>
|
||||
</widget>
|
||||
|
@ -441,6 +443,21 @@
|
|||
<string>Ctrl+Alt+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionReferences">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resource.qrc">
|
||||
<normaloff>:/icons/images/search.png</normaloff>:/icons/images/search.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>References</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>References</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Alt+R</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
|
|
Loading…
Reference in New Issue