diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index 3b9622e7f4c61a59a61545f3c9e519fe3215cb6c..e857f7bdb82a64ff829d951b2c3478785c44856a 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -430,6 +430,7 @@ private: BreakpointData *findBreakpoint(const QString &fileName, int lineNumber); void setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos); + // FIXME: Remove engine-specific state QSharedPointer<DebuggerStartParameters> m_startParameters; DebuggerRunControl *m_runControl; QString m_dumperLib; diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 84380f20548620c90832b043bbacc588568bad17..02e84fd6a9460acb63017bf8bb107f12a78bd216 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -138,6 +138,20 @@ static QByteArray parsePlainConsoleStream(const GdbResultRecord &record) return out.mid(pos + 3); } +/////////////////////////////////////////////////////////////////////// +// +// GdbProcess +// +/////////////////////////////////////////////////////////////////////// + +void GdbProcess::attach(GdbEngine *engine) const +{ + QFileInfo fi(engine->startParameters().executable); + QString fileName = fi.absoluteFilePath(); + engine->postCommand(_("-file-exec-and-symbols ") + fileName, + &GdbEngine::handleFileExecAndSymbols, "handleFileExecAndSymbols"); +} + /////////////////////////////////////////////////////////////////////// // // GdbEngine @@ -1678,26 +1692,28 @@ void GdbEngine::startDebugger2() } else if (m_startParameters.useTerminal) { qq->breakHandler()->setAllPending(); } else if (q->startMode() == StartInternal || q->startMode() == StartExternal) { - QFileInfo fi(m_startParameters.executable); - QString fileName = _c('"') + fi.absoluteFilePath() + _c('"'); - postCommand(_("-file-exec-and-symbols ") + fileName, CB(handleFileExecAndSymbols)); - //postCommand(_("file ") + fileName, handleFileExecAndSymbols); - #ifdef Q_OS_MAC - postCommand(_("sharedlibrary apply-load-rules all")); - #endif - if (!m_startParameters.processArgs.isEmpty()) - postCommand(_("-exec-arguments ") + m_startParameters.processArgs.join(_(" "))); - #ifndef Q_OS_MAC - if (!m_dumperInjectionLoad) - postCommand(_("set auto-solib-add off")); - postCommand(_("info target"), CB(handleStart)); - #else - // On MacOS, breaking in at the entry point wreaks havoc. - postCommand(_("tbreak main")); - m_waitingForFirstBreakpointToBeHit = true; - qq->notifyInferiorRunningRequested(); - postCommand(_("-exec-run"), CB(handleExecRun)); - #endif + m_gdbProc->attach(this); + if (m_gdbProc->isAdapter()) { + qq->notifyInferiorRunningRequested(); + postCommand(_("-exec-continue"), CB(handleExecContinue)); + } else { + #ifdef Q_OS_MAC + postCommand(_("sharedlibrary apply-load-rules all")); + #endif + if (!m_startParameters.processArgs.isEmpty()) + postCommand(_("-exec-arguments ") + m_startParameters.processArgs.join(_(" "))); + #ifdef Q_OS_MAC + // On MacOS, breaking in at the entry point wreaks havoc. + postCommand(_("tbreak main")); + m_waitingForFirstBreakpointToBeHit = true; + qq->notifyInferiorRunningRequested(); + postCommand(_("-exec-run"), CB(handleExecRun)); + #else + if (!m_dumperInjectionLoad) + postCommand(_("set auto-solib-add off")); + postCommand(_("info target"), CB(handleStart)); + #endif + } qq->breakHandler()->setAllPending(); } @@ -1724,16 +1740,11 @@ void GdbEngine::handleStart(const GdbResultRecord &response, const QVariant &) QString msg = _(response.data.findChild("consolestreamoutput").data()); QRegExp needle(_("\\bEntry point: (0x[0-9a-f]+)\\b")); if (needle.indexIn(msg) != -1) { - if (m_gdbProc->isAdapter()) { - postCommand(_("-exec-continue"), CB(handleExecRun)); - qq->notifyInferiorRunningRequested(); - } else { - //debugMessage(_("STREAM: ") + msg + " " + needle.cap(1)); - postCommand(_("tbreak *") + needle.cap(1)); - m_waitingForFirstBreakpointToBeHit = true; - qq->notifyInferiorRunningRequested(); - postCommand(_("-exec-run"), CB(handleExecRun)); - } + //debugMessage(_("STREAM: ") + msg + " " + needle.cap(1)); + postCommand(_("tbreak *") + needle.cap(1)); + m_waitingForFirstBreakpointToBeHit = true; + qq->notifyInferiorRunningRequested(); + postCommand(_("-exec-run"), CB(handleExecRun)); } else { debugMessage(_("PARSING START ADDRESS FAILED: ") + msg); } @@ -1771,7 +1782,6 @@ void GdbEngine::handleAttach(const GdbResultRecord &, const QVariant &) void GdbEngine::handleSetTargetAsync(const GdbResultRecord &record, const QVariant &) { if (record.resultClass == GdbResultDone) { - //postCommand(_("info target"), handleStart); qq->notifyInferiorRunningRequested(); postCommand(_("target remote %1").arg(q->startParameters()->remoteChannel), CB(handleTargetRemote)); diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index e202ec987a56caa7e8d878b7968bbcc1d85925e4..53ae548e277e33781b8c1af482cfbff9dc040f4a 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -107,6 +107,7 @@ public: void setWorkingDirectory(const QString &dir) { m_proc.setWorkingDirectory(dir); } void setEnvironment(const QStringList &env) { m_proc.setEnvironment(env); } bool isAdapter() const { return false; } + void attach(GdbEngine *engine) const; private: QProcess m_proc; @@ -126,6 +127,11 @@ signals: void applicationOutputAvailable(const QString &output); private: + friend class GdbProcess; + friend class SymbianAdapter; + + const DebuggerStartParameters &startParameters() const + { return m_startParameters; } // // IDebuggerEngine implementation // @@ -206,6 +212,7 @@ public: // otherwise the Qt flag macros are unhappy }; Q_DECLARE_FLAGS(GdbCommandFlags, GdbCommandFlag) + private: typedef void (GdbEngine::*GdbCommandCallback)(const GdbResultRecord &record, const QVariant &cookie); diff --git a/src/plugins/debugger/gdb/gdbprocessbase.h b/src/plugins/debugger/gdb/gdbprocessbase.h index 6c5825e6f663bb4304b50864a4b2cccd2defa09a..71483cd2ee5c1e644f3c1a99de22e4bced3c5696 100644 --- a/src/plugins/debugger/gdb/gdbprocessbase.h +++ b/src/plugins/debugger/gdb/gdbprocessbase.h @@ -36,6 +36,8 @@ namespace Debugger { 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 @@ -62,6 +64,8 @@ public: virtual void setEnvironment(const QStringList &env) = 0; virtual bool isAdapter() const = 0; + virtual void attach(GdbEngine *engine) const = 0; + signals: void error(QProcess::ProcessError); void started(); diff --git a/src/plugins/debugger/symbian/symbianadapter.cpp b/src/plugins/debugger/symbian/symbianadapter.cpp index 667bc6bf574b6b060c08ce9fa1e526f5909dcbcd..c5ff3dc2b24d3e06f1e1b50de1730f3368d8760d 100644 --- a/src/plugins/debugger/symbian/symbianadapter.cpp +++ b/src/plugins/debugger/symbian/symbianadapter.cpp @@ -28,9 +28,11 @@ **************************************************************************/ #include "symbianadapter.h" +#ifndef STANDALONE_RUNNER +#include "gdb/gdbengine.h" +#endif #define TrkCB(s) TrkCallback(this, &SymbianAdapter::s) -#define GdbCB(s) GdbCallback(this, &SymbianAdapter::s) using namespace trk; @@ -1307,7 +1309,7 @@ void SymbianAdapter::sendGdbMessage(const QString &msg, GdbCallback callback, data.command = msg; data.callback = callback; data.cookie = cookie; - logMessage(QString("<- GDB: %2").arg(msg)); + logMessage(QString("<- ADAPTER TO GDB: %2").arg(msg)); m_gdbProc.write(msg.toLatin1() + "\n"); } @@ -1410,5 +1412,17 @@ void SymbianAdapter::setEnvironment(const QStringList &env) m_gdbProc.setEnvironment(env); } +void SymbianAdapter::attach(GdbEngine *engine) const +{ +#ifdef STANDALONE_RUNNER +#else + QString fileName = engine->startParameters().executable; + engine->postCommand(_("add-symbol-file \"%1\" %2").arg(fileName) + .arg(m_session.codeseg)); + engine->postCommand(_("symbol-file \"%1\"").arg(fileName)); + engine->postCommand(_("target remote ") + gdbServerName()); +#endif +} + } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/symbian/symbianadapter.h b/src/plugins/debugger/symbian/symbianadapter.h index ed508d91289cf25f1d028154a006337b90982a4a..713692d44fa12a450e194bffabf4821038764f5b 100644 --- a/src/plugins/debugger/symbian/symbianadapter.h +++ b/src/plugins/debugger/symbian/symbianadapter.h @@ -132,6 +132,7 @@ public: void setWorkingDirectory(const QString &dir); void setEnvironment(const QStringList &env); bool isAdapter() const { return true; } + void attach(GdbEngine *engine) const; // // TRK diff --git a/tests/manual/trk/runner.pro b/tests/manual/trk/runner.pro index 21461da2d94b33ce1a3df8759d3894afa3fa154d..20240eb1f737960ad63af3a26cdeebbf5c4b0684 100644 --- a/tests/manual/trk/runner.pro +++ b/tests/manual/trk/runner.pro @@ -4,6 +4,8 @@ TEMPLATE = app DEBUGGERHOME = ../../../src/plugins/debugger/symbian INCLUDEPATH *= $$DEBUGGERHOME +DEFINES += STANDALONE_RUNNER + QT += network win32:CONFIG+=console