diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index af0af2911739972bb8641224e70773aa148aa4ff..a24f53f8e7daa948ed54334d8e4e3a8c292aa786 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -29,6 +29,7 @@ #include "breakhandler.h" +#include "debuggeractions.h" #include "debuggermanager.h" #include "stackframe.h" @@ -507,7 +508,8 @@ QVariant BreakHandler::data(const QModelIndex &mi, int role) const break; } if (role == Qt::ToolTipRole) - return data->toToolTip(); + return theDebuggerBoolSetting(UseToolTipsInLocalsView) + ? data->toToolTip() : QVariant(); return QVariant(); } diff --git a/src/plugins/debugger/cdb/cdbdebugengine.h b/src/plugins/debugger/cdb/cdbdebugengine.h index 6b57235fa34ea36b140090207539f5bd5b913fec..18b660416520f01f54ffbf6d9cecba4aa65a4733 100644 --- a/src/plugins/debugger/cdb/cdbdebugengine.h +++ b/src/plugins/debugger/cdb/cdbdebugengine.h @@ -99,7 +99,6 @@ public: virtual void reloadRegisters(); virtual void reloadSourceFiles(); virtual void reloadFullStack() {} - virtual void addOptionPages(QList<Core::IOptionsPage*> *) const; public slots: void syncDebuggerPaths(); diff --git a/src/plugins/debugger/commonoptionspage.ui b/src/plugins/debugger/commonoptionspage.ui index 249ccaca91796341f56fb1df4784116aeca92e54..245515805971b54763a611bb9c919fce3fab3d82 100644 --- a/src/plugins/debugger/commonoptionspage.ui +++ b/src/plugins/debugger/commonoptionspage.ui @@ -53,12 +53,22 @@ </widget> </item> <item> - <widget class="QCheckBox" name="checkBoxUseToolTips"> + <widget class="QCheckBox" name="checkBoxUseToolTipsInMainEditor"> <property name="toolTip"> <string>Checking this will 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.</string> </property> <property name="text"> - <string>Use tooltips while debugging</string> + <string>Use tooltips in locals view while debugging</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBoxUseToolTipsInLocalsView"> + <property name="toolTip"> + <string>Checking this will enable tooltips for in the locals view during debugging.</string> + </property> + <property name="text"> + <string>Use tooltips in main editor while debugging</string> </property> </widget> </item> diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index d13e3559af87d9c286993e8e415737b16681e754..2c98c9f7c9ebb915ec3ca78b8f942d4fb265185e 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -254,10 +254,17 @@ DebuggerSettings *DebuggerSettings::instance() item = new SavedAction(instance); item->setSettingsKey(debugModeGroup, QLatin1String("UseToolTips")); - item->setText(tr("Use tooltips when debugging")); + item->setText(tr("Use tooltips in main editor when debugging")); item->setCheckable(true); item->setDefaultValue(false); - instance->insertItem(UseToolTips, item); + instance->insertItem(UseToolTipsInMainEditor, item); + + item = new SavedAction(instance); + item->setSettingsKey(debugModeGroup, QLatin1String("UseToolTipsInLocalsView")); + item->setText(tr("Use tooltips in locals view when debugging")); + item->setCheckable(true); + item->setDefaultValue(false); + instance->insertItem(UseToolTipsInLocalsView, item); item = new SavedAction(instance); item->setSettingsKey(debugModeGroup, QLatin1String("ListSourceFiles")); diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h index 6d9656ffce07227754f4747a95ed2c0c8f9eb86b..07cac69e80bc32423f72ce0935b10444f35a500c 100644 --- a/src/plugins/debugger/debuggeractions.h +++ b/src/plugins/debugger/debuggeractions.h @@ -100,7 +100,8 @@ enum DebuggerActionCode WatchExpressionInWindow, RemoveWatchExpression, WatchPoint, - UseToolTips, + UseToolTipsInMainEditor, + UseToolTipsInLocalsView, AssignValue, AssignType, diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp index 3612802085077e495940b9f27873ce2cd84345ac..4796a9b0f19b77b42d2cbbd856472e6861205c38 100644 --- a/src/plugins/debugger/debuggerdialogs.cpp +++ b/src/plugins/debugger/debuggerdialogs.cpp @@ -248,6 +248,7 @@ AttachExternalDialog::AttachExternalDialog(QWidget *parent) QPushButton *refreshButton = new QPushButton(tr("Refresh")); connect(refreshButton, SIGNAL(clicked()), this, SLOT(rebuildProcessList())); m_ui->buttonBox->addButton(refreshButton, QDialogButtonBox::ActionRole); + m_ui->filterLineEdit->setFocus(Qt::TabFocusReason); // Do not use activated, will be single click in Oxygen connect(m_ui->procView, SIGNAL(doubleClicked(QModelIndex)), diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index bc97bcdd84abc84992574277b6b92990a66ef938..903407750c0d3d1e315c2289d43165ff0442b704 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -769,6 +769,9 @@ static IDebuggerEngine *determineDebuggerEngine(const QString &executable, return gdbEngine; #else + // A remote executable? + if (!executable.endsWith(_(".exe"))) + return gdbEngine; // If a file has PDB files, it has been compiled by VS. QStringList pdbFiles; if (!getPDBFiles(executable, &pdbFiles, errorMessage)) diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index 29052449c9e8ba05aa55fc732c65c7393275399c..bf51de7822d0a2940b47904ca7095221630be0d6 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -366,6 +366,7 @@ private: ThreadsHandler *threadsHandler() { return m_threadsHandler; } WatchHandler *watchHandler() { return m_watchHandler; } SourceFilesWindow *sourceFileWindow() { return m_sourceFilesWindow; } + QWidget *threadsWindow() const { return m_threadsWindow; } void notifyInferiorStopped(); void notifyInferiorRunningRequested(); @@ -376,20 +377,16 @@ private: void cleanupViews(); - // - // Implementation of IDebuggerManagerAccessForDebugMode - // - QWidget *threadsWindow() const { return m_threadsWindow; } - - virtual bool qtDumperLibraryEnabled() const; - virtual QString qtDumperLibraryName() const; - virtual QStringList qtDumperLibraryLocations() const; - virtual void showQtDumperLibraryWarning(const QString &details = QString()); - virtual bool isReverseDebugging() const; - // // internal implementation // + bool qtDumperLibraryEnabled() const; + QString qtDumperLibraryName() const; + QStringList qtDumperLibraryLocations() const; + void showQtDumperLibraryWarning(const QString &details = QString()); + bool isReverseDebugging() const; + QAbstractItemModel *threadsModel(); + Q_SLOT void loadSessionData(); Q_SLOT void saveSessionData(); Q_SLOT void dumpLog(); @@ -397,7 +394,6 @@ private: public: // stuff in this block should be made private by moving it to // one of the interfaces - QAbstractItemModel *threadsModel(); int status() const { return m_status; } // FIXME: hide this in the engines? //DebuggerStartMode startMode() const; @@ -471,14 +467,12 @@ private: QAction *m_watchAction; QAction *m_breakAction; QAction *m_sepAction; - //QActio *m_stepByInstructionAction; QAction *m_reverseDirectionAction; QWidget *m_breakWindow; QWidget *m_localsWindow; QWidget *m_registerWindow; QWidget *m_modulesWindow; - //QWidget *m_tooltipWindow; QWidget *m_stackWindow; QWidget *m_threadsWindow; QWidget *m_watchersWindow; diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 24e06712b96255419e695cdfad2cf1de85cde87c..f01d9b569d04c1ff0561f8453525396bc9f42ec1 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -292,8 +292,10 @@ QWidget *CommonOptionsPage::createPage(QWidget *parent) m_ui.checkBoxUseMessageBoxForSignals); m_group.insert(theDebuggerAction(SkipKnownFrames), m_ui.checkBoxSkipKnownFrames); - m_group.insert(theDebuggerAction(UseToolTips), - m_ui.checkBoxUseToolTips); + m_group.insert(theDebuggerAction(UseToolTipsInMainEditor), + m_ui.checkBoxUseToolTipsInMainEditor); + m_group.insert(theDebuggerAction(UseToolTipsInLocalsView), + m_ui.checkBoxUseToolTipsInLocalsView); m_group.insert(theDebuggerAction(EnableReverseDebugging), m_ui.checkBoxEnableReverseDebugging); m_group.insert(theDebuggerAction(MaximalStackDepth), @@ -1036,7 +1038,8 @@ void DebuggerPlugin::requestMark(TextEditor::ITextEditor *editor, int lineNumber void DebuggerPlugin::showToolTip(TextEditor::ITextEditor *editor, const QPoint &point, int pos) { - if (!theDebuggerBoolSetting(UseToolTips) || m_manager->status() == DebuggerProcessNotReady) + if (!theDebuggerBoolSetting(UseToolTipsInMainEditor) + || m_manager->status() == DebuggerProcessNotReady) return; m_manager->setToolTipExpression(point, editor, pos); @@ -1229,7 +1232,7 @@ void DebuggerPlugin::attachExternalApplication(qint64 pid, const QString &crashP const DebuggerStartParametersPtr sp(new DebuggerStartParameters); sp->attachPID = pid; sp->crashParameter = crashParameter; - sp->startMode = crashParameter.isEmpty() ? AttachExternal : AttachCrashedExternal; + sp->startMode = crashParameter.isEmpty() ? AttachExternal : AttachCrashedExternal; RunConfigurationPtr rc = activeRunConfiguration(); if (rc.isNull()) rc = DebuggerRunner::createDefaultRunConfiguration(); diff --git a/src/plugins/debugger/gdb/attachgdbadapter.cpp b/src/plugins/debugger/gdb/attachgdbadapter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6b0e702e14b5711f3067e3b5204bacc32ffa2a55 --- /dev/null +++ b/src/plugins/debugger/gdb/attachgdbadapter.cpp @@ -0,0 +1,205 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "attachgdbadapter.h" + +#include "debuggeractions.h" +#include "gdbengine.h" +#include "procinterrupt.h" + +#include <utils/qtcassert.h> + + +namespace Debugger { +namespace Internal { + +#define STRINGIFY_INTERNAL(x) #x +#define STRINGIFY(x) STRINGIFY_INTERNAL(x) +#define CB(callback) \ + static_cast<GdbEngine::AdapterCallback>(&AttachGdbAdapter::callback), \ + STRINGIFY(callback) + +/////////////////////////////////////////////////////////////////////// +// +// AttachGdbAdapter +// +/////////////////////////////////////////////////////////////////////// + +AttachGdbAdapter::AttachGdbAdapter(GdbEngine *engine, QObject *parent) + : AbstractGdbAdapter(engine, parent) +{ + QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state()); + connect(&m_gdbProc, SIGNAL(error(QProcess::ProcessError)), + this, SIGNAL(error(QProcess::ProcessError))); + connect(&m_gdbProc, SIGNAL(readyReadStandardOutput()), + this, SIGNAL(readyReadStandardOutput())); + connect(&m_gdbProc, SIGNAL(readyReadStandardError()), + this, SIGNAL(readyReadStandardError())); + connect(&m_gdbProc, SIGNAL(started()), + this, SLOT(handleGdbStarted())); + connect(&m_gdbProc, SIGNAL(finished(int, QProcess::ExitStatus)), + this, SLOT(handleGdbFinished(int, QProcess::ExitStatus))); +} + +void AttachGdbAdapter::startAdapter() +{ + QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state()); + setState(AdapterStarting); + debugMessage(_("TRYING TO START ADAPTER")); + + QStringList gdbArgs; + gdbArgs.prepend(_("mi")); + gdbArgs.prepend(_("-i")); + + if (!m_engine->m_outputCollector.listen()) { + emit adapterStartFailed(tr("Cannot set up communication with child process: %1") + .arg(m_engine->m_outputCollector.errorString())); + return; + } + gdbArgs.prepend(_("--tty=") + m_engine->m_outputCollector.serverName()); + + if (!startParameters().workingDir.isEmpty()) + setWorkingDirectory(startParameters().workingDir); + if (!startParameters().environment.isEmpty()) + setEnvironment(startParameters().environment); + + QString location = theDebuggerStringSetting(GdbLocation); + m_gdbProc.start(location, gdbArgs); +} + +void AttachGdbAdapter::handleGdbStarted() +{ + QTC_ASSERT(state() == AdapterStarting, qDebug() << state()); + setState(AdapterStarted); + emit adapterStarted(); +} + +void AttachGdbAdapter::prepareInferior() +{ + const qint64 pid = startParameters().attachPID; + QTC_ASSERT(state() == AdapterStarted, qDebug() << state()); + setState(InferiorPreparing); + qDebug() << "USING " << pid; + m_engine->postCommand(_("attach %1").arg(pid), CB(handleAttach)); + // Task 254674 does not want to remove them + //qq->breakHandler()->removeAllBreakpoints(); +} + +void AttachGdbAdapter::handleAttach(const GdbResultRecord &response, const QVariant &) +{ + QTC_ASSERT(state() == InferiorPreparing, qDebug() << state()); + if (response.resultClass == GdbResultDone) { + setState(InferiorPrepared); + emit inferiorPrepared(); + } else if (response.resultClass == GdbResultError) { + QString msg = __(response.data.findChild("msg").data()); + setState(InferiorPreparationFailed); + emit inferiorPreparationFailed(msg); + } +} + +void AttachGdbAdapter::startInferior() +{ + QTC_ASSERT(state() == InferiorPrepared, qDebug() << state()); + setState(InferiorStarting); + m_engine->postCommand(_("-exec-continue"), CB(handleContinue)); +} + +void AttachGdbAdapter::handleContinue(const GdbResultRecord &response, const QVariant &) +{ + QTC_ASSERT(state() == InferiorStarting, qDebug() << state()); + if (response.resultClass == GdbResultRunning) { + setState(InferiorStarted); + emit inferiorStarted(); + } else { + QTC_ASSERT(response.resultClass == GdbResultError, /**/); + const QByteArray &msg = response.data.findChild("msg").data(); + setState(InferiorStartFailed); + emit inferiorStartFailed(msg); + } +} + +void AttachGdbAdapter::interruptInferior() +{ + debugMessage(_("TRYING TO INTERUPT INFERIOR")); + const qint64 pid = startParameters().attachPID; + if (!interruptProcess(pid)) + debugMessage(_("CANNOT INTERRUPT %1").arg(pid)); +} + +void AttachGdbAdapter::shutdown() +{ + if (state() == InferiorStarted) { + setState(InferiorShuttingDown); + m_engine->postCommand(_("detach"), CB(handleDetach)); + return; + } + + if (state() == InferiorShutDown) { + setState(AdapterShuttingDown); + m_engine->postCommand(_("-gdb-exit"), CB(handleExit)); + return; + } + QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state()); +} + +void AttachGdbAdapter::handleDetach(const GdbResultRecord &response, const QVariant &) +{ + if (response.resultClass == GdbResultDone) { + setState(InferiorShutDown); + emit inferiorShutDown(); + shutdown(); // re-iterate... + } else if (response.resultClass == GdbResultError) { + QString msg = tr("Inferior process could not be stopped:\n") + + __(response.data.findChild("msg").data()); + setState(InferiorShutdownFailed); + emit inferiorShutdownFailed(msg); + } +} + +void AttachGdbAdapter::handleExit(const GdbResultRecord &response, const QVariant &) +{ + if (response.resultClass == GdbResultDone) { + // don't set state here, this will be handled in handleGdbFinished() + } else if (response.resultClass == GdbResultError) { + QString msg = tr("Gdb process could not be stopped:\n") + + __(response.data.findChild("msg").data()); + emit adapterShutdownFailed(msg); + } +} + +void AttachGdbAdapter::handleGdbFinished(int, QProcess::ExitStatus) +{ + debugMessage(_("GDB PROESS FINISHED")); + setState(AdapterNotRunning); + emit adapterShutDown(); +} + +} // namespace Internal +} // namespace Debugger diff --git a/src/plugins/debugger/gdb/attachgdbadapter.h b/src/plugins/debugger/gdb/attachgdbadapter.h new file mode 100644 index 0000000000000000000000000000000000000000..6bedcbfc0029d3568ff180c6afea4f7acf116a37 --- /dev/null +++ b/src/plugins/debugger/gdb/attachgdbadapter.h @@ -0,0 +1,84 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef DEBUGGER_ATTACHGDBADAPTER_H +#define DEBUGGER_ATTACHGDBADAPTER_H + +#include "abstractgdbadapter.h" +#include "gdbengine.h" + +#include <QtCore/QDebug> +#include <QtCore/QProcess> + +namespace Debugger { +namespace Internal { + +/////////////////////////////////////////////////////////////////////// +// +// AttachGdbAdapter +// +/////////////////////////////////////////////////////////////////////// + +class AttachGdbAdapter : public AbstractGdbAdapter +{ + Q_OBJECT + +public: + AttachGdbAdapter(GdbEngine *engine, QObject *parent = 0); + +private: + QByteArray readAllStandardError() { return m_gdbProc.readAllStandardError(); } + QByteArray readAllStandardOutput() { return m_gdbProc.readAllStandardOutput(); } + qint64 write(const char *data) { return m_gdbProc.write(data); } + void setWorkingDirectory(const QString &dir) { m_gdbProc.setWorkingDirectory(dir); } + void setEnvironment(const QStringList &env) { m_gdbProc.setEnvironment(env); } + bool isTrkAdapter() const { return false; } + + void startAdapter(); + void prepareInferior(); + void startInferior(); + void interruptInferior(); + void shutdown(); + + void handleAttach(const GdbResultRecord &, const QVariant &); + void handleContinue(const GdbResultRecord &, const QVariant &); + void handleDetach(const GdbResultRecord &, const QVariant &); + void handleExit(const GdbResultRecord &, const QVariant &); + + void debugMessage(const QString &msg) { m_engine->debugMessage(msg); } + Q_SLOT void handleGdbFinished(int, QProcess::ExitStatus); + Q_SLOT void handleGdbStarted(); + + QProcess m_gdbProc; +}; + +} // namespace Internal +} // namespace Debugger + +#endif // DEBUGGER_ATTACHDBADAPTER_H diff --git a/src/plugins/debugger/gdb/coregdbadapter.cpp b/src/plugins/debugger/gdb/coregdbadapter.cpp index 820d158d10579916cf9a54ca76c5520cb03860a7..d5817633572230d4f67c7393895ec9a0d7c2ae3a 100644 --- a/src/plugins/debugger/gdb/coregdbadapter.cpp +++ b/src/plugins/debugger/gdb/coregdbadapter.cpp @@ -31,13 +31,10 @@ #include "debuggeractions.h" #include "gdbengine.h" -#include "procinterrupt.h" #include <utils/qtcassert.h> -#include <coreplugin/icore.h> #include <QtCore/QFileInfo> -#include <QtGui/QMessageBox> namespace Debugger { namespace Internal { @@ -148,7 +145,7 @@ void CoreGdbAdapter::handleTargetCore(const GdbResultRecord &response, const QVa if (response.resultClass == GdbResultDone) { setState(InferiorStarted); emit inferiorStarted(); - m_engine->handleTargetCore(); + m_engine->updateAll(); } else { QTC_ASSERT(response.resultClass == GdbResultError, /**/); const QByteArray &msg = response.data.findChild("msg").data(); diff --git a/src/plugins/debugger/gdb/gdb.pri b/src/plugins/debugger/gdb/gdb.pri index 08a45315a94338d3062d35a9c5207ea24905819c..344f724eebd09448c9835c8a39464fc26cd1f7f6 100644 --- a/src/plugins/debugger/gdb/gdb.pri +++ b/src/plugins/debugger/gdb/gdb.pri @@ -1,29 +1,31 @@ include(../../../shared/trk/trk.pri) HEADERS += \ - $$PWD/abstractgdbadapter.h \ - $$PWD/plaingdbadapter.h \ $$PWD/gdbmi.h \ $$PWD/gdbengine.h \ $$PWD/gdboptionspage.h \ - $$PWD/remotegdbadapter.h \ - $$PWD/coregdbadapter.h \ - $$PWD/trkgdbadapter.h \ $$PWD/trkoptions.h \ $$PWD/trkoptionswidget.h \ - $$PWD/trkoptionspage.h + $$PWD/trkoptionspage.h \ + $$PWD/abstractgdbadapter.h \ + $$PWD/attachgdbadapter.h \ + $$PWD/coregdbadapter.h \ + $$PWD/plaingdbadapter.h \ + $$PWD/remotegdbadapter.h \ + $$PWD/trkgdbadapter.h \ SOURCES += \ $$PWD/gdbmi.cpp \ $$PWD/gdbengine.cpp \ $$PWD/gdboptionspage.cpp \ - $$PWD/plaingdbadapter.cpp \ - $$PWD/remotegdbadapter.cpp \ - $$PWD/coregdbadapter.cpp \ $$PWD/trkoptions.cpp \ $$PWD/trkoptionswidget.cpp \ $$PWD/trkoptionspage.cpp \ - $$PWD/trkgdbadapter.cpp + $$PWD/attachgdbadapter.cpp \ + $$PWD/coregdbadapter.cpp \ + $$PWD/plaingdbadapter.cpp \ + $$PWD/remotegdbadapter.cpp \ + $$PWD/trkgdbadapter.cpp \ FORMS += $$PWD/gdboptionspage.ui \ $$PWD/trkoptionswidget.ui diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index de6556e693a2a31b6cd67332a3ecba82b13ceaa1..cabd13102590be510250243de996f207f5cf3ee6 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -34,10 +34,11 @@ #include "trkoptions.h" #include "trkoptionspage.h" +#include "attachgdbadapter.h" +#include "coregdbadapter.h" #include "plaingdbadapter.h" -#include "trkgdbadapter.h" #include "remotegdbadapter.h" -#include "coregdbadapter.h" +#include "trkgdbadapter.h" #include "watchutils.h" #include "debuggeractions.h" @@ -46,7 +47,6 @@ #include "debuggermanager.h" #include "debuggertooltip.h" #include "gdbmi.h" -#include "procinterrupt.h" #include "breakhandler.h" #include "moduleshandler.h" @@ -182,6 +182,7 @@ GdbEngine::GdbEngine(DebuggerManager *parent) : m_trkAdapter = new TrkGdbAdapter(this, options); m_remoteAdapter = new RemoteGdbAdapter(this); m_coreAdapter = new CoreGdbAdapter(this); + m_attachAdapter = new AttachGdbAdapter(this); // Output connect(&m_outputCollector, SIGNAL(byteDelivery(QByteArray)), @@ -198,22 +199,23 @@ GdbEngine::GdbEngine(DebuggerManager *parent) : Qt::QueuedConnection); } -void GdbEngine::connectDebuggingHelperActions(bool on) +void GdbEngine::connectDebuggingHelperActions() { - if (on) { - connect(theDebuggerAction(UseDebuggingHelpers), SIGNAL(valueChanged(QVariant)), - this, SLOT(setUseDebuggingHelpers(QVariant))); - connect(theDebuggerAction(DebugDebuggingHelpers), SIGNAL(valueChanged(QVariant)), - this, SLOT(setDebugDebuggingHelpers(QVariant))); - connect(theDebuggerAction(RecheckDebuggingHelpers), SIGNAL(triggered()), - this, SLOT(recheckDebuggingHelperAvailability())); - } else { - disconnect(theDebuggerAction(UseDebuggingHelpers), 0, this, 0); - disconnect(theDebuggerAction(DebugDebuggingHelpers), 0, this, 0); - disconnect(theDebuggerAction(RecheckDebuggingHelpers), 0, this, 0); - } + connect(theDebuggerAction(UseDebuggingHelpers), SIGNAL(valueChanged(QVariant)), + this, SLOT(setUseDebuggingHelpers(QVariant))); + connect(theDebuggerAction(DebugDebuggingHelpers), SIGNAL(valueChanged(QVariant)), + this, SLOT(setDebugDebuggingHelpers(QVariant))); + connect(theDebuggerAction(RecheckDebuggingHelpers), SIGNAL(triggered()), + this, SLOT(recheckDebuggingHelperAvailability())); } +void GdbEngine::disconnectDebuggingHelperActions() +{ + disconnect(theDebuggerAction(UseDebuggingHelpers), 0, this, 0); + disconnect(theDebuggerAction(DebugDebuggingHelpers), 0, this, 0); + disconnect(theDebuggerAction(RecheckDebuggingHelpers), 0, this, 0); +} + DebuggerStartMode GdbEngine::startMode() const { QTC_ASSERT(!m_startParameters.isNull(), return NoStartMode); @@ -232,6 +234,7 @@ GdbEngine::~GdbEngine() delete m_trkAdapter; delete m_remoteAdapter; delete m_coreAdapter; + delete m_attachAdapter; } void GdbEngine::connectAdapter() @@ -324,7 +327,6 @@ void GdbEngine::initializeVariables() m_outputCodec = QTextCodec::codecForLocale(); m_pendingRequests = 0; m_continuationAfterDone = 0; - m_waitingForFirstBreakpointToBeHit = false; m_commandsToRunOnTemporaryBreak.clear(); m_cookieForToken.clear(); m_customOutputForToken.clear(); @@ -698,6 +700,7 @@ void GdbEngine::interruptInferior() return; } + debugMessage(_("TRYING TO INTERUPT INFERIOR")); m_gdbAdapter->interruptInferior(); } @@ -812,7 +815,6 @@ void GdbEngine::handleResultRecord(const GdbResultRecord &record) { //qDebug() << "TOKEN:" << record.token // << " ACCEPTABLE:" << m_oldestAcceptableToken; - //qDebug() << ""; //qDebug() << "\nRESULT" << record.token << record.toString(); int token = record.token; @@ -823,7 +825,7 @@ void GdbEngine::handleResultRecord(const GdbResultRecord &record) // In theory this should not happen, in practice it does. debugMessage(_("COOKIE FOR TOKEN %1 ALREADY EATEN. " "TWO RESPONSES FOR ONE COMMAND?").arg(token)); - // handle a case known to occur on Linux/gdb 6.8 when debugging moc + // Handle a case known to occur on Linux/gdb 6.8 when debugging moc // with helpers enabled. In this case we get a second response with // msg="Cannot find new threads: generic error" if (record.resultClass == GdbResultError) { @@ -832,8 +834,6 @@ void GdbEngine::handleResultRecord(const GdbResultRecord &record) tr("Executable failed"), QString::fromLocal8Bit(msg)); showStatusMessage(tr("Process failed to start.")); exitDebugger(); - //qq->notifyInferiorStopped(); - //qq->notifyInferiorExited(); } return; } @@ -858,8 +858,6 @@ void GdbEngine::handleResultRecord(const GdbResultRecord &record) << "\n record: " << record.toString(); #endif - // << "\n data: " << record.data.toString(true); - if (cmd.callback) (this->*cmd.callback)(record, cmd.cookie); if (cmd.adapterCallback) @@ -904,14 +902,14 @@ void GdbEngine::executeDebuggerCommand(const QString &command) m_gdbAdapter->write(command.toLatin1() + "\r\n"); } -void GdbEngine::handleTargetCore() +void GdbEngine::updateAll() { qq->notifyInferiorStopped(); showStatusMessage(tr("Core file loaded.")); m_manager->resetLocation(); tryLoadDebuggingHelpers(); qq->stackHandler()->setCurrentIndex(0); - updateLocals(); // Quick shot + updateLocals(); reloadStack(); if (supportsThreads()) postCommand(_("-thread-list-ids"), WatchUpdate, CB(handleStackListThreads), 0); @@ -935,7 +933,6 @@ void GdbEngine::handleQuerySources(const GdbResultRecord &record, const QVariant full = QDir::cleanPath(full); #endif if (fullName.isValid() && QFileInfo(full).isReadable()) { - //qDebug() << "STORING 2:" << fileName << full; m_shortToFullName[fileName] = full; m_fullToShortName[full] = fileName; } @@ -1128,21 +1125,6 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) return; } - //MAC: bool isFirstStop = data.findChild("bkptno").data() == "1"; - //!MAC: startSymbolName == data.findChild("frame").findChild("func") - if (m_waitingForFirstBreakpointToBeHit) { - m_waitingForFirstBreakpointToBeHit = false; - - // If the executable dies already that early we might get something - // like >49*stopped,reason="exited",exit-code="0177" - // This is handled now above. - - qq->notifyInferiorStopped(); - handleAqcuiredInferior(); -// FIXME: m_continuationAfterDone = true; - return; - } - if (!m_commandsToRunOnTemporaryBreak.isEmpty()) { QTC_ASSERT(status() == DebuggerInferiorStopRequested, qDebug() << "STATUS:" << status()) @@ -1375,11 +1357,13 @@ void GdbEngine::handleStop2(const GdbMi &data) qq->stackHandler()->setCurrentIndex(0); updateLocals(); // Quick shot - int currentId = data.findChild("thread-id").data().toInt(); - reloadStack(); - if (supportsThreads()) - postCommand(_("-thread-list-ids"), WatchUpdate, CB(handleStackListThreads), currentId); + + if (supportsThreads()) { + int currentId = data.findChild("thread-id").data().toInt(); + postCommand(_("-thread-list-ids"), WatchUpdate, + CB(handleStackListThreads), currentId); + } // // Registers @@ -1525,22 +1509,19 @@ void GdbEngine::shutdown() void GdbEngine::detachDebugger() { - postCommand(_("detach"), CB(handleDetach)); + //postCommand(_("detach"), CB(handleDetach)); + QTC_ASSERT(startMode() == AttachExternal, /**/); + shutdown(); } void GdbEngine::exitDebugger() { - connectDebuggingHelperActions(false); + disconnectDebuggingHelperActions(); m_outputCollector.shutdown(); initializeVariables(); m_gdbAdapter->shutdown(); } -void GdbEngine::handleDetach(const GdbResultRecord &, const QVariant &) -{ - exitDebugger(); -} - int GdbEngine::currentFrame() const { return qq->stackHandler()->currentIndex(); @@ -1556,7 +1537,7 @@ void GdbEngine::startDebugger(const DebuggerStartParametersPtr &sp) m_startParameters = sp; if (startModeAllowsDumpers()) - connectDebuggingHelperActions(true); + connectDebuggingHelperActions(); if (m_gdbAdapter) disconnectAdapter(); @@ -1567,6 +1548,8 @@ void GdbEngine::startDebugger(const DebuggerStartParametersPtr &sp) m_gdbAdapter = m_coreAdapter; else if (sp->startMode == StartRemote) m_gdbAdapter = m_remoteAdapter; + else if (sp->startMode == AttachExternal) + m_gdbAdapter = m_attachAdapter; else m_gdbAdapter = m_plainAdapter; @@ -1622,31 +1605,6 @@ void GdbEngine::continueInferior() } #if 0 -void GdbEngine::handleAttach(const GdbResultRecord &, const QVariant &) -{ - qq->notifyInferiorStopped(); - showStatusMessage(tr("Attached to running process. Stopped.")); - handleAqcuiredInferior(); - - m_manager->resetLocation(); - recheckDebuggingHelperAvailability(); - - // - // Stack - // - qq->stackHandler()->setCurrentIndex(0); - updateLocals(); // Quick shot - - reloadStack(); - if (supportsThreads()) - postCommand(_("-thread-list-ids"), WatchUpdate, CB(handleStackListThreads), 0); - - // - // Registers - // - qq->reloadRegisters(); -} - void GdbEngine::handleSetTargetAsync(const GdbResultRecord &record, const QVariant &) { if (record.resultClass == GdbResultDone) { @@ -4126,7 +4084,7 @@ void GdbEngine::handleAdapterStarted() void GdbEngine::handleInferiorPreparationFailed(const QString &msg) { - debugMessage(_("INFERIOR PREPARATION FAILD")); + debugMessage(_("INFERIOR PREPARATION FAILED")); showMessageBox(QMessageBox::Critical, tr("Inferior start preparation failed"), msg); shutdown(); diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index eb97e06c6a5bfe74386060210a44cdce1b8aa3a2..d39546f9b812f3ea9b4194f91323cc0bd63b9d5b 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -62,13 +62,14 @@ class IDebuggerManagerAccessForEngines; class GdbResultRecord; class GdbMi; -class WatchData; class BreakpointData; +class WatchData; +class AttachGdbAdapter; +class CoreGdbAdapter; class PlainGdbAdapter; -class TrkGdbAdapter; class RemoteGdbAdapter; -class CoreGdbAdapter; +class TrkGdbAdapter; enum DebuggingHelperState { @@ -92,10 +93,11 @@ signals: void applicationOutputAvailable(const QString &output); private: + friend class AttachGdbAdapter; + friend class CoreGdbAdapter; friend class PlainGdbAdapter; - friend class TrkGdbAdapter; friend class RemoteGdbAdapter; - friend class CoreGdbAdapter; + friend class TrkGdbAdapter; // // IDebuggerEngine implementation @@ -226,6 +228,7 @@ private: void postCommandHelper(const GdbCommand &cmd); void setTokenBarrier(); + void updateAll(); void updateLocals(); private slots: @@ -251,7 +254,6 @@ private: int terminationIndex(const QByteArray &buffer, int &length); void handleResponse(const QByteArray &buff); void handleStart(const GdbResultRecord &response, const QVariant &); - //void handleAttach(const GdbResultRecord &, const QVariant &); void handleAqcuiredInferior(); void handleAsyncOutput(const GdbMi &data); void handleStop1(const GdbResultRecord &, const QVariant &cookie); @@ -260,7 +262,6 @@ private: void handleResultRecord(const GdbResultRecord &response); void handleFileExecAndSymbols(const GdbResultRecord &response, const QVariant &); void handleExecContinue(const GdbResultRecord &response, const QVariant &); - //void handleExecRun(const GdbResultRecord &response, const QVariant &); void handleExecJumpToLine(const GdbResultRecord &response, const QVariant &); void handleExecRunToFunction(const GdbResultRecord &response, const QVariant &); void handleInfoShared(const GdbResultRecord &response, const QVariant &); @@ -270,11 +271,9 @@ private: void handleQueryPwd(const GdbResultRecord &response, const QVariant &); void handleQuerySources(const GdbResultRecord &response, const QVariant &); void handleExit(const GdbResultRecord &, const QVariant &); - void handleDetach(const GdbResultRecord &, const QVariant &); //void handleSetTargetAsync(const GdbResultRecord &, const QVariant &); //void handleTargetRemote(const GdbResultRecord &, const QVariant &); void handleWatchPoint(const GdbResultRecord &, const QVariant &); - void handleTargetCore(); bool showToolTip(); // Convenience @@ -412,7 +411,8 @@ private: void setWatchDataType(WatchData &data, const GdbMi &mi); void setWatchDataDisplayedType(WatchData &data, const GdbMi &mi); void setLocals(const QList<GdbMi> &locals); - void connectDebuggingHelperActions(bool on); + void connectDebuggingHelperActions(); + void disconnectDebuggingHelperActions(); bool startModeAllowsDumpers() const; QString parseDisassembler(const GdbMi &lines); @@ -432,7 +432,6 @@ private: Continuation m_continuationAfterDone; void handleInitialBreakpointsSet(); - bool m_waitingForFirstBreakpointToBeHit; bool m_modulesListOutdated; QList<GdbCommand> m_commandsToRunOnTemporaryBreak; @@ -444,10 +443,11 @@ private: // only one of those is active at a given time, available in m_gdbAdapter AbstractGdbAdapter *m_gdbAdapter; // pointer to one listed below + AttachGdbAdapter *m_attachAdapter; // owned + CoreGdbAdapter *m_coreAdapter; // owned PlainGdbAdapter *m_plainAdapter; // owned - TrkGdbAdapter *m_trkAdapter; // owned RemoteGdbAdapter *m_remoteAdapter; // owned - CoreGdbAdapter *m_coreAdapter; // owned + TrkGdbAdapter *m_trkAdapter; // owned public: void showMessageBox(int icon, const QString &title, const QString &text); diff --git a/src/plugins/debugger/gdb/plaingdbadapter.cpp b/src/plugins/debugger/gdb/plaingdbadapter.cpp index 68630fff7a73afa0b016ff4c065e361cfcba5f62..fee4c3974c9f0ae967727b15c4b9abeaa3a10bee 100644 --- a/src/plugins/debugger/gdb/plaingdbadapter.cpp +++ b/src/plugins/debugger/gdb/plaingdbadapter.cpp @@ -225,11 +225,6 @@ void PlainGdbAdapter::startInferior() void PlainGdbAdapter::interruptInferior() { debugMessage(_("TRYING TO INTERUPT INFERIOR")); - if (m_engine->startMode() == StartRemote) { - m_engine->postCommand(_("-exec-interrupt")); - return; - } - const qint64 attachedPID = m_engine->inferiorPid(); if (attachedPID <= 0) { debugMessage(_("TRYING TO INTERRUPT INFERIOR BEFORE PID WAS OBTAINED")); diff --git a/src/plugins/debugger/gdb/remotegdbadapter.cpp b/src/plugins/debugger/gdb/remotegdbadapter.cpp index 0a4a9f92b619d95a36763f5a2d23dbce9e6b8ade..beed13ac93115b95569c5f78a320bd8a572cb9ea 100644 --- a/src/plugins/debugger/gdb/remotegdbadapter.cpp +++ b/src/plugins/debugger/gdb/remotegdbadapter.cpp @@ -31,10 +31,8 @@ #include "debuggeractions.h" #include "gdbengine.h" -#include "procinterrupt.h" #include <utils/qtcassert.h> -#include <coreplugin/icore.h> #include <QtCore/QFileInfo> #include <QtGui/QMessageBox> @@ -229,20 +227,7 @@ void RemoteGdbAdapter::handleExecRun(const GdbResultRecord &response, const QVar void RemoteGdbAdapter::interruptInferior() { - debugMessage(_("TRYING TO INTERUPT INFERIOR")); - if (m_engine->startMode() == StartRemote) { - m_engine->postCommand(_("-exec-interrupt")); - return; - } - - const qint64 attachedPID = m_engine->inferiorPid(); - if (attachedPID <= 0) { - debugMessage(_("TRYING TO INTERRUPT INFERIOR BEFORE PID WAS OBTAINED")); - return; - } - - if (!interruptProcess(attachedPID)) - debugMessage(_("CANNOT INTERRUPT %1").arg(attachedPID)); + m_engine->postCommand(_("-exec-interrupt")); } void RemoteGdbAdapter::shutdown() diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index ac52e47baa369ee5055bf947f5c70d1d0daa5af5..8f6bba03ac1e8ca28516d28b71faa4a488d44d0e 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -702,7 +702,8 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const } case Qt::ToolTipRole: - return data.toToolTip(); + return theDebuggerBoolSetting(UseToolTipsInLocalsView) + ? data.toToolTip() : QVariant(); case Qt::ForegroundRole: { static const QVariant red(QColor(200, 0, 0));