Commit 8bffed4d authored by hjk's avatar hjk

Debugger: Merge {Abstract,Local}PlainAdapter to GdbPlainEngine

Change-Id: Idb2197e429df2fb166f042649d3e95e88c28203e
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@digia.com>
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent ed148374
......@@ -113,7 +113,6 @@ QtcPlugin {
prefix: "gdb/"
files: [
"abstractgdbprocess.cpp", "abstractgdbprocess.h",
"abstractplaingdbadapter.cpp", "abstractplaingdbadapter.h",
"attachgdbadapter.cpp", "attachgdbadapter.h",
"classicgdbengine.cpp",
"coregdbadapter.cpp", "coregdbadapter.h",
......@@ -121,7 +120,7 @@ QtcPlugin {
"gdbengine.cpp", "gdbengine.h",
"gdboptionspage.cpp", "gdboptionspage.h",
"localgdbprocess.cpp", "localgdbprocess.h",
"localplaingdbadapter.cpp", "localplaingdbadapter.h",
"gdbplainengine.cpp", "gdbplainengine.h",
"pythongdbengine.cpp",
"remotegdbserveradapter.cpp", "remotegdbserveradapter.h",
"startgdbserverdialog.cpp", "startgdbserverdialog.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.
**
****************************************************************************/
#ifndef ABSTRACTPLAINGDBADAPTER_H
#define ABSTRACTPLAINGDBADAPTER_H
#include "gdbengine.h"
namespace Debugger {
namespace Internal {
class GdbAbstractPlainEngine : public GdbEngine
{
// Needs tr - context
Q_OBJECT
public:
explicit GdbAbstractPlainEngine(const DebuggerStartParameters &startParameters);
void setupInferior();
void runEngine();
private:
virtual QByteArray execFilePath() const = 0;
virtual QByteArray toLocalEncoding(const QString &str) const = 0;
virtual QString fromLocalEncoding(const QByteArray &ba) const = 0;
void handleExecRun(const GdbResponse &response);
void handleFileExecAndSymbols(const GdbResponse &response);
};
} // namespace Debugger
} // namespace Internal
#endif // ABSTRACTPLAINGDBADAPTER_H
......@@ -3,12 +3,11 @@ HEADERS += \
$$PWD/gdboptionspage.h \
$$PWD/attachgdbadapter.h \
$$PWD/coregdbadapter.h \
$$PWD/localplaingdbadapter.h \
$$PWD/termgdbadapter.h \
$$PWD/remotegdbserveradapter.h \
$$PWD/abstractgdbprocess.h \
$$PWD/gdbplainengine.h \
$$PWD/localgdbprocess.h \
$$PWD/abstractplaingdbadapter.h \
$$PWD/abstractgdbprocess.h \
$$PWD/startgdbserverdialog.h
SOURCES += \
......@@ -18,12 +17,11 @@ SOURCES += \
$$PWD/gdboptionspage.cpp \
$$PWD/attachgdbadapter.cpp \
$$PWD/coregdbadapter.cpp \
$$PWD/localplaingdbadapter.cpp \
$$PWD/termgdbadapter.cpp \
$$PWD/remotegdbserveradapter.cpp \
$$PWD/abstractgdbprocess.cpp \
$$PWD/localgdbprocess.cpp \
$$PWD/abstractplaingdbadapter.cpp \
$$PWD/gdbplainengine.cpp \
$$PWD/startgdbserverdialog.cpp
RESOURCES += $$PWD/gdb.qrc
......@@ -31,7 +31,7 @@
#include "attachgdbadapter.h"
#include "coregdbadapter.h"
#include "localplaingdbadapter.h"
#include "gdbplainengine.h"
#include "termgdbadapter.h"
#include "remotegdbserveradapter.h"
......@@ -5464,7 +5464,7 @@ DebuggerEngine *createGdbEngine(const DebuggerStartParameters &sp)
default:
if (sp.useTerminal)
return new GdbTermEngine(sp);
return new GdbLocalPlainEngine(sp);
return new GdbPlainEngine(sp);
}
}
......
......@@ -27,7 +27,7 @@
**
****************************************************************************/
#include "abstractplaingdbadapter.h"
#include "gdbplainengine.h"
#include <debugger/debuggeractions.h>
#include <debugger/debuggercore.h>
......@@ -35,20 +35,28 @@
#include <debugger/debuggerstartparameters.h>
#include <debugger/debuggerstringutils.h>
#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QFileInfo>
namespace Debugger {
namespace Internal {
#define CB(callback) \
static_cast<GdbEngine::GdbCommandCallback>(&GdbAbstractPlainEngine::callback), \
static_cast<GdbEngine::GdbCommandCallback>(&GdbPlainEngine::callback), \
STRINGIFY(callback)
GdbAbstractPlainEngine::GdbAbstractPlainEngine(const DebuggerStartParameters &startParameters)
GdbPlainEngine::GdbPlainEngine(const DebuggerStartParameters &startParameters)
: GdbEngine(startParameters)
{}
{
// Output
connect(&m_outputCollector, SIGNAL(byteDelivery(QByteArray)),
this, SLOT(readDebugeeOutput(QByteArray)));
}
void GdbAbstractPlainEngine::setupInferior()
void GdbPlainEngine::setupInferior()
{
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
if (!startParameters().processArgs.isEmpty()) {
......@@ -59,7 +67,7 @@ void GdbAbstractPlainEngine::setupInferior()
CB(handleFileExecAndSymbols));
}
void GdbAbstractPlainEngine::handleFileExecAndSymbols(const GdbResponse &response)
void GdbPlainEngine::handleFileExecAndSymbols(const GdbResponse &response)
{
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
if (response.resultClass == GdbResultDone) {
......@@ -74,12 +82,12 @@ void GdbAbstractPlainEngine::handleFileExecAndSymbols(const GdbResponse &respons
}
}
void GdbAbstractPlainEngine::runEngine()
void GdbPlainEngine::runEngine()
{
postCommand("-exec-run", GdbEngine::RunRequest, CB(handleExecRun));
}
void GdbAbstractPlainEngine::handleExecRun(const GdbResponse &response)
void GdbPlainEngine::handleExecRun(const GdbResponse &response)
{
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
if (response.resultClass == GdbResultRunning) {
......@@ -100,5 +108,70 @@ void GdbAbstractPlainEngine::handleExecRun(const GdbResponse &response)
}
}
GdbEngine::DumperHandling GdbPlainEngine::dumperHandling() const
{
// LD_PRELOAD fails for System-Qt on Mac.
return Utils::HostOsInfo::isWindowsHost() || Utils::HostOsInfo::isMacHost()
? DumperLoadedByGdb : DumperLoadedByGdbPreload;
}
void GdbPlainEngine::setupEngine()
{
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
showMessage(_("TRYING TO START ADAPTER"));
if (!prepareCommand())
return;
QStringList gdbArgs;
if (!m_outputCollector.listen()) {
handleAdapterStartFailed(tr("Cannot set up communication with child process: %1")
.arg(m_outputCollector.errorString()));
return;
}
gdbArgs.append(_("--tty=") + m_outputCollector.serverName());
if (!startParameters().workingDirectory.isEmpty())
m_gdbProc.setWorkingDirectory(startParameters().workingDirectory);
if (startParameters().environment.size())
m_gdbProc.setEnvironment(startParameters().environment.toStringList());
startGdb(gdbArgs);
}
void GdbPlainEngine::handleGdbStartFailed()
{
m_outputCollector.shutdown();
}
void GdbPlainEngine::interruptInferior2()
{
interruptLocalInferior(inferiorPid());
}
void GdbPlainEngine::shutdownEngine()
{
showMessage(_("PLAIN ADAPTER SHUTDOWN %1").arg(state()));
m_outputCollector.shutdown();
notifyAdapterShutdownOk();
}
QByteArray GdbPlainEngine::execFilePath() const
{
return QFileInfo(startParameters().executable)
.absoluteFilePath().toLocal8Bit();
}
QByteArray GdbPlainEngine::toLocalEncoding(const QString &s) const
{
return s.toLocal8Bit();
}
QString GdbPlainEngine::fromLocalEncoding(const QByteArray &b) const
{
return QString::fromLocal8Bit(b);
}
} // namespace Debugger
} // namespace Internal
......@@ -27,30 +27,30 @@
**
****************************************************************************/
#ifndef LOCALPLAINGDBADAPTER_H
#define LOCALPLAINGDBADAPTER_H
#ifndef GDBPLAINENGINE_H
#define GDBPLAINENGINE_H
#include "abstractplaingdbadapter.h"
#include "gdbengine.h"
#include "localgdbprocess.h"
#include <debugger/outputcollector.h>
namespace Debugger {
namespace Internal {
///////////////////////////////////////////////////////////////////////
//
// PlainGdbAdapter
//
///////////////////////////////////////////////////////////////////////
class GdbLocalPlainEngine : public GdbAbstractPlainEngine
class GdbPlainEngine : public GdbEngine
{
// Needs tr - Context
Q_OBJECT
public:
explicit GdbLocalPlainEngine(const DebuggerStartParameters &startParameters);
explicit GdbPlainEngine(const DebuggerStartParameters &startParameters);
private:
void handleExecRun(const GdbResponse &response);
void handleFileExecAndSymbols(const GdbResponse &response);
void setupInferior();
void runEngine();
void setupEngine();
void handleGdbStartFailed();
void interruptInferior2();
......@@ -67,7 +67,7 @@ private:
LocalGdbProcess m_gdbProc;
};
} // namespace Internal
} // namespace Debugger
} // namespace Internal
#endif // LOCALPLAINGDBADAPTER_H
#endif // GDBPLAINENGINE_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 "localplaingdbadapter.h"
#include <debugger/debuggerstartparameters.h>
#include <debugger/debuggerstringutils.h>
#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QFileInfo>
namespace Debugger {
namespace Internal {
///////////////////////////////////////////////////////////////////////
//
// PlainGdbAdapter
//
///////////////////////////////////////////////////////////////////////
GdbLocalPlainEngine::GdbLocalPlainEngine(const DebuggerStartParameters &startParameters)
: GdbAbstractPlainEngine(startParameters)
{
// Output
connect(&m_outputCollector, SIGNAL(byteDelivery(QByteArray)),
this, SLOT(readDebugeeOutput(QByteArray)));
}
GdbEngine::DumperHandling GdbLocalPlainEngine::dumperHandling() const
{
// LD_PRELOAD fails for System-Qt on Mac.
return Utils::HostOsInfo::isWindowsHost() || Utils::HostOsInfo::isMacHost()
? DumperLoadedByGdb : DumperLoadedByGdbPreload;
}
void GdbLocalPlainEngine::setupEngine()
{
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
showMessage(_("TRYING TO START ADAPTER"));
if (!prepareCommand())
return;
QStringList gdbArgs;
if (!m_outputCollector.listen()) {
handleAdapterStartFailed(tr("Cannot set up communication with child process: %1")
.arg(m_outputCollector.errorString()));
return;
}
gdbArgs.append(_("--tty=") + m_outputCollector.serverName());
if (!startParameters().workingDirectory.isEmpty())
m_gdbProc.setWorkingDirectory(startParameters().workingDirectory);
if (startParameters().environment.size())
m_gdbProc.setEnvironment(startParameters().environment.toStringList());
startGdb(gdbArgs);
}
void GdbLocalPlainEngine::handleGdbStartFailed()
{
m_outputCollector.shutdown();
}
void GdbLocalPlainEngine::shutdownEngine()
{
showMessage(_("PLAIN ADAPTER SHUTDOWN %1").arg(state()));
m_outputCollector.shutdown();
notifyAdapterShutdownOk();
}
void GdbLocalPlainEngine::interruptInferior2()
{
interruptLocalInferior(inferiorPid());
}
QByteArray GdbLocalPlainEngine::execFilePath() const
{
return QFileInfo(startParameters().executable)
.absoluteFilePath().toLocal8Bit();
}
QByteArray GdbLocalPlainEngine::toLocalEncoding(const QString &s) const
{
return s.toLocal8Bit();
}
QString GdbLocalPlainEngine::fromLocalEncoding(const QByteArray &b) const
{
return QString::fromLocal8Bit(b);
}
} // namespace Internal
} // namespace Debugger
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