Skip to content

Commit a48a45b

Browse files
committed
Add warning when problems with GDB
1 parent a9a7ada commit a48a45b

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

debugger.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Debugger::Debugger(QTextEdit *tEdit,
6262
: QObject(parent)
6363
{
6464
QSettings settings("SASM Project", "SASM");
65+
gdbRun = false;
6566
c = 0;
6667
pid = 0;
6768
firstAction = true;
@@ -128,6 +129,10 @@ Debugger::Debugger(QTextEdit *tEdit,
128129
bufferTimer = new QTimer;
129130
QObject::connect(bufferTimer, SIGNAL(timeout()), this, SLOT(processOutput()), Qt::QueuedConnection);
130131
bufferTimer->start(10);
132+
133+
checkGdbRunTimer = new QTimer;
134+
QObject::connect(checkGdbRunTimer, SIGNAL(timeout()), this, SLOT(checkGdbRun()), Qt::QueuedConnection);
135+
checkGdbRunTimer->start(10000);
131136
}
132137

133138
void Debugger::emitStarted()
@@ -161,6 +166,15 @@ void Debugger::processOutput()
161166
bufferTimer->start(10);
162167
}
163168

169+
void Debugger::checkGdbRun()
170+
{
171+
checkGdbRunTimer->stop();
172+
if (!gdbRun) {
173+
emit printLog(tr("GDB error\n"), Qt::red);
174+
emit finished();
175+
}
176+
}
177+
164178
void Debugger::processMessage(QString output, QString error)
165179
{
166180
if (error.indexOf("PC register is not available") != -1) {
@@ -375,6 +389,7 @@ void Debugger::processAction(QString output, QString error)
375389
return;
376390
} else { //if found highlight and print it
377391
//highlight line number
392+
gdbRun = true;
378393
emit highlightLine(lineNumber);
379394
stopped = true;
380395
emit wasStopped();

debugger.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ class Debugger : public QObject
120120
QVector<LineNum> lines;
121121
//! Counter for sequential performing of actions
122122
int c;
123+
123124
bool registersOk;
125+
126+
//! Flag for checking if gdb run
127+
bool gdbRun;
128+
124129
//! Queue of actions type from enum
125130
QQueue<DebugActionType> actionTypeQueue;
126131

@@ -148,6 +153,9 @@ class Debugger : public QObject
148153
//! Timer for checking output and sending ready output to processing with Debugger::processOutput() function
149154
QTimer *bufferTimer;
150155

156+
//! Timer for run checking
157+
QTimer *checkGdbRunTimer;
158+
151159
//! The number of variable watches
152160
int watchesCount;
153161

@@ -176,6 +184,7 @@ public slots:
176184
void doInput(QString command, DebugActionType actionType);
177185
void changeBreakpoint(quint64 lineNumber, bool isAdded);
178186
void emitStarted();
187+
void checkGdbRun();
179188

180189
signals:
181190
//! Highlight the current debug line.

0 commit comments

Comments
 (0)