From 6edae34a54df4acc38c035aa516798a3e6ed805c Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Tue, 17 Feb 2009 12:24:19 +0100 Subject: [PATCH 01/37] Fixes: Flicker-free update of the editor toolbars (mac -only). --- src/plugins/coreplugin/editormanager/stackededitorgroup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/coreplugin/editormanager/stackededitorgroup.cpp b/src/plugins/coreplugin/editormanager/stackededitorgroup.cpp index cc759c6c7ff..7ad5d056fe5 100644 --- a/src/plugins/coreplugin/editormanager/stackededitorgroup.cpp +++ b/src/plugins/coreplugin/editormanager/stackededitorgroup.cpp @@ -329,8 +329,8 @@ void StackedEditorGroup::updateToolBar(IEditor *editor) toolBar = m_defaultToolBar; if (m_activeToolBar == toolBar) return; - toolBar->setVisible(true); m_activeToolBar->setVisible(false); + toolBar->setVisible(true); m_activeToolBar = toolBar; } From c05e9347bb349b265c61cb38f0c4382363dc91b4 Mon Sep 17 00:00:00 2001 From: con Date: Tue, 17 Feb 2009 12:59:58 +0100 Subject: [PATCH 02/37] Fixes: - Make sure that we find make command for gdbmacros library. Task: - 244273 Details: - We need to search in the path for it. --- src/plugins/qt4projectmanager/gdbmacrosbuildstep.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/qt4projectmanager/gdbmacrosbuildstep.cpp b/src/plugins/qt4projectmanager/gdbmacrosbuildstep.cpp index 507c059239e..6e2ccbc2506 100644 --- a/src/plugins/qt4projectmanager/gdbmacrosbuildstep.cpp +++ b/src/plugins/qt4projectmanager/gdbmacrosbuildstep.cpp @@ -124,7 +124,15 @@ void GdbMacrosBuildStep::run(QFutureInterface & fi) qmake.start(m_qmake, QStringList()<<"-spec"<qtVersion(m_buildConfiguration)->makeCommand(), makeArguments); + QString makeCmd = qt4Project->qtVersion(m_buildConfiguration)->makeCommand(); + if (!value(m_buildConfiguration, "makeCmd").toString().isEmpty()) + makeCmd = value(m_buildConfiguration, "makeCmd").toString(); + if (!QFileInfo(makeCmd).isAbsolute()) { + // Try to detect command in environment + QString tmp = qt4Project->environment(m_buildConfiguration).searchInPath(makeCmd); + makeCmd = tmp; + } + qmake.start(makeCmd, makeArguments); qmake.waitForFinished(); fi.reportResult(true); From 7b8b947946877eecd6dd306c59abed0c307acdca Mon Sep 17 00:00:00 2001 From: con Date: Tue, 17 Feb 2009 13:01:09 +0100 Subject: [PATCH 03/37] Fixes: - Rename System Qt to perhaps avoid some confusion. Task: - 243948 --- src/plugins/qt4projectmanager/qtversionmanager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index f79cc4b5964..e39dc8bf57e 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -296,12 +296,13 @@ void QtVersionManager::updateSystemVersion() foreach (QtVersion *version, m_versions) { if (version->isSystemVersion()) { version->setPath(findSystemQt()); + version->setName(tr("Auto-detected Qt")); haveSystemVersion = true; } } if (haveSystemVersion) return; - QtVersion *version = new QtVersion(tr("System Qt"), + QtVersion *version = new QtVersion(tr("Auto-detected Qt"), findSystemQt(), getUniqueId(), true); From b32198d73645be42924cd0468b780b022bcda08a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 17 Feb 2009 15:11:56 +0100 Subject: [PATCH 04/37] Fix size problems on reusing function argument widget We now hide the parent QFrame while updating the label to work around the problem where the it wouldn't shrink the widget. --- src/plugins/cpptools/cppcodecompletion.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp index 81cc4741b5e..233398026fe 100644 --- a/src/plugins/cpptools/cppcodecompletion.cpp +++ b/src/plugins/cpptools/cppcodecompletion.cpp @@ -217,6 +217,8 @@ FunctionArgumentWidget::FunctionArgumentWidget() void FunctionArgumentWidget::showFunctionHint(Function *functionSymbol, const LookupContext &context) { + m_popupFrame->hide(); + m_item = functionSymbol; m_context = context; m_startpos = m_editor->position(); @@ -230,7 +232,7 @@ void FunctionArgumentWidget::showFunctionHint(Function *functionSymbol, m_popupFrame->move(pos); m_popupFrame->show(); - QCoreApplication::instance()->installEventFilter(this); + qApp->installEventFilter(this); } void FunctionArgumentWidget::update() From 7ec3f73594c21aae67fa695b87c84152222a14bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 17 Feb 2009 16:14:52 +0100 Subject: [PATCH 05/37] Center the cursor after (un)collapse all Requested on the mailing list. Increases usability. --- src/plugins/texteditor/basetexteditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index d5b088396a5..1d0d910a4c8 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -3463,12 +3463,12 @@ void BaseTextEditor::unCollapseAll() if (TextBlockUserData::canCollapse(block)) TextBlockUserData::doCollapse(block, makeVisible); block = block.next(); - } d->moveCursorVisible(); documentLayout->requestUpdate(); documentLayout->emitDocumentSizeChanged(); + centerCursor(); } void BaseTextEditor::setTextCodec(QTextCodec *codec) From 4f20ef9f4e20d9c2080ec66121c5fd4a6cfc2114 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 17 Feb 2009 17:34:10 +0100 Subject: [PATCH 06/37] Fixes: correct name for gdmacros.cpp hint Conflicts: src/plugins/debugger/gdbengine.cpp --- src/plugins/debugger/gdbengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index f6413db72f9..2a4068b447a 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -3338,7 +3338,7 @@ void GdbEngine::handleQueryDataDumper2(const GdbResultRecord &record) tr("The debugged binary does not contain information needed for " "nice display of Qt data types.\n\n" "You might want to try including the file\n\n" - ".../share/qtcreator/gdbmacros/gdbmacros.cpp\n\n" + ".../share/qtcreator/gdbmacros/gdbmacros.cpp'\n\n" "into your project directly.") ); } else { From 433ded47d82dc3fb26b8f5cbcd53058de6b9d83c Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 17 Feb 2009 17:34:41 +0100 Subject: [PATCH 07/37] Fixes: correct path for gcbmnacros.cpp hint Conflicts: src/plugins/debugger/gdbengine.cpp --- src/plugins/debugger/gdbengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 2a4068b447a..f6413db72f9 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -3338,7 +3338,7 @@ void GdbEngine::handleQueryDataDumper2(const GdbResultRecord &record) tr("The debugged binary does not contain information needed for " "nice display of Qt data types.\n\n" "You might want to try including the file\n\n" - ".../share/qtcreator/gdbmacros/gdbmacros.cpp'\n\n" + ".../share/qtcreator/gdbmacros/gdbmacros.cpp\n\n" "into your project directly.") ); } else { From 153766b956bbf5b61681bbae8d4aac3d9095cca6 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 17 Feb 2009 17:36:54 +0100 Subject: [PATCH 08/37] Fixes: debugger: revert accidental parts of b0650238 Conflicts: src/plugins/debugger/gdbengine.cpp --- src/plugins/debugger/gdbengine.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index f6413db72f9..66c9efb887a 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -3590,7 +3590,6 @@ void GdbEngine::updateLocals() setTokenBarrier(); m_pendingRequests = 0; - PENDING_DEBUG("\nRESET PENDING"); m_toolTipCache.clear(); m_toolTipExpression.clear(); @@ -3602,8 +3601,6 @@ void GdbEngine::updateLocals() sendSynchronizedCommand(cmd, StackListArguments); // stage 1/2 // '2' is 'list with type and value' sendSynchronizedCommand("-stack-list-locals 2", StackListLocals); // stage 2/2 - - tryLoadCustomDumpers(); } void GdbEngine::handleStackListArguments(const GdbResultRecord &record) From 1afd270da250f59a893d36dc53124831bd63864d Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 17 Feb 2009 17:38:24 +0100 Subject: [PATCH 09/37] Fixes: debugger: move custom dumper initialization into the first watch view update Conflicts: src/plugins/debugger/gdbengine.cpp --- src/plugins/debugger/gdbengine.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 66c9efb887a..9e818be0d1a 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -3590,6 +3590,7 @@ void GdbEngine::updateLocals() setTokenBarrier(); m_pendingRequests = 0; + PENDING_DEBUG("\nRESET PENDING"); m_toolTipCache.clear(); m_toolTipExpression.clear(); @@ -3601,6 +3602,8 @@ void GdbEngine::updateLocals() sendSynchronizedCommand(cmd, StackListArguments); // stage 1/2 // '2' is 'list with type and value' sendSynchronizedCommand("-stack-list-locals 2", StackListLocals); // stage 2/2 + + tryLoadCustomDumpers(); } void GdbEngine::handleStackListArguments(const GdbResultRecord &record) @@ -3982,9 +3985,9 @@ void GdbEngine::tryLoadCustomDumpers() //if (qq->useFastStart()) // sendCommand("set stop-on-solib-events 0"); QString flag = QString::number(RTLD_NOW); - sendSynchronizedCommand("call (void)dlopen(\"" + lib + "\", " + flag + ")", + sendSyncronizedCommand("call (void)dlopen(\"" + lib + "\", " + flag + ")", WatchDumpCustomSetup); - sendSynchronizedCommand("sharedlibrary " + dotEscape(lib)); + sendSyncronizedCommand("sharedlibrary " + dotEscape(lib)); //if (qq->useFastStart()) // sendCommand("set stop-on-solib-events 1"); } else { @@ -3999,9 +4002,9 @@ void GdbEngine::tryLoadCustomDumpers() // sendCommand("set stop-on-solib-events 0"); //sendCommand("handle SIGSEGV pass stop print"); //sendCommand("set unwindonsignal off"); - sendSynchronizedCommand("call LoadLibraryA(\"" + lib + "\")", + sendSyncronizedCommand("call LoadLibraryA(\"" + lib + "\")", WatchDumpCustomSetup); - sendSynchronizedCommand("sharedlibrary " + dotEscape(lib)); + sendSyncronizedCommand("sharedlibrary " + dotEscape(lib)); //if (qq->useFastStart()) // sendCommand("set stop-on-solib-events 1"); } else { From 7ebfeb037bf83b25ad00805040cef6f87e5943d3 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 12 Feb 2009 09:55:59 +0100 Subject: [PATCH 10/37] Fixes: debugger: introduce early break after application initialization --- src/plugins/debugger/debuggermanager.cpp | 6 -- src/plugins/debugger/gdbengine.cpp | 106 ++++++++++++++++++++--- src/plugins/debugger/gdbengine.h | 3 + 3 files changed, 97 insertions(+), 18 deletions(-) diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index f017cebccef..4868cf4c517 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -540,12 +540,6 @@ void DebuggerManager::notifyStartupFinished() { setStatus(DebuggerProcessReady); showStatusMessage(tr("Startup finished. Debugger ready."), -1); - if (m_startMode == attachExternal) { - // we continue the execution - engine()->continueInferior(); - } else { - engine()->runInferior(); - } } void DebuggerManager::notifyInferiorStopped() diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 9e818be0d1a..6084831b1b4 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -100,6 +100,9 @@ enum GdbCommandType GdbQuerySources, GdbAsyncOutput2, GdbExecRun, + GdbExecStart1, + GdbExecStart2, + GdbExecStart3, GdbExecRunToFunction, GdbExecStep, GdbExecNext, @@ -635,6 +638,7 @@ void GdbEngine::maybeHandleInferiorPidChanged(const QString &pid0) } if (pid == q->m_attachedPID) return; + //qDebug() << "FOUND PID " << pid; q->m_attachedPID = pid; qq->notifyInferiorPidChanged(pid); } @@ -686,8 +690,8 @@ void GdbEngine::sendCommand(const QString &command, int type, //qDebug() << qPrintable(currentTime()) << "RUNNING" << cmd.command; m_gdbProc.write(cmd.command.toLatin1() + "\r\n"); //emit gdbInputAvailable(QString(), " " + currentTime()); - emit gdbInputAvailable(QString(), "[" + currentTime() + "] " + cmd.command); - //emit gdbInputAvailable(QString(), cmd.command); + //emit gdbInputAvailable(QString(), "[" + currentTime() + "] " + cmd.command); + emit gdbInputAvailable(QString(), cmd.command); } if (temporarilyStopped) @@ -753,9 +757,18 @@ void GdbEngine::handleResult(const GdbResultRecord & record, int type, case GdbExecContinue: case GdbExecFinish: // evil code sharing - case GdbExecRun: handleExecRun(record); break; + + case GdbExecStart1: + handleExecStart1(record); + break; + case GdbExecStart2: + handleExecStart2(record); + break; + case GdbExecStart3: + handleExecStart3(record); + break; case GdbInfoProc: handleInfoProc(record); break; @@ -1134,6 +1147,34 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) const QString reason = data.findChild("reason").data(); QString console = data.findChild("consolestreamoutput").data(); + if (reason.isEmpty()) { + GdbMi frame = data.findChild("frame"); + if (frame.findChild("func").data() == "_start") { + // that's the "early stop" + frame.findChild("func").data() + '%'; + #if defined(Q_OS_WIN) + sendCommand("info proc", GdbInfoProc); + #endif + #if defined(Q_OS_LINUX) + sendCommand("info proc", GdbInfoProc); + #endif + #if defined(Q_OS_MAC) + sendCommand("info pid", GdbInfoProc, QVariant(), true); + #endif + sendCommand("-file-list-exec-source-files", GdbQuerySources); + sendCommand("set auto-solib-add on"); + sendCommand("sharedlibrary libc"); // for malloc + sendCommand("sharedlibrary libdl"); // for dlopen + tryLoadCustomDumpers(); + sendCommand("info shared", ModulesList, QVariant()); + // this will "continue" if done + attemptBreakpointSynchronization(); + return; + } + // fall through + } + +#if 0 if (console.contains("Stopped due to shared library event") || reason.isEmpty()) { ++m_shared; //if (m_shared == 2) @@ -1162,6 +1203,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) } return; } +#endif if (isExitedReason(reason)) { qq->notifyInferiorExited(); @@ -1218,7 +1260,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) if (reason == "breakpoint-hit") { q->showStatusMessage(tr("Stopped at breakpoint")); GdbMi frame = data.findChild("frame"); - //qDebug() << frame.toString(); + qDebug() << "HIT BREAKPOINT: " << frame.toString(); m_currentFrame = frame.findChild("addr").data() + '%' + frame.findChild("func").data() + '%'; @@ -1604,16 +1646,27 @@ bool GdbEngine::startDebugger() } } + if (q->startMode() == q->startInternal) { + sendCommand("-file-exec-and-symbols " + fileName, GdbFileExecAndSymbols); + //sendCommand("file " + fileName, GdbFileExecAndSymbols); + #ifdef Q_OS_MAC + sendCommand("sharedlibrary apply-load-rules all"); + #endif + //sendCommand("-gdb-set stop-on-solib-events 1"); + runInferior(); + } + if (q->startMode() == q->attachExternal) { sendCommand("attach " + QString::number(q->m_attachedPID)); } - if (q->startMode() == q->startInternal || q->startMode() == q->startExternal) { - sendCommand("-file-exec-and-symbols " + fileName, GdbFileExecAndSymbols); + if (q->startMode() == q->startExternal) { + //sendCommand("-file-exec-and-symbols " + fileName, GdbFileExecAndSymbols); + sendCommand("file " + fileName, GdbFileExecAndSymbols); #ifdef Q_OS_MAC sendCommand("sharedlibrary apply-load-rules all"); #endif - sendCommand("-file-list-exec-source-files", GdbQuerySources); + //sendCommand("-file-list-exec-source-files", GdbQuerySources); //sendCommand("-gdb-set stop-on-solib-events 1"); } @@ -1625,7 +1678,7 @@ bool GdbEngine::startDebugger() else qq->breakHandler()->setAllPending(); - QTimer::singleShot(0, this, SLOT(attemptBreakpointSynchronization())); + //QTimer::singleShot(0, this, SLOT(attemptBreakpointSynchronization())); return true; } @@ -1648,7 +1701,33 @@ void GdbEngine::runInferior() sendCommand("-exec-arguments " + q->m_processArgs.join(" ")); qq->notifyInferiorRunningRequested(); emit gdbInputAvailable(QString(), QString()); - sendCommand("-exec-run", GdbExecRun); + + sendCommand("set auto-solib-add off"); + sendCommand("x/2i _start", GdbExecStart1); +} + +void GdbEngine::handleExecStart1(const GdbResultRecord &response) +{ + if (response.resultClass == GdbResultDone) { + // stdout:&"x/2i _start\n" + // stdout:~"0x404540 <_start>:\txor %ebp,%ebp\n" + // stdout:~"0x404542 <_start+2>:\tmov %rdx,%r9\n" + QString msg = response.data.findChild("consolestreamoutput").data(); + QRegExp needle("0x([0-9a-f]+) <_start\\+.*>:"); + if (needle.indexIn(msg) != -1) { + //qDebug() << "STREAM: " << msg << needle.cap(1); + sendCommand("tbreak *0x" + needle.cap(1)); // GdbExecStart3); + sendCommand("-exec-run"); // GdbExecStart3); + } else { + qDebug() << "PARSING START ADDRESS FAILED" << msg; + } + } else if (response.resultClass == GdbResultError) { + qDebug() << "PARSING START ADDRESS FAILED" << response.toString(); + } +} + +void GdbEngine::handleExecStart3(const GdbResultRecord &response) +{ #if defined(Q_OS_WIN) sendCommand("info proc", GdbInfoProc); #endif @@ -1658,6 +1737,7 @@ void GdbEngine::runInferior() #if defined(Q_OS_MAC) sendCommand("info pid", GdbInfoProc, QVariant(), true); #endif + attemptBreakpointSynchronization(); } void GdbEngine::stepExec() @@ -2183,8 +2263,10 @@ void GdbEngine::attemptBreakpointSynchronization() //sendListBreakpoints(); } - if (!updateNeeded && q->status() == DebuggerProcessStartingUp) - qq->notifyStartupFinished(); + if (!updateNeeded && q->status() == DebuggerProcessStartingUp) { + // we continue the execution + continueInferior(); + } } @@ -3603,7 +3685,7 @@ void GdbEngine::updateLocals() // '2' is 'list with type and value' sendSynchronizedCommand("-stack-list-locals 2", StackListLocals); // stage 2/2 - tryLoadCustomDumpers(); + //tryLoadCustomDumpers(); } void GdbEngine::handleStackListArguments(const GdbResultRecord &record) diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h index a603aee375d..14cb65d7cdf 100644 --- a/src/plugins/debugger/gdbengine.h +++ b/src/plugins/debugger/gdbengine.h @@ -185,6 +185,9 @@ private: void handleResultRecord(const GdbResultRecord &response); void handleFileExecAndSymbols(const GdbResultRecord &response); void handleExecRun(const GdbResultRecord &response); + void handleExecStart1(const GdbResultRecord &response); + void handleExecStart2(const GdbResultRecord &response); + void handleExecStart3(const GdbResultRecord &response); void handleExecJumpToLine(const GdbResultRecord &response); void handleExecRunToFunction(const GdbResultRecord &response); void handleInfoShared(const GdbResultRecord &response); From ab31640462d4ffffa2d6b2e2236ca7d42e460a34 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 12 Feb 2009 11:18:38 +0100 Subject: [PATCH 11/37] Fixes: debugger: work on more fine-grained breakpoints-in-plugins setting --- src/plugins/debugger/debuggermanager.h | 5 + src/plugins/debugger/debuggerplugin.cpp | 52 ++++++++--- src/plugins/debugger/gdbengine.cpp | 4 +- src/plugins/debugger/gdbengine.h | 1 - src/plugins/debugger/gdboptionpage.ui | 119 +++++++++++++++--------- 5 files changed, 122 insertions(+), 59 deletions(-) diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index 1c12a731643..a43feb7e96c 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -200,6 +200,11 @@ public: bool m_useToolTips; QString m_scriptFile; + + bool m_pluginAllBreakpoints; + bool m_pluginSelectedBreakpoints; + bool m_pluginNoBreakpoints; + QString m_pluginSelectedBreakpointsPattern; }; // diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index b8bffaa14eb..aa3fca911f6 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -274,15 +274,24 @@ QWidget *GdbOptionPage::createPage(QWidget *parent) m_ui.scriptFileChooser->setPromptDialogTitle(tr("Choose Location of Startup Script File")); m_ui.scriptFileChooser->setPath(m_settings.m_scriptFile); m_ui.environmentEdit->setText(m_settings.m_gdbEnv); - m_ui.autoStartBox->setChecked(m_settings.m_autoRun); - m_ui.autoQuitBox->setChecked(m_settings.m_autoQuit); + + m_ui.radioButtonAllPluginBreakpoints-> + setChecked(m_settings.m_pluginAllBreakpoints); + m_ui.radioButtonSelectedPluginBreakpoints-> + setChecked(m_settings.m_pluginSelectedBreakpoints); + m_ui.radioButtonNoPluginBreakpoints-> + setChecked(m_settings.m_pluginNoBreakpoints); + m_ui.lineEditSelectedPluginBreakpointsPattern-> + setEnabled(m_settings.m_pluginSelectedBreakpoints); m_ui.checkBoxSkipKnownFrames->setChecked(m_settings.m_skipKnownFrames); m_ui.checkBoxDebugDumpers->setChecked(m_settings.m_debugDumpers); m_ui.checkBoxUseCustomDumpers->setChecked(m_settings.m_useCustomDumpers); - m_ui.checkBoxFastStart->setChecked(m_settings.m_useFastStart); m_ui.checkBoxUseToolTips->setChecked(m_settings.m_useToolTips); + connect(m_ui.radioButtonSelectedPluginBreakpoints, SIGNAL(toggled(bool)), + m_ui.lineEditSelectedPluginBreakpointsPattern, SLOT(setEnabled(bool))); + #ifndef QT_DEBUG #if 0 cmd = am->registerAction(m_manager->m_dumpLogAction, @@ -294,14 +303,9 @@ QWidget *GdbOptionPage::createPage(QWidget *parent) #endif // FIXME - m_ui.autoStartBox->hide(); - m_ui.autoQuitBox->hide(); m_ui.environmentEdit->hide(); m_ui.labelEnvironment->hide(); - m_ui.checkBoxFastStart->setChecked(false); - m_ui.checkBoxFastStart->hide(); - //m_dumpLogAction = new QAction(this); //m_dumpLogAction->setText(tr("Dump Log File for Debugging Purposes")); // @@ -315,16 +319,23 @@ void GdbOptionPage::apply() { m_settings.m_gdbCmd = m_ui.gdbLocationChooser->path(); m_settings.m_gdbEnv = m_ui.environmentEdit->text(); - m_settings.m_autoRun = m_ui.autoStartBox->isChecked(); - m_settings.m_autoQuit = m_ui.autoQuitBox->isChecked(); m_settings.m_scriptFile = m_ui.scriptFileChooser->path(); m_settings.m_skipKnownFrames = m_ui.checkBoxSkipKnownFrames->isChecked(); m_settings.m_debugDumpers = m_ui.checkBoxDebugDumpers->isChecked(); m_settings.m_useCustomDumpers = m_ui.checkBoxUseCustomDumpers->isChecked(); - m_settings.m_useFastStart = m_ui.checkBoxFastStart->isChecked(); m_settings.m_useToolTips = m_ui.checkBoxUseToolTips->isChecked(); + m_settings.m_pluginAllBreakpoints = + m_ui.radioButtonAllPluginBreakpoints->isChecked(); + m_settings.m_pluginSelectedBreakpoints = + m_ui.radioButtonSelectedPluginBreakpoints->isChecked(); + m_settings.m_pluginNoBreakpoints = + m_ui.radioButtonNoPluginBreakpoints->isChecked(); + m_settings.m_pluginSelectedBreakpointsPattern = + m_ui.lineEditSelectedPluginBreakpointsPattern->text(); + + *m_plugin->m_manager->settings() = m_settings; m_plugin->writeSettings(); } @@ -889,11 +900,16 @@ void DebuggerPlugin::writeSettings() const s->setValue("AutoRun", m->m_autoRun); s->setValue("AutoQuit", m->m_autoQuit); - s->setValue("UseFastStart", m->m_useFastStart); s->setValue("UseToolTips", m->m_useToolTips); s->setValue("UseCustomDumpers", m->m_useCustomDumpers); s->setValue("SkipKnowFrames", m->m_skipKnownFrames); s->setValue("DebugDumpers", m->m_debugDumpers); + + s->setValue("AllPluginBreakpoints", m->m_pluginAllBreakpoints); + s->setValue("SelectedPluginBreakpoints", m->m_pluginSelectedBreakpoints); + s->setValue("NoPluginBreakpoints", m->m_pluginNoBreakpoints); + s->setValue("SelectedPluginBreakpointsPattern", m->m_pluginSelectedBreakpointsPattern); + s->endGroup(); } @@ -911,6 +927,7 @@ void DebuggerPlugin::readSettings() QString defaultScript; s->beginGroup(QLatin1String("DebugMode")); + QByteArray ba = s->value("State", QByteArray()).toByteArray(); m_toggleLockedAction->setChecked(s->value("Locked", true).toBool()); m->m_gdbCmd = s->value("Location", defaultCommand).toString(); @@ -922,8 +939,17 @@ void DebuggerPlugin::readSettings() m->m_skipKnownFrames = s->value("SkipKnownFrames", false).toBool(); m->m_debugDumpers = s->value("DebugDumpers", false).toBool(); m->m_useCustomDumpers = s->value("UseCustomDumpers", true).toBool(); - m->m_useFastStart = s->value("UseFastStart", false).toBool(); m->m_useToolTips = s->value("UseToolTips", false).toBool(); + + m->m_pluginAllBreakpoints = + s->value("AllPluginBreakpoints", false).toBool(); + m->m_pluginSelectedBreakpoints = + s->value("SelectedPluginBreakpoints", false).toBool(); + m->m_pluginNoBreakpoints = + s->value("NoPluginBreakpoints", true).toBool(); + m->m_pluginSelectedBreakpointsPattern = + s->value("SelectedPluginBreakpointsPattern").toString(); + s->endGroup(); m_manager->mainWindow()->restoreState(ba); diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 6084831b1b4..ad97e748b70 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -764,7 +764,7 @@ void GdbEngine::handleResult(const GdbResultRecord & record, int type, handleExecStart1(record); break; case GdbExecStart2: - handleExecStart2(record); + //handleExecStart2(record); break; case GdbExecStart3: handleExecStart3(record); @@ -1726,7 +1726,7 @@ void GdbEngine::handleExecStart1(const GdbResultRecord &response) } } -void GdbEngine::handleExecStart3(const GdbResultRecord &response) +void GdbEngine::handleExecStart3(const GdbResultRecord &) { #if defined(Q_OS_WIN) sendCommand("info proc", GdbInfoProc); diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h index 14cb65d7cdf..fbb56a1b4d5 100644 --- a/src/plugins/debugger/gdbengine.h +++ b/src/plugins/debugger/gdbengine.h @@ -186,7 +186,6 @@ private: void handleFileExecAndSymbols(const GdbResultRecord &response); void handleExecRun(const GdbResultRecord &response); void handleExecStart1(const GdbResultRecord &response); - void handleExecStart2(const GdbResultRecord &response); void handleExecStart3(const GdbResultRecord &response); void handleExecJumpToLine(const GdbResultRecord &response); void handleExecRunToFunction(const GdbResultRecord &response); diff --git a/src/plugins/debugger/gdboptionpage.ui b/src/plugins/debugger/gdboptionpage.ui index ef485ccbf83..e6c46c9bc3a 100644 --- a/src/plugins/debugger/gdboptionpage.ui +++ b/src/plugins/debugger/gdboptionpage.ui @@ -6,22 +6,16 @@ 0 0 - 465 - 372 + 398 + 385 Form - - - 6 - - - 9 - - - + + + Locations @@ -74,7 +68,70 @@ - + + + + Behaviour of breakpoint setting in plugins + + + + + + This is the slowest but safest option. + + + Try to set breakpoints in plugins always automatically. + + + + + + + Try to set breakpoints in selected plugins + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 10 + 10 + + + + + + + + Matching regular expression: + + + + + + + + + + + + Never set breakpoints in plugins automatically + + + + + + + Checking this will make the debugger try to use code to format certain data (QObject, QString, std::string etc.) nicely. @@ -84,17 +141,7 @@ - - - - Checking this will make the debugger start fast by loading only very few debug symbols on start up. This might lead to situations where breakpoints can not be set properly. So uncheck this option if you experience breakpoint related problems. - - - Fast debugger start - - - - + When this option is checked, 'Step Into' compresses several steps into one in certain situations, leading to 'less noisy' debugging. So will, e.g., the atomic @@ -105,7 +152,7 @@ - + Checking this will make enable tooltips for variable values during debugging. Since this can slow down debugging and does not provide reliable information as it does not use scope information, it is switched off by default. @@ -115,7 +162,7 @@ - + This is an internal tool to make debugging the Custom Data Dumper code easier. Using this action is in general not needed unless you want do debug Qt Creator itself. @@ -125,29 +172,15 @@ - - - - Auto run executable on debugger startup - - - - - - - Quit debugger when the executable exits - - - - - + + Qt::Vertical - 415 - 41 + 10 + 1 From 04626a3e2a60fd4caedc7e9f2bf2b49a35701cd8 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 17 Feb 2009 17:39:20 +0100 Subject: [PATCH 12/37] Fixes: debugger: work on plugin breakpoints Conflicts: src/plugins/debugger/gdbengine.cpp --- src/plugins/debugger/debuggermanager.cpp | 10 --- src/plugins/debugger/debuggermanager.h | 16 +++- src/plugins/debugger/debuggerplugin.cpp | 2 + src/plugins/debugger/gdbengine.cpp | 102 +++++++++-------------- src/plugins/debugger/gdbengine.h | 1 - 5 files changed, 53 insertions(+), 78 deletions(-) diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index 4868cf4c517..95010977da6 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -1079,22 +1079,12 @@ bool DebuggerManager::useCustomDumpers() const return m_settings.m_useCustomDumpers; } -bool DebuggerManager::useFastStart() const -{ - return 0; // && m_settings.m_useFastStart; -} - void DebuggerManager::setUseCustomDumpers(bool on) { m_settings.m_useCustomDumpers = on; engine()->setUseCustomDumpers(on); } -void DebuggerManager::setUseFastStart(bool on) -{ - m_settings.m_useFastStart = on; -} - void DebuggerManager::setDebugDumpers(bool on) { m_settings.m_debugDumpers = on; diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index a43feb7e96c..a3407a0aa59 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -170,7 +170,11 @@ private: virtual bool skipKnownFrames() const = 0; virtual bool debugDumpers() const = 0; virtual bool useCustomDumpers() const = 0; - virtual bool useFastStart() const = 0; + + virtual bool wantsAllPluginBreakpoints() const = 0; + virtual bool wantsSelectedPluginBreakpoints() const = 0; + virtual bool wantsNoPluginBreakpoints() const = 0; + virtual QString selectedPluginBreakpointsPattern() const = 0; virtual void reloadDisassembler() = 0; virtual void reloadModules() = 0; @@ -288,7 +292,6 @@ public slots: void setUseCustomDumpers(bool on); void setDebugDumpers(bool on); void setSkipKnownFrames(bool on); - void setUseFastStart(bool on); private slots: void showDebuggerOutput(const QString &prefix, const QString &msg); @@ -323,7 +326,14 @@ private: bool skipKnownFrames() const; bool debugDumpers() const; bool useCustomDumpers() const; - bool useFastStart() const; + bool wantsAllPluginBreakpoints() const + { return m_settings.m_pluginAllBreakpoints; } + bool wantsSelectedPluginBreakpoints() const + { return m_settings.m_pluginSelectedBreakpoints; } + bool wantsNoPluginBreakpoints() const + { return m_settings.m_pluginNoBreakpoints; } + QString selectedPluginBreakpointsPattern() const + { return m_settings.m_pluginSelectedBreakpointsPattern; } void notifyStartupFinished(); void notifyInferiorStopped(); diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index aa3fca911f6..18c7e6d0c56 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -281,6 +281,8 @@ QWidget *GdbOptionPage::createPage(QWidget *parent) setChecked(m_settings.m_pluginSelectedBreakpoints); m_ui.radioButtonNoPluginBreakpoints-> setChecked(m_settings.m_pluginNoBreakpoints); + m_ui.lineEditSelectedPluginBreakpointsPattern-> + setText(m_settings.m_pluginSelectedBreakpointsPattern); m_ui.lineEditSelectedPluginBreakpointsPattern-> setEnabled(m_settings.m_pluginSelectedBreakpoints); diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index ad97e748b70..49b76a5e34d 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -254,7 +254,6 @@ void GdbEngine::init() { m_pendingRequests = 0; m_gdbVersion = 100; - m_shared = 0; m_outputCodec = QTextCodec::codecForLocale(); m_dataDumperState = DataDumperUninitialized; @@ -988,18 +987,6 @@ void GdbEngine::handleInfoShared(const GdbResultRecord &record) if (record.resultClass == GdbResultDone) { // let the modules handler do the parsing handleModulesList(record); - QList modules = qq->modulesHandler()->modules(); - bool reloadNeeded = false; - foreach (const Module &module, modules) { - // FIXME: read this from some list - if (!module.symbolsRead && !module.moduleName.contains("Q")) { - reloadNeeded = true; - sendCommand("sharedlibrary " + dotEscape(module.moduleName)); - } - } - if (reloadNeeded) - reloadModules(); - continueInferior(); } } @@ -1146,7 +1133,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) { const QString reason = data.findChild("reason").data(); - QString console = data.findChild("consolestreamoutput").data(); + QString msg = data.findChild("consolestreamoutput").data(); if (reason.isEmpty()) { GdbMi frame = data.findChild("frame"); if (frame.findChild("func").data() == "_start") { @@ -1162,11 +1149,27 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) sendCommand("info pid", GdbInfoProc, QVariant(), true); #endif sendCommand("-file-list-exec-source-files", GdbQuerySources); - sendCommand("set auto-solib-add on"); + sendCommand("sharedlibrary libc"); // for malloc sendCommand("sharedlibrary libdl"); // for dlopen tryLoadCustomDumpers(); - sendCommand("info shared", ModulesList, QVariant()); + + // intentionally after tryLoadCustomDumpers(), + // otherwise we'd interupt solib loading. + if (qq->wantsAllPluginBreakpoints()) { + sendCommand("set auto-solib-add on"); + sendCommand("set stop-on-solib-events 0"); + sendCommand("sharedlibrary .*"); + } else if (qq->wantsSelectedPluginBreakpoints()) { + sendCommand("set auto-solib-add on"); + sendCommand("set stop-on-solib-events 1"); + sendCommand("sharedlibrary "+qq->selectedPluginBreakpointsPattern()); + } else if (qq->wantsNoPluginBreakpoints()) { + // should be like that already + sendCommand("set auto-solib-add off"); + sendCommand("set stop-on-solib-events 0"); + } + reloadModules(); // this will "continue" if done attemptBreakpointSynchronization(); return; @@ -1174,36 +1177,19 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) // fall through } -#if 0 - if (console.contains("Stopped due to shared library event") || reason.isEmpty()) { - ++m_shared; - //if (m_shared == 2) - // tryLoadCustomDumpers(); - //qDebug() << "SHARED LIBRARY EVENT " << data.toString() << m_shared; - if (qq->useFastStart()) { - if (1 || m_shared <= 16) { // libpthread? - sendCommand("info shared", GdbInfoShared); - //sendCommand("sharedlibrary gdbdebugger "); - //continueInferior(); - } else { - // auto-load from now on - sendCommand("info shared"); - sendCommand("set auto-solib-add on"); - sendCommand("-file-list-exec-source-files", GdbQuerySources); - sendCommand("-break-list", BreakList); - //sendCommand("bt"); - //QVariant var = QVariant::fromValue(data); - //sendCommand("p 1", GdbAsyncOutput2, var); // dummy - continueInferior(); - } - } else { - // slow start requested. - q->showStatusMessage(tr("Loading %1...").arg(QString(data.toString()))); + static bool modulesDirty = false; + if (msg.contains("Stopped due to shared library event") || reason.isEmpty()) { + if (qq->wantsSelectedPluginBreakpoints()) { + qDebug() << "SHARED LIBRARY EVENT " << data.toString(); + qDebug() << "PATTERN" << qq->selectedPluginBreakpointsPattern(); + sendCommand("sharedlibrary " + qq->selectedPluginBreakpointsPattern()); continueInferior(); + q->showStatusMessage(tr("Loading %1...").arg(QString(data.toString()))); + return; } - return; + modulesDirty = true; + // fall through } -#endif if (isExitedReason(reason)) { qq->notifyInferiorExited(); @@ -1256,11 +1242,17 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) } if (isStoppedReason(reason) || reason.isEmpty()) { + if (modulesDirty) { + sendCommand("-file-list-exec-source-files", GdbQuerySources); + sendCommand("-break-list", BreakList); + reloadModules(); + modulesDirty = false; + } // Need another round trip if (reason == "breakpoint-hit") { q->showStatusMessage(tr("Stopped at breakpoint")); GdbMi frame = data.findChild("frame"); - qDebug() << "HIT BREAKPOINT: " << frame.toString(); + //qDebug() << "HIT BREAKPOINT: " << frame.toString(); m_currentFrame = frame.findChild("addr").data() + '%' + frame.findChild("func").data() + '%'; @@ -1504,7 +1496,6 @@ void GdbEngine::exitDebugger() m_fullToShortName.clear(); m_varToType.clear(); m_dataDumperState = DataDumperUninitialized; - m_shared = 0; m_outputCollector.shutdown(); //q->settings()->m_debugDumpers = false; } @@ -1572,12 +1563,7 @@ bool GdbEngine::startDebugger() q->showStatusMessage(tr("Gdb Running")); sendCommand("show version", GdbShowVersion); - if (qq->useFastStart()) { - sendCommand("set auto-solib-add off"); - sendCommand("set stop-on-solib-events 1"); - } //sendCommand("-enable-timings"); - //sendCommand("set stop-on-solib-events 1"); sendCommand("set print static-members off"); // Seemingly doesn't work. //sendCommand("define hook-stop\n-thread-list-ids\n-stack-list-frames\nend"); //sendCommand("define hook-stop\nprint 4\nend"); @@ -4044,8 +4030,6 @@ void GdbEngine::tryLoadCustomDumpers() QString lib = q->m_buildDir + "/qtc-gdbmacros/libgdbmacros.so"; if (QFileInfo(lib).isExecutable()) { //sendCommand("p dlopen"); - //if (qq->useFastStart()) - // sendCommand("set stop-on-solib-events 0"); QString flag = QString::number(RTLD_NOW); sendSynchronizedCommand("call (void)dlopen(\"" + lib + "\", " + flag + ")", WatchDumpCustomSetup); @@ -4053,8 +4037,6 @@ void GdbEngine::tryLoadCustomDumpers() sendSynchronizedCommand("call (void)__dlopen(\"" + lib + "\", " + flag + ")", WatchDumpCustomSetup); sendSynchronizedCommand("sharedlibrary " + dotEscape(lib)); - //if (qq->useFastStart()) - // sendCommand("set stop-on-solib-events 1"); } else { qDebug() << "DEBUG HELPER LIBRARY IS NOT USABLE: " << lib << QFileInfo(lib).isExecutable(); @@ -4064,14 +4046,10 @@ void GdbEngine::tryLoadCustomDumpers() QString lib = q->m_buildDir + "/qtc-gdbmacros/libgdbmacros.dylib"; if (QFileInfo(lib).isExecutable()) { //sendCommand("p dlopen"); // FIXME: remove me - //if (qq->useFastStart()) - // sendCommand("set stop-on-solib-events 0"); QString flag = QString::number(RTLD_NOW); sendSyncronizedCommand("call (void)dlopen(\"" + lib + "\", " + flag + ")", WatchDumpCustomSetup); - sendSyncronizedCommand("sharedlibrary " + dotEscape(lib)); - //if (qq->useFastStart()) - // sendCommand("set stop-on-solib-events 1"); + sendSynchronizedCommand("sharedlibrary " + dotEscape(lib)); } else { qDebug() << "DEBUG HELPER LIBRARY IS NOT USABLE: " << lib << QFileInfo(lib).isExecutable(); @@ -4080,15 +4058,11 @@ void GdbEngine::tryLoadCustomDumpers() #if defined(Q_OS_WIN) QString lib = q->m_buildDir + "/qtc-gdbmacros/debug/gdbmacros.dll"; if (QFileInfo(lib).exists()) { - //if (qq->useFastStart()) - // sendCommand("set stop-on-solib-events 0"); //sendCommand("handle SIGSEGV pass stop print"); //sendCommand("set unwindonsignal off"); sendSyncronizedCommand("call LoadLibraryA(\"" + lib + "\")", WatchDumpCustomSetup); - sendSyncronizedCommand("sharedlibrary " + dotEscape(lib)); - //if (qq->useFastStart()) - // sendCommand("set stop-on-solib-events 1"); + sendSynchronizedCommand("sharedlibrary " + dotEscape(lib)); } else { qDebug() << "DEBUG HELPER LIBRARY IS NOT USABLE: " << lib << QFileInfo(lib).isExecutable(); diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h index fbb56a1b4d5..7973ef4c681 100644 --- a/src/plugins/debugger/gdbengine.h +++ b/src/plugins/debugger/gdbengine.h @@ -217,7 +217,6 @@ private: int m_oldestAcceptableToken; int m_gdbVersion; // 6.8.0 is 680 - int m_shared; // awful hack to keep track of used files QHash m_shortToFullName; From 3aa08efb757b0801686f8d6fa47a6e02ea378ec2 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 12 Feb 2009 13:31:19 +0100 Subject: [PATCH 13/37] Fixes: debugger: work on breakpoints in plugins --- src/plugins/debugger/debuggermanager.cpp | 4 +- src/plugins/debugger/debuggerplugin.cpp | 1 - src/plugins/debugger/gdbengine.cpp | 166 +++++------------------ src/plugins/debugger/gdbengine.h | 5 +- src/plugins/debugger/idebuggerengine.h | 1 - 5 files changed, 36 insertions(+), 141 deletions(-) diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index 95010977da6..6d2b629e77a 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -558,7 +558,7 @@ void DebuggerManager::notifyInferiorUpdateFinished() void DebuggerManager::notifyInferiorRunningRequested() { setStatus(DebuggerInferiorRunningRequested); - showStatusMessage(tr("Running..."), 5000); + showStatusMessage(tr("Running requested..."), 5000); } void DebuggerManager::notifyInferiorRunning() @@ -576,7 +576,7 @@ void DebuggerManager::notifyInferiorExited() void DebuggerManager::notifyInferiorPidChanged(int pid) { //QMessageBox::warning(0, "PID", "PID: " + QString::number(pid)); - //qDebug() << "PID: " << pid; + qDebug() << "PID: " << pid; emit inferiorPidChanged(pid); } diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 18c7e6d0c56..d3e61c79c29 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -337,7 +337,6 @@ void GdbOptionPage::apply() m_settings.m_pluginSelectedBreakpointsPattern = m_ui.lineEditSelectedPluginBreakpointsPattern->text(); - *m_plugin->m_manager->settings() = m_settings; m_plugin->writeSettings(); } diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 49b76a5e34d..350981b8715 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -99,10 +99,8 @@ enum GdbCommandType GdbQueryPwd, GdbQuerySources, GdbAsyncOutput2, + GdbStart, GdbExecRun, - GdbExecStart1, - GdbExecStart2, - GdbExecStart3, GdbExecRunToFunction, GdbExecStep, GdbExecNext, @@ -460,13 +458,28 @@ void GdbEngine::handleResponse() break; } - case '~': - case '@': + case '~': { + QString data = GdbMi::parseCString(from, to); + m_pendingConsoleStreamOutput += data; + m_inbuffer = QByteArray(from, to - from); + break; + } + + case '@': { + QString data = GdbMi::parseCString(from, to); + m_pendingTargetStreamOutput += data; + m_inbuffer = QByteArray(from, to - from); + break; + } + case '&': { QString data = GdbMi::parseCString(from, to); - handleStreamOutput(data, c); - //dump(oldfrom, from, record.toString()); + m_pendingLogStreamOutput += data; m_inbuffer = QByteArray(from, to - from); + // On Windows, the contents seem to depend on the debugger + // version and/or OS version used. + if (data.startsWith("warning:")) + qq->showApplicationOutput(data); break; } @@ -759,14 +772,8 @@ void GdbEngine::handleResult(const GdbResultRecord & record, int type, handleExecRun(record); break; - case GdbExecStart1: - handleExecStart1(record); - break; - case GdbExecStart2: - //handleExecStart2(record); - break; - case GdbExecStart3: - handleExecStart3(record); + case GdbStart: + handleStart(record); break; case GdbInfoProc: handleInfoProc(record); @@ -1028,84 +1035,6 @@ void GdbEngine::handleExecRunToFunction(const GdbResultRecord &record) q->gotoLocation(file, line, true); } -void GdbEngine::handleStreamOutput(const QString &data, char code) -{ - // Linux - if (data.contains("[New Thread")) { - QRegExp re("\\[New Thread 0x([0-9a-f]*) \\(LWP ([0-9]*)\\)\\]"); - if (re.indexIn(data) != -1) - maybeHandleInferiorPidChanged(re.cap(2)); - } - - // Mac - if (data.contains("[Switching to process ")) { - QRegExp re("\\[Switching to process ([0-9]*) local thread 0x([0-9a-f]*)\\]"); - if (re.indexIn(data) != -1) - maybeHandleInferiorPidChanged(re.cap(1)); - } - - // present it twice: now and together with the next 'real' result - switch (code) { - case '~': - m_pendingConsoleStreamOutput += data; - break; - case '@': - m_pendingTargetStreamOutput += data; - break; - case '&': - m_pendingLogStreamOutput += data; - // On Windows, the contents seem to depend on the debugger - // version and/or OS version used. - if (data.startsWith("warning:")) - qq->showApplicationOutput(data); - break; - } - -#ifdef Q_OS_LINUX - if (data.startsWith("Pending break") && data.contains("\" resolved")) { - qDebug() << "SCHEDULING -break-list"; - //m_breakListOnStopNeeded = true; - } -#endif - -#if 0 - if (m_slurpingPTypeOutput) - qDebug() << "SLURP: " << output.data; - - // "No symbol \"__dlopen\" in current context." - // "No symbol \"dlopen\" in current context." - if (output.data.startsWith("No symbol ") - && output.data.contains("dlopen")) { - m_dlopened = true; - return; - } - - // output of 'ptype ' - if (output.data.startsWith("type = ")) { - if (output.data.endsWith("{") || output.data.endsWith("{\\n")) { - // multi-line output started here... - m_slurpingPTypeOutput = true; - m_slurpedPTypeOutput = output.data; - } else { - // Happens for simple types. Process it immediately - m_watchHandler->handleTypeContents(output.data); - } - return; - } - if (m_slurpingPTypeOutput) { - m_slurpedPTypeOutput += '\n'; - m_slurpedPTypeOutput += output.data; - if (output.data.startsWith("}")) { - // this is the last line... - m_slurpingPTypeOutput = false; - m_watchHandler->handleTypeContents(m_slurpedPTypeOutput); - m_slurpedPTypeOutput.clear(); - } - return; - } -#endif -} - static bool isExitedReason(const QString &reason) { return reason == QLatin1String("exited-normally") // inferior exited normally @@ -1633,13 +1562,17 @@ bool GdbEngine::startDebugger() } if (q->startMode() == q->startInternal) { + emit gdbInputAvailable(QString(), QString()); sendCommand("-file-exec-and-symbols " + fileName, GdbFileExecAndSymbols); //sendCommand("file " + fileName, GdbFileExecAndSymbols); #ifdef Q_OS_MAC sendCommand("sharedlibrary apply-load-rules all"); #endif - //sendCommand("-gdb-set stop-on-solib-events 1"); - runInferior(); + setTokenBarrier(); + if (!q->m_processArgs.isEmpty()) + sendCommand("-exec-arguments " + q->m_processArgs.join(" ")); + sendCommand("set auto-solib-add off"); + sendCommand("x/2i _start", GdbStart); } if (q->startMode() == q->attachExternal) { @@ -1678,21 +1611,7 @@ void GdbEngine::continueInferior() sendCommand("-exec-continue", GdbExecContinue); } -void GdbEngine::runInferior() -{ - q->resetLocation(); - // FIXME: this ignores important startup messages - setTokenBarrier(); - if (!q->m_processArgs.isEmpty()) - sendCommand("-exec-arguments " + q->m_processArgs.join(" ")); - qq->notifyInferiorRunningRequested(); - emit gdbInputAvailable(QString(), QString()); - - sendCommand("set auto-solib-add off"); - sendCommand("x/2i _start", GdbExecStart1); -} - -void GdbEngine::handleExecStart1(const GdbResultRecord &response) +void GdbEngine::handleStart(const GdbResultRecord &response) { if (response.resultClass == GdbResultDone) { // stdout:&"x/2i _start\n" @@ -1702,8 +1621,9 @@ void GdbEngine::handleExecStart1(const GdbResultRecord &response) QRegExp needle("0x([0-9a-f]+) <_start\\+.*>:"); if (needle.indexIn(msg) != -1) { //qDebug() << "STREAM: " << msg << needle.cap(1); - sendCommand("tbreak *0x" + needle.cap(1)); // GdbExecStart3); - sendCommand("-exec-run"); // GdbExecStart3); + sendCommand("tbreak *0x" + needle.cap(1)); + sendCommand("-exec-run"); + qq->notifyInferiorRunningRequested(); } else { qDebug() << "PARSING START ADDRESS FAILED" << msg; } @@ -1712,20 +1632,6 @@ void GdbEngine::handleExecStart1(const GdbResultRecord &response) } } -void GdbEngine::handleExecStart3(const GdbResultRecord &) -{ -#if defined(Q_OS_WIN) - sendCommand("info proc", GdbInfoProc); -#endif -#if defined(Q_OS_LINUX) - sendCommand("info proc", GdbInfoProc); -#endif -#if defined(Q_OS_MAC) - sendCommand("info pid", GdbInfoProc, QVariant(), true); -#endif - attemptBreakpointSynchronization(); -} - void GdbEngine::stepExec() { setTokenBarrier(); @@ -2244,12 +2150,7 @@ void GdbEngine::attemptBreakpointSynchronization() } } - if (updateNeeded) { - //interruptAndContinue(); - //sendListBreakpoints(); - } - - if (!updateNeeded && q->status() == DebuggerProcessStartingUp) { + if (!updateNeeded) { // we continue the execution continueInferior(); } @@ -4017,7 +3918,6 @@ void GdbEngine::assignValueInDebugger(const QString &expression, const QString & sendCommand("-var-assign assign " + value, WatchVarAssign); } - void GdbEngine::tryLoadCustomDumpers() { if (m_dataDumperState != DataDumperUninitialized) diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h index 7973ef4c681..0b304e10660 100644 --- a/src/plugins/debugger/gdbengine.h +++ b/src/plugins/debugger/gdbengine.h @@ -113,7 +113,6 @@ private: void exitDebugger(); void continueInferior(); - void runInferior(); void interruptInferior(); void runToLineExec(const QString &fileName, int lineNumber); @@ -179,14 +178,12 @@ private slots: private: int terminationIndex(const QByteArray &buffer, int &length); - void handleStreamOutput(const QString &output, char code); + void handleStart(const GdbResultRecord &response); void handleAsyncOutput2(const GdbMi &data); void handleAsyncOutput(const GdbMi &data); void handleResultRecord(const GdbResultRecord &response); void handleFileExecAndSymbols(const GdbResultRecord &response); void handleExecRun(const GdbResultRecord &response); - void handleExecStart1(const GdbResultRecord &response); - void handleExecStart3(const GdbResultRecord &response); void handleExecJumpToLine(const GdbResultRecord &response); void handleExecRunToFunction(const GdbResultRecord &response); void handleInfoShared(const GdbResultRecord &response); diff --git a/src/plugins/debugger/idebuggerengine.h b/src/plugins/debugger/idebuggerengine.h index 1558d140ee6..ee1e15793f3 100644 --- a/src/plugins/debugger/idebuggerengine.h +++ b/src/plugins/debugger/idebuggerengine.h @@ -62,7 +62,6 @@ public: virtual void nextIExec() = 0; virtual void continueInferior() = 0; - virtual void runInferior() = 0; virtual void interruptInferior() = 0; virtual void runToLineExec(const QString &fileName, int lineNumber) = 0; From 1b5703b72959603a2ff4fc1d24250f6d843da5ad Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 12 Feb 2009 16:06:23 +0100 Subject: [PATCH 14/37] Fixes: uic warning about duplicate name Details: Give the layout a name. --- src/plugins/debugger/gdboptionpage.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/debugger/gdboptionpage.ui b/src/plugins/debugger/gdboptionpage.ui index e6c46c9bc3a..884080c1a30 100644 --- a/src/plugins/debugger/gdboptionpage.ui +++ b/src/plugins/debugger/gdboptionpage.ui @@ -19,7 +19,7 @@ Locations - + 9 From 0565b3a7fea5b3450475f1d98dace55670da40da Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 17 Feb 2009 17:40:13 +0100 Subject: [PATCH 15/37] Fixes: debugger: start symbol is WinMainCRTStartup, not _start sometimes... Conflicts: src/plugins/debugger/gdbengine.cpp --- src/plugins/debugger/gdbengine.cpp | 72 +++++++++++++++++++----------- src/plugins/debugger/gdbengine.h | 2 + 2 files changed, 48 insertions(+), 26 deletions(-) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 350981b8715..663bd7c38cf 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -230,6 +230,15 @@ static bool isLeavableFunction(const QString &funcName, const QString &fileName) return false; } +static QString startSymbolName() +{ +#ifdef Q_OS_WIN + return "WinMainCRTStartup"; +#else + return "_start"; +#endif +} + /////////////////////////////////////////////////////////////////////// // @@ -251,6 +260,7 @@ GdbEngine::~GdbEngine() void GdbEngine::init() { m_pendingRequests = 0; + m_waitingForBreakpointSynchronizationToContinue = false; m_gdbVersion = 100; m_outputCodec = QTextCodec::codecForLocale(); m_dataDumperState = DataDumperUninitialized; @@ -650,7 +660,7 @@ void GdbEngine::maybeHandleInferiorPidChanged(const QString &pid0) } if (pid == q->m_attachedPID) return; - //qDebug() << "FOUND PID " << pid; + qDebug() << "FOUND PID " << pid; q->m_attachedPID = pid; qq->notifyInferiorPidChanged(pid); } @@ -750,8 +760,10 @@ void GdbEngine::handleResultRecord(const GdbResultRecord &record) --m_pendingRequests; PENDING_DEBUG(" TYPE " << cmd.type << " DECREMENTS PENDING TO: " << m_pendingRequests << cmd.command); - if (m_pendingRequests <= 0) + if (m_pendingRequests <= 0) { + PENDING_DEBUG(" .... AND TRIGGERS MODEL UPDATE"); updateWatchModel2(); + } } else { PENDING_DEBUG(" UNKNOWN TYPE " << cmd.type << " LEAVES PENDING AT: " << m_pendingRequests << cmd.command); @@ -1065,8 +1077,10 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) QString msg = data.findChild("consolestreamoutput").data(); if (reason.isEmpty()) { GdbMi frame = data.findChild("frame"); - if (frame.findChild("func").data() == "_start") { + if (frame.findChild("func").data() == startSymbolName()) { + // // that's the "early stop" + // frame.findChild("func").data() + '%'; #if defined(Q_OS_WIN) sendCommand("info proc", GdbInfoProc); @@ -1078,9 +1092,6 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) sendCommand("info pid", GdbInfoProc, QVariant(), true); #endif sendCommand("-file-list-exec-source-files", GdbQuerySources); - - sendCommand("sharedlibrary libc"); // for malloc - sendCommand("sharedlibrary libdl"); // for dlopen tryLoadCustomDumpers(); // intentionally after tryLoadCustomDumpers(), @@ -1098,11 +1109,12 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) sendCommand("set auto-solib-add off"); sendCommand("set stop-on-solib-events 0"); } - reloadModules(); // this will "continue" if done - attemptBreakpointSynchronization(); + m_waitingForBreakpointSynchronizationToContinue = true; + QTimer::singleShot(0, this, SLOT(attemptBreakpointSynchronization())); return; } + qDebug() << "EMPTY REASON FOR STOPPED"; // fall through } @@ -1231,7 +1243,7 @@ void GdbEngine::handleAsyncOutput2(const GdbMi &data) // // Breakpoints // - //qDebug() << "BREAK ASYNC: " << output.toString(); + //qDebug() << "BREAK ASYNC: " << data.toString(); //sendListBreakpoints(); //attemptBreakpointSynchronization(); //if (m_breakListOnStopNeeded) @@ -1572,7 +1584,7 @@ bool GdbEngine::startDebugger() if (!q->m_processArgs.isEmpty()) sendCommand("-exec-arguments " + q->m_processArgs.join(" ")); sendCommand("set auto-solib-add off"); - sendCommand("x/2i _start", GdbStart); + sendCommand("x/2i " + startSymbolName(), GdbStart); } if (q->startMode() == q->attachExternal) { @@ -1597,8 +1609,6 @@ bool GdbEngine::startDebugger() else qq->breakHandler()->setAllPending(); - //QTimer::singleShot(0, this, SLOT(attemptBreakpointSynchronization())); - return true; } @@ -1618,7 +1628,7 @@ void GdbEngine::handleStart(const GdbResultRecord &response) // stdout:~"0x404540 <_start>:\txor %ebp,%ebp\n" // stdout:~"0x404542 <_start+2>:\tmov %rdx,%r9\n" QString msg = response.data.findChild("consolestreamoutput").data(); - QRegExp needle("0x([0-9a-f]+) <_start\\+.*>:"); + QRegExp needle("0x([0-9a-f]+) <" + startSymbolName() + "\\+.*>:"); if (needle.indexIn(msg) != -1) { //qDebug() << "STREAM: " << msg << needle.cap(1); sendCommand("tbreak *0x" + needle.cap(1)); @@ -2080,11 +2090,14 @@ void GdbEngine::handleBreakInsert1(const GdbResultRecord &record, int index) void GdbEngine::attemptBreakpointSynchronization() { + // Non-lethal check for nested calls + static bool inBreakpointSychronization = false; + QTC_ASSERT(!inBreakpointSychronization, /**/); + inBreakpointSychronization = true; + BreakHandler *handler = qq->breakHandler(); - //qDebug() << "BREAKPOINT SYNCHRONIZATION "; foreach (BreakpointData *data, handler->takeRemovedBreakpoints()) { - //qDebug() << " SYNCHRONIZATION REMOVING" << data; QString bpNumber = data->bpNumber; if (!bpNumber.trimmed().isEmpty()) sendCommand("-break-delete " + bpNumber, BreakDelete, 0, true); @@ -2150,10 +2163,13 @@ void GdbEngine::attemptBreakpointSynchronization() } } - if (!updateNeeded) { + if (!updateNeeded && m_waitingForBreakpointSynchronizationToContinue) { + m_waitingForBreakpointSynchronizationToContinue = false; // we continue the execution continueInferior(); } + + inBreakpointSychronization = false; } @@ -3931,12 +3947,14 @@ void GdbEngine::tryLoadCustomDumpers() if (QFileInfo(lib).isExecutable()) { //sendCommand("p dlopen"); QString flag = QString::number(RTLD_NOW); - sendSynchronizedCommand("call (void)dlopen(\"" + lib + "\", " + flag + ")", + sendCommand("sharedlibrary libc"); // for malloc + sendCommand("sharedlibrary libdl"); // for dlopen + sendCommand("call (void)dlopen(\"" + lib + "\", " + flag + ")", WatchDumpCustomSetup); // some older systems like CentOS 4.6 prefer this: - sendSynchronizedCommand("call (void)__dlopen(\"" + lib + "\", " + flag + ")", + sendCommand("call (void)__dlopen(\"" + lib + "\", " + flag + ")", WatchDumpCustomSetup); - sendSynchronizedCommand("sharedlibrary " + dotEscape(lib)); + sendCommand("sharedlibrary " + dotEscape(lib)); } else { qDebug() << "DEBUG HELPER LIBRARY IS NOT USABLE: " << lib << QFileInfo(lib).isExecutable(); @@ -3945,11 +3963,12 @@ void GdbEngine::tryLoadCustomDumpers() #if defined(Q_OS_MAC) QString lib = q->m_buildDir + "/qtc-gdbmacros/libgdbmacros.dylib"; if (QFileInfo(lib).isExecutable()) { - //sendCommand("p dlopen"); // FIXME: remove me + sendCommand("sharedlibrary libc"); // for malloc + sendCommand("sharedlibrary libdl"); // for dlopen QString flag = QString::number(RTLD_NOW); - sendSyncronizedCommand("call (void)dlopen(\"" + lib + "\", " + flag + ")", + sendCommand("call (void)dlopen(\"" + lib + "\", " + flag + ")", WatchDumpCustomSetup); - sendSynchronizedCommand("sharedlibrary " + dotEscape(lib)); + sendCommand("sharedlibrary " + dotEscape(lib)); } else { qDebug() << "DEBUG HELPER LIBRARY IS NOT USABLE: " << lib << QFileInfo(lib).isExecutable(); @@ -3958,11 +3977,12 @@ void GdbEngine::tryLoadCustomDumpers() #if defined(Q_OS_WIN) QString lib = q->m_buildDir + "/qtc-gdbmacros/debug/gdbmacros.dll"; if (QFileInfo(lib).exists()) { + sendCommand("sharedlibrary .*"); // for LoadLibraryA //sendCommand("handle SIGSEGV pass stop print"); //sendCommand("set unwindonsignal off"); - sendSyncronizedCommand("call LoadLibraryA(\"" + lib + "\")", + sendCommand("call LoadLibraryA(\"" + lib + "\")", WatchDumpCustomSetup); - sendSynchronizedCommand("sharedlibrary " + dotEscape(lib)); + sendCommand("sharedlibrary " + dotEscape(lib)); } else { qDebug() << "DEBUG HELPER LIBRARY IS NOT USABLE: " << lib << QFileInfo(lib).isExecutable(); @@ -3970,9 +3990,9 @@ void GdbEngine::tryLoadCustomDumpers() #endif // retreive list of dumpable classes - sendSynchronizedCommand("call qDumpObjectData440(1,%1+1,0,0,0,0,0,0)", + sendCommand("call qDumpObjectData440(1,%1+1,0,0,0,0,0,0)", GdbQueryDataDumper1); - sendSynchronizedCommand("p (char*)qDumpOutBuffer", GdbQueryDataDumper2); + sendCommand("p (char*)qDumpOutBuffer", GdbQueryDataDumper2); } diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h index 0b304e10660..f41990747d5 100644 --- a/src/plugins/debugger/gdbengine.h +++ b/src/plugins/debugger/gdbengine.h @@ -328,6 +328,8 @@ private: QString m_currentFrame; QMap m_varToType; + bool m_waitingForBreakpointSynchronizationToContinue; + DebuggerManager *q; IDebuggerManagerAccessForEngines *qq; }; From ce652e8ffc6e651d61712f4c736f6bc2b6626219 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 13 Feb 2009 13:50:50 +0100 Subject: [PATCH 16/37] Fixes: debugger: load modules list early Details: feels better --- src/plugins/debugger/debuggerrunner.cpp | 9 +++-- src/plugins/debugger/gdbengine.cpp | 44 ++++++++++++++----------- src/plugins/debugger/gdbengine.h | 4 ++- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index 7f3e42f47fa..21313428aef 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -107,11 +107,14 @@ DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager, : RunControl(runConfiguration), m_manager(manager), m_running(false) { connect(m_manager, SIGNAL(debuggingFinished()), - this, SLOT(debuggingFinished())); + this, SLOT(debuggingFinished()), + Qt::QueuedConnection); connect(m_manager, SIGNAL(applicationOutputAvailable(QString)), - this, SLOT(slotAddToOutputWindowInline(QString))); + this, SLOT(slotAddToOutputWindowInline(QString)), + Qt::QueuedConnection); connect(m_manager, SIGNAL(inferiorPidChanged(qint64)), - this, SLOT(bringApplicationToForeground(qint64))); + this, SLOT(bringApplicationToForeground(qint64)), + Qt::QueuedConnection); } void DebuggerRunControl::start() diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 663bd7c38cf..3238862d355 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -250,23 +250,16 @@ GdbEngine::GdbEngine(DebuggerManager *parent) { q = parent; qq = parent->engineInterface(); - init(); + initializeVariables(); + initializeConnections(); } GdbEngine::~GdbEngine() { } -void GdbEngine::init() +void GdbEngine::initializeConnections() { - m_pendingRequests = 0; - m_waitingForBreakpointSynchronizationToContinue = false; - m_gdbVersion = 100; - m_outputCodec = QTextCodec::codecForLocale(); - m_dataDumperState = DataDumperUninitialized; - - m_oldestAcceptableToken = -1; - // Gdb Process interaction connect(&m_gdbProc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(gdbProcError(QProcess::ProcessError))); @@ -294,6 +287,22 @@ void GdbEngine::init() Qt::QueuedConnection); } +void GdbEngine::initializeVariables() +{ + m_dataDumperState = DataDumperUninitialized; + m_gdbVersion = 100; + + m_fullToShortName.clear(); + m_shortToFullName.clear(); + m_varToType.clear(); + + m_modulesListOutdated = true; + m_oldestAcceptableToken = -1; + m_outputCodec = QTextCodec::codecForLocale(); + m_pendingRequests = 0; + m_waitingForBreakpointSynchronizationToContinue = false; +} + void GdbEngine::gdbProcError(QProcess::ProcessError error) { QString msg; @@ -1109,6 +1118,8 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) sendCommand("set auto-solib-add off"); sendCommand("set stop-on-solib-events 0"); } + // nicer to see a bit of the world we live in + reloadModules(); // this will "continue" if done m_waitingForBreakpointSynchronizationToContinue = true; QTimer::singleShot(0, this, SLOT(attemptBreakpointSynchronization())); @@ -1118,7 +1129,6 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) // fall through } - static bool modulesDirty = false; if (msg.contains("Stopped due to shared library event") || reason.isEmpty()) { if (qq->wantsSelectedPluginBreakpoints()) { qDebug() << "SHARED LIBRARY EVENT " << data.toString(); @@ -1128,7 +1138,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) q->showStatusMessage(tr("Loading %1...").arg(QString(data.toString()))); return; } - modulesDirty = true; + m_modulesListOutdated = true; // fall through } @@ -1183,11 +1193,11 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) } if (isStoppedReason(reason) || reason.isEmpty()) { - if (modulesDirty) { + if (m_modulesListOutdated) { sendCommand("-file-list-exec-source-files", GdbQuerySources); sendCommand("-break-list", BreakList); reloadModules(); - modulesDirty = false; + m_modulesListOutdated = false; } // Need another round trip if (reason == "breakpoint-hit") { @@ -1345,7 +1355,6 @@ void GdbEngine::handleExecRun(const GdbResultRecord &response) if (response.resultClass == GdbResultRunning) { qq->notifyInferiorRunning(); q->showStatusMessage(tr("Running...")); - //reloadModules(); } else if (response.resultClass == GdbResultError) { QString msg = response.data.findChild("msg").data(); if (msg == "Cannot find bounds of current function") { @@ -1433,11 +1442,8 @@ void GdbEngine::exitDebugger() if (m_gdbProc.state() != QProcess::NotRunning) qDebug() << "PROBLEM STOPPING DEBUGGER"; - m_shortToFullName.clear(); - m_fullToShortName.clear(); - m_varToType.clear(); - m_dataDumperState = DataDumperUninitialized; m_outputCollector.shutdown(); + initializeVariables(); //q->settings()->m_debugDumpers = false; } diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h index f41990747d5..58021fb765a 100644 --- a/src/plugins/debugger/gdbengine.h +++ b/src/plugins/debugger/gdbengine.h @@ -144,7 +144,8 @@ private: bool supportsThreads() const; - void init(); // called by destructor + void initializeConnections(); + void initializeVariables(); void queryFullName(const QString &fileName, QString *fullName); QString fullName(const QString &fileName); QString shortName(const QString &fullName); @@ -329,6 +330,7 @@ private: QMap m_varToType; bool m_waitingForBreakpointSynchronizationToContinue; + bool m_modulesListOutdated; DebuggerManager *q; IDebuggerManagerAccessForEngines *qq; From 50d486685c89717842953e4b385d2e735e62962e Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 13 Feb 2009 14:45:46 +0100 Subject: [PATCH 17/37] Fixes: debugger: put error message into log if loading of dumpers failed --- src/plugins/debugger/gdbengine.cpp | 33 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 3238862d355..07e842307a5 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -3946,11 +3946,12 @@ void GdbEngine::tryLoadCustomDumpers() return; PENDING_DEBUG("TRY LOAD CUSTOM DUMPERS"); - m_dataDumperState = DataDumperLoadTried; + m_dataDumperState = DataDumperUnavailable; #if defined(Q_OS_LINUX) QString lib = q->m_buildDir + "/qtc-gdbmacros/libgdbmacros.so"; - if (QFileInfo(lib).isExecutable()) { + if (QFileInfo(lib).exists()) { + m_dataDumperState = DataDumperLoadTried; //sendCommand("p dlopen"); QString flag = QString::number(RTLD_NOW); sendCommand("sharedlibrary libc"); // for malloc @@ -3961,44 +3962,44 @@ void GdbEngine::tryLoadCustomDumpers() sendCommand("call (void)__dlopen(\"" + lib + "\", " + flag + ")", WatchDumpCustomSetup); sendCommand("sharedlibrary " + dotEscape(lib)); - } else { - qDebug() << "DEBUG HELPER LIBRARY IS NOT USABLE: " - << lib << QFileInfo(lib).isExecutable(); } #endif #if defined(Q_OS_MAC) QString lib = q->m_buildDir + "/qtc-gdbmacros/libgdbmacros.dylib"; - if (QFileInfo(lib).isExecutable()) { + if (QFileInfo(lib).exists()) { + m_dataDumperState = DataDumperLoadTried; sendCommand("sharedlibrary libc"); // for malloc sendCommand("sharedlibrary libdl"); // for dlopen QString flag = QString::number(RTLD_NOW); sendCommand("call (void)dlopen(\"" + lib + "\", " + flag + ")", WatchDumpCustomSetup); sendCommand("sharedlibrary " + dotEscape(lib)); - } else { - qDebug() << "DEBUG HELPER LIBRARY IS NOT USABLE: " - << lib << QFileInfo(lib).isExecutable(); } #endif #if defined(Q_OS_WIN) QString lib = q->m_buildDir + "/qtc-gdbmacros/debug/gdbmacros.dll"; if (QFileInfo(lib).exists()) { + m_dataDumperState = DataDumperLoadTried; sendCommand("sharedlibrary .*"); // for LoadLibraryA //sendCommand("handle SIGSEGV pass stop print"); //sendCommand("set unwindonsignal off"); sendCommand("call LoadLibraryA(\"" + lib + "\")", WatchDumpCustomSetup); sendCommand("sharedlibrary " + dotEscape(lib)); - } else { - qDebug() << "DEBUG HELPER LIBRARY IS NOT USABLE: " - << lib << QFileInfo(lib).isExecutable(); } #endif - // retreive list of dumpable classes - sendCommand("call qDumpObjectData440(1,%1+1,0,0,0,0,0,0)", - GdbQueryDataDumper1); - sendCommand("p (char*)qDumpOutBuffer", GdbQueryDataDumper2); + if (m_dataDumperState == DataDumperLoadTried) { + // retreive list of dumpable classes + sendCommand("call qDumpObjectData440(1,%1+1,0,0,0,0,0,0)", + GdbQueryDataDumper1); + sendCommand("p (char*)qDumpOutBuffer", GdbQueryDataDumper2); + } else { + gdbOutputAvailable("", QString("DEBUG HELPER LIBRARY IS NOT USABLE: " + " %1 EXISTS: %2, EXECUTABLE: %3").arg(lib) + .arg(QFileInfo(lib).exists()) + .arg(QFileInfo(lib).isExecutable())); + } } From 8dd03e5f530f74d895f08ad7162294f49c0b25ff Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 13 Feb 2009 14:54:36 +0100 Subject: [PATCH 18/37] Fixes: debugger: don't run -file-list-exec-source-files too often --- src/plugins/debugger/gdbengine.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 07e842307a5..c0ce1fb7f6e 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -1194,8 +1194,6 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) if (isStoppedReason(reason) || reason.isEmpty()) { if (m_modulesListOutdated) { - sendCommand("-file-list-exec-source-files", GdbQuerySources); - sendCommand("-break-list", BreakList); reloadModules(); m_modulesListOutdated = false; } From 7008467506231bd8491af42e7e07c6ba5aee7139 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 13 Feb 2009 14:57:24 +0100 Subject: [PATCH 19/37] Fixes: debugger: remove some dead code --- src/plugins/debugger/gdbengine.cpp | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index c0ce1fb7f6e..aa96254d5a9 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -1195,6 +1195,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) if (isStoppedReason(reason) || reason.isEmpty()) { if (m_modulesListOutdated) { reloadModules(); +QT_END_INCLUDE_NAMESPACE m_modulesListOutdated = false; } // Need another round trip @@ -1248,30 +1249,6 @@ void GdbEngine::handleAsyncOutput2(const GdbMi &data) { qq->notifyInferiorStopped(); - // - // Breakpoints - // - //qDebug() << "BREAK ASYNC: " << data.toString(); - //sendListBreakpoints(); - //attemptBreakpointSynchronization(); - //if (m_breakListOnStopNeeded) - // sendListBreakpoints(); - - // something reasonably 'invariant' - // Linux: - //"79*stopped,reason="end-stepping-range",reason="breakpoint-hit",bkptno="1", - //thread-id="1",frame={addr="0x0000000000405d8f",func="run1", - //args=[{name="argc",value="1"},{name="argv",value="0x7fffb7c23058"}], - //file="test1.cpp",fullname="/home/apoenitz/dev/work/test1/test1.cpp" - //,line="261"}" - // Mac: (but only sometimes) - // "82*stopped,bkpt={number="0",type="step - // resume",disp="keep",enabled="y",addr="0x43127171",at="",thread="1",shlib="/Users/epreuss/dev/ide/main/bin/ - // workbench.app/Contents/PlugIns/Trolltech/libFind.1.0.0.dylib", - // frame="0xbfffd800",thread="1",times="1"}, - // // Stack // @@ -3461,8 +3438,6 @@ void GdbEngine::handleDumpCustomValue1(const GdbResultRecord &record, && msg.startsWith("The program being debugged stopped while") && msg.contains("qDumpObjectData440")) { // Fake full stop - sendCommand("-file-list-exec-source-files", GdbQuerySources); - sendCommand("-break-list", BreakList); sendCommand("p 0", GdbAsyncOutput2); // dummy return; } From 140f34c529119072215828babae4e1a5905dacd0 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 13 Feb 2009 16:55:24 +0100 Subject: [PATCH 20/37] Fixes: debugger: try fixing startup break on make --- src/plugins/debugger/gdbengine.cpp | 93 ++++++++++++++++-------------- src/plugins/debugger/gdbengine.h | 1 + 2 files changed, 51 insertions(+), 43 deletions(-) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index aa96254d5a9..381b28c4ef0 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -301,6 +301,7 @@ void GdbEngine::initializeVariables() m_outputCodec = QTextCodec::codecForLocale(); m_pendingRequests = 0; m_waitingForBreakpointSynchronizationToContinue = false; + m_waitingForFirstBreakpointToBeHit = false; } void GdbEngine::gdbProcError(QProcess::ProcessError error) @@ -1083,52 +1084,47 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) { const QString reason = data.findChild("reason").data(); - QString msg = data.findChild("consolestreamoutput").data(); - if (reason.isEmpty()) { - GdbMi frame = data.findChild("frame"); - if (frame.findChild("func").data() == startSymbolName()) { - // - // that's the "early stop" - // - frame.findChild("func").data() + '%'; - #if defined(Q_OS_WIN) - sendCommand("info proc", GdbInfoProc); - #endif - #if defined(Q_OS_LINUX) - sendCommand("info proc", GdbInfoProc); - #endif - #if defined(Q_OS_MAC) - sendCommand("info pid", GdbInfoProc, QVariant(), true); - #endif - sendCommand("-file-list-exec-source-files", GdbQuerySources); - tryLoadCustomDumpers(); + bool isFirstStop = data.findChild("bkptno").data() == "1"; + if (isFirstStop && m_waitingForFirstBreakpointToBeHit) { + // + // that's the "early stop" + // + #if defined(Q_OS_WIN) + sendCommand("info proc", GdbInfoProc); + #endif + #if defined(Q_OS_LINUX) + sendCommand("info proc", GdbInfoProc); + #endif + #if defined(Q_OS_MAC) + sendCommand("info pid", GdbInfoProc, QVariant(), true); + #endif + sendCommand("-file-list-exec-source-files", GdbQuerySources); + tryLoadCustomDumpers(); - // intentionally after tryLoadCustomDumpers(), - // otherwise we'd interupt solib loading. - if (qq->wantsAllPluginBreakpoints()) { - sendCommand("set auto-solib-add on"); - sendCommand("set stop-on-solib-events 0"); - sendCommand("sharedlibrary .*"); - } else if (qq->wantsSelectedPluginBreakpoints()) { - sendCommand("set auto-solib-add on"); - sendCommand("set stop-on-solib-events 1"); - sendCommand("sharedlibrary "+qq->selectedPluginBreakpointsPattern()); - } else if (qq->wantsNoPluginBreakpoints()) { - // should be like that already - sendCommand("set auto-solib-add off"); - sendCommand("set stop-on-solib-events 0"); - } - // nicer to see a bit of the world we live in - reloadModules(); - // this will "continue" if done - m_waitingForBreakpointSynchronizationToContinue = true; - QTimer::singleShot(0, this, SLOT(attemptBreakpointSynchronization())); - return; + // intentionally after tryLoadCustomDumpers(), + // otherwise we'd interupt solib loading. + if (qq->wantsAllPluginBreakpoints()) { + sendCommand("set auto-solib-add on"); + sendCommand("set stop-on-solib-events 0"); + sendCommand("sharedlibrary .*"); + } else if (qq->wantsSelectedPluginBreakpoints()) { + sendCommand("set auto-solib-add on"); + sendCommand("set stop-on-solib-events 1"); + sendCommand("sharedlibrary "+qq->selectedPluginBreakpointsPattern()); + } else if (qq->wantsNoPluginBreakpoints()) { + // should be like that already + sendCommand("set auto-solib-add off"); + sendCommand("set stop-on-solib-events 0"); } - qDebug() << "EMPTY REASON FOR STOPPED"; - // fall through + // nicer to see a bit of the world we live in + reloadModules(); + // this will "continue" if done + m_waitingForBreakpointSynchronizationToContinue = true; + QTimer::singleShot(0, this, SLOT(attemptBreakpointSynchronization())); + return; } + QString msg = data.findChild("consolestreamoutput").data(); if (msg.contains("Stopped due to shared library event") || reason.isEmpty()) { if (qq->wantsSelectedPluginBreakpoints()) { qDebug() << "SHARED LIBRARY EVENT " << data.toString(); @@ -1142,6 +1138,17 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) // fall through } + // seen on XP after removing a breakpoint while running + // stdout:945*stopped,reason="signal-received",signal-name="SIGTRAP", + // signal-meaning="Trace/breakpoint trap",thread-id="2", + // frame={addr="0x7c91120f",func="ntdll!DbgUiConnectToDbg", + // args=[],from="C:\\WINDOWS\\system32\\ntdll.dll"} + if (reason == "signal-received" + && data.findChild("signal-name").toString() == "SIGTRAP") { + continueInferior(); + return; + } + if (isExitedReason(reason)) { qq->notifyInferiorExited(); QString msg = "Program exited normally"; @@ -1195,7 +1202,6 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) if (isStoppedReason(reason) || reason.isEmpty()) { if (m_modulesListOutdated) { reloadModules(); -QT_END_INCLUDE_NAMESPACE m_modulesListOutdated = false; } // Need another round trip @@ -1613,6 +1619,7 @@ void GdbEngine::handleStart(const GdbResultRecord &response) if (needle.indexIn(msg) != -1) { //qDebug() << "STREAM: " << msg << needle.cap(1); sendCommand("tbreak *0x" + needle.cap(1)); + m_waitingForFirstBreakpointToBeHit = true; sendCommand("-exec-run"); qq->notifyInferiorRunningRequested(); } else { diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h index 58021fb765a..bf90ad97c99 100644 --- a/src/plugins/debugger/gdbengine.h +++ b/src/plugins/debugger/gdbengine.h @@ -330,6 +330,7 @@ private: QMap m_varToType; bool m_waitingForBreakpointSynchronizationToContinue; + bool m_waitingForFirstBreakpointToBeHit; bool m_modulesListOutdated; DebuggerManager *q; From 24479744ebc24100c4592f561b708be9725e6dcf Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 13 Feb 2009 17:11:34 +0100 Subject: [PATCH 21/37] Fixes: debugger: try to extact pid from 'info threads' on windows --- src/plugins/debugger/gdbengine.cpp | 25 ++++++++++++++++++++++--- src/plugins/debugger/gdbengine.h | 1 + 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 381b28c4ef0..0641dac2114 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -112,6 +112,7 @@ enum GdbCommandType GdbExecInterrupt, GdbInfoShared, GdbInfoProc, + GdbInfoThreads, GdbQueryDataDumper1, GdbQueryDataDumper2, @@ -800,6 +801,9 @@ void GdbEngine::handleResult(const GdbResultRecord & record, int type, case GdbInfoProc: handleInfoProc(record); break; + case GdbInfoThreads: + handleInfoThreads(record); + break; case GdbShowVersion: handleShowVersion(record); @@ -993,6 +997,19 @@ void GdbEngine::handleQuerySources(const GdbResultRecord &record) } } +void GdbEngine::handleInfoThreads(const GdbResultRecord &record) +{ + if (record.resultClass == GdbResultDone) { + // FIXME: use something more robust + // WIN: * 3 Thread 2312.0x4d0 0x7c91120f in ?? () + // LINUX: * 1 Thread 0x7f466273c6f0 (LWP 21455) 0x0000000000404542 in ... + QRegExp re(QLatin1String("Thread (\\d+)\\.0x.* in")); + QString data = record.data.findChild("consolestreamoutput").data(); + if (re.indexIn(data) != -1) + maybeHandleInferiorPidChanged(re.cap(1)); + } +} + void GdbEngine::handleInfoProc(const GdbResultRecord &record) { if (record.resultClass == GdbResultDone) { @@ -1084,13 +1101,15 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) { const QString reason = data.findChild("reason").data(); - bool isFirstStop = data.findChild("bkptno").data() == "1"; - if (isFirstStop && m_waitingForFirstBreakpointToBeHit) { + //MAC: bool isFirstStop = data.findChild("bkptno").data() == "1"; + //!MAC: startSymbolName == data.findChild("frame").findChild("func") + if (m_waitingForFirstBreakpointToBeHit) { + m_waitingForFirstBreakpointToBeHit = false; // // that's the "early stop" // #if defined(Q_OS_WIN) - sendCommand("info proc", GdbInfoProc); + sendCommand("info thread", GdbInfoThreads); #endif #if defined(Q_OS_LINUX) sendCommand("info proc", GdbInfoProc); diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h index bf90ad97c99..0d710e359cf 100644 --- a/src/plugins/debugger/gdbengine.h +++ b/src/plugins/debugger/gdbengine.h @@ -189,6 +189,7 @@ private: void handleExecRunToFunction(const GdbResultRecord &response); void handleInfoShared(const GdbResultRecord &response); void handleInfoProc(const GdbResultRecord &response); + void handleInfoThreads(const GdbResultRecord &response); void handleShowVersion(const GdbResultRecord &response); void handleQueryPwd(const GdbResultRecord &response); void handleQuerySources(const GdbResultRecord &response); From 65212f119c975f53121c2cf60796774680ec1940 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 16 Feb 2009 09:59:12 +0100 Subject: [PATCH 22/37] Fixes: debugger: make shutdown a bit more robust --- src/plugins/debugger/debuggermanager.cpp | 138 ++++++++++++++++------- src/plugins/debugger/debuggermanager.h | 2 + 2 files changed, 98 insertions(+), 42 deletions(-) diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index 6d2b629e77a..a41b2be883c 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -33,7 +33,6 @@ #include "debuggermanager.h" -#include "assert.h" #include "debuggerconstants.h" #include "idebuggerengine.h" @@ -58,6 +57,8 @@ #include "startexternaldialog.h" #include "attachexternaldialog.h" +#include + #include #include #include @@ -149,6 +150,7 @@ void DebuggerManager::init() { m_status = -1; m_busy = false; + m_shutdown = false; m_attachedPID = 0; m_startMode = startInternal; @@ -588,7 +590,18 @@ void DebuggerManager::showApplicationOutput(const QString &str) void DebuggerManager::shutdown() { //qDebug() << "DEBUGGER_MANAGER SHUTDOWN START"; - engine()->shutdown(); + m_shutdown = true; + if (m_engine) + m_engine->shutdown(); + m_engine = 0; + + delete scriptEngine; + scriptEngine = 0; + delete gdbEngine; + gdbEngine = 0; + delete winEngine; + winEngine = 0; + // Delete these manually before deleting the manager // (who will delete the models for most views) delete m_breakWindow; @@ -642,41 +655,49 @@ void DebuggerManager::toggleBreakpoint() void DebuggerManager::toggleBreakpoint(const QString &fileName, int lineNumber) { + QTC_ASSERT(m_engine, return); + QTC_ASSERT(m_breakHandler, return); int index = m_breakHandler->indexOf(fileName, lineNumber); if (index == -1) - breakHandler()->setBreakpoint(fileName, lineNumber); + m_breakHandler->setBreakpoint(fileName, lineNumber); else - breakHandler()->removeBreakpoint(index); - engine()->attemptBreakpointSynchronization(); + m_breakHandler->removeBreakpoint(index); + m_engine->attemptBreakpointSynchronization(); } void DebuggerManager::setToolTipExpression(const QPoint &pos, const QString &exp) { - engine()->setToolTipExpression(pos, exp); + QTC_ASSERT(m_engine, return); + m_engine->setToolTipExpression(pos, exp); } void DebuggerManager::updateWatchModel() { - engine()->updateWatchModel(); + QTC_ASSERT(m_engine, return); + m_engine->updateWatchModel(); } void DebuggerManager::expandChildren(const QModelIndex &idx) { - watchHandler()->expandChildren(idx); + QTC_ASSERT(m_watchHandler, return); + m_watchHandler->expandChildren(idx); } void DebuggerManager::collapseChildren(const QModelIndex &idx) { - watchHandler()->collapseChildren(idx); + QTC_ASSERT(m_watchHandler, return); + m_watchHandler->collapseChildren(idx); } void DebuggerManager::removeWatchExpression(const QString &exp) { - watchHandler()->removeWatchExpression(exp); + QTC_ASSERT(m_watchHandler, return); + m_watchHandler->removeWatchExpression(exp); } QVariant DebuggerManager::sessionValue(const QString &name) { + // this is answered by the plugin QVariant value; emit sessionValueRequested(name, &value); return value; @@ -684,16 +705,19 @@ QVariant DebuggerManager::sessionValue(const QString &name) void DebuggerManager::querySessionValue(const QString &name, QVariant *value) { + // this is answered by the plugin emit sessionValueRequested(name, value); } void DebuggerManager::setSessionValue(const QString &name, const QVariant &value) { + // this is answered by the plugin emit setSessionValueRequested(name, value); } QVariant DebuggerManager::configValue(const QString &name) { + // this is answered by the plugin QVariant value; emit configValueRequested(name, &value); return value; @@ -701,11 +725,13 @@ QVariant DebuggerManager::configValue(const QString &name) void DebuggerManager::queryConfigValue(const QString &name, QVariant *value) { + // this is answered by the plugin emit configValueRequested(name, value); } void DebuggerManager::setConfigValue(const QString &name, const QVariant &value) { + // this is answered by the plugin emit setConfigValueRequested(name, value); } @@ -788,7 +814,7 @@ bool DebuggerManager::startNewDebugger(StartMode mode) else setDebuggerType(GdbDebugger); - if (!engine()->startDebugger()) + if (!m_engine->startDebugger()) return false; m_busy = false; @@ -809,7 +835,10 @@ void DebuggerManager::cleanupViews() void DebuggerManager::exitDebugger() { - engine()->exitDebugger(); + if (m_shutdown) + return; + QTC_ASSERT(m_engine, return); + m_engine->exitDebugger(); cleanupViews(); setStatus(DebuggerProcessNotReady); setBusyCursor(false); @@ -818,62 +847,73 @@ void DebuggerManager::exitDebugger() void DebuggerManager::assignValueInDebugger(const QString &expr, const QString &value) { - engine()->assignValueInDebugger(expr, value); + QTC_ASSERT(m_engine, return); + m_engine->assignValueInDebugger(expr, value); } void DebuggerManager::activateFrame(int index) { - engine()->activateFrame(index); + QTC_ASSERT(m_engine, return); + m_engine->activateFrame(index); } void DebuggerManager::selectThread(int index) { - engine()->selectThread(index); + QTC_ASSERT(m_engine, return); + m_engine->selectThread(index); } void DebuggerManager::loadAllSymbols() { - engine()->loadAllSymbols(); + QTC_ASSERT(m_engine, return); + m_engine->loadAllSymbols(); } void DebuggerManager::loadSymbols(const QString &module) { - engine()->loadSymbols(module); + QTC_ASSERT(m_engine, return); + m_engine->loadSymbols(module); } void DebuggerManager::stepExec() { + QTC_ASSERT(m_engine, return); resetLocation(); - engine()->stepExec(); + m_engine->stepExec(); } void DebuggerManager::stepOutExec() { + QTC_ASSERT(m_engine, return); resetLocation(); - engine()->stepOutExec(); + m_engine->stepOutExec(); } void DebuggerManager::nextExec() { + QTC_ASSERT(m_engine, return); resetLocation(); - engine()->nextExec(); + m_engine->nextExec(); } void DebuggerManager::stepIExec() { + QTC_ASSERT(m_engine, return); resetLocation(); - engine()->stepIExec(); + m_engine->stepIExec(); } void DebuggerManager::nextIExec() { + QTC_ASSERT(m_engine, return); resetLocation(); - engine()->nextIExec(); + m_engine->nextIExec(); } void DebuggerManager::executeDebuggerCommand(const QString &command) { - engine()->executeDebuggerCommand(command); + QTC_ASSERT(m_engine, return); + m_engine->executeDebuggerCommand(command); } void DebuggerManager::sessionLoaded() @@ -891,16 +931,18 @@ void DebuggerManager::aboutToSaveSession() void DebuggerManager::loadSessionData() { + QTC_ASSERT(m_engine, return); m_breakHandler->loadSessionData(); m_watchHandler->loadSessionData(); - engine()->loadSessionData(); + m_engine->loadSessionData(); } void DebuggerManager::saveSessionData() { + QTC_ASSERT(m_engine, return); m_breakHandler->saveSessionData(); m_watchHandler->saveSessionData(); - engine()->saveSessionData(); + m_engine->saveSessionData(); } void DebuggerManager::dumpLog() @@ -959,19 +1001,24 @@ void DebuggerManager::addToWatchWindow() void DebuggerManager::watchExpression(const QString &expression) { - watchHandler()->watchExpression(expression); + QTC_ASSERT(m_watchHandler, return); + m_watchHandler->watchExpression(expression); } void DebuggerManager::setBreakpoint(const QString &fileName, int lineNumber) { - breakHandler()->setBreakpoint(fileName, lineNumber); - engine()->attemptBreakpointSynchronization(); + QTC_ASSERT(m_breakHandler, return); + QTC_ASSERT(m_engine, return); + m_breakHandler->setBreakpoint(fileName, lineNumber); + m_engine->attemptBreakpointSynchronization(); } void DebuggerManager::breakByFunction(const QString &functionName) { - breakHandler()->breakByFunction(functionName); - engine()->attemptBreakpointSynchronization(); + QTC_ASSERT(m_breakHandler, return); + QTC_ASSERT(m_engine, return); + m_breakHandler->breakByFunction(functionName); + m_engine->attemptBreakpointSynchronization(); } void DebuggerManager::breakByFunction() @@ -1081,14 +1128,16 @@ bool DebuggerManager::useCustomDumpers() const void DebuggerManager::setUseCustomDumpers(bool on) { + QTC_ASSERT(m_engine, return); m_settings.m_useCustomDumpers = on; - engine()->setUseCustomDumpers(on); + m_engine->setUseCustomDumpers(on); } void DebuggerManager::setDebugDumpers(bool on) { + QTC_ASSERT(m_engine, return); m_settings.m_debugDumpers = on; - engine()->setDebugDumpers(on); + m_engine->setDebugDumpers(on); } void DebuggerManager::setSkipKnownFrames(bool on) @@ -1104,29 +1153,31 @@ void DebuggerManager::queryCurrentTextEditor(QString *fileName, int *lineNumber, void DebuggerManager::continueExec() { - engine()->continueInferior(); + m_engine->continueInferior(); } void DebuggerManager::interruptDebuggingRequest() { + QTC_ASSERT(m_engine, return); //qDebug() << "INTERRUPTING AT" << status(); bool interruptIsExit = (status() != DebuggerInferiorRunning); if (interruptIsExit) exitDebugger(); else { setStatus(DebuggerInferiorStopRequested); - engine()->interruptInferior(); + m_engine->interruptInferior(); } } void DebuggerManager::runToLineExec() { + QTC_ASSERT(m_engine, return); QString fileName; int lineNumber = -1; emit currentTextEditorRequested(&fileName, &lineNumber, 0); if (!fileName.isEmpty()) - engine()->runToLineExec(fileName, lineNumber); + m_engine->runToLineExec(fileName, lineNumber); } void DebuggerManager::runToFunctionExec() @@ -1158,7 +1209,7 @@ void DebuggerManager::runToFunctionExec() } //qDebug() << "RUN TO FUNCTION " << functionName; if (!functionName.isEmpty()) - engine()->runToFunctionExec(functionName); + m_engine->runToFunctionExec(functionName); } void DebuggerManager::jumpToLineExec() @@ -1167,20 +1218,20 @@ void DebuggerManager::jumpToLineExec() int lineNumber = -1; emit currentTextEditorRequested(&fileName, &lineNumber, 0); if (!fileName.isEmpty()) - engine()->jumpToLineExec(fileName, lineNumber); + m_engine->jumpToLineExec(fileName, lineNumber); } void DebuggerManager::resetLocation() { - //m_watchHandler->removeMouseMoveCatcher(editor->widget()); + // connected to the plugin emit resetLocationRequested(); } void DebuggerManager::gotoLocation(const QString &fileName, int line, bool setMarker) { + // connected to the plugin emit gotoLocationRequested(fileName, line, setMarker); - //m_watchHandler->installMouseMoveCatcher(editor->widget()); } @@ -1192,9 +1243,10 @@ void DebuggerManager::gotoLocation(const QString &fileName, int line, void DebuggerManager::reloadDisassembler() { + QTC_ASSERT(m_engine, return); if (!m_disassemblerDock || !m_disassemblerDock->isVisible()) return; - engine()->reloadDisassembler(); + m_engine->reloadDisassembler(); } void DebuggerManager::disassemblerDockToggled(bool on) @@ -1214,7 +1266,7 @@ void DebuggerManager::reloadModules() { if (!m_modulesDock || !m_modulesDock->isVisible()) return; - engine()->reloadModules(); + m_engine->reloadModules(); } void DebuggerManager::modulesDockToggled(bool on) @@ -1232,11 +1284,13 @@ void DebuggerManager::modulesDockToggled(bool on) void DebuggerManager::showDebuggerOutput(const QString &prefix, const QString &msg) { + QTC_ASSERT(m_outputWindow, return); m_outputWindow->showOutput(prefix, msg); } void DebuggerManager::showDebuggerInput(const QString &prefix, const QString &msg) { + QTC_ASSERT(m_outputWindow, return); m_outputWindow->showInput(prefix, msg); } @@ -1257,7 +1311,7 @@ void DebuggerManager::reloadRegisters() { if (!m_registerDock || !m_registerDock->isVisible()) return; - engine()->reloadRegisters(); + m_engine->reloadRegisters(); } diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index a3407a0aa59..bd10b7b0259 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -466,6 +466,8 @@ private: IDebuggerEngine *engine(); IDebuggerEngine *m_engine; DebuggerSettings m_settings; + // set during application shutdown + bool m_shutdown; }; } // namespace Internal From 2cb3536a3c7e959be7b30e9c56a4ddfcf4739c95 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 16 Feb 2009 13:29:57 +0100 Subject: [PATCH 23/37] Fixes: debugger: work on shutdown --- src/plugins/debugger/debuggermanager.cpp | 42 +++---------- src/plugins/debugger/debuggermanager.h | 2 - src/plugins/debugger/debuggerrunner.cpp | 8 ++- src/plugins/debugger/debuggerrunner.h | 3 + src/plugins/debugger/gdbengine.cpp | 79 +++++++++++++----------- src/plugins/debugger/gdbengine.h | 1 + 6 files changed, 62 insertions(+), 73 deletions(-) diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index a41b2be883c..93597c51768 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -150,7 +150,6 @@ void DebuggerManager::init() { m_status = -1; m_busy = false; - m_shutdown = false; m_attachedPID = 0; m_startMode = startInternal; @@ -578,7 +577,7 @@ void DebuggerManager::notifyInferiorExited() void DebuggerManager::notifyInferiorPidChanged(int pid) { //QMessageBox::warning(0, "PID", "PID: " + QString::number(pid)); - qDebug() << "PID: " << pid; + //qDebug() << "PID: " << pid; emit inferiorPidChanged(pid); } @@ -590,9 +589,10 @@ void DebuggerManager::showApplicationOutput(const QString &str) void DebuggerManager::shutdown() { //qDebug() << "DEBUGGER_MANAGER SHUTDOWN START"; - m_shutdown = true; - if (m_engine) + if (m_engine) { + //qDebug() << "SHUTTING DOWN ENGINE" << m_engine; m_engine->shutdown(); + } m_engine = 0; delete scriptEngine; @@ -835,10 +835,9 @@ void DebuggerManager::cleanupViews() void DebuggerManager::exitDebugger() { - if (m_shutdown) - return; - QTC_ASSERT(m_engine, return); - m_engine->exitDebugger(); + //qDebug() << "DebuggerManager::exitDebugger"; + if (m_engine) + m_engine->exitDebugger(); cleanupViews(); setStatus(DebuggerProcessNotReady); setBusyCursor(false); @@ -960,33 +959,6 @@ void DebuggerManager::dumpLog() ts << m_outputWindow->combinedContents(); } -#if 0 -// call after m_gdbProc exited. -void GdbEngine::procFinished() -{ - //qDebug() << "GDB PROCESS FINISHED"; - setStatus(DebuggerProcessNotReady); - showStatusMessage(tr("Done"), 5000); - q->m_breakHandler->procFinished(); - q->m_watchHandler->cleanup(); - m_stackHandler->m_stackFrames.clear(); - m_stackHandler->resetModel(); - m_threadsHandler->resetModel(); - if (q->m_modulesHandler) - q->m_modulesHandler->procFinished(); - q->resetLocation(); - setStatus(DebuggerProcessNotReady); - emit q->previousModeRequested(); - emit q->debuggingFinished(); - //exitDebugger(); - //showStatusMessage("Gdb killed"); - m_shortToFullName.clear(); - m_fullToShortName.clear(); - m_shared = 0; - q->m_busy = false; -} -#endif - void DebuggerManager::addToWatchWindow() { // requires a selection, but that's the only case we want... diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index bd10b7b0259..a3407a0aa59 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -466,8 +466,6 @@ private: IDebuggerEngine *engine(); IDebuggerEngine *m_engine; DebuggerSettings m_settings; - // set during application shutdown - bool m_shutdown; }; } // namespace Internal diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index 21313428aef..5034a0d9a4a 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -115,6 +115,8 @@ DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager, connect(m_manager, SIGNAL(inferiorPidChanged(qint64)), this, SLOT(bringApplicationToForeground(qint64)), Qt::QueuedConnection); + connect(this, SIGNAL(stopRequested()), + m_manager, SLOT(exitDebugger())); } void DebuggerRunControl::start() @@ -148,17 +150,21 @@ void DebuggerRunControl::slotAddToOutputWindowInline(const QString &data) void DebuggerRunControl::stop() { - m_manager->exitDebugger(); + //qDebug() << "DebuggerRunControl::stop"; + m_running = false; + emit stopRequested(); } void DebuggerRunControl::debuggingFinished() { m_running = false; + //qDebug() << "DebuggerRunControl::finished"; //emit addToOutputWindow(this, tr("Debugging %1 finished").arg(m_executable)); emit finished(); } bool DebuggerRunControl::isRunning() const { + //qDebug() << "DebuggerRunControl::isRunning" << m_running; return m_running; } diff --git a/src/plugins/debugger/debuggerrunner.h b/src/plugins/debugger/debuggerrunner.h index 0c6d979c010..7b73178d103 100644 --- a/src/plugins/debugger/debuggerrunner.h +++ b/src/plugins/debugger/debuggerrunner.h @@ -82,6 +82,9 @@ public: virtual void stop(); virtual bool isRunning() const; +signals: + void stopRequested(); + private slots: void debuggingFinished(); void slotAddToOutputWindowInline(const QString &output); diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 0641dac2114..7f99a0a9b3e 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -257,6 +257,8 @@ GdbEngine::GdbEngine(DebuggerManager *parent) GdbEngine::~GdbEngine() { + // prevent sending error messages afterwards + m_gdbProc.disconnect(this); } void GdbEngine::initializeConnections() @@ -386,6 +388,11 @@ void GdbEngine::readDebugeeOutput(const QByteArray &data) data.constData(), data.length(), &m_outputCodecState)); } +void GdbEngine::debugMessage(const QString &msg) +{ + emit gdbOutputAvailable("debug:", msg); +} + // called asyncronously as response to Gdb stdout output in // gdbResponseAvailable() void GdbEngine::handleResponse() @@ -656,7 +663,7 @@ void GdbEngine::interruptInferior() sendCommand("-exec-interrupt", GdbExecInterrupt); qq->notifyInferiorStopped(); #else - qDebug() << "CANNOT STOP INFERIOR" << m_gdbProc.pid(); + debugMessage(QString("CANNOT STOP INFERIOR %1").arg(m_gdbProc.pid())); if (interruptChildProcess(m_gdbProc.pid())) qq->notifyInferiorStopped(); #endif @@ -666,12 +673,12 @@ void GdbEngine::maybeHandleInferiorPidChanged(const QString &pid0) { int pid = pid0.toInt(); if (pid == 0) { - qDebug() << "Cannot parse PID from " << pid0; + debugMessage(QString("Cannot parse PID from %1").arg(pid0)); return; } if (pid == q->m_attachedPID) return; - qDebug() << "FOUND PID " << pid; + debugMessage(QString("FOUND PID %1").arg(pid)); q->m_attachedPID = pid; qq->notifyInferiorPidChanged(pid); } @@ -686,7 +693,7 @@ void GdbEngine::sendCommand(const QString &command, int type, const QVariant &cookie, bool needStop, bool synchronized) { if (m_gdbProc.state() == QProcess::NotRunning) { - //qDebug() << "NO GDB PROCESS RUNNING, CMD IGNORED:" << command; + debugMessage("NO GDB PROCESS RUNNING, CMD IGNORED: " + command); return; } @@ -718,9 +725,7 @@ void GdbEngine::sendCommand(const QString &command, int type, m_cookieForToken[currentToken()] = cmd; - //qDebug() << ""; if (!command.isEmpty()) { - //qDebug() << qPrintable(currentTime()) << "RUNNING" << cmd.command; m_gdbProc.write(cmd.command.toLatin1() + "\r\n"); //emit gdbInputAvailable(QString(), " " + currentTime()); //emit gdbInputAvailable(QString(), "[" + currentTime() + "] " + cmd.command); @@ -920,8 +925,8 @@ void GdbEngine::handleResult(const GdbResultRecord & record, int type, break; default: - qDebug() << "FIXME: GdbEngine::handleResult: " - "should not happen" << type; + debugMessage(QString("FIXME: GdbEngine::handleResult: " + "should not happen %1").arg(type)); break; } } @@ -930,7 +935,7 @@ void GdbEngine::executeDebuggerCommand(const QString &command) { //createGdbProcessIfNeeded(); if (m_gdbProc.state() == QProcess::NotRunning) { - qDebug() << "NO GDB PROCESS RUNNING, PLAIN CMD IGNORED: " << command; + debugMessage("NO GDB PROCESS RUNNING, PLAIN CMD IGNORED: " + command); return; } @@ -938,11 +943,6 @@ void GdbEngine::executeDebuggerCommand(const QString &command) cmd.command = command; cmd.type = -1; - //m_cookieForToken[currentToken()] = cmd; - //++currentToken(); - - //qDebug() << ""; - //qDebug() << currentTime() << "Running command: " << cmd.command; emit gdbInputAvailable(QString(), cmd.command); m_gdbProc.write(cmd.command.toLatin1() + "\r\n"); } @@ -969,7 +969,7 @@ void GdbEngine::handleQueryPwd(const GdbResultRecord &record) m_pwd = record.data.findChild("consolestreamoutput").data(); m_pwd = m_pwd.trimmed(); #endif - //qDebug() << "PWD RESULT:" << m_pwd; + debugMessage("PWD RESULT: " + m_pwd); } } @@ -1146,8 +1146,8 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) QString msg = data.findChild("consolestreamoutput").data(); if (msg.contains("Stopped due to shared library event") || reason.isEmpty()) { if (qq->wantsSelectedPluginBreakpoints()) { - qDebug() << "SHARED LIBRARY EVENT " << data.toString(); - qDebug() << "PATTERN" << qq->selectedPluginBreakpointsPattern(); + debugMessage("SHARED LIBRARY EVENT: " + data.toString()); + debugMessage("PATTERN: " + qq->selectedPluginBreakpointsPattern()); sendCommand("sharedlibrary " + qq->selectedPluginBreakpointsPattern()); continueInferior(); q->showStatusMessage(tr("Loading %1...").arg(QString(data.toString()))); @@ -1182,6 +1182,8 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) + data.findChild("signal-name").toString(); } q->showStatusMessage(msg); + // FIXME: shouldn't this use a statis change? + debugMessage("CALLING PARENT EXITDEBUGGER"); q->exitDebugger(); return; } @@ -1193,21 +1195,21 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) if (qq->skipKnownFrames()) { if (reason == "end-stepping-range" || reason == "function-finished") { GdbMi frame = data.findChild("frame"); - //qDebug() << frame.toString(); + //debugMessage(frame.toString()); m_currentFrame = frame.findChild("addr").data() + '%' + frame.findChild("func").data() + '%'; QString funcName = frame.findChild("func").data(); QString fileName = frame.findChild("file").data(); if (isLeavableFunction(funcName, fileName)) { - //qDebug() << "LEAVING" << funcName; + //debugMessage("LEAVING" + funcName); ++stepCounter; q->stepOutExec(); //stepExec(); return; } if (isSkippableFunction(funcName, fileName)) { - //qDebug() << "SKIPPING" << funcName; + //debugMessage("SKIPPING" + funcName); ++stepCounter; q->stepExec(); return; @@ -1227,7 +1229,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) if (reason == "breakpoint-hit") { q->showStatusMessage(tr("Stopped at breakpoint")); GdbMi frame = data.findChild("frame"); - //qDebug() << "HIT BREAKPOINT: " << frame.toString(); + //debugMessage("HIT BREAKPOINT: " + frame.toString()); m_currentFrame = frame.findChild("addr").data() + '%' + frame.findChild("func").data() + '%'; @@ -1243,7 +1245,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) return; } - qDebug() << "STOPPED FOR UNKNOWN REASON" << data.toString(); + debugMessage("STOPPED FOR UNKNOWN REASON: " + data.toString()); // Ignore it. Will be handled with full response later in the // JumpToLine or RunToFunction handlers #if 1 @@ -1310,7 +1312,7 @@ void GdbEngine::handleShowVersion(const GdbResultRecord &response) QString msg = response.data.findChild("consolestreamoutput").data(); QRegExp supported("GNU gdb(.*) (\\d+)\\.(\\d+)(\\.(\\d+))?"); if (supported.indexIn(msg) == -1) { - qDebug() << "UNSUPPORTED GDB VERSION " << msg; + debugMessage("UNSUPPORTED GDB VERSION " + msg); QStringList list = msg.split("\n"); while (list.size() > 2) list.removeLast(); @@ -1331,7 +1333,7 @@ void GdbEngine::handleShowVersion(const GdbResultRecord &response) m_gdbVersion = 10000 * supported.cap(2).toInt() + 100 * supported.cap(3).toInt() + 1 * supported.cap(5).toInt(); - //qDebug() << "GDB VERSION " << m_gdbVersion; + //debugMessage(QString("GDB VERSION: %1").arg(m_gdbVersion)); } } } @@ -1387,7 +1389,7 @@ QString GdbEngine::fullName(const QString &fileName) if (fileName.isEmpty()) return QString(); QString full = m_shortToFullName.value(fileName, QString()); - //qDebug() << "RESOLVING: " << fileName << full; + //debugMessage("RESOLVING: " + fileName + " " + full); if (!full.isEmpty()) return full; QFileInfo fi(fileName); @@ -1397,7 +1399,7 @@ QString GdbEngine::fullName(const QString &fileName) #ifdef Q_OS_WIN full = QDir::cleanPath(full); #endif - //qDebug() << "STORING: " << fileName << full; + //debugMessage("STORING: " + fileName + " " + full); m_shortToFullName[fileName] = full; m_fullToShortName[full] = fileName; return full; @@ -1425,22 +1427,29 @@ void GdbEngine::shutdown() void GdbEngine::exitDebugger() { - //qDebug() << "EXITING: " << m_gdbProc.state(); - if (m_gdbProc.state() == QProcess::Starting) + debugMessage(QString("GDBENGINE EXITDEBUFFER: %1").arg(m_gdbProc.state())); + if (m_gdbProc.state() == QProcess::Starting) { + debugMessage(QString("WAITING FOR GDB STARTUP TO SHUTDOWN: %1") + .arg(m_gdbProc.state())); m_gdbProc.waitForStarted(); + } if (m_gdbProc.state() == QProcess::Running) { + debugMessage(QString("WAITING FOR RUNNING GDB TO SHUTDOWN: %1") + .arg(m_gdbProc.state())); interruptInferior(); sendCommand("kill"); sendCommand("-gdb-exit"); // 20s can easily happen when loading webkit debug information m_gdbProc.waitForFinished(20000); if (m_gdbProc.state() != QProcess::Running) { + debugMessage(QString("FORCING TERMINATION: %1") + .arg(m_gdbProc.state())); m_gdbProc.terminate(); m_gdbProc.waitForFinished(20000); } } if (m_gdbProc.state() != QProcess::NotRunning) - qDebug() << "PROBLEM STOPPING DEBUGGER"; + debugMessage("PROBLEM STOPPING DEBUGGER"); m_outputCollector.shutdown(); initializeVariables(); @@ -1462,7 +1471,7 @@ bool GdbEngine::startDebugger() QString fileName = '"' + fi.absoluteFilePath() + '"'; if (m_gdbProc.state() != QProcess::NotRunning) { - qDebug() << "GDB IS ALREADY RUNNING!"; + debugMessage("GDB IS ALREADY RUNNING!"); return false; } @@ -1636,16 +1645,16 @@ void GdbEngine::handleStart(const GdbResultRecord &response) QString msg = response.data.findChild("consolestreamoutput").data(); QRegExp needle("0x([0-9a-f]+) <" + startSymbolName() + "\\+.*>:"); if (needle.indexIn(msg) != -1) { - //qDebug() << "STREAM: " << msg << needle.cap(1); + //debugMessage("STREAM: " + msg + " " + needle.cap(1)); sendCommand("tbreak *0x" + needle.cap(1)); m_waitingForFirstBreakpointToBeHit = true; sendCommand("-exec-run"); qq->notifyInferiorRunningRequested(); } else { - qDebug() << "PARSING START ADDRESS FAILED" << msg; + debugMessage("PARSING START ADDRESS FAILED: " + msg); } } else if (response.resultClass == GdbResultError) { - qDebug() << "PARSING START ADDRESS FAILED" << response.toString(); + debugMessage("PARSING START ADDRESS FAILED: " + response.toString()); } } @@ -1740,12 +1749,12 @@ void GdbEngine::setTokenBarrier() void GdbEngine::setDebugDumpers(bool on) { if (on) { - qDebug() << "SWITCHING ON DUMPER DEBUGGING"; + debugMessage("SWITCHING ON DUMPER DEBUGGING"); sendCommand("set unwindonsignal off"); q->breakByFunction("qDumpObjectData440"); //updateLocals(); } else { - qDebug() << "SWITCHING OFF DUMPER DEBUGGING"; + debugMessage("SWITCHING OFF DUMPER DEBUGGING"); sendCommand("set unwindonsignal on"); } } diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h index 0d710e359cf..ee5de645c3d 100644 --- a/src/plugins/debugger/gdbengine.h +++ b/src/plugins/debugger/gdbengine.h @@ -193,6 +193,7 @@ private: void handleShowVersion(const GdbResultRecord &response); void handleQueryPwd(const GdbResultRecord &response); void handleQuerySources(const GdbResultRecord &response); + void debugMessage(const QString &msg); OutputCollector m_outputCollector; QTextCodec *m_outputCodec; From 32ff5cf9eeed51d652d7243d3e126a5231940338 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 16 Feb 2009 13:41:57 +0100 Subject: [PATCH 24/37] Fixes: debugging external apps just treat it the same as internal apps as far as gdbengine is concerned. --- src/plugins/debugger/gdbengine.cpp | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 7f99a0a9b3e..6e68184913d 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -1588,7 +1588,9 @@ bool GdbEngine::startDebugger() } } - if (q->startMode() == q->startInternal) { + if (q->startMode() == q->attachExternal) { + sendCommand("attach " + QString::number(q->m_attachedPID)); + } else { emit gdbInputAvailable(QString(), QString()); sendCommand("-file-exec-and-symbols " + fileName, GdbFileExecAndSymbols); //sendCommand("file " + fileName, GdbFileExecAndSymbols); @@ -1602,20 +1604,6 @@ bool GdbEngine::startDebugger() sendCommand("x/2i " + startSymbolName(), GdbStart); } - if (q->startMode() == q->attachExternal) { - sendCommand("attach " + QString::number(q->m_attachedPID)); - } - - if (q->startMode() == q->startExternal) { - //sendCommand("-file-exec-and-symbols " + fileName, GdbFileExecAndSymbols); - sendCommand("file " + fileName, GdbFileExecAndSymbols); - #ifdef Q_OS_MAC - sendCommand("sharedlibrary apply-load-rules all"); - #endif - //sendCommand("-file-list-exec-source-files", GdbQuerySources); - //sendCommand("-gdb-set stop-on-solib-events 1"); - } - sendCommand("-data-list-register-names", RegisterListNames); // set all to "pending" From aef3fa67039739f4a223a446b0138009dcffa957 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 16 Feb 2009 13:58:43 +0100 Subject: [PATCH 25/37] Fixes: debugger: enum naming cosmetics --- src/plugins/debugger/debuggermanager.cpp | 12 ++++++------ src/plugins/debugger/debuggermanager.h | 2 +- src/plugins/debugger/debuggerrunner.cpp | 2 +- src/plugins/debugger/gdbengine.cpp | 5 +++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index 93597c51768..660448a6bcc 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -152,7 +152,7 @@ void DebuggerManager::init() m_busy = false; m_attachedPID = 0; - m_startMode = startInternal; + m_startMode = StartInternal; m_disassemblerHandler = 0; m_modulesHandler = 0; @@ -737,13 +737,13 @@ void DebuggerManager::setConfigValue(const QString &name, const QVariant &value) void DebuggerManager::startExternalApplication() { - if (!startNewDebugger(startExternal)) + if (!startNewDebugger(StartExternal)) emit debuggingFinished(); } void DebuggerManager::attachExternalApplication() { - if (!startNewDebugger(attachExternal)) + if (!startNewDebugger(AttachExternal)) emit debuggingFinished(); } @@ -752,7 +752,7 @@ bool DebuggerManager::startNewDebugger(StartMode mode) m_startMode = mode; // FIXME: Clean up - if (startMode() == startExternal) { + if (startMode() == StartExternal) { StartExternalDialog dlg(mainWindow()); dlg.setExecutableFile( configValue(QLatin1String("LastExternalExecutableFile")).toString()); @@ -768,7 +768,7 @@ bool DebuggerManager::startNewDebugger(StartMode mode) m_processArgs = dlg.executableArguments().split(' '); m_workingDir = QString(); m_attachedPID = -1; - } else if (startMode() == attachExternal) { + } else if (startMode() == AttachExternal) { AttachExternalDialog dlg(mainWindow()); if (dlg.exec() != QDialog::Accepted) return false; @@ -781,7 +781,7 @@ bool DebuggerManager::startNewDebugger(StartMode mode) tr("Cannot attach to PID 0")); return false; } - } else if (startMode() == startInternal) { + } else if (startMode() == StartInternal) { if (m_executable.isEmpty()) { QString startDirectory = m_executable; if (m_executable.isEmpty()) { diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index a3407a0aa59..8af4a683378 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -229,7 +229,7 @@ public: QLabel *statusLabel() const { return m_statusLabel; } DebuggerSettings *settings() { return &m_settings; } - enum StartMode { startInternal, startExternal, attachExternal }; + enum StartMode { StartInternal, StartExternal, AttachExternal }; enum DebuggerType { GdbDebugger, ScriptDebugger, WinDebugger }; public slots: diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index 5034a0d9a4a..149b137727e 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -137,7 +137,7 @@ void DebuggerRunControl::start() // andre: + "\qtc-gdbmacros\" //emit addToOutputWindow(this, tr("Debugging %1").arg(m_executable)); - if (m_manager->startNewDebugger(DebuggerManager::startInternal)) + if (m_manager->startNewDebugger(DebuggerManager::StartInternal)) emit started(); else debuggingFinished(); diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 6e68184913d..4e5c8bf82b2 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -1588,9 +1588,10 @@ bool GdbEngine::startDebugger() } } - if (q->startMode() == q->attachExternal) { + if (q->startMode() == DebuggerManager::AttachExternal) { sendCommand("attach " + QString::number(q->m_attachedPID)); } else { + // StartInternal or StartExternal emit gdbInputAvailable(QString(), QString()); sendCommand("-file-exec-and-symbols " + fileName, GdbFileExecAndSymbols); //sendCommand("file " + fileName, GdbFileExecAndSymbols); @@ -1607,7 +1608,7 @@ bool GdbEngine::startDebugger() sendCommand("-data-list-register-names", RegisterListNames); // set all to "pending" - if (q->startMode() == q->attachExternal) + if (q->startMode() == DebuggerManager::AttachExternal) qq->breakHandler()->removeAllBreakpoints(); else qq->breakHandler()->setAllPending(); From 1dd1752c4e7f961c4f1bc27b971f7445eb7144da Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 16 Feb 2009 16:00:46 +0100 Subject: [PATCH 26/37] move -data-list-register-names up to the other initializers. --- src/plugins/debugger/gdbengine.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 4e5c8bf82b2..58cba9c426a 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -1534,6 +1534,7 @@ bool GdbEngine::startDebugger() //sendCommand("set pagination off"); sendCommand("set breakpoint pending on", BreakEnablePending); sendCommand("set print elements 10000"); + sendCommand("-data-list-register-names", RegisterListNames); // one of the following is needed to prevent crashes in gdb on code like: // template T foo() { return T(0); } @@ -1605,8 +1606,6 @@ bool GdbEngine::startDebugger() sendCommand("x/2i " + startSymbolName(), GdbStart); } - sendCommand("-data-list-register-names", RegisterListNames); - // set all to "pending" if (q->startMode() == DebuggerManager::AttachExternal) qq->breakHandler()->removeAllBreakpoints(); From 25c7eb3dff87d1a47378e9980f39a779e7623a6f Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 16 Feb 2009 16:50:20 +0100 Subject: [PATCH 27/37] Fixes: windows build --- src/plugins/debugger/gdbengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 58cba9c426a..ae80da5b716 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -663,7 +663,7 @@ void GdbEngine::interruptInferior() sendCommand("-exec-interrupt", GdbExecInterrupt); qq->notifyInferiorStopped(); #else - debugMessage(QString("CANNOT STOP INFERIOR %1").arg(m_gdbProc.pid())); + debugMessage(QString("CANNOT STOP INFERIOR")); if (interruptChildProcess(m_gdbProc.pid())) qq->notifyInferiorStopped(); #endif From b4a79218326b622a0c2dd8918fb6e2824583070c Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 17 Feb 2009 17:42:08 +0100 Subject: [PATCH 28/37] Fixes: debugger: work on process logic Conflicts: src/plugins/debugger/gdbengine.cpp --- src/plugins/debugger/debuggermanager.cpp | 12 +++ src/plugins/debugger/debuggermanager.h | 2 + src/plugins/debugger/gdbengine.cpp | 105 +++++++++++++++-------- src/plugins/debugger/gdbengine.h | 11 ++- 4 files changed, 89 insertions(+), 41 deletions(-) diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index 660448a6bcc..9130d57c54b 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -543,6 +543,12 @@ void DebuggerManager::notifyStartupFinished() showStatusMessage(tr("Startup finished. Debugger ready."), -1); } +void DebuggerManager::notifyInferiorStopRequested() +{ + setStatus(DebuggerInferiorStopRequested); + showStatusMessage(tr("Stop requested..."), 5000); +} + void DebuggerManager::notifyInferiorStopped() { resetLocation(); @@ -657,6 +663,12 @@ void DebuggerManager::toggleBreakpoint(const QString &fileName, int lineNumber) { QTC_ASSERT(m_engine, return); QTC_ASSERT(m_breakHandler, return); + if (status() != DebuggerInferiorRunning && status() != DebuggerInferiorStopped) { + showStatusMessage(tr("Changing breakpoint state requires either a " + "fully running or fully stopped application.")); + return; + } + int index = m_breakHandler->indexOf(fileName, lineNumber); if (index == -1) m_breakHandler->setBreakpoint(fileName, lineNumber); diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index 8af4a683378..636187d68cd 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -151,6 +151,7 @@ private: // called from the engines after successful startup virtual void notifyStartupFinished() = 0; + virtual void notifyInferiorStopRequested() = 0; virtual void notifyInferiorStopped() = 0; virtual void notifyInferiorUpdateFinished() = 0; virtual void notifyInferiorRunningRequested() = 0; @@ -339,6 +340,7 @@ private: void notifyInferiorStopped(); void notifyInferiorUpdateFinished(); void notifyInferiorRunningRequested(); + void notifyInferiorStopRequested(); void notifyInferiorRunning(); void notifyInferiorExited(); void notifyInferiorPidChanged(int); diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index ae80da5b716..6f41c83379d 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -115,6 +115,7 @@ enum GdbCommandType GdbInfoThreads, GdbQueryDataDumper1, GdbQueryDataDumper2, + GdbTemporaryContinue, BreakCondition = 200, BreakEnablePending, @@ -305,6 +306,7 @@ void GdbEngine::initializeVariables() m_pendingRequests = 0; m_waitingForBreakpointSynchronizationToContinue = false; m_waitingForFirstBreakpointToBeHit = false; + m_commandsToRunOnTemporaryBreak.clear(); } void GdbEngine::gdbProcError(QProcess::ProcessError error) @@ -650,22 +652,29 @@ void GdbEngine::readGdbStandardOutput() void GdbEngine::interruptInferior() { - if (m_gdbProc.state() == QProcess::NotRunning) + qq->notifyInferiorStopRequested(); + if (m_gdbProc.state() == QProcess::NotRunning) { + debugMessage("TRYING TO INTERRUPT INFERIOR WITHOUT RUNNING GDB"); + qq->notifyInferiorExited(); return; + } if (q->m_attachedPID > 0) { - if (interruptProcess(q->m_attachedPID)) - qq->notifyInferiorStopped(); + if (!interruptProcess(q->m_attachedPID)) + // qq->notifyInferiorStopped(); + //else + debugMessage(QString("CANNOT INTERRUPT %1").arg(q->m_attachedPID)); return; } #ifdef Q_OS_MAC sendCommand("-exec-interrupt", GdbExecInterrupt); - qq->notifyInferiorStopped(); + //qq->notifyInferiorStopped(); #else - debugMessage(QString("CANNOT STOP INFERIOR")); - if (interruptChildProcess(m_gdbProc.pid())) - qq->notifyInferiorStopped(); + if (!interruptChildProcess(m_gdbProc.pid())) + // qq->notifyInferiorStopped(); + //else + debugMessage(QString("CANNOT STOP INFERIOR")); #endif } @@ -684,27 +693,19 @@ void GdbEngine::maybeHandleInferiorPidChanged(const QString &pid0) } void GdbEngine::sendSynchronizedCommand(const QString & command, - int type, const QVariant &cookie, bool needStop) + int type, const QVariant &cookie, StopNeeded needStop) { - sendCommand(command, type, cookie, needStop, true); + sendCommand(command, type, cookie, needStop, Synchronized); } void GdbEngine::sendCommand(const QString &command, int type, - const QVariant &cookie, bool needStop, bool synchronized) + const QVariant &cookie, StopNeeded needStop, Synchronization synchronized) { if (m_gdbProc.state() == QProcess::NotRunning) { debugMessage("NO GDB PROCESS RUNNING, CMD IGNORED: " + command); return; } - bool temporarilyStopped = false; - if (needStop && q->status() == DebuggerInferiorRunning) { - q->showStatusMessage(tr("Temporarily stopped")); - interruptInferior(); - temporarilyStopped = true; - } - - ++currentToken(); if (synchronized) { ++m_pendingRequests; PENDING_DEBUG(" TYPE " << type << " INCREMENTS PENDING TO: " @@ -717,26 +718,30 @@ void GdbEngine::sendCommand(const QString &command, int type, GdbCookie cmd; cmd.synchronized = synchronized; cmd.command = command; - cmd.command = QString::number(currentToken()) + cmd.command; - if (cmd.command.contains("%1")) - cmd.command = cmd.command.arg(currentToken()); cmd.type = type; cmd.cookie = cookie; - m_cookieForToken[currentToken()] = cmd; + if (needStop && q->status() != DebuggerInferiorStopped + && q->status() != DebuggerProcessStartingUp) { + // queue the commands that we cannot send at once + QTC_ASSERT(q->status() == DebuggerInferiorRunning, + qDebug() << "STATUS: " << q->status()); + q->showStatusMessage(tr("Stopping temporarily.")); + debugMessage("QUEUING COMMAND " + cmd.command); + m_commandsToRunOnTemporaryBreak.append(cmd); + interruptInferior(); + } else if (!command.isEmpty()) { + ++currentToken(); + m_cookieForToken[currentToken()] = cmd; + cmd.command = QString::number(currentToken()) + cmd.command; + if (cmd.command.contains("%1")) + cmd.command = cmd.command.arg(currentToken()); - if (!command.isEmpty()) { m_gdbProc.write(cmd.command.toLatin1() + "\r\n"); //emit gdbInputAvailable(QString(), " " + currentTime()); //emit gdbInputAvailable(QString(), "[" + currentTime() + "] " + cmd.command); emit gdbInputAvailable(QString(), cmd.command); } - - if (temporarilyStopped) - sendCommand("-exec-continue"); - - // slows down - //qApp->processEvents(); } void GdbEngine::handleResultRecord(const GdbResultRecord &record) @@ -822,6 +827,7 @@ void GdbEngine::handleResult(const GdbResultRecord & record, int type, //handleExecRunToFunction(record); break; case GdbExecInterrupt: + qq->notifyInferiorStopped(); break; case GdbExecJumpToLine: handleExecJumpToLine(record); @@ -844,6 +850,10 @@ void GdbEngine::handleResult(const GdbResultRecord & record, int type, case GdbQueryDataDumper2: handleQueryDataDumper2(record); break; + case GdbTemporaryContinue: + continueInferior(); + q->showStatusMessage(tr("Continuing after temporary stop.")); + break; case BreakList: handleBreakList(record); @@ -1104,6 +1114,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) //MAC: bool isFirstStop = data.findChild("bkptno").data() == "1"; //!MAC: startSymbolName == data.findChild("frame").findChild("func") if (m_waitingForFirstBreakpointToBeHit) { + qq->notifyInferiorStopped(); m_waitingForFirstBreakpointToBeHit = false; // // that's the "early stop" @@ -1143,6 +1154,23 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) return; } + if (!m_commandsToRunOnTemporaryBreak.isEmpty()) { + QTC_ASSERT(q->status() == DebuggerInferiorStopRequested, + qDebug() << "STATUS: " << q->status()) + qq->notifyInferiorStopped(); + q->showStatusMessage(tr("Temporarily stopped.")); + // FIXME: racy + foreach (const GdbCookie &cmd, m_commandsToRunOnTemporaryBreak) { + debugMessage(QString("RUNNING QUEUED COMMAND %1 %2") + .arg(cmd.command).arg(cmd.type)); + sendCommand(cmd.command, cmd.type, cmd.cookie); + } + sendCommand("p temporaryStop", GdbTemporaryContinue); + m_commandsToRunOnTemporaryBreak.clear(); + q->showStatusMessage(tr("Handling queued commands.")); + return; + } + QString msg = data.findChild("consolestreamoutput").data(); if (msg.contains("Stopped due to shared library event") || reason.isEmpty()) { if (qq->wantsSelectedPluginBreakpoints()) { @@ -1619,8 +1647,8 @@ void GdbEngine::continueInferior() { q->resetLocation(); setTokenBarrier(); - qq->notifyInferiorRunningRequested(); emit gdbInputAvailable(QString(), QString()); + qq->notifyInferiorRunningRequested(); sendCommand("-exec-continue", GdbExecContinue); } @@ -1636,8 +1664,8 @@ void GdbEngine::handleStart(const GdbResultRecord &response) //debugMessage("STREAM: " + msg + " " + needle.cap(1)); sendCommand("tbreak *0x" + needle.cap(1)); m_waitingForFirstBreakpointToBeHit = true; - sendCommand("-exec-run"); qq->notifyInferiorRunningRequested(); + sendCommand("-exec-run"); } else { debugMessage("PARSING START ADDRESS FAILED: " + msg); } @@ -1649,8 +1677,8 @@ void GdbEngine::handleStart(const GdbResultRecord &response) void GdbEngine::stepExec() { setTokenBarrier(); - qq->notifyInferiorRunningRequested(); emit gdbInputAvailable(QString(), QString()); + qq->notifyInferiorRunningRequested(); sendCommand("-exec-step", GdbExecStep); } @@ -1671,8 +1699,8 @@ void GdbEngine::stepOutExec() void GdbEngine::nextExec() { setTokenBarrier(); - qq->notifyInferiorRunningRequested(); emit gdbInputAvailable(QString(), QString()); + qq->notifyInferiorRunningRequested(); sendCommand("-exec-next", GdbExecNext); } @@ -1865,8 +1893,8 @@ void GdbEngine::sendInsertBreakpoint(int index) // cmd += "-c " + data->condition + " "; cmd += where; #endif - sendCommand(cmd, BreakInsert, index, true); - //processQueueAndContinue(); + debugMessage(QString("Current state: %1").arg(q->status())); + sendCommand(cmd, BreakInsert, index, NeedsStop); } void GdbEngine::handleBreakList(const GdbResultRecord &record) @@ -2103,10 +2131,11 @@ void GdbEngine::attemptBreakpointSynchronization() foreach (BreakpointData *data, handler->takeRemovedBreakpoints()) { QString bpNumber = data->bpNumber; + debugMessage(QString("DELETING BP %1 IN %2").arg(bpNumber) + .arg(data->markerFileName)); if (!bpNumber.trimmed().isEmpty()) - sendCommand("-break-delete " + bpNumber, BreakDelete, 0, true); - //else - // qDebug() << "BP HAS NO NUMBER: " << data->markerFileName; + sendCommand("-break-delete " + bpNumber, BreakDelete, QVariant(), + NeedsStop); delete data; } diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h index ee5de645c3d..0b59af8b1c7 100644 --- a/src/plugins/debugger/gdbengine.h +++ b/src/plugins/debugger/gdbengine.h @@ -158,12 +158,15 @@ private: // queue". resultNeeded == true increments m_pendingResults on // send and decrements on receipt, effectively preventing // watch model updates before everything is finished. - void sendCommand(const QString & command, + enum StopNeeded { DoesNotNeedStop, NeedsStop }; + enum Synchronization { NotSynchronized, Synchronized }; + void sendCommand(const QString &command, int type = 0, const QVariant &cookie = QVariant(), - bool needStop = false, bool synchronized = false); + StopNeeded needStop = DoesNotNeedStop, + Synchronization synchronized = NotSynchronized); void sendSynchronizedCommand(const QString & command, int type = 0, const QVariant &cookie = QVariant(), - bool needStop = false); + StopNeeded needStop = DoesNotNeedStop); void setTokenBarrier(); @@ -335,6 +338,8 @@ private: bool m_waitingForFirstBreakpointToBeHit; bool m_modulesListOutdated; + QList m_commandsToRunOnTemporaryBreak; + DebuggerManager *q; IDebuggerManagerAccessForEngines *qq; }; From 7020acb36715a69f790c9ca4efc064a32f0feee1 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 16 Feb 2009 18:38:10 +0100 Subject: [PATCH 29/37] Fixes: debugger: set width and height of "terminal" to 0 to avoid extra prompting --- src/plugins/debugger/gdbengine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 6f41c83379d..6b472e25577 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -1588,6 +1588,8 @@ bool GdbEngine::startDebugger() sendCommand("set unwindonsignal on"); sendCommand("pwd", GdbQueryPwd); + sendCommand("set width 0"); + sendCommand("set height 0"); #ifdef Q_OS_MAC sendCommand("-gdb-set inferior-auto-start-cfm off"); From 97d77408a05d9394bb43245bdd7c9f0b89e1afa7 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 17 Feb 2009 17:43:49 +0100 Subject: [PATCH 30/37] Fixes: debugger: fix assert includes Conflicts: src/plugins/debugger/cdbdebugengine.cpp --- src/plugins/debugger/disassemblerhandler.cpp | 2 +- src/plugins/debugger/moduleshandler.cpp | 2 +- src/plugins/debugger/registerhandler.cpp | 3 ++- src/plugins/debugger/stackwindow.cpp | 3 ++- src/plugins/debugger/threadswindow.cpp | 3 ++- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/plugins/debugger/disassemblerhandler.cpp b/src/plugins/debugger/disassemblerhandler.cpp index ff935dabfdf..59ca259e80e 100644 --- a/src/plugins/debugger/disassemblerhandler.cpp +++ b/src/plugins/debugger/disassemblerhandler.cpp @@ -33,7 +33,7 @@ #include "disassemblerhandler.h" -#include "assert.h" +#include #include #include diff --git a/src/plugins/debugger/moduleshandler.cpp b/src/plugins/debugger/moduleshandler.cpp index e87c92a73d2..a49e87495ec 100644 --- a/src/plugins/debugger/moduleshandler.cpp +++ b/src/plugins/debugger/moduleshandler.cpp @@ -33,7 +33,7 @@ #include "moduleshandler.h" -#include "assert.h" +#include #include #include diff --git a/src/plugins/debugger/registerhandler.cpp b/src/plugins/debugger/registerhandler.cpp index e594326009a..9300e5a4df7 100644 --- a/src/plugins/debugger/registerhandler.cpp +++ b/src/plugins/debugger/registerhandler.cpp @@ -33,9 +33,10 @@ #include "registerhandler.h" -#include "assert.h" #include "debuggerconstants.h" +#include + #include #include diff --git a/src/plugins/debugger/stackwindow.cpp b/src/plugins/debugger/stackwindow.cpp index d40f8a3c5ff..8b33b08ae7c 100644 --- a/src/plugins/debugger/stackwindow.cpp +++ b/src/plugins/debugger/stackwindow.cpp @@ -33,9 +33,10 @@ #include "stackwindow.h" -#include "assert.h" #include "stackhandler.h" +#include + #include #include #include diff --git a/src/plugins/debugger/threadswindow.cpp b/src/plugins/debugger/threadswindow.cpp index bf418cd0fc5..5d49e5dc798 100644 --- a/src/plugins/debugger/threadswindow.cpp +++ b/src/plugins/debugger/threadswindow.cpp @@ -33,9 +33,10 @@ #include "threadswindow.h" -#include "assert.h" #include "stackhandler.h" +#include + #include #include #include From 84e5a57bab506511753db63152c9b220364562fd Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 17 Feb 2009 14:08:49 +0100 Subject: [PATCH 31/37] Fixes: add a view to see current source file mapping --- src/plugins/debugger/debugger.pro | 2 + src/plugins/debugger/debuggermanager.cpp | 33 ++++ src/plugins/debugger/debuggermanager.h | 9 + src/plugins/debugger/gdbengine.cpp | 24 ++- src/plugins/debugger/gdbengine.h | 8 +- src/plugins/debugger/idebuggerengine.h | 2 + src/plugins/debugger/scriptengine.h | 1 + src/plugins/debugger/sourcefileswindow.cpp | 213 +++++++++++++++++++++ src/plugins/debugger/sourcefileswindow.h | 76 ++++++++ src/plugins/debugger/statuswindow.cpp | 213 +++++++++++++++++++++ 10 files changed, 575 insertions(+), 6 deletions(-) create mode 100644 src/plugins/debugger/sourcefileswindow.cpp create mode 100644 src/plugins/debugger/sourcefileswindow.h create mode 100644 src/plugins/debugger/statuswindow.cpp diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro index 469ea346011..0578a52720b 100644 --- a/src/plugins/debugger/debugger.pro +++ b/src/plugins/debugger/debugger.pro @@ -37,6 +37,7 @@ HEADERS += attachexternaldialog.h \ scriptengine.h \ stackhandler.h \ stackwindow.h \ + sourcefileswindow.h \ startexternaldialog.h \ threadswindow.h \ watchhandler.h \ @@ -64,6 +65,7 @@ SOURCES += attachexternaldialog.cpp \ scriptengine.cpp \ stackhandler.cpp \ stackwindow.cpp \ + sourcefileswindow.cpp \ startexternaldialog.cpp \ threadswindow.cpp \ watchhandler.cpp \ diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index 9130d57c54b..769d63c7228 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -42,6 +42,7 @@ #include "moduleswindow.h" #include "registerwindow.h" #include "stackwindow.h" +#include "sourcefileswindow.h" #include "threadswindow.h" #include "watchwindow.h" @@ -165,6 +166,7 @@ void DebuggerManager::init() m_outputWindow = new DebuggerOutputWindow; m_registerWindow = new RegisterWindow; m_stackWindow = new StackWindow; + m_sourceFilesWindow = new SourceFilesWindow; m_threadsWindow = new ThreadsWindow; m_localsWindow = new WatchWindow(WatchWindow::LocalsType); m_watchersWindow = new WatchWindow(WatchWindow::WatchersType); @@ -227,6 +229,13 @@ void DebuggerManager::init() connect(modulesView, SIGNAL(loadAllSymbolsRequested()), this, SLOT(loadAllSymbols())); + // Source Files + //m_sourceFilesHandler = new SourceFilesHandler; + QAbstractItemView *sourceFilesView = + qobject_cast(m_sourceFilesWindow); + //sourceFileView->setModel(m_stackHandler->stackModel()); + connect(sourceFilesView, SIGNAL(reloadSourceFilesRequested()), + this, SLOT(reloadSourceFiles())); // Registers QAbstractItemView *registerView = @@ -403,6 +412,10 @@ void DebuggerManager::init() m_stackDock = createDockForWidget(m_stackWindow); + m_sourceFilesDock = createDockForWidget(m_sourceFilesWindow); + connect(m_sourceFilesDock->toggleViewAction(), SIGNAL(toggled(bool)), + this, SLOT(reloadSourceFiles()), Qt::QueuedConnection); + m_threadsDock = createDockForWidget(m_threadsWindow); setStatus(DebuggerProcessNotReady); @@ -1240,6 +1253,26 @@ void DebuggerManager::disassemblerDockToggled(bool on) } +////////////////////////////////////////////////////////////////////// +// +// Sourec files specific stuff +// +////////////////////////////////////////////////////////////////////// + +void DebuggerManager::reloadSourceFiles() +{ + if (!m_sourceFilesDock || !m_sourceFilesDock->isVisible()) + return; + m_engine->reloadSourceFiles(); +} + +void DebuggerManager::sourceFilesDockToggled(bool on) +{ + if (on) + reloadSourceFiles(); +} + + ////////////////////////////////////////////////////////////////////// // // Modules specific stuff diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index 636187d68cd..fd5c06e4c6e 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -66,6 +66,7 @@ class RegisterHandler; class StackHandler; class ThreadsHandler; class WatchHandler; +class SourceFilesWindow; class WatchData; class BreakpointData; @@ -166,6 +167,7 @@ private: virtual StackHandler *stackHandler() = 0; virtual ThreadsHandler *threadsHandler() = 0; virtual WatchHandler *watchHandler() = 0; + virtual SourceFilesWindow *sourceFileWindow() = 0; virtual void showApplicationOutput(const QString &data) = 0; virtual bool skipKnownFrames() const = 0; @@ -179,6 +181,7 @@ private: virtual void reloadDisassembler() = 0; virtual void reloadModules() = 0; + virtual void reloadSourceFiles() = 0; virtual void reloadRegisters() = 0; }; @@ -302,6 +305,9 @@ private slots: void reloadDisassembler(); void disassemblerDockToggled(bool on); + void reloadSourceFiles(); + void sourceFilesDockToggled(bool on); + void reloadModules(); void modulesDockToggled(bool on); void loadSymbols(const QString &moduleName); @@ -323,6 +329,7 @@ private: StackHandler *stackHandler() { return m_stackHandler; } ThreadsHandler *threadsHandler() { return m_threadsHandler; } WatchHandler *watchHandler() { return m_watchHandler; } + SourceFilesWindow *sourceFileWindow() { return m_sourceFilesWindow; } bool skipKnownFrames() const; bool debugDumpers() const; @@ -416,6 +423,7 @@ private: QDockWidget *m_outputDock; QDockWidget *m_registerDock; QDockWidget *m_stackDock; + QDockWidget *m_sourceFilesDock; QDockWidget *m_threadsDock; QDockWidget *m_watchDock; QList m_dockWidgets; @@ -427,6 +435,7 @@ private: StackHandler *m_stackHandler; ThreadsHandler *m_threadsHandler; WatchHandler *m_watchHandler; + SourceFilesWindow *m_sourceFilesWindow; /// Actions friend class DebuggerPlugin; diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 6b472e25577..33c930fbe30 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -44,6 +44,7 @@ #include "registerhandler.h" #include "stackhandler.h" #include "watchhandler.h" +#include "sourcefileswindow.h" #include "startexternaldialog.h" #include "attachexternaldialog.h" @@ -986,6 +987,7 @@ void GdbEngine::handleQueryPwd(const GdbResultRecord &record) void GdbEngine::handleQuerySources(const GdbResultRecord &record) { if (record.resultClass == GdbResultDone) { + QMap oldShortToFull = m_shortToFullName; m_shortToFullName.clear(); m_fullToShortName.clear(); // "^done,files=[{file="../../../../bin/gdbmacros/gdbmacros.cpp", @@ -1004,6 +1006,8 @@ void GdbEngine::handleQuerySources(const GdbResultRecord &record) m_fullToShortName[full] = fileName; } } + if (m_shortToFullName != oldShortToFull) + qq->sourceFileWindow()->setSourceFiles(m_shortToFullName); } } @@ -1128,7 +1132,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) #if defined(Q_OS_MAC) sendCommand("info pid", GdbInfoProc, QVariant(), true); #endif - sendCommand("-file-list-exec-source-files", GdbQuerySources); + reloadSourceFiles(); tryLoadCustomDumpers(); // intentionally after tryLoadCustomDumpers(), @@ -1262,7 +1266,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) frame.findChild("func").data() + '%'; QApplication::alert(q->mainWindow(), 3000); - sendCommand("-file-list-exec-source-files", GdbQuerySources); + reloadSourceFiles(); sendCommand("-break-list", BreakList); QVariant var = QVariant::fromValue(data); sendCommand("p 0", GdbAsyncOutput2, var); // dummy @@ -2317,6 +2321,18 @@ void GdbEngine::handleModulesList(const GdbResultRecord &record) } +////////////////////////////////////////////////////////////////////// +// +// Source files specific stuff +// +////////////////////////////////////////////////////////////////////// + +void GdbEngine::reloadSourceFiles() +{ + sendCommand("-file-list-exec-source-files", GdbQuerySources); +} + + ////////////////////////////////////////////////////////////////////// // // Stack specific stuff @@ -2546,7 +2562,7 @@ bool GdbEngine::supportsThreads() const static WatchData m_toolTip; static QString m_toolTipExpression; static QPoint m_toolTipPos; -static QHash m_toolTipCache; +static QMap m_toolTipCache; static bool hasLetterOrNumber(const QString &exp) { @@ -3672,7 +3688,7 @@ void GdbEngine::handleStackListLocals(const GdbResultRecord &record) void GdbEngine::setLocals(const QList &locals) { //qDebug() << m_varToType; - QHash seen; + QMap seen; foreach (const GdbMi &item, locals) { // Local variables of inlined code are reported as diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h index 0b59af8b1c7..43b87b873c8 100644 --- a/src/plugins/debugger/gdbengine.h +++ b/src/plugins/debugger/gdbengine.h @@ -222,8 +222,8 @@ private: int m_gdbVersion; // 6.8.0 is 680 // awful hack to keep track of used files - QHash m_shortToFullName; - QHash m_fullToShortName; + QMap m_shortToFullName; + QMap m_fullToShortName; // // Breakpoint specific stuff @@ -263,6 +263,10 @@ private: void handleRegisterListNames(const GdbResultRecord &record); void handleRegisterListValues(const GdbResultRecord &record); + // + // Source file specific stuff + // + void reloadSourceFiles(); // // Stack specific stuff diff --git a/src/plugins/debugger/idebuggerengine.h b/src/plugins/debugger/idebuggerengine.h index ee1e15793f3..6da7ecb15ed 100644 --- a/src/plugins/debugger/idebuggerengine.h +++ b/src/plugins/debugger/idebuggerengine.h @@ -87,6 +87,8 @@ public: virtual void reloadRegisters() = 0; virtual void setDebugDumpers(bool on) = 0; virtual void setUseCustomDumpers(bool on) = 0; + + virtual void reloadSourceFiles() = 0; }; } // namespace Internal diff --git a/src/plugins/debugger/scriptengine.h b/src/plugins/debugger/scriptengine.h index b7f37f2cc67..8368d367e82 100644 --- a/src/plugins/debugger/scriptengine.h +++ b/src/plugins/debugger/scriptengine.h @@ -112,6 +112,7 @@ private: void reloadDisassembler(); void reloadModules(); void reloadRegisters() {} + void reloadSourceFiles() {} bool supportsThreads() const { return true; } void maybeBreakNow(bool byFunction); diff --git a/src/plugins/debugger/sourcefileswindow.cpp b/src/plugins/debugger/sourcefileswindow.cpp new file mode 100644 index 00000000000..17b68a1c775 --- /dev/null +++ b/src/plugins/debugger/sourcefileswindow.cpp @@ -0,0 +1,213 @@ +/*************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** +** Non-Open Source Usage +** +** Licensees may use this file in accordance with the Qt Beta Version +** License Agreement, Agreement version 2.2 provided with the Software or, +** alternatively, in accordance with the terms contained in a written +** agreement between you and Nokia. +** +** GNU General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the packaging +** of this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt GPL Exception +** version 1.3, included in the file GPL_EXCEPTION.txt in this package. +** +***************************************************************************/ + +#include "sourcefileswindow.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using Debugger::Internal::SourceFilesWindow; +using Debugger::Internal::SourceFilesModel; + +////////////////////////////////////////////////////////////////// +// +// SourceFilesModel +// +////////////////////////////////////////////////////////////////// + +class Debugger::Internal::SourceFilesModel : public QAbstractItemModel +{ +public: + SourceFilesModel(QObject *parent = 0) : QAbstractItemModel(parent) {} + + // QAbstractItemModel + int columnCount(const QModelIndex &parent) const + { return parent.isValid() ? 0 : 2; } + int rowCount(const QModelIndex &parent) const + { return parent.isValid() ? 0 : m_shortNames.size(); } + QModelIndex parent(const QModelIndex &) const { return QModelIndex(); } + QModelIndex index(int row, int column, const QModelIndex &) const + { return createIndex(row, column); } + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QVariant data(const QModelIndex &index, int role) const; + bool setData(const QModelIndex &index, const QVariant &value, int role); + Qt::ItemFlags flags(const QModelIndex &index) const; + + void clearModel(); + void update() { reset(); } + void setSourceFiles(const QMap &sourceFiles); + +public: + QStringList m_shortNames; + QStringList m_fullNames; +}; + +void SourceFilesModel::clearModel() +{ + if (m_shortNames.isEmpty()) + return; + m_shortNames.clear(); + m_fullNames.clear(); + reset(); +} + +QVariant SourceFilesModel::headerData(int section, + Qt::Orientation orientation, int role) const +{ + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { + static QString headers[] = { + tr("Internal name") + " ", + tr("Full name") + " ", + }; + return headers[section]; + } + return QVariant(); +} + +Qt::ItemFlags SourceFilesModel::flags(const QModelIndex &index) const +{ + if (index.row() >= m_fullNames.size()) + return 0; + QFileInfo fi(m_fullNames.at(index.row())); + return fi.isReadable() ? QAbstractItemModel::flags(index) : Qt::ItemFlags(0); +} + +QVariant SourceFilesModel::data(const QModelIndex &index, int role) const +{ + //static const QIcon icon(":/gdbdebugger/images/breakpoint.svg"); + //static const QIcon icon2(":/gdbdebugger/images/breakpoint_pending.svg"); + + int row = index.row(); + if (row < 0 || row >= m_shortNames.size()) + return QVariant(); + + switch (index.column()) { + case 0: + if (role == Qt::DisplayRole) + return m_shortNames.at(row); + // FIXME: add icons + //if (role == Qt::DecorationRole) + // return module.symbolsRead ? icon2 : icon; + break; + case 1: + if (role == Qt::DisplayRole) + return m_fullNames.at(row); + //if (role == Qt::DecorationRole) + // return module.symbolsRead ? icon2 : icon; + break; + } + return QVariant(); +} + +bool SourceFilesModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + return QAbstractItemModel::setData(index, value, role); +} + +void SourceFilesModel::setSourceFiles(const QMap &sourceFiles) +{ + m_shortNames.clear(); + m_fullNames.clear(); + QMap::ConstIterator it = sourceFiles.begin(); + QMap::ConstIterator et = sourceFiles.end(); + for (; it != et; ++it) { + m_shortNames.append(it.key()); + m_fullNames.append(it.value()); + } + reset(); +} + +////////////////////////////////////////////////////////////////// +// +// SourceFilesWindow +// +////////////////////////////////////////////////////////////////// + +SourceFilesWindow::SourceFilesWindow(QWidget *parent) + : QTreeView(parent) +{ + m_model = new SourceFilesModel(this); + + QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); + proxyModel->setSourceModel(m_model); + setModel(proxyModel); + + setWindowTitle(tr("Source Files")); + setSortingEnabled(true); + setAlternatingRowColors(true); + setRootIsDecorated(false); + setIconSize(QSize(10, 10)); + //header()->setDefaultAlignment(Qt::AlignLeft); + + connect(this, SIGNAL(activated(QModelIndex)), + this, SLOT(sourceFileActivated(QModelIndex))); +} + +SourceFilesWindow::~SourceFilesWindow() +{ +} + +void SourceFilesWindow::sourceFileActivated(const QModelIndex &index) +{ + qDebug() << "ACTIVATED: " << index.row() << index.column(); +} + +void SourceFilesWindow::contextMenuEvent(QContextMenuEvent *ev) +{ + QMenu menu; + QAction *act1 = new QAction(tr("Reload data"), &menu); + //act1->setCheckable(true); + + menu.addAction(act1); + + QAction *act = menu.exec(ev->globalPos()); + + if (act == act1) { + emit reloadSourceFilesRequested(); + } +} + +void SourceFilesWindow::setSourceFiles(const QMap &sourceFiles) +{ + m_model->setSourceFiles(sourceFiles); + header()->setResizeMode(0, QHeaderView::ResizeToContents); +} diff --git a/src/plugins/debugger/sourcefileswindow.h b/src/plugins/debugger/sourcefileswindow.h new file mode 100644 index 00000000000..4d17d0cb1e9 --- /dev/null +++ b/src/plugins/debugger/sourcefileswindow.h @@ -0,0 +1,76 @@ +/*************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** +** Non-Open Source Usage +** +** Licensees may use this file in accordance with the Qt Beta Version +** License Agreement, Agreement version 2.2 provided with the Software or, +** alternatively, in accordance with the terms contained in a written +** agreement between you and Nokia. +** +** GNU General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the packaging +** of this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt GPL Exception +** version 1.3, included in the file GPL_EXCEPTION.txt in this package. +** +***************************************************************************/ + +#ifndef DEBUGGER_SOURCEFILEWINDOW_H +#define DEBUGGER_SOURCEFILEWINDOW_H + +#include +#include + +QT_BEGIN_NAMESPACE +class QComboBox; +class QModelIndex; +class QStandardItemModel; +QT_END_NAMESPACE + +namespace Debugger { +namespace Internal { + +class SourceFilesModel; + +class SourceFilesWindow : public QTreeView +{ + Q_OBJECT + +public: + SourceFilesWindow(QWidget *parent = 0); + ~SourceFilesWindow(); + + void setSourceFiles(const QMap &sourceFiles); + +signals: + void reloadSourceFilesRequested(); + +private slots: + void sourceFileActivated(const QModelIndex &index); + +private: + void contextMenuEvent(QContextMenuEvent *ev); + SourceFilesModel *m_model; +}; + +} // namespace Internal +} // namespace Debugger + +#endif // DEBUGGER_SOURCEFILEWINDOW_H + diff --git a/src/plugins/debugger/statuswindow.cpp b/src/plugins/debugger/statuswindow.cpp new file mode 100644 index 00000000000..17b68a1c775 --- /dev/null +++ b/src/plugins/debugger/statuswindow.cpp @@ -0,0 +1,213 @@ +/*************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** +** Non-Open Source Usage +** +** Licensees may use this file in accordance with the Qt Beta Version +** License Agreement, Agreement version 2.2 provided with the Software or, +** alternatively, in accordance with the terms contained in a written +** agreement between you and Nokia. +** +** GNU General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the packaging +** of this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt GPL Exception +** version 1.3, included in the file GPL_EXCEPTION.txt in this package. +** +***************************************************************************/ + +#include "sourcefileswindow.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using Debugger::Internal::SourceFilesWindow; +using Debugger::Internal::SourceFilesModel; + +////////////////////////////////////////////////////////////////// +// +// SourceFilesModel +// +////////////////////////////////////////////////////////////////// + +class Debugger::Internal::SourceFilesModel : public QAbstractItemModel +{ +public: + SourceFilesModel(QObject *parent = 0) : QAbstractItemModel(parent) {} + + // QAbstractItemModel + int columnCount(const QModelIndex &parent) const + { return parent.isValid() ? 0 : 2; } + int rowCount(const QModelIndex &parent) const + { return parent.isValid() ? 0 : m_shortNames.size(); } + QModelIndex parent(const QModelIndex &) const { return QModelIndex(); } + QModelIndex index(int row, int column, const QModelIndex &) const + { return createIndex(row, column); } + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QVariant data(const QModelIndex &index, int role) const; + bool setData(const QModelIndex &index, const QVariant &value, int role); + Qt::ItemFlags flags(const QModelIndex &index) const; + + void clearModel(); + void update() { reset(); } + void setSourceFiles(const QMap &sourceFiles); + +public: + QStringList m_shortNames; + QStringList m_fullNames; +}; + +void SourceFilesModel::clearModel() +{ + if (m_shortNames.isEmpty()) + return; + m_shortNames.clear(); + m_fullNames.clear(); + reset(); +} + +QVariant SourceFilesModel::headerData(int section, + Qt::Orientation orientation, int role) const +{ + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { + static QString headers[] = { + tr("Internal name") + " ", + tr("Full name") + " ", + }; + return headers[section]; + } + return QVariant(); +} + +Qt::ItemFlags SourceFilesModel::flags(const QModelIndex &index) const +{ + if (index.row() >= m_fullNames.size()) + return 0; + QFileInfo fi(m_fullNames.at(index.row())); + return fi.isReadable() ? QAbstractItemModel::flags(index) : Qt::ItemFlags(0); +} + +QVariant SourceFilesModel::data(const QModelIndex &index, int role) const +{ + //static const QIcon icon(":/gdbdebugger/images/breakpoint.svg"); + //static const QIcon icon2(":/gdbdebugger/images/breakpoint_pending.svg"); + + int row = index.row(); + if (row < 0 || row >= m_shortNames.size()) + return QVariant(); + + switch (index.column()) { + case 0: + if (role == Qt::DisplayRole) + return m_shortNames.at(row); + // FIXME: add icons + //if (role == Qt::DecorationRole) + // return module.symbolsRead ? icon2 : icon; + break; + case 1: + if (role == Qt::DisplayRole) + return m_fullNames.at(row); + //if (role == Qt::DecorationRole) + // return module.symbolsRead ? icon2 : icon; + break; + } + return QVariant(); +} + +bool SourceFilesModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + return QAbstractItemModel::setData(index, value, role); +} + +void SourceFilesModel::setSourceFiles(const QMap &sourceFiles) +{ + m_shortNames.clear(); + m_fullNames.clear(); + QMap::ConstIterator it = sourceFiles.begin(); + QMap::ConstIterator et = sourceFiles.end(); + for (; it != et; ++it) { + m_shortNames.append(it.key()); + m_fullNames.append(it.value()); + } + reset(); +} + +////////////////////////////////////////////////////////////////// +// +// SourceFilesWindow +// +////////////////////////////////////////////////////////////////// + +SourceFilesWindow::SourceFilesWindow(QWidget *parent) + : QTreeView(parent) +{ + m_model = new SourceFilesModel(this); + + QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); + proxyModel->setSourceModel(m_model); + setModel(proxyModel); + + setWindowTitle(tr("Source Files")); + setSortingEnabled(true); + setAlternatingRowColors(true); + setRootIsDecorated(false); + setIconSize(QSize(10, 10)); + //header()->setDefaultAlignment(Qt::AlignLeft); + + connect(this, SIGNAL(activated(QModelIndex)), + this, SLOT(sourceFileActivated(QModelIndex))); +} + +SourceFilesWindow::~SourceFilesWindow() +{ +} + +void SourceFilesWindow::sourceFileActivated(const QModelIndex &index) +{ + qDebug() << "ACTIVATED: " << index.row() << index.column(); +} + +void SourceFilesWindow::contextMenuEvent(QContextMenuEvent *ev) +{ + QMenu menu; + QAction *act1 = new QAction(tr("Reload data"), &menu); + //act1->setCheckable(true); + + menu.addAction(act1); + + QAction *act = menu.exec(ev->globalPos()); + + if (act == act1) { + emit reloadSourceFilesRequested(); + } +} + +void SourceFilesWindow::setSourceFiles(const QMap &sourceFiles) +{ + m_model->setSourceFiles(sourceFiles); + header()->setResizeMode(0, QHeaderView::ResizeToContents); +} From 72f72d5119d018be3c6b8a60a07c6fce73fd6e4c Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Tue, 17 Feb 2009 11:25:44 +0100 Subject: [PATCH 32/37] Compile. --- src/plugins/debugger/gdbengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 33c930fbe30..01db793c359 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -1130,7 +1130,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) sendCommand("info proc", GdbInfoProc); #endif #if defined(Q_OS_MAC) - sendCommand("info pid", GdbInfoProc, QVariant(), true); + sendCommand("info pid", GdbInfoProc); #endif reloadSourceFiles(); tryLoadCustomDumpers(); From 5ba9809489054eca52f657459ddf9ac4340fc58a Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 17 Feb 2009 14:09:52 +0100 Subject: [PATCH 33/37] Fixes: debugger: remove accidentally commited file --- src/plugins/debugger/statuswindow.cpp | 213 -------------------------- 1 file changed, 213 deletions(-) delete mode 100644 src/plugins/debugger/statuswindow.cpp diff --git a/src/plugins/debugger/statuswindow.cpp b/src/plugins/debugger/statuswindow.cpp deleted file mode 100644 index 17b68a1c775..00000000000 --- a/src/plugins/debugger/statuswindow.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/*************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Qt Software Information (qt-info@nokia.com) -** -** -** Non-Open Source Usage -** -** Licensees may use this file in accordance with the Qt Beta Version -** License Agreement, Agreement version 2.2 provided with the Software or, -** alternatively, in accordance with the terms contained in a written -** agreement between you and Nokia. -** -** GNU General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the packaging -** of this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt GPL Exception -** version 1.3, included in the file GPL_EXCEPTION.txt in this package. -** -***************************************************************************/ - -#include "sourcefileswindow.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using Debugger::Internal::SourceFilesWindow; -using Debugger::Internal::SourceFilesModel; - -////////////////////////////////////////////////////////////////// -// -// SourceFilesModel -// -////////////////////////////////////////////////////////////////// - -class Debugger::Internal::SourceFilesModel : public QAbstractItemModel -{ -public: - SourceFilesModel(QObject *parent = 0) : QAbstractItemModel(parent) {} - - // QAbstractItemModel - int columnCount(const QModelIndex &parent) const - { return parent.isValid() ? 0 : 2; } - int rowCount(const QModelIndex &parent) const - { return parent.isValid() ? 0 : m_shortNames.size(); } - QModelIndex parent(const QModelIndex &) const { return QModelIndex(); } - QModelIndex index(int row, int column, const QModelIndex &) const - { return createIndex(row, column); } - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - QVariant data(const QModelIndex &index, int role) const; - bool setData(const QModelIndex &index, const QVariant &value, int role); - Qt::ItemFlags flags(const QModelIndex &index) const; - - void clearModel(); - void update() { reset(); } - void setSourceFiles(const QMap &sourceFiles); - -public: - QStringList m_shortNames; - QStringList m_fullNames; -}; - -void SourceFilesModel::clearModel() -{ - if (m_shortNames.isEmpty()) - return; - m_shortNames.clear(); - m_fullNames.clear(); - reset(); -} - -QVariant SourceFilesModel::headerData(int section, - Qt::Orientation orientation, int role) const -{ - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { - static QString headers[] = { - tr("Internal name") + " ", - tr("Full name") + " ", - }; - return headers[section]; - } - return QVariant(); -} - -Qt::ItemFlags SourceFilesModel::flags(const QModelIndex &index) const -{ - if (index.row() >= m_fullNames.size()) - return 0; - QFileInfo fi(m_fullNames.at(index.row())); - return fi.isReadable() ? QAbstractItemModel::flags(index) : Qt::ItemFlags(0); -} - -QVariant SourceFilesModel::data(const QModelIndex &index, int role) const -{ - //static const QIcon icon(":/gdbdebugger/images/breakpoint.svg"); - //static const QIcon icon2(":/gdbdebugger/images/breakpoint_pending.svg"); - - int row = index.row(); - if (row < 0 || row >= m_shortNames.size()) - return QVariant(); - - switch (index.column()) { - case 0: - if (role == Qt::DisplayRole) - return m_shortNames.at(row); - // FIXME: add icons - //if (role == Qt::DecorationRole) - // return module.symbolsRead ? icon2 : icon; - break; - case 1: - if (role == Qt::DisplayRole) - return m_fullNames.at(row); - //if (role == Qt::DecorationRole) - // return module.symbolsRead ? icon2 : icon; - break; - } - return QVariant(); -} - -bool SourceFilesModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - return QAbstractItemModel::setData(index, value, role); -} - -void SourceFilesModel::setSourceFiles(const QMap &sourceFiles) -{ - m_shortNames.clear(); - m_fullNames.clear(); - QMap::ConstIterator it = sourceFiles.begin(); - QMap::ConstIterator et = sourceFiles.end(); - for (; it != et; ++it) { - m_shortNames.append(it.key()); - m_fullNames.append(it.value()); - } - reset(); -} - -////////////////////////////////////////////////////////////////// -// -// SourceFilesWindow -// -////////////////////////////////////////////////////////////////// - -SourceFilesWindow::SourceFilesWindow(QWidget *parent) - : QTreeView(parent) -{ - m_model = new SourceFilesModel(this); - - QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); - proxyModel->setSourceModel(m_model); - setModel(proxyModel); - - setWindowTitle(tr("Source Files")); - setSortingEnabled(true); - setAlternatingRowColors(true); - setRootIsDecorated(false); - setIconSize(QSize(10, 10)); - //header()->setDefaultAlignment(Qt::AlignLeft); - - connect(this, SIGNAL(activated(QModelIndex)), - this, SLOT(sourceFileActivated(QModelIndex))); -} - -SourceFilesWindow::~SourceFilesWindow() -{ -} - -void SourceFilesWindow::sourceFileActivated(const QModelIndex &index) -{ - qDebug() << "ACTIVATED: " << index.row() << index.column(); -} - -void SourceFilesWindow::contextMenuEvent(QContextMenuEvent *ev) -{ - QMenu menu; - QAction *act1 = new QAction(tr("Reload data"), &menu); - //act1->setCheckable(true); - - menu.addAction(act1); - - QAction *act = menu.exec(ev->globalPos()); - - if (act == act1) { - emit reloadSourceFilesRequested(); - } -} - -void SourceFilesWindow::setSourceFiles(const QMap &sourceFiles) -{ - m_model->setSourceFiles(sourceFiles); - header()->setResizeMode(0, QHeaderView::ResizeToContents); -} From f47ef22fabe44f2d950425925f1b41f3360a571d Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 17 Feb 2009 14:35:32 +0100 Subject: [PATCH 34/37] Fixes: debugger: enable debugger view actions even if "locked" --- src/plugins/debugger/debuggermanager.cpp | 3 +++ src/plugins/debugger/debuggerplugin.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index 769d63c7228..711a3ae2bc7 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -490,9 +490,11 @@ void DebuggerManager::setSimpleDockWidgetArrangement() m_mainWindow->tabifyDockWidget(m_watchDock, m_outputDock); m_mainWindow->tabifyDockWidget(m_watchDock, m_registerDock); m_mainWindow->tabifyDockWidget(m_watchDock, m_threadsDock); + m_mainWindow->tabifyDockWidget(m_watchDock, m_sourceFilesDock); // They are rarely used even in ordinary debugging. Hiding them also saves // cycles since the corresponding information won't be retrieved. + m_sourceFilesDock->hide(); m_registerDock->hide(); m_disassemblerDock->hide(); m_modulesDock->hide(); @@ -515,6 +517,7 @@ void DebuggerManager::setLocked(bool locked) } dockWidget->setTitleBarWidget(titleBarWidget); dockWidget->setFeatures(features); + dockWidget->toggleViewAction()->setEnabled(true); } } diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index d3e61c79c29..c313b0592e7 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -453,7 +453,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *error_mes #endif cmd = am->registerAction(m_manager->m_continueAction, - ProjectExplorer::Constants::DEBUG, QList()<< m_gdbRunningContext); + ProjectExplorer::Constants::DEBUG, QList() << m_gdbRunningContext); cmd = am->registerAction(m_manager->m_stopAction, Constants::INTERRUPT, globalcontext); From fff32b5fd266d9fde7ca762d65019ea897833064 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 17 Feb 2009 17:44:46 +0100 Subject: [PATCH 35/37] Fixes: debugger: simplify state logic Conflicts: src/plugins/debugger/cdbdebugeventcallback.cpp --- src/plugins/debugger/debuggermanager.cpp | 33 +++++++----------------- src/plugins/debugger/debuggermanager.h | 24 +++-------------- src/plugins/debugger/scriptengine.cpp | 1 - 3 files changed, 13 insertions(+), 45 deletions(-) diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index 711a3ae2bc7..e92bdfcdec1 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -553,12 +553,6 @@ void DebuggerManager::showStatusMessage(const QString &msg, int timeout) } } -void DebuggerManager::notifyStartupFinished() -{ - setStatus(DebuggerProcessReady); - showStatusMessage(tr("Startup finished. Debugger ready."), -1); -} - void DebuggerManager::notifyInferiorStopRequested() { setStatus(DebuggerInferiorStopRequested); @@ -572,12 +566,6 @@ void DebuggerManager::notifyInferiorStopped() showStatusMessage(tr("Stopped."), 5000); } -void DebuggerManager::notifyInferiorUpdateFinished() -{ - setStatus(DebuggerInferiorReady); - showStatusMessage(tr("Stopped."), 5000); -} - void DebuggerManager::notifyInferiorRunningRequested() { setStatus(DebuggerInferiorRunningRequested); @@ -592,7 +580,7 @@ void DebuggerManager::notifyInferiorRunning() void DebuggerManager::notifyInferiorExited() { - setStatus(DebuggerProcessReady); + setStatus(DebuggerProcessNotReady); showStatusMessage(tr("Stopped."), 5000); } @@ -679,7 +667,9 @@ void DebuggerManager::toggleBreakpoint(const QString &fileName, int lineNumber) { QTC_ASSERT(m_engine, return); QTC_ASSERT(m_breakHandler, return); - if (status() != DebuggerInferiorRunning && status() != DebuggerInferiorStopped) { + if (status() != DebuggerInferiorRunning + && status() != DebuggerInferiorStopped + && status() != DebuggerProcessNotReady) { showStatusMessage(tr("Changing breakpoint state requires either a " "fully running or fully stopped application.")); return; @@ -842,11 +832,13 @@ bool DebuggerManager::startNewDebugger(StartMode mode) else setDebuggerType(GdbDebugger); - if (!m_engine->startDebugger()) + setStatus(DebuggerProcessStartingUp); + if (!m_engine->startDebugger()) { + setStatus(DebuggerProcessNotReady); return false; + } m_busy = false; - setStatus(DebuggerProcessStartingUp); return true; } @@ -1049,16 +1041,11 @@ void DebuggerManager::setStatus(int status) const bool started = status == DebuggerInferiorRunning || status == DebuggerInferiorRunningRequested || status == DebuggerInferiorStopRequested - || status == DebuggerInferiorStopped - || status == DebuggerInferiorUpdating - || status == DebuggerInferiorUpdateFinishing - || status == DebuggerInferiorReady; + || status == DebuggerInferiorStopped; const bool starting = status == DebuggerProcessStartingUp; const bool running = status == DebuggerInferiorRunning; - const bool ready = status == DebuggerInferiorStopped - || status == DebuggerInferiorReady - || status == DebuggerProcessReady; + const bool ready = status == DebuggerInferiorStopped; m_startExternalAction->setEnabled(!started && !starting); m_attachExternalAction->setEnabled(!started && !starting); diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index fd5c06e4c6e..18d5475e728 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -77,23 +77,15 @@ class BreakpointData; // DebuggerProcessNotReady // | // DebuggerProcessStartingUp -// | -// DebuggerReady [R] [N] // | <-------------------------------------. // DebuggerInferiorRunningRequested | -// | | -// DebuggerInferiorRunning | -// | | +// | | +// DebuggerInferiorRunning | +// | | // DebuggerInferiorStopRequested | // | | // DebuggerInferiorStopped | // | | -// DebuggerInferiorUpdating | -// | | -// DebuggerInferiorUpdateFinishing | -// | | -// DebuggerInferiorReady [C] [N] | -// | | // `---------------------------------------' // // Allowed actions: @@ -107,17 +99,11 @@ enum DebuggerStatus { DebuggerProcessNotReady, // Debugger not started DebuggerProcessStartingUp, // Debugger starting up - DebuggerProcessReady, // Debugger started, Inferior not yet - // running or already finished DebuggerInferiorRunningRequested, // Debuggee requested to run DebuggerInferiorRunning, // Debuggee running DebuggerInferiorStopRequested, // Debuggee running, stop requested DebuggerInferiorStopped, // Debuggee stopped - - DebuggerInferiorUpdating, // Debuggee updating data views - DebuggerInferiorUpdateFinishing, // Debuggee updating data views aborting - DebuggerInferiorReady, }; @@ -151,10 +137,8 @@ private: friend class WinEngine; // called from the engines after successful startup - virtual void notifyStartupFinished() = 0; virtual void notifyInferiorStopRequested() = 0; virtual void notifyInferiorStopped() = 0; - virtual void notifyInferiorUpdateFinished() = 0; virtual void notifyInferiorRunningRequested() = 0; virtual void notifyInferiorRunning() = 0; virtual void notifyInferiorExited() = 0; @@ -343,9 +327,7 @@ private: QString selectedPluginBreakpointsPattern() const { return m_settings.m_pluginSelectedBreakpointsPattern; } - void notifyStartupFinished(); void notifyInferiorStopped(); - void notifyInferiorUpdateFinished(); void notifyInferiorRunningRequested(); void notifyInferiorStopRequested(); void notifyInferiorRunning(); diff --git a/src/plugins/debugger/scriptengine.cpp b/src/plugins/debugger/scriptengine.cpp index b868dcd99ad..0af40332273 100644 --- a/src/plugins/debugger/scriptengine.cpp +++ b/src/plugins/debugger/scriptengine.cpp @@ -216,7 +216,6 @@ bool ScriptEngine::startDebugger() m_scriptContents = stream.readAll(); scriptFile.close(); attemptBreakpointSynchronization(); - QTimer::singleShot(0, q, SLOT(notifyStartupFinished())); return true; } From 5a07f48691068aa2aaecce78ab042b8af586c642 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 17 Feb 2009 16:25:48 +0100 Subject: [PATCH 36/37] Fixes: debugger: on async output, first handle all cases where the inferior exited. Details: that catches early exits due to startup problems as well --- src/plugins/debugger/gdbengine.cpp | 45 +++++++++++++++++------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 01db793c359..37f35929edc 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -1115,9 +1115,34 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) { const QString reason = data.findChild("reason").data(); + if (isExitedReason(reason)) { + qq->notifyInferiorExited(); + QString msg = "Program exited normally"; + if (reason == "exited") { + msg = "Program exited with exit code " + + data.findChild("exit-code").toString(); + } else if (reason == "exited-signalled") { + msg = "Program exited after receiving signal " + + data.findChild("signal-name").toString(); + } else if (reason == "signal-received") { + msg = "Program exited after receiving signal " + + data.findChild("signal-name").toString(); + } + q->showStatusMessage(msg); + // FIXME: shouldn't this use a statis change? + debugMessage("CALLING PARENT EXITDEBUGGER"); + q->exitDebugger(); + return; + } + + //MAC: bool isFirstStop = data.findChild("bkptno").data() == "1"; //!MAC: startSymbolName == data.findChild("frame").findChild("func") if (m_waitingForFirstBreakpointToBeHit) { + // If the executable dies already that early we might get something + // like stdout:49*stopped,reason="exited",exit-code="0177" + // This is handled now above. + qq->notifyInferiorStopped(); m_waitingForFirstBreakpointToBeHit = false; // @@ -1200,26 +1225,6 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) return; } - if (isExitedReason(reason)) { - qq->notifyInferiorExited(); - QString msg = "Program exited normally"; - if (reason == "exited") { - msg = "Program exited with exit code " - + data.findChild("exit-code").toString(); - } else if (reason == "exited-signalled") { - msg = "Program exited after receiving signal " - + data.findChild("signal-name").toString(); - } else if (reason == "signal-received") { - msg = "Program exited after receiving signal " - + data.findChild("signal-name").toString(); - } - q->showStatusMessage(msg); - // FIXME: shouldn't this use a statis change? - debugMessage("CALLING PARENT EXITDEBUGGER"); - q->exitDebugger(); - return; - } - //tryLoadCustomDumpers(); // jump over well-known frames From 7587f6e39f084c4fa88d4348d54486ae20a1b793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 17 Feb 2009 15:27:44 +0100 Subject: [PATCH 37/37] This line shouldn't be necessary Enabled state of the action is managed by QDockWidget. --- src/plugins/debugger/debuggermanager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index e92bdfcdec1..0bc4b47c5c3 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -517,7 +517,6 @@ void DebuggerManager::setLocked(bool locked) } dockWidget->setTitleBarWidget(titleBarWidget); dockWidget->setFeatures(features); - dockWidget->toggleViewAction()->setEnabled(true); } }