Commit e642b0b1 authored by hjk's avatar hjk
Browse files

debugger: work on startup

parent 67e04194
...@@ -826,7 +826,7 @@ void DebuggerManager::startNewDebugger(const DebuggerStartParametersPtr &sp) ...@@ -826,7 +826,7 @@ void DebuggerManager::startNewDebugger(const DebuggerStartParametersPtr &sp)
QString errorMessage; QString errorMessage;
QString settingsIdHint; QString settingsIdHint;
switch (startMode()) { switch (m_startParameters->startMode) {
case AttachExternal: case AttachExternal:
case AttachCrashedExternal: case AttachCrashedExternal:
m_engine = determineDebuggerEngine(m_startParameters->attachPID, m_engine = determineDebuggerEngine(m_startParameters->attachPID,
...@@ -1130,7 +1130,7 @@ void DebuggerManager::setStatus(int status) ...@@ -1130,7 +1130,7 @@ void DebuggerManager::setStatus(int status)
const bool running = status == DebuggerInferiorRunning; const bool running = status == DebuggerInferiorRunning;
const bool ready = status == DebuggerInferiorStopped const bool ready = status == DebuggerInferiorStopped
&& startMode() != AttachCore; && m_startParameters->startMode != AttachCore;
if (ready) if (ready)
QApplication::alert(mainWindow(), 3000); QApplication::alert(mainWindow(), 3000);
...@@ -1437,11 +1437,6 @@ void DebuggerManager::showQtDumperLibraryWarning(const QString &details) ...@@ -1437,11 +1437,6 @@ void DebuggerManager::showQtDumperLibraryWarning(const QString &details)
} }
} }
DebuggerStartMode DebuggerManager::startMode() const
{
return m_startParameters->startMode;
}
void DebuggerManager::reloadFullStack() void DebuggerManager::reloadFullStack()
{ {
if (m_engine) if (m_engine)
......
...@@ -399,7 +399,7 @@ public: ...@@ -399,7 +399,7 @@ public:
QAbstractItemModel *threadsModel(); QAbstractItemModel *threadsModel();
int status() const { return m_status; } int status() const { return m_status; }
// FIXME: hide this in the engines? // FIXME: hide this in the engines?
DebuggerStartMode startMode() const; //DebuggerStartMode startMode() const;
QList<Symbol> moduleSymbols(const QString &moduleName); QList<Symbol> moduleSymbols(const QString &moduleName);
......
...@@ -1334,7 +1334,7 @@ void DebuggerPlugin::updateActions(int status) ...@@ -1334,7 +1334,7 @@ void DebuggerPlugin::updateActions(int status)
//const bool running = status == DebuggerInferiorRunning; //const bool running = status == DebuggerInferiorRunning;
const bool ready = status == DebuggerInferiorStopped const bool ready = status == DebuggerInferiorStopped
&& m_manager->startMode() != AttachCore; && m_manager->startParameters()->startMode != AttachCore;
m_startExternalAction->setEnabled(!started && !starting); m_startExternalAction->setEnabled(!started && !starting);
m_attachExternalAction->setEnabled(!started && !starting); m_attachExternalAction->setEnabled(!started && !starting);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
......
...@@ -154,7 +154,7 @@ void PlainGdbAdapter::attach() ...@@ -154,7 +154,7 @@ void PlainGdbAdapter::attach()
void PlainGdbAdapter::interruptInferior() void PlainGdbAdapter::interruptInferior()
{ {
if (m_engine->manager()->startMode() == StartRemote) { if (m_engine->startMode() == StartRemote) {
m_engine->postCommand(_("-exec-interrupt")); m_engine->postCommand(_("-exec-interrupt"));
return; return;
} }
...@@ -1545,7 +1545,7 @@ int GdbEngine::currentFrame() const ...@@ -1545,7 +1545,7 @@ int GdbEngine::currentFrame() const
void GdbEngine::startDebugger(const QSharedPointer<DebuggerStartParameters> &sp) void GdbEngine::startDebugger(const QSharedPointer<DebuggerStartParameters> &sp)
{ {
m_startParameters = *sp; m_startParameters = sp;
// This should be set by the constructor or in exitDebugger(). // This should be set by the constructor or in exitDebugger().
QTC_ASSERT(m_debuggingHelperState == DebuggingHelperUninitialized, QTC_ASSERT(m_debuggingHelperState == DebuggingHelperUninitialized,
initializeVariables()); initializeVariables());
...@@ -1566,24 +1566,24 @@ void GdbEngine::startDebugger(const QSharedPointer<DebuggerStartParameters> &sp) ...@@ -1566,24 +1566,24 @@ void GdbEngine::startDebugger(const QSharedPointer<DebuggerStartParameters> &sp)
// nothing to do // nothing to do
} else if (startMode() == StartRemote) { } else if (startMode() == StartRemote) {
// Start the remote server // Start the remote server
if (m_startParameters.serverStartScript.isEmpty()) { if (m_startParameters->serverStartScript.isEmpty()) {
showStatusMessage(_("No server start script given. " showStatusMessage(_("No server start script given. "
"Assuming server runs already.")); "Assuming server runs already."));
} else { } else {
if (!m_startParameters.workingDir.isEmpty()) if (!m_startParameters->workingDir.isEmpty())
m_uploadProc.setWorkingDirectory(m_startParameters.workingDir); m_uploadProc.setWorkingDirectory(m_startParameters->workingDir);
if (!m_startParameters.environment.isEmpty()) if (!m_startParameters->environment.isEmpty())
m_uploadProc.setEnvironment(m_startParameters.environment); m_uploadProc.setEnvironment(m_startParameters->environment);
m_uploadProc.start(_("/bin/sh ") + m_startParameters.serverStartScript); m_uploadProc.start(_("/bin/sh ") + m_startParameters->serverStartScript);
m_uploadProc.waitForStarted(); m_uploadProc.waitForStarted();
} }
} else if (m_startParameters.useTerminal) { } else if (m_startParameters->useTerminal) {
m_stubProc.stop(); // We leave the console open, so recycle it now. m_stubProc.stop(); // We leave the console open, so recycle it now.
m_stubProc.setWorkingDirectory(m_startParameters.workingDir); m_stubProc.setWorkingDirectory(m_startParameters->workingDir);
m_stubProc.setEnvironment(m_startParameters.environment); m_stubProc.setEnvironment(m_startParameters->environment);
if (!m_stubProc.start(m_startParameters.executable, if (!m_stubProc.start(m_startParameters->executable,
m_startParameters.processArgs)) { m_startParameters->processArgs)) {
// Error message for user is delivered via a signal. // Error message for user is delivered via a signal.
emitStartFailed(); emitStartFailed();
return; return;
...@@ -1598,10 +1598,10 @@ void GdbEngine::startDebugger(const QSharedPointer<DebuggerStartParameters> &sp) ...@@ -1598,10 +1598,10 @@ void GdbEngine::startDebugger(const QSharedPointer<DebuggerStartParameters> &sp)
} }
gdbArgs.prepend(_("--tty=") + m_outputCollector.serverName()); gdbArgs.prepend(_("--tty=") + m_outputCollector.serverName());
if (!m_startParameters.workingDir.isEmpty()) if (!m_startParameters->workingDir.isEmpty())
m_gdbAdapter->setWorkingDirectory(m_startParameters.workingDir); m_gdbAdapter->setWorkingDirectory(m_startParameters->workingDir);
if (!m_startParameters.environment.isEmpty()) if (!m_startParameters->environment.isEmpty())
m_gdbAdapter->setEnvironment(m_startParameters.environment); m_gdbAdapter->setEnvironment(m_startParameters->environment);
} }
#if 0 #if 0
...@@ -1610,8 +1610,8 @@ void GdbEngine::startDebugger(const QSharedPointer<DebuggerStartParameters> &sp) ...@@ -1610,8 +1610,8 @@ void GdbEngine::startDebugger(const QSharedPointer<DebuggerStartParameters> &sp)
qDebug() << "ScriptFile:" << m_manager->settings()->m_scriptFile; qDebug() << "ScriptFile:" << m_manager->settings()->m_scriptFile;
qDebug() << "Environment:" << m_gdbAdapter->environment(); qDebug() << "Environment:" << m_gdbAdapter->environment();
qDebug() << "Arguments:" << gdbArgs; qDebug() << "Arguments:" << gdbArgs;
qDebug() << "BuildDir:" << m_startParameters.buildDir; qDebug() << "BuildDir:" << m_startParameters->buildDir;
qDebug() << "ExeFile:" << m_startParameters.executable; qDebug() << "ExeFile:" << m_startParameters->executable;
#endif #endif
QString loc = theDebuggerStringSetting(GdbLocation); QString loc = theDebuggerStringSetting(GdbLocation);
...@@ -1713,28 +1713,28 @@ void GdbEngine::startDebugger2() ...@@ -1713,28 +1713,28 @@ void GdbEngine::startDebugger2()
} }
if (startMode() == AttachExternal || startMode() == AttachCrashedExternal) { if (startMode() == AttachExternal || startMode() == AttachCrashedExternal) {
postCommand(_("attach %1").arg(m_startParameters.attachPID), CB(handleAttach)); postCommand(_("attach %1").arg(m_startParameters->attachPID), CB(handleAttach));
// Task 254674 does not want to remove them // Task 254674 does not want to remove them
//qq->breakHandler()->removeAllBreakpoints(); //qq->breakHandler()->removeAllBreakpoints();
} else if (startMode() == AttachCore) { } else if (startMode() == AttachCore) {
QFileInfo fi(m_startParameters.executable); QFileInfo fi(m_startParameters->executable);
QString fileName = _c('"') + fi.absoluteFilePath() + _c('"'); QString fileName = _c('"') + fi.absoluteFilePath() + _c('"');
QFileInfo fi2(m_startParameters.coreFile); QFileInfo fi2(m_startParameters->coreFile);
// quoting core name below fails in gdb 6.8-debian // quoting core name below fails in gdb 6.8-debian
QString coreName = fi2.absoluteFilePath(); QString coreName = fi2.absoluteFilePath();
postCommand(_("-file-exec-and-symbols ") + fileName, CB(handleFileExecAndSymbols)); postCommand(_("-file-exec-and-symbols ") + fileName, CB(handleFileExecAndSymbols));
postCommand(_("target core ") + coreName, CB(handleTargetCore)); postCommand(_("target core ") + coreName, CB(handleTargetCore));
qq->breakHandler()->removeAllBreakpoints(); qq->breakHandler()->removeAllBreakpoints();
} else if (startMode() == StartRemote) { } else if (startMode() == StartRemote) {
postCommand(_("set architecture %1").arg(m_startParameters.remoteArchitecture)); postCommand(_("set architecture %1").arg(m_startParameters->remoteArchitecture));
qq->breakHandler()->setAllPending(); qq->breakHandler()->setAllPending();
//QFileInfo fi(m_startParameters.executable); //QFileInfo fi(m_startParameters->executable);
//QString fileName = fi.absoluteFileName(); //QString fileName = fi.absoluteFileName();
QString fileName = m_startParameters.executable; QString fileName = m_startParameters->executable;
postCommand(_("-file-exec-and-symbols \"%1\"").arg(fileName), CB(handleFileExecAndSymbols)); postCommand(_("-file-exec-and-symbols \"%1\"").arg(fileName), CB(handleFileExecAndSymbols));
// works only for > 6.8 // works only for > 6.8
postCommand(_("set target-async on"), CB(handleSetTargetAsync)); postCommand(_("set target-async on"), CB(handleSetTargetAsync));
} else if (m_startParameters.useTerminal) { } else if (m_startParameters->useTerminal) {
qq->breakHandler()->setAllPending(); qq->breakHandler()->setAllPending();
} else if (startMode() == StartInternal || startMode() == StartExternal) { } else if (startMode() == StartInternal || startMode() == StartExternal) {
qq->breakHandler()->setAllPending(); qq->breakHandler()->setAllPending();
...@@ -1748,8 +1748,8 @@ void GdbEngine::startDebugger2() ...@@ -1748,8 +1748,8 @@ void GdbEngine::startDebugger2()
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
postCommand(_("sharedlibrary apply-load-rules all")); postCommand(_("sharedlibrary apply-load-rules all"));
#endif #endif
if (!m_startParameters.processArgs.isEmpty()) if (!m_startParameters->processArgs.isEmpty())
postCommand(_("-exec-arguments ") + m_startParameters.processArgs.join(_(" "))); postCommand(_("-exec-arguments ") + m_startParameters->processArgs.join(_(" ")));
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
// On MacOS, breaking in at the entry point wreaks havoc. // On MacOS, breaking in at the entry point wreaks havoc.
postCommand(_("tbreak main")); postCommand(_("tbreak main"));
......
...@@ -132,7 +132,7 @@ private: ...@@ -132,7 +132,7 @@ private:
friend class TrkGdbAdapter; friend class TrkGdbAdapter;
const DebuggerStartParameters &startParameters() const const DebuggerStartParameters &startParameters() const
{ return m_startParameters; } { return *m_startParameters; }
// //
// IDebuggerEngine implementation // IDebuggerEngine implementation
// //
...@@ -298,7 +298,7 @@ private: ...@@ -298,7 +298,7 @@ private:
{ m_manager->showStatusMessage(msg, timeout); } { m_manager->showStatusMessage(msg, timeout); }
int status() const { return m_manager->status(); } int status() const { return m_manager->status(); }
QMainWindow *mainWindow() const { return m_manager->mainWindow(); } QMainWindow *mainWindow() const { return m_manager->mainWindow(); }
DebuggerStartMode startMode() const { return m_manager->startMode(); } DebuggerStartMode startMode() const { return m_startParameters->startMode; }
qint64 inferiorPid() const { return m_manager->inferiorPid(); } qint64 inferiorPid() const { return m_manager->inferiorPid(); }
void handleChildren(const WatchData &parent, const GdbMi &child, void handleChildren(const WatchData &parent, const GdbMi &child,
...@@ -455,7 +455,7 @@ private: ...@@ -455,7 +455,7 @@ private:
DebuggerManager * const m_manager; DebuggerManager * const m_manager;
IDebuggerManagerAccessForEngines * const qq; IDebuggerManagerAccessForEngines * const qq;
DebuggerStartParameters m_startParameters; DebuggerStartParametersPtr m_startParameters;
// make sure to re-initialize new members in initializeVariables(); // make sure to re-initialize new members in initializeVariables();
}; };
......
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