forked from qt-creator/qt-creator
		
	debugger: re-enable interrupting in remote setups
Change-Id: I6d4503ec78e3ce590691dde69992a1599b506fc5 Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
		@@ -54,6 +54,7 @@ public:
 | 
			
		||||
    virtual bool waitForStarted() = 0;
 | 
			
		||||
    virtual qint64 write(const QByteArray &data) = 0;
 | 
			
		||||
    virtual void kill() = 0;
 | 
			
		||||
    virtual bool interrupt() = 0;
 | 
			
		||||
 | 
			
		||||
    virtual QProcess::ProcessState state() const = 0;
 | 
			
		||||
    virtual QString errorString() const = 0;
 | 
			
		||||
@@ -63,8 +64,6 @@ public:
 | 
			
		||||
    virtual void setEnvironment(const QStringList &env) = 0;
 | 
			
		||||
    virtual void setWorkingDirectory(const QString &dir) = 0;
 | 
			
		||||
 | 
			
		||||
    virtual ~AbstractGdbProcess() {}
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
    void error(QProcess::ProcessError);
 | 
			
		||||
    void finished(int exitCode, QProcess::ExitStatus exitStatus);
 | 
			
		||||
 
 | 
			
		||||
@@ -32,6 +32,14 @@
 | 
			
		||||
 | 
			
		||||
#include "localgdbprocess.h"
 | 
			
		||||
 | 
			
		||||
#include <utils/qtcassert.h>
 | 
			
		||||
 | 
			
		||||
#ifdef Q_OS_UNIX
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
namespace Debugger {
 | 
			
		||||
namespace Internal {
 | 
			
		||||
 | 
			
		||||
@@ -77,6 +85,20 @@ void LocalGdbProcess::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
 | 
			
		||||
{
 | 
			
		||||
    return m_gdbProc.state();
 | 
			
		||||
@@ -84,7 +106,7 @@ QProcess::ProcessState LocalGdbProcess::state() const
 | 
			
		||||
 | 
			
		||||
QString LocalGdbProcess::errorString() const
 | 
			
		||||
{
 | 
			
		||||
    return m_gdbProc.errorString();
 | 
			
		||||
    return m_errorString + m_gdbProc.errorString();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QProcessEnvironment LocalGdbProcess::processEnvironment() const
 | 
			
		||||
 
 | 
			
		||||
@@ -50,6 +50,7 @@ public:
 | 
			
		||||
    virtual bool waitForStarted();
 | 
			
		||||
    virtual qint64 write(const QByteArray &data);
 | 
			
		||||
    virtual void kill();
 | 
			
		||||
    virtual bool interrupt();
 | 
			
		||||
 | 
			
		||||
    virtual QProcess::ProcessState state() const;
 | 
			
		||||
    virtual QString errorString() const;
 | 
			
		||||
@@ -61,6 +62,7 @@ public:
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    QProcess m_gdbProc;
 | 
			
		||||
    QString m_errorString;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
} // namespace Internal
 | 
			
		||||
 
 | 
			
		||||
@@ -237,6 +237,11 @@ void RemoteGdbProcess::kill()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool RemoteGdbProcess::interrupt()
 | 
			
		||||
{
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void RemoteGdbProcess::interruptInferior()
 | 
			
		||||
{
 | 
			
		||||
    QTC_ASSERT(m_state == RunningGdb, return);
 | 
			
		||||
 
 | 
			
		||||
@@ -60,6 +60,7 @@ public:
 | 
			
		||||
    virtual bool waitForStarted();
 | 
			
		||||
    virtual qint64 write(const QByteArray &data);
 | 
			
		||||
    virtual void kill();
 | 
			
		||||
    virtual bool interrupt();
 | 
			
		||||
 | 
			
		||||
    virtual QProcess::ProcessState state() const;
 | 
			
		||||
    virtual QString errorString() const;
 | 
			
		||||
 
 | 
			
		||||
@@ -274,8 +274,15 @@ void RemoteGdbServerAdapter::runEngine()
 | 
			
		||||
void RemoteGdbServerAdapter::interruptInferior()
 | 
			
		||||
{
 | 
			
		||||
    QTC_ASSERT(state() == InferiorStopRequested, qDebug() << state());
 | 
			
		||||
    m_engine->postCommand("-exec-interrupt", GdbEngine::Immediate,
 | 
			
		||||
        CB(handleInterruptInferior));
 | 
			
		||||
    //m_engine->postCommand("-exec-interrupt", GdbEngine::Immediate,
 | 
			
		||||
    //    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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user