Commit 994075dd authored by hjk's avatar hjk

Debugger: Merge {Abstract,Local}GdbProcess to GdbProcess

Change-Id: I46e8b4347205791eeb6ebd3ebbde9a993d892e93
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@digia.com>
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent c260d7cd
...@@ -112,14 +112,13 @@ QtcPlugin { ...@@ -112,14 +112,13 @@ QtcPlugin {
name: "gdb" name: "gdb"
prefix: "gdb/" prefix: "gdb/"
files: [ files: [
"abstractgdbprocess.cpp", "abstractgdbprocess.h",
"attachgdbadapter.cpp", "attachgdbadapter.h", "attachgdbadapter.cpp", "attachgdbadapter.h",
"classicgdbengine.cpp", "classicgdbengine.cpp",
"coregdbadapter.cpp", "coregdbadapter.h", "coregdbadapter.cpp", "coregdbadapter.h",
"gdb.qrc", "gdb.qrc",
"gdbengine.cpp", "gdbengine.h", "gdbengine.cpp", "gdbengine.h",
"gdboptionspage.cpp", "gdboptionspage.h", "gdboptionspage.cpp", "gdboptionspage.h",
"localgdbprocess.cpp", "localgdbprocess.h", "gdbprocess.cpp", "gdbprocess.h",
"gdbplainengine.cpp", "gdbplainengine.h", "gdbplainengine.cpp", "gdbplainengine.h",
"pythongdbengine.cpp", "pythongdbengine.cpp",
"remotegdbserveradapter.cpp", "remotegdbserveradapter.h", "remotegdbserveradapter.cpp", "remotegdbserveradapter.h",
......
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "abstractgdbprocess.h"
namespace Debugger {
namespace Internal {
} // namespace Internal
} // namespace Debugger
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef ABSTRACTGDBPROCESS_H
#define ABSTRACTGDBPROCESS_H
#include <QProcess>
namespace Debugger {
namespace Internal {
class AbstractGdbProcess : public QObject
{
Q_OBJECT
protected:
explicit AbstractGdbProcess(QObject *parent = 0) : QObject(parent) {}
public:
virtual QByteArray readAllStandardOutput() = 0;
virtual QByteArray readAllStandardError() = 0;
virtual void start(const QString &cmd, const QStringList &args) = 0;
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;
virtual QProcessEnvironment processEnvironment() const = 0;
virtual void setProcessEnvironment(const QProcessEnvironment &env) = 0;
virtual void setEnvironment(const QStringList &env) = 0;
virtual void setWorkingDirectory(const QString &dir) = 0;
signals:
void error(QProcess::ProcessError);
void finished(int exitCode, QProcess::ExitStatus exitStatus);
void readyReadStandardError();
void readyReadStandardOutput();
};
} // namespace Internal
} // namespace Debugger
#endif // ABSTRACTGDBPROCESS_H
...@@ -60,9 +60,9 @@ void GdbAttachEngine::setupEngine() ...@@ -60,9 +60,9 @@ void GdbAttachEngine::setupEngine()
showMessage(_("TRYING TO START ADAPTER")); showMessage(_("TRYING TO START ADAPTER"));
if (!startParameters().workingDirectory.isEmpty()) if (!startParameters().workingDirectory.isEmpty())
m_gdbProc.setWorkingDirectory(startParameters().workingDirectory); m_gdbProc->setWorkingDirectory(startParameters().workingDirectory);
if (startParameters().environment.size()) if (startParameters().environment.size())
m_gdbProc.setEnvironment(startParameters().environment.toStringList()); m_gdbProc->setEnvironment(startParameters().environment.toStringList());
startGdb(); startGdb();
} }
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#define DEBUGGER_ATTACHGDBADAPTER_H #define DEBUGGER_ATTACHGDBADAPTER_H
#include "gdbengine.h" #include "gdbengine.h"
#include "localgdbprocess.h" #include "gdbprocess.h"
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
...@@ -58,10 +58,7 @@ private: ...@@ -58,10 +58,7 @@ private:
void interruptInferior2(); void interruptInferior2();
void shutdownEngine(); void shutdownEngine();
AbstractGdbProcess *gdbProc() { return &m_gdbProc; }
void handleAttach(const GdbResponse &response); void handleAttach(const GdbResponse &response);
LocalGdbProcess m_gdbProc;
}; };
} // namespace Internal } // namespace Internal
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#define DEBUGGER_COREGDBADAPTER_H #define DEBUGGER_COREGDBADAPTER_H
#include "gdbengine.h" #include "gdbengine.h"
#include "localgdbprocess.h"
#include <QFile> #include <QFile>
...@@ -61,8 +60,6 @@ private: ...@@ -61,8 +60,6 @@ private:
void interruptInferior(); void interruptInferior();
void shutdownEngine(); void shutdownEngine();
AbstractGdbProcess *gdbProc() { return &m_gdbProc; }
void handleFileExecAndSymbols(const GdbResponse &response); void handleFileExecAndSymbols(const GdbResponse &response);
void handleTargetCore(const GdbResponse &response); void handleTargetCore(const GdbResponse &response);
void handleRoundTrip(const GdbResponse &response); void handleRoundTrip(const GdbResponse &response);
...@@ -78,7 +75,6 @@ private slots: ...@@ -78,7 +75,6 @@ private slots:
private: private:
QString m_executable; QString m_executable;
QString m_coreName; QString m_coreName;
LocalGdbProcess m_gdbProc;
QString m_tempCoreName; QString m_tempCoreName;
QProcess *m_coreUnpackProcess; QProcess *m_coreUnpackProcess;
QFile m_tempCoreFile; QFile m_tempCoreFile;
......
...@@ -6,8 +6,7 @@ HEADERS += \ ...@@ -6,8 +6,7 @@ HEADERS += \
$$PWD/termgdbadapter.h \ $$PWD/termgdbadapter.h \
$$PWD/remotegdbserveradapter.h \ $$PWD/remotegdbserveradapter.h \
$$PWD/gdbplainengine.h \ $$PWD/gdbplainengine.h \
$$PWD/localgdbprocess.h \ $$PWD/gdbprocess.h \
$$PWD/abstractgdbprocess.h \
$$PWD/startgdbserverdialog.h $$PWD/startgdbserverdialog.h
SOURCES += \ SOURCES += \
...@@ -19,8 +18,7 @@ SOURCES += \ ...@@ -19,8 +18,7 @@ SOURCES += \
$$PWD/coregdbadapter.cpp \ $$PWD/coregdbadapter.cpp \
$$PWD/termgdbadapter.cpp \ $$PWD/termgdbadapter.cpp \
$$PWD/remotegdbserveradapter.cpp \ $$PWD/remotegdbserveradapter.cpp \
$$PWD/abstractgdbprocess.cpp \ $$PWD/gdbprocess.cpp \
$$PWD/localgdbprocess.cpp \
$$PWD/gdbplainengine.cpp \ $$PWD/gdbplainengine.cpp \
$$PWD/startgdbserverdialog.cpp $$PWD/startgdbserverdialog.cpp
......
...@@ -245,6 +245,7 @@ GdbEngine::GdbEngine(const DebuggerStartParameters &startParameters) ...@@ -245,6 +245,7 @@ GdbEngine::GdbEngine(const DebuggerStartParameters &startParameters)
m_systemDumpersLoaded = false; m_systemDumpersLoaded = false;
m_forceAsyncModel = false; m_forceAsyncModel = false;
m_pythonAttemptedToLoad = false; m_pythonAttemptedToLoad = false;
m_gdbProc = new GdbProcess(this);
invalidateSourcesList(); invalidateSourcesList();
...@@ -311,6 +312,11 @@ QString GdbEngine::errorMessage(QProcess::ProcessError error) ...@@ -311,6 +312,11 @@ QString GdbEngine::errorMessage(QProcess::ProcessError error)
} }
} }
GdbProcess *GdbEngine::gdbProc() const
{
return m_gdbProc;
}
#if 0 #if 0
static void dump(const char *first, const char *middle, const QString & to) static void dump(const char *first, const char *middle, const QString & to)
{ {
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
class AbstractGdbProcess; class GdbProcess;
class DebugInfoTask; class DebugInfoTask;
class DebugInfoTaskHandler; class DebugInfoTaskHandler;
class GdbResponse; class GdbResponse;
...@@ -650,7 +650,7 @@ protected: ...@@ -650,7 +650,7 @@ protected:
// Convenience Functions // Convenience Functions
// //
QString errorMessage(QProcess::ProcessError error); QString errorMessage(QProcess::ProcessError error);
AbstractGdbProcess *gdbProc() const; GdbProcess *gdbProc() const;
void showExecutionError(const QString &message); void showExecutionError(const QString &message);
static QByteArray tooltipIName(const QString &exp); static QByteArray tooltipIName(const QString &exp);
...@@ -722,12 +722,13 @@ protected: ...@@ -722,12 +722,13 @@ protected:
virtual void write(const QByteArray &data); virtual void write(const QByteArray &data);
virtual AbstractGdbProcess *gdbProc() = 0;
virtual DumperHandling dumperHandling() const = 0; virtual DumperHandling dumperHandling() const = 0;
protected: protected:
bool prepareCommand(); bool prepareCommand();
void interruptLocalInferior(qint64 pid); void interruptLocalInferior(qint64 pid);
GdbProcess *m_gdbProc;
}; };
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
****************************************************************************/ ****************************************************************************/
#include "gdbplainengine.h" #include "gdbplainengine.h"
#include "gdbprocess.h"
#include <debugger/debuggeractions.h> #include <debugger/debuggeractions.h>
#include <debugger/debuggercore.h> #include <debugger/debuggercore.h>
...@@ -133,9 +134,9 @@ void GdbPlainEngine::setupEngine() ...@@ -133,9 +134,9 @@ void GdbPlainEngine::setupEngine()
gdbArgs.append(_("--tty=") + m_outputCollector.serverName()); gdbArgs.append(_("--tty=") + m_outputCollector.serverName());
if (!startParameters().workingDirectory.isEmpty()) if (!startParameters().workingDirectory.isEmpty())
m_gdbProc.setWorkingDirectory(startParameters().workingDirectory); m_gdbProc->setWorkingDirectory(startParameters().workingDirectory);
if (startParameters().environment.size()) if (startParameters().environment.size())
m_gdbProc.setEnvironment(startParameters().environment.toStringList()); m_gdbProc->setEnvironment(startParameters().environment.toStringList());
startGdb(gdbArgs); startGdb(gdbArgs);
} }
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#define GDBPLAINENGINE_H #define GDBPLAINENGINE_H
#include "gdbengine.h" #include "gdbengine.h"
#include "localgdbprocess.h"
#include <debugger/outputcollector.h> #include <debugger/outputcollector.h>
namespace Debugger { namespace Debugger {
...@@ -57,14 +56,12 @@ private: ...@@ -57,14 +56,12 @@ private:
void shutdownEngine(); void shutdownEngine();
DumperHandling dumperHandling() const; DumperHandling dumperHandling() const;
AbstractGdbProcess *gdbProc() { return &m_gdbProc; }
QByteArray execFilePath() const; QByteArray execFilePath() const;
QByteArray toLocalEncoding(const QString &s) const; QByteArray toLocalEncoding(const QString &s) const;
QString fromLocalEncoding(const QByteArray &b) const; QString fromLocalEncoding(const QByteArray &b) const;
OutputCollector m_outputCollector; OutputCollector m_outputCollector;
LocalGdbProcess m_gdbProc;
}; };
} // namespace Debugger } // namespace Debugger
......
...@@ -27,17 +27,15 @@ ...@@ -27,17 +27,15 @@
** **
****************************************************************************/ ****************************************************************************/
#include "localgdbprocess.h" #include "gdbprocess.h"
#include <debugger/procinterrupt.h>
#include <debugger/debuggerconstants.h> #include <debugger/debuggerconstants.h>
#include <debugger/procinterrupt.h>
#include <utils/qtcprocess.h>
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
LocalGdbProcess::LocalGdbProcess(QObject *parent) : AbstractGdbProcess(parent) GdbProcess::GdbProcess(QObject *parent) : QObject(parent)
{ {
connect(&m_gdbProc, SIGNAL(error(QProcess::ProcessError)), connect(&m_gdbProc, SIGNAL(error(QProcess::ProcessError)),
this, SIGNAL(error(QProcess::ProcessError))); this, SIGNAL(error(QProcess::ProcessError)));
...@@ -49,84 +47,85 @@ LocalGdbProcess::LocalGdbProcess(QObject *parent) : AbstractGdbProcess(parent) ...@@ -49,84 +47,85 @@ LocalGdbProcess::LocalGdbProcess(QObject *parent) : AbstractGdbProcess(parent)
this, SIGNAL(readyReadStandardError())); this, SIGNAL(readyReadStandardError()));
} }
QByteArray LocalGdbProcess::readAllStandardOutput() QByteArray GdbProcess::readAllStandardOutput()
{ {
return m_gdbProc.readAllStandardOutput(); return m_gdbProc.readAllStandardOutput();
} }
QByteArray LocalGdbProcess::readAllStandardError() QByteArray GdbProcess::readAllStandardError()
{ {
return m_gdbProc.readAllStandardError(); return m_gdbProc.readAllStandardError();
} }
void LocalGdbProcess::start(const QString &cmd, const QStringList &args) void GdbProcess::start(const QString &cmd, const QStringList &args)
{ {
m_gdbProc.setCommand(cmd, Utils::QtcProcess::joinArgs(args)); m_gdbProc.setCommand(cmd, Utils::QtcProcess::joinArgs(args));
m_gdbProc.start(); m_gdbProc.start();
} }
bool LocalGdbProcess::waitForStarted() bool GdbProcess::waitForStarted()
{ {
return m_gdbProc.waitForStarted(); return m_gdbProc.waitForStarted();
} }
qint64 LocalGdbProcess::write(const QByteArray &data) qint64 GdbProcess::write(const QByteArray &data)
{ {
return m_gdbProc.write(data); return m_gdbProc.write(data);
} }
void LocalGdbProcess::kill() void GdbProcess::kill()
{ {
m_gdbProc.kill(); m_gdbProc.kill();
} }
bool LocalGdbProcess::interrupt() bool GdbProcess::interrupt()
{ {
long pid = Utils::qPidToPid(m_gdbProc.pid()); long pid = Utils::qPidToPid(m_gdbProc.pid());
return interruptProcess(pid, GdbEngineType, &m_errorString); return interruptProcess(pid, GdbEngineType, &m_errorString);
} }
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
void LocalGdbProcess::setUseCtrlCStub(bool enable) void GdbProcess::setUseCtrlCStub(bool enable)
{ {
m_gdbProc.setUseCtrlCStub(enable); m_gdbProc.setUseCtrlCStub(enable);
} }
void LocalGdbProcess::winInterruptByCtrlC() void GdbProcess::winInterruptByCtrlC()
{ {
m_gdbProc.interrupt(); m_gdbProc.interrupt();
} }
#endif #endif
QProcess::ProcessState LocalGdbProcess::state() const QProcess::ProcessState GdbProcess::state() const
{ {
return m_gdbProc.state(); return m_gdbProc.state();
} }
QString LocalGdbProcess::errorString() const QString GdbProcess::errorString() const
{ {
return m_errorString + m_gdbProc.errorString(); return m_errorString + m_gdbProc.errorString();
} }
QProcessEnvironment LocalGdbProcess::processEnvironment() const QProcessEnvironment GdbProcess::processEnvironment() const
{ {
return m_gdbProc.processEnvironment(); return m_gdbProc.processEnvironment();
} }
void LocalGdbProcess::setProcessEnvironment(const QProcessEnvironment &env) void GdbProcess::setProcessEnvironment(const QProcessEnvironment &env)
{ {
m_gdbProc.setProcessEnvironment(env); m_gdbProc.setProcessEnvironment(env);
} }
void LocalGdbProcess::setEnvironment(const QStringList &env) void GdbProcess::setEnvironment(const QStringList &env)
{ {
m_gdbProc.setEnvironment(Utils::Environment(env)); m_gdbProc.setEnvironment(Utils::Environment(env));
} }
void LocalGdbProcess::setWorkingDirectory(const QString &dir) void GdbProcess::setWorkingDirectory(const QString &dir)
{ {
m_gdbProc.setWorkingDirectory(dir); m_gdbProc.setWorkingDirectory(dir);
} }
} // namespace Internal } // namespace Internal
} // namespace Debugger } // namespace Debugger
...@@ -27,41 +27,47 @@ ...@@ -27,41 +27,47 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef LOCALGDBPROCESS_H #ifndef GDBPROCESS_H
#define LOCALGDBPROCESS_H #define GDBPROCESS_H
#include "abstractgdbprocess.h"
#include <utils/qtcprocess.h> #include <utils/qtcprocess.h>
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
class LocalGdbProcess : public AbstractGdbProcess class GdbProcess : public QObject
{ {