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 {
name: "gdb"
prefix: "gdb/"
files: [
"abstractgdbprocess.cpp", "abstractgdbprocess.h",
"attachgdbadapter.cpp", "attachgdbadapter.h",
"classicgdbengine.cpp",
"coregdbadapter.cpp", "coregdbadapter.h",
"gdb.qrc",
"gdbengine.cpp", "gdbengine.h",
"gdboptionspage.cpp", "gdboptionspage.h",
"localgdbprocess.cpp", "localgdbprocess.h",
"gdbprocess.cpp", "gdbprocess.h",
"gdbplainengine.cpp", "gdbplainengine.h",
"pythongdbengine.cpp",
"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()
showMessage(_("TRYING TO START ADAPTER"));
if (!startParameters().workingDirectory.isEmpty())
m_gdbProc.setWorkingDirectory(startParameters().workingDirectory);
m_gdbProc->setWorkingDirectory(startParameters().workingDirectory);
if (startParameters().environment.size())
m_gdbProc.setEnvironment(startParameters().environment.toStringList());
m_gdbProc->setEnvironment(startParameters().environment.toStringList());
startGdb();
}
......
......@@ -31,7 +31,7 @@
#define DEBUGGER_ATTACHGDBADAPTER_H
#include "gdbengine.h"
#include "localgdbprocess.h"
#include "gdbprocess.h"
namespace Debugger {
namespace Internal {
......@@ -58,10 +58,7 @@ private:
void interruptInferior2();
void shutdownEngine();
AbstractGdbProcess *gdbProc() { return &m_gdbProc; }
void handleAttach(const GdbResponse &response);
LocalGdbProcess m_gdbProc;
};
} // namespace Internal
......
......@@ -31,7 +31,6 @@
#define DEBUGGER_COREGDBADAPTER_H
#include "gdbengine.h"
#include "localgdbprocess.h"
#include <QFile>
......@@ -61,8 +60,6 @@ private:
void interruptInferior();
void shutdownEngine();
AbstractGdbProcess *gdbProc() { return &m_gdbProc; }
void handleFileExecAndSymbols(const GdbResponse &response);
void handleTargetCore(const GdbResponse &response);
void handleRoundTrip(const GdbResponse &response);
......@@ -78,7 +75,6 @@ private slots:
private:
QString m_executable;
QString m_coreName;
LocalGdbProcess m_gdbProc;
QString m_tempCoreName;
QProcess *m_coreUnpackProcess;
QFile m_tempCoreFile;
......
......@@ -6,8 +6,7 @@ HEADERS += \
$$PWD/termgdbadapter.h \
$$PWD/remotegdbserveradapter.h \
$$PWD/gdbplainengine.h \
$$PWD/localgdbprocess.h \
$$PWD/abstractgdbprocess.h \
$$PWD/gdbprocess.h \
$$PWD/startgdbserverdialog.h
SOURCES += \
......@@ -19,8 +18,7 @@ SOURCES += \
$$PWD/coregdbadapter.cpp \
$$PWD/termgdbadapter.cpp \
$$PWD/remotegdbserveradapter.cpp \
$$PWD/abstractgdbprocess.cpp \
$$PWD/localgdbprocess.cpp \
$$PWD/gdbprocess.cpp \
$$PWD/gdbplainengine.cpp \
$$PWD/startgdbserverdialog.cpp
......
......@@ -245,6 +245,7 @@ GdbEngine::GdbEngine(const DebuggerStartParameters &startParameters)
m_systemDumpersLoaded = false;
m_forceAsyncModel = false;
m_pythonAttemptedToLoad = false;
m_gdbProc = new GdbProcess(this);
invalidateSourcesList();
......@@ -311,6 +312,11 @@ QString GdbEngine::errorMessage(QProcess::ProcessError error)
}
}
GdbProcess *GdbEngine::gdbProc() const
{
return m_gdbProc;
}
#if 0
static void dump(const char *first, const char *middle, const QString & to)
{
......
......@@ -45,7 +45,7 @@
namespace Debugger {
namespace Internal {
class AbstractGdbProcess;
class GdbProcess;
class DebugInfoTask;
class DebugInfoTaskHandler;
class GdbResponse;
......@@ -650,7 +650,7 @@ protected:
// Convenience Functions
//
QString errorMessage(QProcess::ProcessError error);
AbstractGdbProcess *gdbProc() const;
GdbProcess *gdbProc() const;
void showExecutionError(const QString &message);
static QByteArray tooltipIName(const QString &exp);
......@@ -722,12 +722,13 @@ protected:
virtual void write(const QByteArray &data);
virtual AbstractGdbProcess *gdbProc() = 0;
virtual DumperHandling dumperHandling() const = 0;
protected:
bool prepareCommand();
void interruptLocalInferior(qint64 pid);
GdbProcess *m_gdbProc;
};
......
......@@ -28,6 +28,7 @@
****************************************************************************/
#include "gdbplainengine.h"
#include "gdbprocess.h"
#include <debugger/debuggeractions.h>
#include <debugger/debuggercore.h>
......@@ -133,9 +134,9 @@ void GdbPlainEngine::setupEngine()
gdbArgs.append(_("--tty=") + m_outputCollector.serverName());
if (!startParameters().workingDirectory.isEmpty())
m_gdbProc.setWorkingDirectory(startParameters().workingDirectory);
m_gdbProc->setWorkingDirectory(startParameters().workingDirectory);
if (startParameters().environment.size())
m_gdbProc.setEnvironment(startParameters().environment.toStringList());
m_gdbProc->setEnvironment(startParameters().environment.toStringList());
startGdb(gdbArgs);
}
......
......@@ -31,7 +31,6 @@
#define GDBPLAINENGINE_H
#include "gdbengine.h"
#include "localgdbprocess.h"
#include <debugger/outputcollector.h>
namespace Debugger {
......@@ -57,14 +56,12 @@ private:
void shutdownEngine();
DumperHandling dumperHandling() const;
AbstractGdbProcess *gdbProc() { return &m_gdbProc; }
QByteArray execFilePath() const;
QByteArray toLocalEncoding(const QString &s) const;
QString fromLocalEncoding(const QByteArray &b) const;
OutputCollector m_outputCollector;
LocalGdbProcess m_gdbProc;
};
} // namespace Debugger
......
......@@ -27,17 +27,15 @@
**
****************************************************************************/
#include "localgdbprocess.h"
#include "gdbprocess.h"
#include <debugger/procinterrupt.h>
#include <debugger/debuggerconstants.h>
#include <utils/qtcprocess.h>
#include <debugger/procinterrupt.h>
namespace Debugger {
namespace Internal {
LocalGdbProcess::LocalGdbProcess(QObject *parent) : AbstractGdbProcess(parent)
GdbProcess::GdbProcess(QObject *parent) : QObject(parent)
{
connect(&m_gdbProc, SIGNAL(error(QProcess::ProcessError)),
this, SIGNAL(error(QProcess::ProcessError)));
......@@ -49,84 +47,85 @@ LocalGdbProcess::LocalGdbProcess(QObject *parent) : AbstractGdbProcess(parent)
this, SIGNAL(readyReadStandardError()));
}
QByteArray LocalGdbProcess::readAllStandardOutput()
QByteArray GdbProcess::readAllStandardOutput()
{
return m_gdbProc.readAllStandardOutput();
}
QByteArray LocalGdbProcess::readAllStandardError()
QByteArray GdbProcess::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.start();
}
bool LocalGdbProcess::waitForStarted()
bool GdbProcess::waitForStarted()
{
return m_gdbProc.waitForStarted();
}
qint64 LocalGdbProcess::write(const QByteArray &data)
qint64 GdbProcess::write(const QByteArray &data)
{
return m_gdbProc.write(data);
}
void LocalGdbProcess::kill()
void GdbProcess::kill()
{
m_gdbProc.kill();
}
bool LocalGdbProcess::interrupt()
bool GdbProcess::interrupt()
{
long pid = Utils::qPidToPid(m_gdbProc.pid());
return interruptProcess(pid, GdbEngineType, &m_errorString);
}
#ifdef Q_OS_WIN
void LocalGdbProcess::setUseCtrlCStub(bool enable)
void GdbProcess::setUseCtrlCStub(bool enable)
{
m_gdbProc.setUseCtrlCStub(enable);
}
void LocalGdbProcess::winInterruptByCtrlC()
void GdbProcess::winInterruptByCtrlC()
{
m_gdbProc.interrupt();
}
#endif
QProcess::ProcessState LocalGdbProcess::state() const
QProcess::ProcessState GdbProcess::state() const
{
return m_gdbProc.state();
}
QString LocalGdbProcess::errorString() const
QString GdbProcess::errorString() const
{
return m_errorString + m_gdbProc.errorString();
}
QProcessEnvironment LocalGdbProcess::processEnvironment() const
QProcessEnvironment GdbProcess::processEnvironment() const
{
return m_gdbProc.processEnvironment();
}
void LocalGdbProcess::setProcessEnvironment(const QProcessEnvironment &env)
void GdbProcess::setProcessEnvironment(const QProcessEnvironment &env)
{
m_gdbProc.setProcessEnvironment(env);
}
void LocalGdbProcess::setEnvironment(const QStringList &env)
void GdbProcess::setEnvironment(const QStringList &env)
{
m_gdbProc.setEnvironment(Utils::Environment(env));
}
void LocalGdbProcess::setWorkingDirectory(const QString &dir)
void GdbProcess::setWorkingDirectory(const QString &dir)
{
m_gdbProc.setWorkingDirectory(dir);
}
} // namespace Internal
} // namespace Debugger
......@@ -27,41 +27,47 @@
**
****************************************************************************/
#ifndef LOCALGDBPROCESS_H
#define LOCALGDBPROCESS_H
#include "abstractgdbprocess.h"
#ifndef GDBPROCESS_H
#define GDBPROCESS_H
#include <utils/qtcprocess.h>
namespace Debugger {
namespace Internal {
class LocalGdbProcess : public AbstractGdbProcess
class GdbProcess : public QObject
{
Q_OBJECT
public:
explicit LocalGdbProcess(QObject *parent = 0);
explicit GdbProcess(QObject *parent = 0);
virtual QByteArray readAllStandardOutput();
virtual QByteArray readAllStandardError();
QByteArray readAllStandardOutput();
QByteArray readAllStandardError();
virtual void start(const QString &cmd, const QStringList &args);
virtual bool waitForStarted();
virtual qint64 write(const QByteArray &data);
virtual void kill();
virtual bool interrupt();
void start(const QString &cmd, const QStringList &args);
bool waitForStarted();
qint64 write(const QByteArray &data);
void kill();
bool interrupt();
#ifdef Q_OS_WIN
void setUseCtrlCStub(bool enable);
void winInterruptByCtrlC();
#endif
virtual QProcess::ProcessState state() const;
virtual QString errorString() const;
QProcess::ProcessState state() const;
QString errorString() const;
QProcessEnvironment processEnvironment() const;
void setProcessEnvironment(const QProcessEnvironment &env);
void setEnvironment(const QStringList &env);
void setWorkingDirectory(const QString &dir);
virtual QProcessEnvironment processEnvironment() const;
virtual void setProcessEnvironment(const QProcessEnvironment &env);
virtual void setEnvironment(const QStringList &env);
virtual void setWorkingDirectory(const QString &dir);
signals:
void error(QProcess::ProcessError);
void finished(int exitCode, QProcess::ExitStatus exitStatus);
void readyReadStandardError();
void readyReadStandardOutput();
private:
Utils::QtcProcess m_gdbProc;
......@@ -71,4 +77,4 @@ private:
} // namespace Internal
} // namespace Debugger
#endif // LOCALGDBPROCESS_H
#endif // GDBPROCESS_H
......@@ -29,6 +29,8 @@
#include "remotegdbserveradapter.h"
#include "gdbprocess.h"
#include <debugger/debuggeractions.h>
#include <debugger/debuggercore.h>
#include <debugger/debuggerprotocol.h>
......@@ -99,9 +101,9 @@ void GdbRemoteServerEngine::setupEngine()
m_uploadProc.waitForStarted();
}
if (!startParameters().workingDirectory.isEmpty())
m_gdbProc.setWorkingDirectory(startParameters().workingDirectory);
m_gdbProc->setWorkingDirectory(startParameters().workingDirectory);
if (startParameters().environment.size())
m_gdbProc.setEnvironment(startParameters().environment.toStringList());
m_gdbProc->setEnvironment(startParameters().environment.toStringList());
if (startParameters().remoteSetupNeeded)
notifyEngineRequestRemoteSetup();
......@@ -435,10 +437,10 @@ void GdbRemoteServerEngine::interruptInferior2()
CB(handleInterruptInferior));
#ifdef Q_OS_WIN
} else if (m_isQnxGdb) {
m_gdbProc.winInterruptByCtrlC();
m_gdbProc->winInterruptByCtrlC();
#endif
} else {
bool ok = m_gdbProc.interrupt();
bool ok = m_gdbProc->interrupt();
if (!ok) {
// FIXME: Extra state needed?
showMessage(_("NOTE: INFERIOR STOP NOT POSSIBLE"));
......
......@@ -31,7 +31,6 @@
#define REMOTEGDBSERVERADAPTER_H
#include "gdbengine.h"
#include "localgdbprocess.h"
namespace Debugger {
namespace Internal {
......@@ -58,8 +57,6 @@ private:
void interruptInferior2();
void shutdownEngine();
AbstractGdbProcess *gdbProc() { return &m_gdbProc; }
signals:
/*
* For "external" clients of a debugger run control that need to do
......@@ -95,7 +92,6 @@ private:
void handleExecRun(const GdbResponse &response);
QProcess m_uploadProc;
LocalGdbProcess m_gdbProc;
bool m_isMulti;
int m_targetPid;
QByteArray m_serverChannel;
......
......@@ -31,7 +31,6 @@
#define DEBUGGER_TERMGDBADAPTER_H
#include "gdbengine.h"
#include "localgdbprocess.h"
#include <utils/consoleprocess.h>
......@@ -62,8 +61,6 @@ private:
void interruptInferior2();
void shutdownEngine();
AbstractGdbProcess *gdbProc() { return &m_gdbProc; }
void handleStubAttached(const GdbResponse &response);
Q_SLOT void stubStarted();
......@@ -71,7 +68,6 @@ private:
Q_SLOT void stubError(const QString &msg);
Utils::ConsoleProcess m_stubProc;
LocalGdbProcess m_gdbProc;
};
} // namespace Internal
......
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