Commit d25066f8 authored by hjk's avatar hjk
Browse files

debugger: let the gdb adapters access the engines start parameter instead of keeping a copy

parent 89861828
......@@ -81,12 +81,15 @@ public:
virtual void setEnvironment(const QStringList &env) = 0;
virtual bool isTrkAdapter() const = 0;
virtual void startAdapter(const DebuggerStartParametersPtr &sp) = 0;
virtual void startAdapter() = 0;
virtual void prepareInferior() = 0;
virtual void startInferior() = 0;
virtual void interruptInferior() = 0;
virtual void shutdown() = 0;
virtual const DebuggerStartParameters &startParameters() const
{ return m_engine->startParameters(); }
signals:
void adapterStarted();
void adapterStartFailed(const QString &msg);
......
......@@ -1521,6 +1521,8 @@ void GdbEngine::startDebugger(const DebuggerStartParametersPtr &sp)
// initializeVariables());
//QTC_ASSERT(m_gdbAdapter == 0, delete m_gdbAdapter; m_gdbAdapter = 0);
m_startParameters = sp;
if (m_gdbAdapter)
disconnectAdapter();
......@@ -1532,9 +1534,7 @@ void GdbEngine::startDebugger(const DebuggerStartParametersPtr &sp)
initializeVariables();
connectAdapter();
m_startParameters = sp;
m_gdbAdapter->startAdapter(sp);
m_gdbAdapter->startAdapter();
/*
QStringList gdbArgs;
......
......@@ -95,8 +95,6 @@ private:
friend class TrkGdbAdapter;
friend class RemoteGdbAdapter;
const DebuggerStartParameters &startParameters() const
{ return *m_startParameters; }
//
// IDebuggerEngine implementation
//
......@@ -452,6 +450,8 @@ public:
void showMessageBox(int icon, const QString &title, const QString &text);
void debugMessage(const QString &msg);
void addOptionPages(QList<Core::IOptionsPage*> *opts) const;
const DebuggerStartParameters &startParameters() const
{ return *m_startParameters; }
OutputCollector m_outputCollector;
};
......
......@@ -83,24 +83,23 @@ PlainGdbAdapter::PlainGdbAdapter(GdbEngine *engine, QObject *parent)
// m_manager, SLOT(exitDebugger()));
}
void PlainGdbAdapter::startAdapter(const DebuggerStartParametersPtr &sp)
void PlainGdbAdapter::startAdapter()
{
QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state());
setState(AdapterStarting);
debugMessage(_("TRYING TO START ADAPTER"));
m_startParameters = sp;
QStringList gdbArgs;
gdbArgs.prepend(_("mi"));
gdbArgs.prepend(_("-i"));
if (m_startParameters->useTerminal) {
if (startParameters().useTerminal) {
m_stubProc.stop(); // We leave the console open, so recycle it now.
m_stubProc.setWorkingDirectory(m_startParameters->workingDir);
m_stubProc.setEnvironment(m_startParameters->environment);
if (!m_stubProc.start(m_startParameters->executable,
m_startParameters->processArgs)) {
m_stubProc.setWorkingDirectory(startParameters().workingDir);
m_stubProc.setEnvironment(startParameters().environment);
if (!m_stubProc.start(startParameters().executable,
startParameters().processArgs)) {
// Error message for user is delivered via a signal.
emitAdapterStartFailed(QString());
return;
......@@ -113,10 +112,10 @@ void PlainGdbAdapter::startAdapter(const DebuggerStartParametersPtr &sp)
}
gdbArgs.prepend(_("--tty=") + m_engine->m_outputCollector.serverName());
if (!m_startParameters->workingDir.isEmpty())
setWorkingDirectory(m_startParameters->workingDir);
if (!m_startParameters->environment.isEmpty())
setEnvironment(m_startParameters->environment);
if (!startParameters().workingDir.isEmpty())
setWorkingDirectory(startParameters().workingDir);
if (!startParameters().environment.isEmpty())
setEnvironment(startParameters().environment);
}
QString location = theDebuggerStringSetting(GdbLocation);
......@@ -135,9 +134,9 @@ void PlainGdbAdapter::prepareInferior()
{
QTC_ASSERT(state() == AdapterStarted, qDebug() << state());
setState(InferiorPreparing);
if (!m_startParameters->processArgs.isEmpty())
if (!startParameters().processArgs.isEmpty())
m_engine->postCommand(_("-exec-arguments ")
+ m_startParameters->processArgs.join(_(" ")));
+ startParameters().processArgs.join(_(" ")));
QFileInfo fi(m_engine->startParameters().executable);
m_engine->postCommand(_("-file-exec-and-symbols \"%1\"").arg(fi.absoluteFilePath()),
CB(handleFileExecAndSymbols));
......
......@@ -61,7 +61,7 @@ public:
void setEnvironment(const QStringList &env) { m_gdbProc.setEnvironment(env); }
bool isTrkAdapter() const { return false; }
void startAdapter(const DebuggerStartParametersPtr &sp);
void startAdapter();
void prepareInferior();
void startInferior();
void interruptInferior();
......@@ -83,7 +83,6 @@ private:
Q_SLOT void stubError(const QString &msg);
QProcess m_gdbProc;
DebuggerStartParametersPtr m_startParameters;
Core::Utils::ConsoleProcess m_stubProc;
};
......
......@@ -1344,12 +1344,11 @@ void TrkGdbAdapter::handleGdbStateChanged(QProcess::ProcessState newState)
logMessage(_("GDB: Process State %1").arg(newState));
}
void TrkGdbAdapter::startAdapter(const DebuggerStartParametersPtr &sp)
void TrkGdbAdapter::startAdapter()
{
QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state());
setState(AdapterStarting);
debugMessage(_("TRYING TO START ADAPTER"));
m_startParameters = sp;
logMessage(QLatin1String("### Starting TrkGdbAdapter"));
if (m_options->mode == TrkOptions::BlueTooth) {
const QString device = effectiveTrkDevice();
......
......@@ -32,6 +32,7 @@
#include "trkutils.h"
#include "trkdevice.h"
#include "trkoptions.h"
#include "abstractgdbadapter.h"
#include <QtCore/QHash>
......@@ -48,8 +49,6 @@
namespace Debugger {
namespace Internal {
struct TrkOptions;
struct GdbResult
{
QByteArray data;
......@@ -101,7 +100,6 @@ private:
QProcess m_gdbProc;
QProcess m_rfcommProc;
bool m_running;
DebuggerStartParametersPtr m_startParameters;
void debugMessage(const QString &msg) { m_engine->debugMessage(msg); }
public:
......@@ -117,7 +115,7 @@ public:
void setEnvironment(const QStringList &env);
bool isTrkAdapter() const { return true; }
void startAdapter(const DebuggerStartParametersPtr &sp);
void startAdapter();
void prepareInferior();
void startInferior();
void interruptInferior();
......
Supports Markdown
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