work save
This commit is contained in:
parent
66da8f2df8
commit
ffadc81dff
|
@ -41,7 +41,7 @@ void Debugger::start()
|
|||
}
|
||||
mReader = new DebugReader(this);
|
||||
mReader->setDebuggerPath(debuggerPath);
|
||||
connect(mReader, &QThread::finished,this,&Debugger::stop);
|
||||
connect(mReader, &QThread::finished,this,&Debugger::clearUpReader);
|
||||
connect(mReader, &DebugReader::parseFinished,this,&Debugger::syncFinishedParsing,Qt::BlockingQueuedConnection);
|
||||
connect(mReader, &DebugReader::changeDebugConsoleLastLine,this,&Debugger::onChangeDebugConsoleLastline,Qt::BlockingQueuedConnection);
|
||||
mReader->start();
|
||||
|
@ -65,16 +65,20 @@ void Debugger::start()
|
|||
|
||||
//Application.HintHidePause := 5000;
|
||||
}
|
||||
|
||||
void Debugger::stop()
|
||||
void Debugger::stop() {
|
||||
if (mExecuting) {
|
||||
mReader->stopDebug();
|
||||
}
|
||||
}
|
||||
void Debugger::clearUpReader()
|
||||
{
|
||||
if (mExecuting) {
|
||||
mExecuting = false;
|
||||
|
||||
//stop debugger
|
||||
mReader->stopDebug();
|
||||
mReader->deleteLater();
|
||||
mReader=nullptr;
|
||||
|
||||
// if WatchVarList.Count = 0 then // nothing worth showing, restore view
|
||||
// MainForm.LeftPageControl.ActivePageIndex := LeftPageIndexBackup;
|
||||
|
||||
|
@ -1229,6 +1233,7 @@ void DebugReader::run()
|
|||
}
|
||||
if (mStop) {
|
||||
mProcess->terminate();
|
||||
break;
|
||||
}
|
||||
if (errorOccurred)
|
||||
break;
|
||||
|
@ -1430,3 +1435,124 @@ const QList<PTrace> &BacktraceModel::backtraces() const
|
|||
{
|
||||
return mList;
|
||||
}
|
||||
|
||||
QModelIndex WatchModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (!hasIndex(row,column,parent))
|
||||
return QModelIndex();
|
||||
|
||||
WatchVar* parentItem;
|
||||
PWatchVar pChild;
|
||||
if (!parent.isValid()) {
|
||||
parentItem = nullptr;
|
||||
pChild = mWatchVars[row];
|
||||
} else {
|
||||
parentItem = static_cast<WatchVar*>(parent.internalPointer());
|
||||
pChild = parentItem->children[row];
|
||||
}
|
||||
if (pChild)
|
||||
return createIndex(row,column,pChild.get());
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
static int getWatchIndex(WatchVar* var, const QList<PWatchVar> list) {
|
||||
for (int i=0;i<list.size();i++) {
|
||||
PWatchVar v = list[i];
|
||||
if (v.get() == var) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex WatchModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid()) {
|
||||
return QModelIndex();
|
||||
}
|
||||
WatchVar* childItem = static_cast<WatchVar*>(index.internalPointer());
|
||||
WatchVar* parentItem =childItem->parent;
|
||||
|
||||
//parent is root
|
||||
if (parentItem == nullptr) {
|
||||
return QModelIndex();
|
||||
}
|
||||
int row;
|
||||
WatchVar* grandItem = parentItem->parent;
|
||||
if (grandItem == nullptr) {
|
||||
row = getWatchIndex(parentItem,mWatchVars);
|
||||
} else {
|
||||
row = getWatchIndex(parentItem,grandItem->children);
|
||||
}
|
||||
return createIndex(row,0,parentItem);
|
||||
}
|
||||
|
||||
int WatchModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (!parent.isValid()) {
|
||||
return mWatchVars.count();
|
||||
} else {
|
||||
WatchVar* parentItem = static_cast<WatchVar*>(parent.internalPointer());
|
||||
return parentItem->children.count();
|
||||
}
|
||||
}
|
||||
|
||||
int WatchModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void WatchModel::addWatchVar(PWatchVar watchVar)
|
||||
{
|
||||
for (PWatchVar var:mWatchVars) {
|
||||
if (watchVar->name == var->name) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
mWatchVars.append(watchVar);
|
||||
}
|
||||
|
||||
void WatchModel::removeWatchVar(const QString &name)
|
||||
{
|
||||
for (PWatchVar var:mWatchVars) {
|
||||
if (name == var->name) {
|
||||
mWatchVars.removeOne(var);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WatchModel::removeWatchVar(int gdbIndex)
|
||||
{
|
||||
for (PWatchVar var:mWatchVars) {
|
||||
if (gdbIndex == var->gdbIndex) {
|
||||
mWatchVars.removeOne(var);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WatchModel::clear()
|
||||
{
|
||||
mWatchVars.clear();
|
||||
}
|
||||
|
||||
QList<PWatchVar> &WatchModel::watchVars()
|
||||
{
|
||||
return mWatchVars;
|
||||
}
|
||||
|
||||
PWatchVar WatchModel::findWatchVar(const QString &name)
|
||||
{
|
||||
for (PWatchVar var:mWatchVars) {
|
||||
if (name == var->name) {
|
||||
return var;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PWatchVar WatchModel::findWatchVar(int gdbIndex)
|
||||
{
|
||||
for (PWatchVar var:mWatchVars) {
|
||||
if (gdbIndex == var->gdbIndex) {
|
||||
return var;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,13 +48,17 @@ struct DebugCommand{
|
|||
};
|
||||
|
||||
using PDebugCommand = std::shared_ptr<DebugCommand>;
|
||||
|
||||
struct WatchVar;
|
||||
using PWatchVar = std::shared_ptr<WatchVar>;
|
||||
struct WatchVar {
|
||||
QString name;
|
||||
QString text;
|
||||
QString value;
|
||||
int gdbIndex;
|
||||
QList<PWatchVar> children;
|
||||
WatchVar * parent; //use raw point to prevent circular-reference
|
||||
};
|
||||
|
||||
using PWatchVar = std::shared_ptr<WatchVar>;
|
||||
|
||||
struct Breakpoint {
|
||||
int line;
|
||||
|
@ -99,6 +103,7 @@ private:
|
|||
};
|
||||
|
||||
class BacktraceModel : public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
// QAbstractItemModel interface
|
||||
public:
|
||||
explicit BacktraceModel(QObject *parent = nullptr);
|
||||
|
@ -114,6 +119,31 @@ private:
|
|||
QList<PTrace> mList;
|
||||
};
|
||||
|
||||
class WatchModel: public QAbstractItemModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const override;
|
||||
|
||||
QModelIndex index(int row, int column,
|
||||
const QModelIndex &parent = QModelIndex()) const override;
|
||||
QModelIndex parent(const QModelIndex &index) const override;
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
void addWatchVar(PWatchVar watchVar);
|
||||
void removeWatchVar(const QString& name);
|
||||
void removeWatchVar(int gdbIndex);
|
||||
void clear();
|
||||
const QList<PWatchVar>& watchVars();
|
||||
PWatchVar findWatchVar(const QString& name);
|
||||
PWatchVar findWatchVar(int gdbIndex);
|
||||
private:
|
||||
QList<PWatchVar> mWatchVars;
|
||||
};
|
||||
|
||||
|
||||
class DebugReader;
|
||||
class Editor;
|
||||
|
@ -181,6 +211,7 @@ private:
|
|||
private slots:
|
||||
void syncFinishedParsing();
|
||||
void onChangeDebugConsoleLastline(const QString& text);
|
||||
void clearUpReader();
|
||||
private:
|
||||
bool mExecuting;
|
||||
bool mCommandChanged;
|
||||
|
|
|
@ -1294,3 +1294,80 @@ bool MainWindow::debugInferiorhasBreakpoint()
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MainWindow::on_actionStep_Over_triggered()
|
||||
{
|
||||
if (mDebugger->executing()) {
|
||||
//WatchView.Items.BeginUpdate();
|
||||
mDebugger->invalidateAllVars();
|
||||
mDebugger->sendCommand("next", "");
|
||||
mDebugger->updateDebugInfo();
|
||||
// if (CPUForm) then
|
||||
// CPUForm.UpdateInfo;
|
||||
//WatchView.Items.EndUpdate();
|
||||
//fDebugger.RefreshWatchVars;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionStep_Into_triggered()
|
||||
{
|
||||
if (mDebugger->executing()) {
|
||||
//WatchView.Items.BeginUpdate();
|
||||
mDebugger->invalidateAllVars();
|
||||
mDebugger->sendCommand("step", "");
|
||||
mDebugger->updateDebugInfo();
|
||||
// if (CPUForm) then
|
||||
// CPUForm.UpdateInfo;
|
||||
//WatchView.Items.EndUpdate();
|
||||
//fDebugger.RefreshWatchVars;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::on_actionStep_Out_triggered()
|
||||
{
|
||||
if (mDebugger->executing()) {
|
||||
//WatchView.Items.BeginUpdate();
|
||||
mDebugger->invalidateAllVars();
|
||||
mDebugger->sendCommand("finish", "");
|
||||
mDebugger->updateDebugInfo();
|
||||
// if (CPUForm) then
|
||||
// CPUForm.UpdateInfo;
|
||||
//WatchView.Items.EndUpdate();
|
||||
//fDebugger.RefreshWatchVars;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::on_actionRun_To_Cursor_triggered()
|
||||
{
|
||||
if (mDebugger->executing()) {
|
||||
Editor *e=mEditorList->getEditor();
|
||||
if (e!=nullptr) {
|
||||
//WatchView.Items.BeginUpdate();
|
||||
mDebugger->invalidateAllVars();
|
||||
mDebugger->sendCommand("tbreak", QString(" %1").arg(e->caretY()));
|
||||
mDebugger->sendCommand("continue", "");
|
||||
mDebugger->updateDebugInfo();
|
||||
// if (CPUForm) then
|
||||
// CPUForm.UpdateInfo;
|
||||
//WatchView.Items.EndUpdate();
|
||||
//fDebugger.RefreshWatchVars;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::on_actionContinue_triggered()
|
||||
{
|
||||
if (mDebugger->executing()) {
|
||||
//WatchView.Items.BeginUpdate();
|
||||
mDebugger->invalidateAllVars();
|
||||
mDebugger->sendCommand("continue", "");
|
||||
mDebugger->updateDebugInfo();
|
||||
// if (CPUForm) then
|
||||
// CPUForm.UpdateInfo;
|
||||
//WatchView.Items.EndUpdate();
|
||||
//fDebugger.RefreshWatchVars;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,6 +141,16 @@ private slots:
|
|||
CompileTarget getCompileTarget();
|
||||
bool debugInferiorhasBreakpoint();
|
||||
|
||||
void on_actionStep_Over_triggered();
|
||||
|
||||
void on_actionStep_Into_triggered();
|
||||
|
||||
void on_actionStep_Out_triggered();
|
||||
|
||||
void on_actionRun_To_Cursor_triggered();
|
||||
|
||||
void on_actionContinue_triggered();
|
||||
|
||||
public slots:
|
||||
void onCompileLog(const QString& msg);
|
||||
void onCompileIssue(PCompileIssue issue);
|
||||
|
|
|
@ -551,6 +551,11 @@
|
|||
<addaction name="actionCompile_Run"/>
|
||||
<addaction name="actionRebuild"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionDebug"/>
|
||||
<addaction name="actionStep_Over"/>
|
||||
<addaction name="actionStep_Into"/>
|
||||
<addaction name="actionRun_To_Cursor"/>
|
||||
<addaction name="actionContinue"/>
|
||||
<addaction name="actionStop_Execution"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuEdit">
|
||||
|
@ -631,6 +636,10 @@
|
|||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionDebug"/>
|
||||
<addaction name="actionStep_Over"/>
|
||||
<addaction name="actionStep_Into"/>
|
||||
<addaction name="actionStep_Out"/>
|
||||
<addaction name="actionContinue"/>
|
||||
<addaction name="actionStop_Execution"/>
|
||||
</widget>
|
||||
<action name="actionNew">
|
||||
|
@ -915,6 +924,9 @@
|
|||
<property name="text">
|
||||
<string>Stop Execution</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F6</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDebug">
|
||||
<property name="icon">
|
||||
|
@ -931,6 +943,66 @@
|
|||
<string>F5</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionStep_Over">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/images/newlook24/028-Debug-StepOver.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Step Over</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F7</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionStep_Into">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/images/newlook24/024-Debug-StepInto.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Step Into</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F8</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionStep_Out">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/images/newlook24/026-Debug-StepOut.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Step Out</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+F8</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRun_To_Cursor">
|
||||
<property name="text">
|
||||
<string>Run To Cursor</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+F5</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionContinue">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/images/newlook24/021-Debug-Continue.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Continue</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F4</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
Loading…
Reference in New Issue