Commit 63dac82a authored by hjk's avatar hjk Committed by Eike Ziller

debugger: re-enable interrupting in remote setups

Change-Id: I6d4503ec78e3ce590691dde69992a1599b506fc5
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@nokia.com>
(cherry picked from commit 0e865710)
Reviewed-by: default avatarEike Ziller <eike.ziller@nokia.com>
parent ace2b806
...@@ -874,7 +874,9 @@ void DebuggerEngine::notifyInferiorRunRequested() ...@@ -874,7 +874,9 @@ void DebuggerEngine::notifyInferiorRunRequested()
void DebuggerEngine::notifyInferiorRunOk() void DebuggerEngine::notifyInferiorRunOk()
{ {
showMessage(_("NOTE: INFERIOR RUN OK")); showMessage(_("NOTE: INFERIOR RUN OK"));
QTC_ASSERT(state() == InferiorRunRequested, qDebug() << this << state()); // Transition from StopRequested can happen sin remotegdbadapter.
QTC_ASSERT(state() == InferiorRunRequested
|| state() == InferiorStopRequested, qDebug() << this << state());
setState(InferiorRunOk); setState(InferiorRunOk);
} }
......
...@@ -54,6 +54,7 @@ public: ...@@ -54,6 +54,7 @@ public:
virtual bool waitForStarted() = 0; virtual bool waitForStarted() = 0;
virtual qint64 write(const QByteArray &data) = 0; virtual qint64 write(const QByteArray &data) = 0;
virtual void kill() = 0; virtual void kill() = 0;
virtual bool interrupt() = 0;
virtual QProcess::ProcessState state() const = 0; virtual QProcess::ProcessState state() const = 0;
virtual QString errorString() const = 0; virtual QString errorString() const = 0;
...@@ -63,8 +64,6 @@ public: ...@@ -63,8 +64,6 @@ public:
virtual void setEnvironment(const QStringList &env) = 0; virtual void setEnvironment(const QStringList &env) = 0;
virtual void setWorkingDirectory(const QString &dir) = 0; virtual void setWorkingDirectory(const QString &dir) = 0;
virtual ~AbstractGdbProcess() {}
signals: signals:
void error(QProcess::ProcessError); void error(QProcess::ProcessError);
void finished(int exitCode, QProcess::ExitStatus exitStatus); void finished(int exitCode, QProcess::ExitStatus exitStatus);
......
...@@ -32,6 +32,14 @@ ...@@ -32,6 +32,14 @@
#include "localgdbprocess.h" #include "localgdbprocess.h"
#include <utils/qtcassert.h>
#ifdef Q_OS_UNIX
#include <errno.h>
#include <signal.h>
#include <string.h>
#endif
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
...@@ -77,6 +85,20 @@ void LocalGdbProcess::kill() ...@@ -77,6 +85,20 @@ void LocalGdbProcess::kill()
m_gdbProc.kill(); m_gdbProc.kill();
} }
bool LocalGdbProcess::interrupt()
{
#ifdef Q_OS_UNIX
Q_PID pid = m_gdbProc.pid();
int res = ::kill(pid, SIGINT);
if (res != 0)
m_errorString = QString::fromLocal8Bit(strerror(errno));
return res == 0;
#else
QTC_ASSERT(false, "NOT IMPLEMENTED");
return false;
#endif
}
QProcess::ProcessState LocalGdbProcess::state() const QProcess::ProcessState LocalGdbProcess::state() const
{ {
return m_gdbProc.state(); return m_gdbProc.state();
...@@ -84,7 +106,7 @@ QProcess::ProcessState LocalGdbProcess::state() const ...@@ -84,7 +106,7 @@ QProcess::ProcessState LocalGdbProcess::state() const
QString LocalGdbProcess::errorString() const QString LocalGdbProcess::errorString() const
{ {
return m_gdbProc.errorString(); return m_errorString + m_gdbProc.errorString();
} }
QProcessEnvironment LocalGdbProcess::processEnvironment() const QProcessEnvironment LocalGdbProcess::processEnvironment() const
......
...@@ -50,6 +50,7 @@ public: ...@@ -50,6 +50,7 @@ public:
virtual bool waitForStarted(); virtual bool waitForStarted();
virtual qint64 write(const QByteArray &data); virtual qint64 write(const QByteArray &data);
virtual void kill(); virtual void kill();
virtual bool interrupt();
virtual QProcess::ProcessState state() const; virtual QProcess::ProcessState state() const;
virtual QString errorString() const; virtual QString errorString() const;
...@@ -61,6 +62,7 @@ public: ...@@ -61,6 +62,7 @@ public:
private: private:
QProcess m_gdbProc; QProcess m_gdbProc;
QString m_errorString;
}; };
} // namespace Internal } // namespace Internal
......
...@@ -237,6 +237,11 @@ void RemoteGdbProcess::kill() ...@@ -237,6 +237,11 @@ void RemoteGdbProcess::kill()
} }
} }
bool RemoteGdbProcess::interrupt()
{
return false;
}
void RemoteGdbProcess::interruptInferior() void RemoteGdbProcess::interruptInferior()
{ {
QTC_ASSERT(m_state == RunningGdb, return); QTC_ASSERT(m_state == RunningGdb, return);
......
...@@ -60,6 +60,7 @@ public: ...@@ -60,6 +60,7 @@ public:
virtual bool waitForStarted(); virtual bool waitForStarted();
virtual qint64 write(const QByteArray &data); virtual qint64 write(const QByteArray &data);
virtual void kill(); virtual void kill();
virtual bool interrupt();
virtual QProcess::ProcessState state() const; virtual QProcess::ProcessState state() const;
virtual QString errorString() const; virtual QString errorString() const;
......
...@@ -274,8 +274,15 @@ void RemoteGdbServerAdapter::runEngine() ...@@ -274,8 +274,15 @@ void RemoteGdbServerAdapter::runEngine()
void RemoteGdbServerAdapter::interruptInferior() void RemoteGdbServerAdapter::interruptInferior()
{ {
QTC_ASSERT(state() == InferiorStopRequested, qDebug() << state()); QTC_ASSERT(state() == InferiorStopRequested, qDebug() << state());
m_engine->postCommand("-exec-interrupt", GdbEngine::Immediate, //m_engine->postCommand("-exec-interrupt", GdbEngine::Immediate,
CB(handleInterruptInferior)); // CB(handleInterruptInferior));
bool ok = m_gdbProc.interrupt();
if (!ok) {
// FIXME: Extra state needed?
m_engine->showMessage(_("NOTE: INFERIOR STOP NOT POSSIBLE"));
m_engine->showStatusMessage(tr("Interrupting not possible"));
m_engine->notifyInferiorRunOk();
}
} }
void RemoteGdbServerAdapter::handleInterruptInferior(const GdbResponse &response) void RemoteGdbServerAdapter::handleInterruptInferior(const GdbResponse &response)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment