debugger: refactoring

rename GdbProcessBase into AbstractGdbAdapter
rename SymbianAdapter into TrkGdbAdapter
rename GdbProcess into PlainGdbAdapter
This commit is contained in:
hjk
2009-09-11 15:53:08 +02:00
parent 5077794f54
commit 491a747ebb
8 changed files with 153 additions and 151 deletions

View File

@@ -27,8 +27,8 @@
**
**************************************************************************/
#ifndef DEBUGGER_PROCESSBASE_H
#define DEBUGGER_PROCESSBASE_H
#ifndef DEBUGGER_ABSTRACT_GDB_ADAPTER
#define DEBUGGER_ABSTRACT_GDB_ADAPTER
#include <QtCore/QObject>
#include <QtCore/QProcess>
@@ -38,16 +38,17 @@ namespace Internal {
class GdbEngine;
// GdbProcessBase is inherited by GdbProcess and the gdb/trk Adapter.
// In the GdbProcess case it's just a wrapper around a QProcess running
// gdb, in the Adapter case it's the interface to the gdb process in
// AbstractGdbAdapter is inherited by PlainGdbAdapter used for local
// debugging and TrkGdbAdapter used for on-device debugging.
// In the PlainGdbAdapter case it's just a wrapper around a QProcess running
// gdb, in the TrkGdbAdapter case it's the interface to the gdb process in
// the whole rfomm/gdb/gdbserver combo.
class GdbProcessBase : public QObject
class AbstractGdbAdapter : public QObject
{
Q_OBJECT
public:
GdbProcessBase(QObject *parent = 0) : QObject(parent) {}
AbstractGdbAdapter(QObject *parent = 0) : QObject(parent) {}
virtual void start(const QString &program, const QStringList &args,
QIODevice::OpenMode mode = QIODevice::ReadWrite) = 0;
@@ -77,4 +78,4 @@ signals:
} // namespace Internal
} // namespace Debugger
#endif // DEBUGGER_PROCESSBASE_H
#endif // DEBUGGER_ABSTRACT_GDB_ADAPTER

View File

@@ -1,12 +1,12 @@
HEADERS += \
$$PWD/gdbprocessbase.h \
$$PWD/abstractgdbadapter.h \
$$PWD/gdbmi.h \
$$PWD/gdbengine.h \
$$PWD/gdboptionspage.h \
$$PWD/callback.h \
$$PWD/trkutils.h \
$$PWD/trkclient.h \
$$PWD/symbianadapter.h \
$$PWD/trkgdbadapter.h \
#$$PWD/gdboptionspage.h \
SOURCES += \
@@ -15,7 +15,7 @@ SOURCES += \
$$PWD/gdboptionspage.cpp \
$$PWD/trkutils.cpp \
$$PWD/trkclient.cpp \
$$PWD/symbianadapter.cpp \
$$PWD/trkgdbadapter.cpp \
#$$PWD/gdboptionspage.cpp \
FORMS += $$PWD/gdboptionspage.ui

View File

@@ -31,6 +31,7 @@
#include "gdbengine.h"
#include "gdboptionspage.h"
#include "trkgdbadapter.h"
#include "watchutils.h"
#include "debuggeractions.h"
@@ -140,11 +141,11 @@ static QByteArray parsePlainConsoleStream(const GdbResultRecord &record)
///////////////////////////////////////////////////////////////////////
//
// GdbProcess
// PlainGdbAdapter
//
///////////////////////////////////////////////////////////////////////
void GdbProcess::attach(GdbEngine *engine) const
void PlainGdbAdapter::attach(GdbEngine *engine) const
{
QFileInfo fi(engine->startParameters().executable);
QString fileName = fi.absoluteFilePath();
@@ -158,7 +159,7 @@ void GdbProcess::attach(GdbEngine *engine) const
//
///////////////////////////////////////////////////////////////////////
GdbEngine::GdbEngine(DebuggerManager *parent, GdbProcessBase *gdbProc) :
GdbEngine::GdbEngine(DebuggerManager *parent, AbstractGdbAdapter *gdbAdapter) :
#ifdef Q_OS_WIN // Do injection loading with MinGW (call loading does not work with 64bit)
m_dumperInjectionLoad(true),
#else
@@ -167,7 +168,7 @@ GdbEngine::GdbEngine(DebuggerManager *parent, GdbProcessBase *gdbProc) :
q(parent),
qq(parent->engineInterface())
{
m_gdbProc = gdbProc;
m_gdbAdapter = gdbAdapter;
m_stubProc.setMode(Core::Utils::ConsoleProcess::Debug);
#ifdef Q_OS_UNIX
m_stubProc.setSettings(Core::ICore::instance()->settings());
@@ -179,22 +180,22 @@ GdbEngine::GdbEngine(DebuggerManager *parent, GdbProcessBase *gdbProc) :
GdbEngine::~GdbEngine()
{
// prevent sending error messages afterwards
m_gdbProc->disconnect(this);
delete m_gdbProc;
m_gdbAdapter->disconnect(this);
delete m_gdbAdapter;
}
void GdbEngine::initializeConnections()
{
// Gdb Process interaction
connect(m_gdbProc, SIGNAL(error(QProcess::ProcessError)),
connect(m_gdbAdapter, SIGNAL(error(QProcess::ProcessError)),
this, SLOT(gdbProcError(QProcess::ProcessError)));
connect(m_gdbProc, SIGNAL(readyReadStandardOutput()),
connect(m_gdbAdapter, SIGNAL(readyReadStandardOutput()),
this, SLOT(readGdbStandardOutput()));
connect(m_gdbProc, SIGNAL(readyReadStandardError()),
connect(m_gdbAdapter, SIGNAL(readyReadStandardError()),
this, SLOT(readGdbStandardError()));
connect(m_gdbProc, SIGNAL(finished(int, QProcess::ExitStatus)),
connect(m_gdbAdapter, SIGNAL(finished(int, QProcess::ExitStatus)),
q, SLOT(exitDebugger()));
connect(m_gdbProc, SIGNAL(started()),
connect(m_gdbAdapter, SIGNAL(started()),
this, SLOT(startDebugger2()));
connect(&m_stubProc, SIGNAL(processError(QString)),
@@ -267,7 +268,7 @@ void GdbEngine::initializeVariables()
// FIXME: unhandled:
//m_outputCodecState = QTextCodec::ConverterState();
//OutputCollector m_outputCollector;
//QProcess m_gdbProc;
//QProcess m_gdbAdapter;
//QProcess m_uploadProc;
//Core::Utils::ConsoleProcess m_stubProc;
}
@@ -633,7 +634,7 @@ void GdbEngine::stubError(const QString &msg)
void GdbEngine::readGdbStandardError()
{
qWarning() << "Unexpected gdb stderr:" << m_gdbProc->readAllStandardError();
qWarning() << "Unexpected gdb stderr:" << m_gdbAdapter->readAllStandardError();
}
void GdbEngine::readGdbStandardOutput()
@@ -641,7 +642,7 @@ void GdbEngine::readGdbStandardOutput()
int newstart = 0;
int scan = m_inbuffer.size();
m_inbuffer.append(m_gdbProc->readAllStandardOutput());
m_inbuffer.append(m_gdbAdapter->readAllStandardOutput());
while (newstart < m_inbuffer.size()) {
int start = newstart;
@@ -670,7 +671,7 @@ void GdbEngine::interruptInferior()
{
qq->notifyInferiorStopRequested();
if (m_gdbProc->state() == QProcess::NotRunning) {
if (m_gdbAdapter->state() == QProcess::NotRunning) {
debugMessage(_("TRYING TO INTERRUPT INFERIOR WITHOUT RUNNING GDB"));
qq->notifyInferiorExited();
return;
@@ -717,7 +718,7 @@ void GdbEngine::postCommand(const QString &command, GdbCommandFlags flags,
GdbCommandCallback callback, const char *callbackName,
const QVariant &cookie)
{
if (m_gdbProc->state() == QProcess::NotRunning) {
if (m_gdbAdapter->state() == QProcess::NotRunning) {
debugMessage(_("NO GDB PROCESS RUNNING, CMD IGNORED: ") + command);
return;
}
@@ -846,12 +847,12 @@ void GdbEngine::handleResultRecord(const GdbResultRecord &record)
void GdbEngine::executeDebuggerCommand(const QString &command)
{
if (m_gdbProc->state() != QProcess::Running) {
if (m_gdbAdapter->state() != QProcess::Running) {
debugMessage(_("GDB PROCESS NOT RUNNING, PLAIN CMD IGNORED: ") + command);
return;
}
m_gdbProc->write(command.toLatin1() + "\r\n");
m_gdbAdapter->write(command.toLatin1() + "\r\n");
}
void GdbEngine::handleTargetCore(const GdbResultRecord &, const QVariant &)
@@ -1292,7 +1293,7 @@ void GdbEngine::handleAsyncOutput2(const GdbMi &data)
}
// FIXME: Hack, remove as soon as we get real stack traces.
if (m_gdbProc->isAdapter()) {
if (m_gdbAdapter->isAdapter()) {
StackFrame f;
f.file = QString::fromLocal8Bit(fullName.data());
f.line = frame.findChild("line").data().toInt();
@@ -1459,16 +1460,16 @@ void GdbEngine::detachDebugger()
void GdbEngine::exitDebugger()
{
debugMessage(_("GDBENGINE EXITDEBUGGER: %1").arg(m_gdbProc->state()));
if (m_gdbProc->state() == QProcess::Starting) {
debugMessage(_("GDBENGINE EXITDEBUGGER: %1").arg(m_gdbAdapter->state()));
if (m_gdbAdapter->state() == QProcess::Starting) {
debugMessage(_("WAITING FOR GDB STARTUP TO SHUTDOWN: %1")
.arg(m_gdbProc->state()));
.arg(m_gdbAdapter->state()));
// FIXME: handle this!
//m_gdbProc->waitForStarted();
//m_gdbAdapter->waitForStarted();
}
if (m_gdbProc->state() == QProcess::Running) {
if (m_gdbAdapter->state() == QProcess::Running) {
debugMessage(_("WAITING FOR RUNNING GDB TO SHUTDOWN: %1")
.arg(m_gdbProc->state()));
.arg(m_gdbAdapter->state()));
if (q->status() != DebuggerInferiorStopped
&& q->status() != DebuggerProcessStartingUp) {
QTC_ASSERT(q->status() == DebuggerInferiorRunning,
@@ -1481,17 +1482,17 @@ void GdbEngine::exitDebugger()
postCommand(_("kill"));
postCommand(_("-gdb-exit"), CB(handleExit));
// 20s can easily happen when loading webkit debug information
if (!m_gdbProc->waitForFinished(20000)) {
if (!m_gdbAdapter->waitForFinished(20000)) {
debugMessage(_("FORCING TERMINATION: %1")
.arg(m_gdbProc->state()));
m_gdbProc->terminate();
m_gdbProc->waitForFinished(20000);
.arg(m_gdbAdapter->state()));
m_gdbAdapter->terminate();
m_gdbAdapter->waitForFinished(20000);
}
}
if (m_gdbProc->state() != QProcess::NotRunning) {
if (m_gdbAdapter->state() != QProcess::NotRunning) {
debugMessage(_("PROBLEM STOPPING DEBUGGER: STATE %1")
.arg(m_gdbProc->state()));
m_gdbProc->kill();
.arg(m_gdbAdapter->state()));
m_gdbAdapter->kill();
}
m_outputCollector.shutdown();
@@ -1514,9 +1515,9 @@ void GdbEngine::startDebugger(const QSharedPointer<DebuggerStartParameters> &sp)
QStringList gdbArgs;
if (m_gdbProc->state() != QProcess::NotRunning) {
debugMessage(_("GDB IS ALREADY RUNNING, STATE: %1").arg(m_gdbProc->state()));
m_gdbProc->kill();
if (m_gdbAdapter->state() != QProcess::NotRunning) {
debugMessage(_("GDB IS ALREADY RUNNING, STATE: %1").arg(m_gdbAdapter->state()));
m_gdbAdapter->kill();
emitStartFailed();
return;
}
@@ -1562,16 +1563,16 @@ void GdbEngine::startDebugger(const QSharedPointer<DebuggerStartParameters> &sp)
gdbArgs.prepend(_("--tty=") + m_outputCollector.serverName());
if (!m_startParameters.workingDir.isEmpty())
m_gdbProc->setWorkingDirectory(m_startParameters.workingDir);
m_gdbAdapter->setWorkingDirectory(m_startParameters.workingDir);
if (!m_startParameters.environment.isEmpty())
m_gdbProc->setEnvironment(m_startParameters.environment);
m_gdbAdapter->setEnvironment(m_startParameters.environment);
}
#if 0
qDebug() << "Command:" << q->settings()->m_gdbCmd;
qDebug() << "WorkingDirectory:" << m_gdbProc->workingDirectory();
qDebug() << "WorkingDirectory:" << m_gdbAdapter->workingDirectory();
qDebug() << "ScriptFile:" << q->settings()->m_scriptFile;
qDebug() << "Environment:" << m_gdbProc->environment();
qDebug() << "Environment:" << m_gdbAdapter->environment();
qDebug() << "Arguments:" << gdbArgs;
qDebug() << "BuildDir:" << m_startParameters.buildDir;
qDebug() << "ExeFile:" << m_startParameters.executable;
@@ -1579,13 +1580,13 @@ void GdbEngine::startDebugger(const QSharedPointer<DebuggerStartParameters> &sp)
QString loc = theDebuggerStringSetting(GdbLocation);
q->showStatusMessage(tr("Starting Debugger: ") + loc + _c(' ') + gdbArgs.join(_(" ")));
m_gdbProc->start(loc, gdbArgs);
m_gdbAdapter->start(loc, gdbArgs);
}
void GdbEngine::emitStartFailed()
{
// QMessageBox::critical(q->mainWindow(), tr("Debugger Startup Failure"),
// tr("Cannot start debugger: %1").arg(m_gdbProc->errorString()));
// tr("Cannot start debugger: %1").arg(m_gdbAdapter->errorString()));
m_outputCollector.shutdown();
m_stubProc.blockSignals(true);
m_stubProc.stop();
@@ -1700,8 +1701,8 @@ void GdbEngine::startDebugger2()
} else if (m_startParameters.useTerminal) {
qq->breakHandler()->setAllPending();
} else if (q->startMode() == StartInternal || q->startMode() == StartExternal) {
m_gdbProc->attach(this);
if (m_gdbProc->isAdapter()) {
m_gdbAdapter->attach(this);
if (m_gdbAdapter->isAdapter()) {
qq->notifyInferiorRunningRequested();
postCommand(_("-exec-continue"), CB(handleExecContinue));
} else {
@@ -2059,7 +2060,7 @@ void GdbEngine::sendInsertBreakpoint(int index)
// cmd += "-c " + data->condition + " ";
#else
QString cmd = _("-break-insert -f ");
if (m_gdbProc->isAdapter())
if (m_gdbAdapter->isAdapter())
cmd = _("-break-insert ");
//if (!data->condition.isEmpty())
// cmd += _("-c ") + data->condition + ' ';
@@ -4242,7 +4243,7 @@ IDebuggerEngine *createGdbEngine(DebuggerManager *parent,
QList<Core::IOptionsPage*> *opts)
{
opts->push_back(new GdbOptionsPage);
return new GdbEngine(parent, new GdbProcess);
return new GdbEngine(parent, new PlainGdbAdapter);
}
IDebuggerEngine *createSymbianEngine(DebuggerManager *parent,
@@ -4250,7 +4251,7 @@ IDebuggerEngine *createSymbianEngine(DebuggerManager *parent,
{
Q_UNUSED(opts);
//opts->push_back(new GdbOptionsPage);
SymbianAdapter *adapter = new SymbianAdapter;
TrkGdbAdapter *adapter = new TrkGdbAdapter;
GdbEngine *engine = new GdbEngine(parent, adapter);
QObject::connect(adapter, SIGNAL(output(QString)),
parent, SLOT(showDebuggerOutput(QString)));

View File

@@ -33,7 +33,7 @@
#include "idebuggerengine.h"
#include "debuggermanager.h" // only for StartParameters
#include "gdbmi.h"
#include "gdbprocessbase.h"
#include "abstractgdbadapter.h"
#include "outputcollector.h"
#include "watchutils.h"
@@ -75,11 +75,11 @@ enum DebuggingHelperState
DebuggingHelperUnavailable,
};
class GdbProcess : public GdbProcessBase
class PlainGdbAdapter : public AbstractGdbAdapter
{
public:
GdbProcess(QObject *parent = 0)
: GdbProcessBase(parent)
PlainGdbAdapter(QObject *parent = 0)
: AbstractGdbAdapter(parent)
{
connect(&m_proc, SIGNAL(error(QProcess::ProcessError)),
this, SIGNAL(error(QProcess::ProcessError)));
@@ -118,7 +118,7 @@ class GdbEngine : public IDebuggerEngine
Q_OBJECT
public:
GdbEngine(DebuggerManager *parent, GdbProcessBase *gdbProc);
GdbEngine(DebuggerManager *parent, AbstractGdbAdapter *gdbAdapter);
~GdbEngine();
signals:
@@ -127,8 +127,8 @@ signals:
void applicationOutputAvailable(const QString &output);
private:
friend class GdbProcess;
friend class SymbianAdapter;
friend class PlainGdbAdapter;
friend class TrkGdbAdapter;
const DebuggerStartParameters &startParameters() const
{ return m_startParameters; }
@@ -299,7 +299,7 @@ private:
QByteArray m_inbuffer;
GdbProcessBase *m_gdbProc;
AbstractGdbAdapter *m_gdbAdapter;
QProcess m_uploadProc;
Core::Utils::ConsoleProcess m_stubProc;

View File

@@ -27,12 +27,12 @@
**
**************************************************************************/
#include "symbianadapter.h"
#include "trkgdbadapter.h"
#ifndef STANDALONE_RUNNER
#include "gdbengine.h"
#endif
#define TrkCB(s) TrkCallback(this, &SymbianAdapter::s)
#define TrkCB(s) TrkCallback(this, &TrkGdbAdapter::s)
using namespace trk;
@@ -69,7 +69,7 @@ namespace Internal {
trk::Endianness m_registerEndianness = LittleEndian;
SymbianAdapter::SymbianAdapter()
TrkGdbAdapter::TrkGdbAdapter()
{
m_running = false;
m_gdbAckMode = true;
@@ -115,23 +115,23 @@ SymbianAdapter::SymbianAdapter()
this, SLOT(trkLogMessage(QString)));
}
SymbianAdapter::~SymbianAdapter()
TrkGdbAdapter::~TrkGdbAdapter()
{
m_gdbServer.close();
logMessage("Shutting down.\n");
}
void SymbianAdapter::trkLogMessage(const QString &msg)
void TrkGdbAdapter::trkLogMessage(const QString &msg)
{
logMessage("TRK " + msg);
}
void SymbianAdapter::setGdbServerName(const QString &name)
void TrkGdbAdapter::setGdbServerName(const QString &name)
{
m_gdbServerName = name;
}
QString SymbianAdapter::gdbServerIP() const
QString TrkGdbAdapter::gdbServerIP() const
{
int pos = m_gdbServerName.indexOf(':');
if (pos == -1)
@@ -139,7 +139,7 @@ QString SymbianAdapter::gdbServerIP() const
return m_gdbServerName.left(pos);
}
uint SymbianAdapter::gdbServerPort() const
uint TrkGdbAdapter::gdbServerPort() const
{
int pos = m_gdbServerName.indexOf(':');
if (pos == -1)
@@ -147,7 +147,7 @@ uint SymbianAdapter::gdbServerPort() const
return m_gdbServerName.mid(pos + 1).toUInt();
}
QByteArray SymbianAdapter::trkContinueMessage()
QByteArray TrkGdbAdapter::trkContinueMessage()
{
QByteArray ba;
appendInt(&ba, m_session.pid);
@@ -155,7 +155,7 @@ QByteArray SymbianAdapter::trkContinueMessage()
return ba;
}
QByteArray SymbianAdapter::trkReadRegisterMessage()
QByteArray TrkGdbAdapter::trkReadRegisterMessage()
{
QByteArray ba;
appendByte(&ba, 0); // Register set, only 0 supported
@@ -166,7 +166,7 @@ QByteArray SymbianAdapter::trkReadRegisterMessage()
return ba;
}
QByteArray SymbianAdapter::trkReadMemoryMessage(uint addr, uint len)
QByteArray TrkGdbAdapter::trkReadMemoryMessage(uint addr, uint len)
{
QByteArray ba;
appendByte(&ba, 0x08); // Options, FIXME: why?
@@ -177,7 +177,7 @@ QByteArray SymbianAdapter::trkReadMemoryMessage(uint addr, uint len)
return ba;
}
void SymbianAdapter::startInferior()
void TrkGdbAdapter::startInferior()
{
QString errorMessage;
if (!m_trkDevice.open(m_rfcommDevice, &errorMessage)) {
@@ -207,7 +207,7 @@ void SymbianAdapter::startInferior()
//sendTrkMessage(TRK_WRITE_QUEUE_NOOP_CODE, TrkCB(startGdbServer));
}
void SymbianAdapter::logMessage(const QString &msg)
void TrkGdbAdapter::logMessage(const QString &msg)
{
if (m_verbose)
emit output(msg);
@@ -216,7 +216,7 @@ void SymbianAdapter::logMessage(const QString &msg)
//
// Gdb
//
void SymbianAdapter::handleGdbConnection()
void TrkGdbAdapter::handleGdbConnection()
{
logMessage("HANDLING GDB CONNECTION");
@@ -232,7 +232,7 @@ static inline QString msgGdbPacket(const QString &p)
return QLatin1String("gdb: ") + p;
}
void SymbianAdapter::readGdbServerCommand()
void TrkGdbAdapter::readGdbServerCommand()
{
QByteArray packet = m_gdbConnection->readAll();
m_gdbReadBuffer.append(packet);
@@ -299,7 +299,7 @@ void SymbianAdapter::readGdbServerCommand()
}
}
bool SymbianAdapter::sendGdbServerPacket(const QByteArray &packet, bool doFlush)
bool TrkGdbAdapter::sendGdbServerPacket(const QByteArray &packet, bool doFlush)
{
if (!m_gdbConnection) {
logMessage(QString::fromLatin1("Cannot write to gdb: No connection (%1)")
@@ -321,7 +321,7 @@ bool SymbianAdapter::sendGdbServerPacket(const QByteArray &packet, bool doFlush)
return true;
}
void SymbianAdapter::sendGdbServerAck()
void TrkGdbAdapter::sendGdbServerAck()
{
if (!m_gdbAckMode)
return;
@@ -330,7 +330,7 @@ void SymbianAdapter::sendGdbServerAck()
sendGdbServerPacket(packet, false);
}
void SymbianAdapter::sendGdbServerMessage(const QByteArray &msg, const QByteArray &logNote)
void TrkGdbAdapter::sendGdbServerMessage(const QByteArray &msg, const QByteArray &logNote)
{
byte sum = 0;
for (int i = 0; i != msg.size(); ++i)
@@ -351,14 +351,14 @@ void SymbianAdapter::sendGdbServerMessage(const QByteArray &msg, const QByteArra
sendGdbServerPacket(packet, true);
}
void SymbianAdapter::sendGdbServerMessageAfterTrkResponse(const QByteArray &msg,
void TrkGdbAdapter::sendGdbServerMessageAfterTrkResponse(const QByteArray &msg,
const QByteArray &logNote)
{
QByteArray ba = msg + char(1) + logNote;
sendTrkMessage(TRK_WRITE_QUEUE_NOOP_CODE, TrkCB(reportToGdb), "", ba); // Answer gdb
}
void SymbianAdapter::reportToGdb(const TrkResult &result)
void TrkGdbAdapter::reportToGdb(const TrkResult &result)
{
QByteArray message = result.cookie.toByteArray();
QByteArray note;
@@ -374,7 +374,7 @@ void SymbianAdapter::reportToGdb(const TrkResult &result)
sendGdbServerMessage(message, note);
}
QByteArray SymbianAdapter::trkBreakpointMessage(uint addr, uint len, bool armMode)
QByteArray TrkGdbAdapter::trkBreakpointMessage(uint addr, uint len, bool armMode)
{
QByteArray ba;
appendByte(&ba, 0x82); // unused option
@@ -387,7 +387,7 @@ QByteArray SymbianAdapter::trkBreakpointMessage(uint addr, uint len, bool armMod
return ba;
}
void SymbianAdapter::handleGdbServerCommand(const QByteArray &cmd)
void TrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
{
// http://sourceware.org/gdb/current/onlinedocs/gdb_34.html
if (0) {}
@@ -717,7 +717,7 @@ void SymbianAdapter::handleGdbServerCommand(const QByteArray &cmd)
}
}
void SymbianAdapter::executeCommand(const QString &msg)
void TrkGdbAdapter::executeCommand(const QString &msg)
{
if (msg == "EI") {
sendGdbMessage("-exec-interrupt");
@@ -734,24 +734,24 @@ void SymbianAdapter::executeCommand(const QString &msg)
}
}
void SymbianAdapter::sendTrkMessage(byte code, TrkCallback callback,
void TrkGdbAdapter::sendTrkMessage(byte code, TrkCallback callback,
const QByteArray &data, const QVariant &cookie)
{
m_trkDevice.sendTrkMessage(code, callback, data, cookie);
}
void SymbianAdapter::sendTrkAck(byte token)
void TrkGdbAdapter::sendTrkAck(byte token)
{
logMessage(QString("SENDING ACKNOWLEDGEMENT FOR TOKEN %1").arg(int(token)));
m_trkDevice.sendTrkAck(token);
}
void SymbianAdapter::handleTrkError(const QString &msg)
void TrkGdbAdapter::handleTrkError(const QString &msg)
{
logMessage("## TRK ERROR: " + msg);
}
void SymbianAdapter::handleTrkResult(const TrkResult &result)
void TrkGdbAdapter::handleTrkResult(const TrkResult &result)
{
if (result.isDebugOutput) {
sendTrkAck(result.token);
@@ -874,7 +874,7 @@ void SymbianAdapter::handleTrkResult(const TrkResult &result)
}
}
void SymbianAdapter::handleCpuType(const TrkResult &result)
void TrkGdbAdapter::handleCpuType(const TrkResult &result)
{
//---TRK------------------------------------------------------
// Command: 0x80 Acknowledge
@@ -896,7 +896,7 @@ void SymbianAdapter::handleCpuType(const TrkResult &result)
logMessage(logMsg);
}
void SymbianAdapter::handleCreateProcess(const TrkResult &result)
void TrkGdbAdapter::handleCreateProcess(const TrkResult &result)
{
// 40 00 00]
//logMessage(" RESULT: " + result.toString());
@@ -919,7 +919,7 @@ void SymbianAdapter::handleCreateProcess(const TrkResult &result)
startGdb();
}
void SymbianAdapter::handleReadRegisters(const TrkResult &result)
void TrkGdbAdapter::handleReadRegisters(const TrkResult &result)
{
logMessage(" RESULT: " + result.toString());
// [80 0B 00 00 00 00 00 C9 24 FF BC 00 00 00 00 00
@@ -933,7 +933,7 @@ void SymbianAdapter::handleReadRegisters(const TrkResult &result)
m_snapshot.registers[i] = extractInt(data + 4 * i);
}
void SymbianAdapter::handleAndReportReadRegisters(const TrkResult &result)
void TrkGdbAdapter::handleAndReportReadRegisters(const TrkResult &result)
{
handleReadRegisters(result);
QByteArray ba;
@@ -959,7 +959,7 @@ static QString msgMemoryReadError(int code, uint addr, uint len = 0)
.arg(code).arg(addr, 0 ,16).arg(lenS);
}
void SymbianAdapter::handleReadMemoryBuffered(const TrkResult &result)
void TrkGdbAdapter::handleReadMemoryBuffered(const TrkResult &result)
{
if (extractShort(result.data.data() + 1) + 3 != result.data.size())
logMessage("\n BAD MEMORY RESULT: " + result.data.toHex() + "\n");
@@ -973,7 +973,7 @@ void SymbianAdapter::handleReadMemoryBuffered(const TrkResult &result)
}
// Format log message for memory access with some smartness about registers
QByteArray SymbianAdapter::memoryReadLogMessage(uint addr, uint len, const QByteArray &ba) const
QByteArray TrkGdbAdapter::memoryReadLogMessage(uint addr, uint len, const QByteArray &ba) const
{
QByteArray logMsg = "memory contents";
if (m_verbose > 1) {
@@ -1003,7 +1003,7 @@ QByteArray SymbianAdapter::memoryReadLogMessage(uint addr, uint len, const QByte
return logMsg;
}
void SymbianAdapter::reportReadMemoryBuffered(const TrkResult &result)
void TrkGdbAdapter::reportReadMemoryBuffered(const TrkResult &result)
{
const qulonglong cookie = result.cookie.toULongLong();
const uint addr = cookie >> 32;
@@ -1033,7 +1033,7 @@ void SymbianAdapter::reportReadMemoryBuffered(const TrkResult &result)
}
}
void SymbianAdapter::handleReadMemoryUnbuffered(const TrkResult &result)
void TrkGdbAdapter::handleReadMemoryUnbuffered(const TrkResult &result)
{
//logMessage("UNBUFFERED MEMORY READ: " + stringFromArray(result.data));
const uint blockaddr = result.cookie.toUInt();
@@ -1048,7 +1048,7 @@ void SymbianAdapter::handleReadMemoryUnbuffered(const TrkResult &result)
}
}
void SymbianAdapter::handleStepRange(const TrkResult &result)
void TrkGdbAdapter::handleStepRange(const TrkResult &result)
{
// [80 0f 00]
if (result.errorCode()) {
@@ -1061,7 +1061,7 @@ void SymbianAdapter::handleStepRange(const TrkResult &result)
//sendGdbServerMessage("S05", "Stepping finished");
}
void SymbianAdapter::handleAndReportSetBreakpoint(const TrkResult &result)
void TrkGdbAdapter::handleAndReportSetBreakpoint(const TrkResult &result)
{
//---TRK------------------------------------------------------
// Command: 0x80 Acknowledge
@@ -1076,7 +1076,7 @@ void SymbianAdapter::handleAndReportSetBreakpoint(const TrkResult &result)
//sendGdbServerMessage("OK");
}
void SymbianAdapter::handleClearBreakpoint(const TrkResult &result)
void TrkGdbAdapter::handleClearBreakpoint(const TrkResult &result)
{
logMessage("CLEAR BREAKPOINT ");
if (result.errorCode()) {
@@ -1086,7 +1086,7 @@ void SymbianAdapter::handleClearBreakpoint(const TrkResult &result)
sendGdbServerMessage("OK");
}
void SymbianAdapter::handleSignalContinue(const TrkResult &result)
void TrkGdbAdapter::handleSignalContinue(const TrkResult &result)
{
int signalNumber = result.cookie.toInt();
logMessage(" HANDLE SIGNAL CONTINUE: " + stringFromArray(result.data));
@@ -1095,7 +1095,7 @@ void SymbianAdapter::handleSignalContinue(const TrkResult &result)
sendGdbServerMessage("W81"); // "Process exited with result 1
}
void SymbianAdapter::handleSupportMask(const TrkResult &result)
void TrkGdbAdapter::handleSupportMask(const TrkResult &result)
{
const char *data = result.data.data();
QByteArray str;
@@ -1108,7 +1108,7 @@ void SymbianAdapter::handleSupportMask(const TrkResult &result)
logMessage("SUPPORTED: " + str);
}
void SymbianAdapter::handleTrkVersions(const TrkResult &result)
void TrkGdbAdapter::handleTrkVersions(const TrkResult &result)
{
QString logMsg;
QTextStream str(&logMsg);
@@ -1122,12 +1122,12 @@ void SymbianAdapter::handleTrkVersions(const TrkResult &result)
logMessage(logMsg);
}
void SymbianAdapter::handleDisconnect(const TrkResult & /*result*/)
void TrkGdbAdapter::handleDisconnect(const TrkResult & /*result*/)
{
logMessage(QLatin1String("Trk disconnected"));
}
void SymbianAdapter::readMemory(uint addr, uint len)
void TrkGdbAdapter::readMemory(uint addr, uint len)
{
Q_ASSERT(len < (2 << 16));
@@ -1161,7 +1161,7 @@ void SymbianAdapter::readMemory(uint addr, uint len)
}
}
void SymbianAdapter::interruptInferior()
void TrkGdbAdapter::interruptInferior()
{
QByteArray ba;
// stop the thread (2) or the process (1) or the whole system (0)
@@ -1172,30 +1172,30 @@ void SymbianAdapter::interruptInferior()
sendTrkMessage(0x1a, TrkCallback(), ba, "Interrupting...");
}
void SymbianAdapter::handleGdbError(QProcess::ProcessError error)
void TrkGdbAdapter::handleGdbError(QProcess::ProcessError error)
{
emit output(QString("GDB: Process Error %1: %2").arg(error).arg(errorString()));
}
void SymbianAdapter::handleGdbFinished(int exitCode, QProcess::ExitStatus exitStatus)
void TrkGdbAdapter::handleGdbFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
emit output(QString("GDB: ProcessFinished %1 %2").arg(exitCode).arg(exitStatus));
}
void SymbianAdapter::handleGdbStarted()
void TrkGdbAdapter::handleGdbStarted()
{
emit output(QString("GDB: Process Started"));
emit started();
}
void SymbianAdapter::handleGdbStateChanged(QProcess::ProcessState newState)
void TrkGdbAdapter::handleGdbStateChanged(QProcess::ProcessState newState)
{
emit output(QString("GDB: Process State %1").arg(newState));
}
void SymbianAdapter::run()
void TrkGdbAdapter::run()
{
emit output("### Starting SymbianAdapter");
emit output("### Starting TrkGdbAdapter");
m_rfcommProc.start("rfcomm listen " + m_rfcommDevice + " 1");
m_rfcommProc.waitForStarted();
@@ -1212,7 +1212,7 @@ void SymbianAdapter::run()
startInferior();
}
void SymbianAdapter::startGdb()
void TrkGdbAdapter::startGdb()
{
if (!m_gdbServer.listen(QHostAddress(gdbServerIP()), gdbServerPort())) {
logMessage(QString("Unable to start the gdb server at %1: %2.")
@@ -1235,7 +1235,7 @@ void SymbianAdapter::startGdb()
m_gdbProc.start(QDir::currentPath() + "/cs-gdb", gdbArgs);
}
void SymbianAdapter::sendGdbMessage(const QString &msg, GdbCallback callback,
void TrkGdbAdapter::sendGdbMessage(const QString &msg, GdbCallback callback,
const QVariant &cookie)
{
GdbCommand data;
@@ -1250,35 +1250,35 @@ void SymbianAdapter::sendGdbMessage(const QString &msg, GdbCallback callback,
// GdbProcessBase
//
void SymbianAdapter::handleRfcommReadyReadStandardError()
void TrkGdbAdapter::handleRfcommReadyReadStandardError()
{
QByteArray ba = m_rfcommProc.readAllStandardError();
emit output(QString("RFCONN stderr: %1").arg(QString::fromLatin1(ba)));
}
void SymbianAdapter::handleRfcommReadyReadStandardOutput()
void TrkGdbAdapter::handleRfcommReadyReadStandardOutput()
{
QByteArray ba = m_rfcommProc.readAllStandardOutput();
emit output(QString("RFCONN stdout: %1").arg(QString::fromLatin1(ba)));
}
void SymbianAdapter::handleRfcommError(QProcess::ProcessError error)
void TrkGdbAdapter::handleRfcommError(QProcess::ProcessError error)
{
emit output(QString("RFCOMM: Process Error %1: %2").arg(error).arg(errorString()));
}
void SymbianAdapter::handleRfcommFinished(int exitCode, QProcess::ExitStatus exitStatus)
void TrkGdbAdapter::handleRfcommFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
emit output(QString("RFCOMM: ProcessFinished %1 %2").arg(exitCode).arg(exitStatus));
}
void SymbianAdapter::handleRfcommStarted()
void TrkGdbAdapter::handleRfcommStarted()
{
emit output(QString("RFCOMM: Process Started"));
}
void SymbianAdapter::handleRfcommStateChanged(QProcess::ProcessState newState)
void TrkGdbAdapter::handleRfcommStateChanged(QProcess::ProcessState newState)
{
emit output(QString("RFCOMM: Process State %1").arg(newState));
}
@@ -1287,64 +1287,64 @@ void SymbianAdapter::handleRfcommStateChanged(QProcess::ProcessState newState)
// GdbProcessBase
//
void SymbianAdapter::start(const QString &program, const QStringList &args,
void TrkGdbAdapter::start(const QString &program, const QStringList &args,
QIODevice::OpenMode mode)
{
Q_UNUSED(mode);
run();
}
void SymbianAdapter::kill()
void TrkGdbAdapter::kill()
{
m_gdbProc.kill();
}
void SymbianAdapter::terminate()
void TrkGdbAdapter::terminate()
{
m_gdbProc.terminate();
}
bool SymbianAdapter::waitForFinished(int msecs)
bool TrkGdbAdapter::waitForFinished(int msecs)
{
return m_gdbProc.waitForFinished(msecs);
}
QProcess::ProcessState SymbianAdapter::state() const
QProcess::ProcessState TrkGdbAdapter::state() const
{
return m_gdbProc.state();
}
QString SymbianAdapter::errorString() const
QString TrkGdbAdapter::errorString() const
{
return m_gdbProc.errorString();
}
QByteArray SymbianAdapter::readAllStandardError()
QByteArray TrkGdbAdapter::readAllStandardError()
{
return m_gdbProc.readAllStandardError();
}
QByteArray SymbianAdapter::readAllStandardOutput()
QByteArray TrkGdbAdapter::readAllStandardOutput()
{
return m_gdbProc.readAllStandardOutput();
}
qint64 SymbianAdapter::write(const char *data)
qint64 TrkGdbAdapter::write(const char *data)
{
return m_gdbProc.write(data);
}
void SymbianAdapter::setWorkingDirectory(const QString &dir)
void TrkGdbAdapter::setWorkingDirectory(const QString &dir)
{
m_gdbProc.setWorkingDirectory(dir);
}
void SymbianAdapter::setEnvironment(const QStringList &env)
void TrkGdbAdapter::setEnvironment(const QStringList &env)
{
m_gdbProc.setEnvironment(env);
}
void SymbianAdapter::attach(GdbEngine *engine) const
void TrkGdbAdapter::attach(GdbEngine *engine) const
{
#ifdef STANDALONE_RUNNER
#else

View File

@@ -27,12 +27,12 @@
**
**************************************************************************/
#ifndef DEBUGGER_SYMBIANADAPTER_H
#define DEBUGGER_SYMBIANADAPTER_H
#ifndef DEBUGGER_TRKGDBADAPTER_H
#define DEBUGGER_TRKGDBADAPTER_H
#include "trkutils.h"
#include "trkclient.h"
#include "gdbprocessbase.h"
#include "abstractgdbadapter.h"
#include <QtCore/QDebug>
#include <QtCore/QDir>
@@ -69,11 +69,11 @@ struct GdbResult
///////////////////////////////////////////////////////////////////////
//
// SymbianAdapter
// TrkGdbAdapter
//
///////////////////////////////////////////////////////////////////////
class SymbianAdapter : public GdbProcessBase
class TrkGdbAdapter : public AbstractGdbAdapter
{
Q_OBJECT
@@ -82,8 +82,8 @@ public:
typedef Callback<const TrkResult &> TrkCallback;
typedef Callback<const GdbResult &> GdbCallback;
SymbianAdapter();
~SymbianAdapter();
TrkGdbAdapter();
~TrkGdbAdapter();
void setGdbServerName(const QString &name);
QString gdbServerName() const { return m_gdbServerName; }
QString gdbServerIP() const;
@@ -242,4 +242,4 @@ public:
} // namespace Internal
} // namespace Debugger
#endif // DEBUGGER_SYMBIANADAPTER_H
#endif // DEBUGGER_TRKGDBADAPTER_H

View File

@@ -27,7 +27,7 @@
**
**************************************************************************/
#include "symbianadapter.h"
#include "trkgdbadapter.h"
#include <QtCore/QDebug>
@@ -97,7 +97,7 @@ class RunnerGui : public QMainWindow
Q_OBJECT
public:
RunnerGui(SymbianAdapter *adapter);
RunnerGui(TrkGdbAdapter *adapter);
private slots:
void executeStepICommand() { executeCommand("-exec-step-instruction"); }
@@ -118,7 +118,7 @@ private:
void executeCommand(const QString &cmd) { m_adapter->executeCommand(cmd); }
void connectAction(QAction *&, QString name, const char *slot);
SymbianAdapter *m_adapter;
TrkGdbAdapter *m_adapter;
TextEdit m_textEdit;
QToolBar m_toolBar;
QAction *m_stopAction;
@@ -130,7 +130,7 @@ private:
QAction *m_continueAction;
};
RunnerGui::RunnerGui(SymbianAdapter *adapter)
RunnerGui::RunnerGui(TrkGdbAdapter *adapter)
: m_adapter(adapter)
{
resize(1200, 1000);
@@ -224,7 +224,7 @@ void RunnerGui::started()
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
SymbianAdapter adapter;
TrkGdbAdapter adapter;
adapter.setVerbose(2);
RunnerGui gui(&adapter);
gui.show();

View File

@@ -11,13 +11,13 @@ QT += network
win32:CONFIG+=console
HEADERS += \
$$DEBUGGERHOME/../gdb/gdbprocessbase.h \
$$DEBUGGERHOME/../gdb/abstractgdbadapter.h \
$$DEBUGGERHOME/trkutils.h \
$$DEBUGGERHOME/trkclient.h \
$$DEBUGGERHOME/symbianadapter.h \
$$DEBUGGERHOME/trkgdbadapter.h \
SOURCES += \
$$DEBUGGERHOME/trkutils.cpp \
$$DEBUGGERHOME/trkclient.cpp \
$$DEBUGGERHOME/symbianadapter.cpp \
$$DEBUGGERHOME/trkgdbadapter.cpp \
$$PWD/runner.cpp \