diff options
Diffstat (limited to 'src/plugins/debugger')
63 files changed, 677 insertions, 1568 deletions
diff --git a/src/plugins/debugger/CMakeLists.txt b/src/plugins/debugger/CMakeLists.txt new file mode 100644 index 00000000000..f88c5ffd602 --- /dev/null +++ b/src/plugins/debugger/CMakeLists.txt @@ -0,0 +1,109 @@ +add_qtc_plugin(Debugger + DEPENDS LanguageUtils QmlDebug qmljs QtcSsh registryaccess + PLUGIN_DEPENDS Core CppTools ProjectExplorer QtSupport TextEditor + PLUGIN_RECOMMENDS QmakeProjectManager + SOURCES + analyzer/analyzerbase.qrc + analyzer/analyzerconstants.h + analyzer/analyzericons.h + analyzer/analyzermanager.h + analyzer/analyzerrunconfigwidget.cpp analyzer/analyzerrunconfigwidget.h + analyzer/analyzerutils.cpp analyzer/analyzerutils.h + analyzer/detailederrorview.cpp analyzer/detailederrorview.h + analyzer/diagnosticlocation.cpp analyzer/diagnosticlocation.h + analyzer/startremotedialog.cpp analyzer/startremotedialog.h + breakhandler.cpp breakhandler.h + breakpoint.cpp breakpoint.h + cdb/cdbengine.cpp cdb/cdbengine.h + cdb/cdboptionspage.cpp cdb/cdboptionspage.h + cdb/cdboptionspagewidget.ui + cdb/cdbparsehelpers.cpp cdb/cdbparsehelpers.h + cdb/stringinputstream.cpp cdb/stringinputstream.h + commonoptionspage.cpp commonoptionspage.h + console/console.cpp console/console.h + console/consoleedit.cpp console/consoleedit.h + console/consoleitem.cpp console/consoleitem.h + console/consoleitemdelegate.cpp console/consoleitemdelegate.h + console/consoleitemmodel.cpp console/consoleitemmodel.h + console/consoleproxymodel.cpp console/consoleproxymodel.h + console/consoleview.cpp console/consoleview.h + debugger.qrc + debugger_global.h + debuggeractions.cpp debuggeractions.h + debuggerconstants.h + debuggercore.h + debuggerdialogs.cpp debuggerdialogs.h + debuggerengine.cpp debuggerengine.h + debuggericons.cpp debuggericons.h + debuggerinternalconstants.h + debuggeritem.cpp debuggeritem.h + debuggeritemmanager.cpp debuggeritemmanager.h + debuggerkitinformation.cpp debuggerkitinformation.h + debuggermainwindow.cpp debuggermainwindow.h + debuggerplugin.cpp debuggerplugin.h + debuggerprotocol.cpp debuggerprotocol.h + debuggerrunconfigurationaspect.cpp debuggerrunconfigurationaspect.h + debuggerruncontrol.cpp debuggerruncontrol.h + debuggersourcepathmappingwidget.cpp debuggersourcepathmappingwidget.h + debuggertooltipmanager.cpp debuggertooltipmanager.h + disassembleragent.cpp disassembleragent.h + disassemblerlines.cpp disassemblerlines.h + gdb/gdbengine.cpp gdb/gdbengine.h + gdb/gdboptionspage.cpp + imageviewer.cpp imageviewer.h + enginemanager.cpp enginemanager.h + lldb/lldbengine.cpp lldb/lldbengine.h + loadcoredialog.cpp loadcoredialog.h + localsandexpressionswindow.cpp localsandexpressionswindow.h + logwindow.cpp logwindow.h + memoryagent.cpp memoryagent.h + moduleshandler.cpp moduleshandler.h + namedemangler/demanglerexceptions.h + namedemangler/globalparsestate.cpp namedemangler/globalparsestate.h + namedemangler/namedemangler.cpp namedemangler/namedemangler.h + namedemangler/parsetreenodes.cpp namedemangler/parsetreenodes.h + outputcollector.cpp outputcollector.h + pdb/pdbengine.cpp pdb/pdbengine.h + procinterrupt.cpp procinterrupt.h + qml/interactiveinterpreter.cpp qml/interactiveinterpreter.h + #qml/qmlcppengine.cpp qml/qmlcppengine.h + qml/qmlengine.cpp qml/qmlengine.h + qml/qmlengineutils.cpp qml/qmlengineutils.h + qml/qmlinspectoragent.cpp qml/qmlinspectoragent.h + qml/qmlv8debuggerclientconstants.h + registerhandler.cpp registerhandler.h + shared/backtrace.cpp shared/backtrace.h + shared/cdbsymbolpathlisteditor.cpp shared/cdbsymbolpathlisteditor.h + shared/hostutils.cpp shared/hostutils.h + shared/peutils.cpp shared/peutils.h + shared/symbolpathsdialog.cpp shared/symbolpathsdialog.h shared/symbolpathsdialog.ui + simplifytype.cpp simplifytype.h + sourceagent.cpp sourceagent.h + sourcefileshandler.cpp sourcefileshandler.h + sourceutils.cpp sourceutils.h + stackframe.cpp stackframe.h + stackhandler.cpp stackhandler.h + stackwindow.cpp stackwindow.h + terminal.cpp terminal.h + threaddata.h + threadshandler.cpp threadshandler.h + unstartedappwatcherdialog.cpp unstartedappwatcherdialog.h + watchdata.cpp watchdata.h + watchdelegatewidgets.cpp watchdelegatewidgets.h + watchhandler.cpp watchhandler.h + watchutils.cpp watchutils.h + watchwindow.cpp watchwindow.h +) + +extend_qtc_plugin(Debugger + CONDITION WIN32 + SOURCES registerpostmortemaction.cpp registerpostmortemaction.h + DEFINES UNICODE _UNICODE +) + +extend_qtc_plugin(Debugger + CONDITION WITH_TESTS + SOURCES + debuggerunittests.qrc + unit-tests/simple/main.cpp +) diff --git a/src/plugins/debugger/analyzer/analyzerrunconfigwidget.cpp b/src/plugins/debugger/analyzer/analyzerrunconfigwidget.cpp index 137e0612b4d..39a3684ab36 100644 --- a/src/plugins/debugger/analyzer/analyzerrunconfigwidget.cpp +++ b/src/plugins/debugger/analyzer/analyzerrunconfigwidget.cpp @@ -52,7 +52,7 @@ AnalyzerRunConfigWidget::AnalyzerRunConfigWidget(ProjectExplorer::GlobalOrProjec QApplication::translate("ProjectExplorer::Internal::EditorSettingsPropertiesPage", "Custom") })); globalSettingLayout->addWidget(m_settingsCombo); - connect(m_settingsCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), + connect(m_settingsCombo, QOverload<int>::of(&QComboBox::activated), this, &AnalyzerRunConfigWidget::chooseSettings); m_restoreButton = new QPushButton( QApplication::translate("ProjectExplorer::Internal::EditorSettingsPropertiesPage", "Restore Global"), diff --git a/src/plugins/debugger/analyzer/startremotedialog.cpp b/src/plugins/debugger/analyzer/startremotedialog.cpp index 07025362629..30ce83eca2d 100644 --- a/src/plugins/debugger/analyzer/startremotedialog.cpp +++ b/src/plugins/debugger/analyzer/startremotedialog.cpp @@ -28,7 +28,7 @@ #include <coreplugin/icore.h> #include <projectexplorer/kitchooser.h> #include <projectexplorer/kitinformation.h> -#include <projectexplorer/runconfiguration.h> +#include <projectexplorer/runcontrol.h> #include <ssh/sshconnection.h> #include <QDialogButtonBox> @@ -63,7 +63,7 @@ StartRemoteDialog::StartRemoteDialog(QWidget *parent) d->kitChooser = new KitChooser(this); d->kitChooser->setKitPredicate([](const Kit *kit) { - const IDevice::ConstPtr device = DeviceKitInformation::device(kit); + const IDevice::ConstPtr device = DeviceKitAspect::device(kit); return kit->isValid() && device && !device->sshParameters().host().isEmpty(); }); d->executable = new QLineEdit(this); @@ -132,7 +132,7 @@ Runnable StartRemoteDialog::runnable() const { Kit *kit = d->kitChooser->currentKit(); Runnable r; - r.device = DeviceKitInformation::device(kit); + r.device = DeviceKitAspect::device(kit); r.executable = d->executable->text(); r.commandLineArguments = d->arguments->text(); r.workingDirectory = d->workingDirectory->text(); diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index 481c123046a..2fd197c618e 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -87,7 +87,7 @@ static BreakpointManager *theBreakpointManager = nullptr; class BreakpointMarker : public TextEditor::TextMark { public: - BreakpointMarker(const Breakpoint &bp, const FileName &fileName, int lineNumber) + BreakpointMarker(const Breakpoint &bp, const FilePath &fileName, int lineNumber) : TextMark(fileName, lineNumber, Constants::TEXT_MARK_CATEGORY_BREAKPOINT), m_bp(bp) { setColor(Theme::Debugger_Breakpoint_TextMarkColor); @@ -106,7 +106,7 @@ public: gbp->m_params.lineNumber = lineNumber; } - void updateFileName(const FileName &fileName) final + void updateFileName(const FilePath &fileName) final { TextMark::updateFileName(fileName); QTC_ASSERT(m_bp, return); @@ -145,7 +145,7 @@ public: class GlobalBreakpointMarker : public TextEditor::TextMark { public: - GlobalBreakpointMarker(GlobalBreakpoint gbp, const FileName &fileName, int lineNumber) + GlobalBreakpointMarker(GlobalBreakpoint gbp, const FilePath &fileName, int lineNumber) : TextMark(fileName, lineNumber, Constants::TEXT_MARK_CATEGORY_BREAKPOINT), m_gbp(gbp) { setColor(Theme::Debugger_Breakpoint_TextMarkColor); @@ -174,7 +174,7 @@ public: m_gbp->update(); } - void updateFileName(const FileName &fileName) final + void updateFileName(const FilePath &fileName) final { TextMark::updateFileName(fileName); QTC_ASSERT(m_gbp, return); @@ -541,7 +541,7 @@ BreakpointDialog::BreakpointDialog(unsigned int enabledParts, QWidget *parent) verticalLayout->addWidget(m_buttonBox); verticalLayout->setStretchFactor(groupBoxAdvanced, 10); - connect(m_comboBoxType, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), + connect(m_comboBoxType, QOverload<int>::of(&QComboBox::activated), this, &BreakpointDialog::typeChanged); connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); @@ -1877,7 +1877,7 @@ void BreakpointItem::updateMarkerIcon() void BreakpointItem::updateMarker() { - FileName file = FileName::fromString(markerFileName()); + FilePath file = FilePath::fromString(markerFileName()); int line = markerLineNumber(); if (m_marker && (file != m_marker->fileName() || line != m_marker->lineNumber())) destroyMarker(); @@ -2298,7 +2298,7 @@ void GlobalBreakpointItem::updateMarker() return; } - const FileName file = FileName::fromString(m_params.fileName); + const FilePath file = FilePath::fromString(m_params.fileName); const int line = m_params.lineNumber; if (m_marker && (file != m_marker->fileName() || line != m_marker->lineNumber())) destroyMarker(); diff --git a/src/plugins/debugger/breakhandler.h b/src/plugins/debugger/breakhandler.h index 544f4a509eb..83d934034b6 100644 --- a/src/plugins/debugger/breakhandler.h +++ b/src/plugins/debugger/breakhandler.h @@ -76,7 +76,7 @@ public: void removeBreakpointFromModel(); void updateLineNumber(int lineNumber); - void updateFileName(const Utils::FileName &fileName); + void updateFileName(const Utils::FilePath &fileName); QString displayName() const; QString markerFileName() const; @@ -191,7 +191,7 @@ public: void deleteGlobalOrThisBreakpoint(); void updateLineNumber(int lineNumber); - void updateFileName(const Utils::FileName &fileName); + void updateFileName(const Utils::FilePath &fileName); const GlobalBreakpoint globalBreakpoint() const; void gotoState(BreakpointState target, BreakpointState assumedCurrent); diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index b5372bce5b6..4a3839159ec 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -203,7 +203,7 @@ CdbEngine::CdbEngine() : connect(action(CreateFullBacktrace), &QAction::triggered, this, &CdbEngine::createFullBacktrace); - connect(&m_process, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), + connect(&m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, &CdbEngine::processFinished); connect(&m_process, &QProcess::errorOccurred, this, &CdbEngine::processError); connect(&m_process, &QProcess::readyReadStandardOutput, @@ -256,7 +256,7 @@ void CdbEngine::init() if (!sourcePathMap.isEmpty()) { for (auto it = sourcePathMap.constBegin(), cend = sourcePathMap.constEnd(); it != cend; ++it) { m_sourcePathMappings.push_back({QDir::toNativeSeparators(it.key()), - QDir::toNativeSeparators(it.value())}); + QDir::toNativeSeparators(expand(it.value()))}); } } // update source path maps from debugger start params @@ -324,12 +324,9 @@ static QStringList mergeEnvironment(QStringList runConfigEnvironment, return runConfigEnvironment; } -int CdbEngine::elapsedLogTime() const +int CdbEngine::elapsedLogTime() { - const int elapsed = m_logTime.elapsed(); - const int delta = elapsed - m_elapsedLogTime; - m_elapsedLogTime = elapsed; - return delta; + return m_logTimer.restart(); } void CdbEngine::createFullBacktrace() @@ -352,8 +349,8 @@ void CdbEngine::setupEngine() qDebug(">setupEngine"); init(); - if (!m_logTime.elapsed()) - m_logTime.start(); + if (!m_logTimer.elapsed()) + m_logTimer.start(); // Console: Launch the stub with the suspended application and attach to it // CDB in theory has a command line option '-2' that launches a @@ -526,7 +523,7 @@ void CdbEngine::handleInitialSessionIdle() if (rp.breakOnMain) { BreakpointParameters bp(BreakpointAtMain); if (rp.startMode == StartInternal || rp.startMode == StartExternal) { - const QString &moduleFileName = Utils::FileName::fromString(rp.inferior.executable) + const QString &moduleFileName = Utils::FilePath::fromString(rp.inferior.executable) .fileName(); bp.module = moduleFileName.left(moduleFileName.indexOf('.')); } @@ -1119,6 +1116,7 @@ void CdbEngine::doUpdateLocals(const UpdateParameters &updateParameters) cmd.arg("dyntype", boolSetting(UseDynamicType)); cmd.arg("partialvar", updateParameters.partialVariable); cmd.arg("qobjectnames", boolSetting(ShowQObjectNames)); + cmd.arg("timestamps", boolSetting(LogTimeStamps)); StackFrame frame = stackHandler()->currentFrame(); cmd.arg("context", frame.context); @@ -2204,7 +2202,7 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QString &what, c if (!isDebuggerWinException(exception.exceptionCode)) { const Task::TaskType type = isFatalWinException(exception.exceptionCode) ? Task::Error : Task::Warning; - const FileName fileName = FileName::fromUserInput(exception.file); + const FilePath fileName = FilePath::fromUserInput(exception.file); const QString taskEntry = tr("Debugger encountered an exception: %1").arg( exception.toString(false).trimmed()); TaskHub::addTask(type, taskEntry, diff --git a/src/plugins/debugger/cdb/cdbengine.h b/src/plugins/debugger/cdb/cdbengine.h index 16b71b954b4..fd0e35ba8a3 100644 --- a/src/plugins/debugger/cdb/cdbengine.h +++ b/src/plugins/debugger/cdb/cdbengine.h @@ -32,14 +32,12 @@ #include <projectexplorer/devicesupport/idevice.h> -#include <QTime> +#include <QElapsedTimer> namespace Debugger { namespace Internal { class CdbCommand; -struct MemoryViewCookie; -class StringInputStream; class CdbEngine : public CppDebuggerEngine { @@ -195,7 +193,7 @@ private: NormalizedSourceFileName sourceMapNormalizeFileNameFromDebugger(const QString &f); void doUpdateLocals(const UpdateParameters ¶ms) override; void updateAll() override; - int elapsedLogTime() const; + int elapsedLogTime(); unsigned parseStackTrace(const GdbMi &data, bool sourceStepInto); void mergeStartParametersSourcePathMap(); @@ -223,8 +221,7 @@ private: wow64Stack32Bit, wow64Stack64Bit } m_wow64State = wow64Uninitialized; - QTime m_logTime; - mutable int m_elapsedLogTime = 0; + QElapsedTimer m_logTimer; QString m_extensionMessageBuffer; bool m_sourceStepInto = false; int m_watchPointX = 0; diff --git a/src/plugins/debugger/cdb/cdbparsehelpers.cpp b/src/plugins/debugger/cdb/cdbparsehelpers.cpp index 577776f8fbd..2590a47a09e 100644 --- a/src/plugins/debugger/cdb/cdbparsehelpers.cpp +++ b/src/plugins/debugger/cdb/cdbparsehelpers.cpp @@ -84,7 +84,7 @@ static inline QString cdbBreakPointFileName(const BreakpointParameters ¶ms, if (params.fileName.isEmpty()) return params.fileName; if (params.pathUsage == BreakpointUseShortPath) - return Utils::FileName::fromString(params.fileName).fileName(); + return Utils::FilePath::fromString(params.fileName).fileName(); return cdbSourcePathMapping(QDir::toNativeSeparators(params.fileName), sourcePathMapping, SourceToDebugger); } diff --git a/src/plugins/debugger/console/console.cpp b/src/plugins/debugger/console/console.cpp index 1ff13a25458..c7fe001c746 100644 --- a/src/plugins/debugger/console/console.cpp +++ b/src/plugins/debugger/console/console.cpp @@ -100,7 +100,6 @@ Console::Console() vbox->addWidget(new Core::FindToolBarPlaceHolder(m_consoleWidget)); m_showDebugButton = new QToolButton(m_consoleWidget); - m_showDebugButton->setAutoRaise(true); m_showDebugButtonAction = new Utils::SavedAction(this); m_showDebugButtonAction->setDefaultValue(true); @@ -114,7 +113,6 @@ Console::Console() m_showDebugButton->setDefaultAction(m_showDebugButtonAction); m_showWarningButton = new QToolButton(m_consoleWidget); - m_showWarningButton->setAutoRaise(true); m_showWarningButtonAction = new Utils::SavedAction(this); m_showWarningButtonAction->setDefaultValue(true); @@ -128,7 +126,6 @@ Console::Console() m_showWarningButton->setDefaultAction(m_showWarningButtonAction); m_showErrorButton = new QToolButton(m_consoleWidget); - m_showErrorButton->setAutoRaise(true); m_showErrorButtonAction = new Utils::SavedAction(this); m_showErrorButtonAction->setDefaultValue(true); diff --git a/src/plugins/debugger/console/consoleitemdelegate.cpp b/src/plugins/debugger/console/consoleitemdelegate.cpp index 265ee6ce179..2196d7a260a 100644 --- a/src/plugins/debugger/console/consoleitemdelegate.cpp +++ b/src/plugins/debugger/console/consoleitemdelegate.cpp @@ -186,7 +186,7 @@ void ConsoleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o const int pos = file.lastIndexOf('/'); if (pos != -1) file = file.mid(pos +1); - const int realFileWidth = fm.width(file); + const int realFileWidth = fm.horizontalAdvance(file); painter->setClipRect(positions.fileArea()); painter->drawText(positions.fileAreaLeft(), positions.adjustedTop() + fm.ascent(), file); @@ -203,7 +203,7 @@ void ConsoleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o // Paint LineArea QString lineText = index.data(ConsoleItem::LineRole).toString(); painter->setClipRect(positions.lineArea()); - const int realLineWidth = fm.width(lineText); + const int realLineWidth = fm.horizontalAdvance(lineText); painter->drawText(positions.lineAreaRight() - realLineWidth, positions.adjustedTop() + fm.ascent(), lineText); } diff --git a/src/plugins/debugger/console/consoleitemmodel.cpp b/src/plugins/debugger/console/consoleitemmodel.cpp index 525aca0dc0d..aa31132956f 100644 --- a/src/plugins/debugger/console/consoleitemmodel.cpp +++ b/src/plugins/debugger/console/consoleitemmodel.cpp @@ -92,7 +92,7 @@ int ConsoleItemModel::sizeOfFile(const QFont &font) filename = filename.mid(pos + 1); QFontMetrics fm(font); - m_maxSizeOfFileName = qMax(m_maxSizeOfFileName, fm.width(filename)); + m_maxSizeOfFileName = qMax(m_maxSizeOfFileName, fm.horizontalAdvance(filename)); return m_maxSizeOfFileName; } @@ -100,7 +100,7 @@ int ConsoleItemModel::sizeOfFile(const QFont &font) int ConsoleItemModel::sizeOfLineNumber(const QFont &font) { QFontMetrics fm(font); - return fm.width("88888"); + return fm.horizontalAdvance("88888"); } } // Internal diff --git a/src/plugins/debugger/console/consoleview.cpp b/src/plugins/debugger/console/consoleview.cpp index 9969bfb0f5c..c6387cc9e05 100644 --- a/src/plugins/debugger/console/consoleview.cpp +++ b/src/plugins/debugger/console/consoleview.cpp @@ -218,7 +218,8 @@ void ConsoleView::onRowActivated(const QModelIndex &index) if (!index.isValid()) return; - const QFileInfo fi(m_finder.findFile(model()->data(index, ConsoleItem::FileRole).toString())); + const QFileInfo fi = m_finder.findFile(model()->data(index, ConsoleItem::FileRole).toString()) + .first().toFileInfo(); if (fi.exists() && fi.isFile() && fi.isReadable()) { Core::EditorManager::openEditorAt(fi.canonicalFilePath(), model()->data(index, ConsoleItem::LineRole).toInt()); diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro index acbf5136b9a..0f91ac1a92d 100644 --- a/src/plugins/debugger/debugger.pro +++ b/src/plugins/debugger/debugger.pro @@ -29,7 +29,6 @@ HEADERS += \ debuggerprotocol.h \ debuggerrunconfigurationaspect.h \ debuggerruncontrol.h \ - debuggerkitconfigwidget.h \ debuggerkitinformation.h \ disassembleragent.h \ disassemblerlines.h \ @@ -76,7 +75,6 @@ SOURCES += \ debuggerprotocol.cpp \ debuggerrunconfigurationaspect.cpp \ debuggerruncontrol.cpp \ - debuggerkitconfigwidget.cpp \ debuggerkitinformation.cpp \ disassembleragent.cpp \ disassemblerlines.cpp \ diff --git a/src/plugins/debugger/debugger.qbs b/src/plugins/debugger/debugger.qbs index 50dd65fe764..6add8dd906c 100644 --- a/src/plugins/debugger/debugger.qbs +++ b/src/plugins/debugger/debugger.qbs @@ -51,7 +51,6 @@ Project { "debuggerinternalconstants.h", "debuggeritem.cpp", "debuggeritem.h", "debuggeritemmanager.cpp", "debuggeritemmanager.h", - "debuggerkitconfigwidget.cpp", "debuggerkitconfigwidget.h", "debuggerkitinformation.cpp", "debuggerkitinformation.h", "debuggermainwindow.cpp", "debuggermainwindow.h", "debuggerplugin.cpp", "debuggerplugin.h", diff --git a/src/plugins/debugger/debugger.qrc b/src/plugins/debugger/debugger.qrc index bf8095b3380..86a05a73ff1 100644 --- a/src/plugins/debugger/debugger.qrc +++ b/src/plugins/debugger/debugger.qrc @@ -14,6 +14,8 @@ <file>images/debugger_interrupt@2x.png</file> <file>images/debugger_interrupt_mask.png</file> <file>images/debugger_interrupt_mask@2x.png</file> + <file>images/debugger_stop.png</file> + <file>images/debugger_stop@2x.png</file> <file>images/debugger_stop_mask.png</file> <file>images/debugger_stop_mask@2x.png</file> <file>images/debugger_reversemode.png</file> diff --git a/src/plugins/debugger/debuggerconstants.h b/src/plugins/debugger/debuggerconstants.h index e0ddfff85cf..5c27458f471 100644 --- a/src/plugins/debugger/debuggerconstants.h +++ b/src/plugins/debugger/debuggerconstants.h @@ -33,82 +33,11 @@ namespace Constants { // Debug mode const char MODE_DEBUG[] = "Mode.Debug"; -// Contexts +// Debug mode context const char C_DEBUGMODE[] = "Debugger.DebugMode"; -const char C_CPPDEBUGGER[] = "Gdb Debugger"; -const char C_QMLDEBUGGER[] = "Qml/JavaScript Debugger"; -const char C_DEBUGGER_NOTRUNNING[] = "Debugger.NotRunning"; - -const char PRESET_PERSPECTIVE_ID[] = "Debugger.Perspective.Preset"; - -// Menu Groups -const char G_GENERAL[] = "Debugger.Group.General"; -const char G_SPECIAL[] = "Debugger.Group.Special"; -const char G_START_QML[] = "Debugger.Group.Start.Qml"; - -// Common actions -const char INTERRUPT[] = "Debugger.Interrupt"; -const char CONTINUE[] = "Debugger.Continue"; -const char STOP[] = "Debugger.Stop"; -const char ABORT[] = "Debugger.Abort"; -const char STEP[] = "Debugger.StepLine"; -const char STEPOUT[] = "Debugger.StepOut"; -const char NEXT[] = "Debugger.NextLine"; -const char RUNTOLINE[] = "Debugger.RunToLine"; -const char RUNTOSELECTEDFUNCTION[] = "Debugger.RunToSelectedFunction"; -const char JUMPTOLINE[] = "Debugger.JumpToLine"; -const char RETURNFROMFUNCTION[] = "Debugger.ReturnFromFunction"; -const char RESET[] = "Debugger.Reset"; -const char WATCH[] = "Debugger.AddToWatch"; -const char DETACH[] = "Debugger.Detach"; -const char OPERATE_BY_INSTRUCTION[] = "Debugger.OperateByInstruction"; -const char OPEN_MEMORY_EDITOR[] = "Debugger.Views.OpenMemoryEditor"; -const char FRAME_UP[] = "Debugger.FrameUp"; -const char FRAME_DOWN[] = "Debugger.FrameDown"; -const char QML_SHOW_APP_ON_TOP[] = "Debugger.QmlShowAppOnTop"; -const char QML_SELECTTOOL[] = "Debugger.QmlSelectTool"; - -const char TASK_CATEGORY_DEBUGGER_DEBUGINFO[] = "Debuginfo"; -const char TASK_CATEGORY_DEBUGGER_RUNTIME[] = "DebugRuntime"; - -const char TEXT_MARK_CATEGORY_BREAKPOINT[] = "Debugger.Mark.Breakpoint"; -const char TEXT_MARK_CATEGORY_LOCATION[] = "Debugger.Mark.Location"; - -// Run Configuration Aspect defaults: -const int QML_DEFAULT_DEBUG_SERVER_PORT = 3768; } // namespace Constants -enum DebuggerState -{ - DebuggerNotReady, // Debugger not started - - EngineSetupRequested, // Engine starts - EngineSetupFailed, - EngineSetupOk, - - EngineRunRequested, - EngineRunFailed, - - InferiorUnrunnable, // Used in the core dump adapter - - InferiorRunRequested, // Debuggee requested to run - InferiorRunOk, // Debuggee running - InferiorRunFailed, // Debuggee running - - InferiorStopRequested, // Debuggee running, stop requested - InferiorStopOk, // Debuggee stopped - InferiorStopFailed, // Debuggee not stopped, will kill debugger - - InferiorShutdownRequested, - InferiorShutdownFinished, - - EngineShutdownRequested, - EngineShutdownFinished, - - DebuggerFinished -}; - // Keep in sync with dumper.py enum DebuggerStartMode { diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp index 0e274e439d9..5fc852cf2c9 100644 --- a/src/plugins/debugger/debuggerdialogs.cpp +++ b/src/plugins/debugger/debuggerdialogs.cpp @@ -110,21 +110,21 @@ DebuggerKitChooser::DebuggerKitChooser(Mode mode, QWidget *parent) { setKitPredicate([this](const Kit *k) { // Match valid debuggers and restrict local debugging to compatible toolchains. - auto errors = DebuggerKitInformation::configurationErrors(k); + auto errors = DebuggerKitAspect::configurationErrors(k); // we do not care for mismatched ABI if we want *any* debugging - if (m_mode == AnyDebugging && errors == DebuggerKitInformation::DebuggerDoesNotMatch) - errors = DebuggerKitInformation::NoConfigurationError; + if (m_mode == AnyDebugging && errors == DebuggerKitAspect::DebuggerDoesNotMatch) + errors = DebuggerKitAspect::NoConfigurationError; if (errors) return false; if (m_mode == LocalDebugging) - return ToolChainKitInformation::targetAbi(k).os() == m_hostAbi.os(); + return ToolChainKitAspect::targetAbi(k).os() == m_hostAbi.os(); return true; }); } QString DebuggerKitChooser::kitToolTip(Kit *k) const { - return DebuggerKitInformation::displayString(k); + return DebuggerKitAspect::displayString(k); } /////////////////////////////////////////////////////////////////////// @@ -150,7 +150,7 @@ public: Runnable runnable; bool breakAtMain = false; bool runInTerminal = false; - QString serverStartScript; + FilePath serverStartScript; QString debugInfoLocation; }; @@ -172,7 +172,7 @@ QString StartApplicationParameters::displayName() const { const int maxLength = 60; - QString name = FileName::fromString(runnable.executable).fileName() + QString name = FilePath::fromString(runnable.executable).fileName() + ' ' + runnable.commandLineArguments; if (name.size() > 60) { int index = name.lastIndexOf(' ', maxLength); @@ -198,7 +198,7 @@ void StartApplicationParameters::toSettings(QSettings *settings) const settings->setValue("LastExternalWorkingDirectory", runnable.workingDirectory); settings->setValue("LastExternalBreakAtMain", breakAtMain); settings->setValue("LastExternalRunInTerminal", runInTerminal); - settings->setValue("LastServerStartScript", serverStartScript); + settings->setValue("LastServerStartScript", serverStartScript.toVariant()); settings->setValue("LastDebugInfoLocation", debugInfoLocation); } @@ -212,7 +212,7 @@ void StartApplicationParameters::fromSettings(const QSettings *settings) runnable.workingDirectory = settings->value("LastExternalWorkingDirectory").toString(); breakAtMain = settings->value("LastExternalBreakAtMain").toBool(); runInTerminal = settings->value("LastExternalRunInTerminal").toBool(); - serverStartScript = settings->value("LastServerStartScript").toString(); + serverStartScript = FilePath::fromVariant(settings->value("LastServerStartScript")); debugInfoLocation = settings->value("LastDebugInfoLocation").toString(); } @@ -229,9 +229,7 @@ StartApplicationDialog::StartApplicationDialog(QWidget *parent) setWindowTitle(tr("Start Debugger")); d->kitChooser = new KitChooser(this); - d->kitChooser->setKitPredicate([](const Kit *k) { - return !DebuggerKitInformation::configurationErrors(k); - }); + d->kitChooser->setShowIcons(true); d->kitChooser->populate(); d->serverPortLabel = new QLabel(tr("Server port:"), this); @@ -326,7 +324,7 @@ StartApplicationDialog::StartApplicationDialog(QWidget *parent) this, &StartApplicationDialog::updateState); connect(d->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(d->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); - connect(d->historyComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + connect(d->historyComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &StartApplicationDialog::historyIndexChanged); connect(d->channelOverrideEdit, &QLineEdit::textChanged, @@ -408,10 +406,10 @@ void StartApplicationDialog::run(bool attachRemote) return; Kit *k = dialog.d->kitChooser->currentKit(); - IDevice::ConstPtr dev = DeviceKitInformation::device(k); - auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); - auto debugger = new DebuggerRunTool(runControl, k); + auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); + runControl->setKit(k); + auto debugger = new DebuggerRunTool(runControl); const StartApplicationParameters newParameters = dialog.parameters(); if (newParameters != history.back()) { @@ -428,6 +426,7 @@ void StartApplicationDialog::run(bool attachRemote) settings->endGroup(); } + IDevice::ConstPtr dev = DeviceKitAspect::device(k); Runnable inferior = newParameters.runnable; const QString inputAddress = dialog.d->channelOverrideEdit->text(); if (!inputAddress.isEmpty()) @@ -474,7 +473,7 @@ StartApplicationParameters StartApplicationDialog::parameters() const result.serverPort = d->serverPortSpinBox->value(); result.serverAddress = d->channelOverrideEdit->text(); result.runnable.executable = d->localExecutablePathChooser->path(); - result.serverStartScript = d->serverStartScriptPathChooser->path(); + result.serverStartScript = d->serverStartScriptPathChooser->fileName(); result.kitId = d->kitChooser->currentKitId(); result.debugInfoLocation = d->debuginfoPathChooser->path(); result.runnable.commandLineArguments = d->arguments->text(); @@ -490,7 +489,7 @@ void StartApplicationDialog::setParameters(const StartApplicationParameters &p) d->serverPortSpinBox->setValue(p.serverPort); d->channelOverrideEdit->setText(p.serverAddress); d->localExecutablePathChooser->setPath(p.runnable.executable); - d->serverStartScriptPathChooser->setPath(p.serverStartScript); + d->serverStartScriptPathChooser->setFileName(p.serverStartScript); d->debuginfoPathChooser->setPath(p.debugInfoLocation); d->arguments->setText(p.runnable.commandLineArguments); d->workingDirectory->setPath(p.runnable.workingDirectory); diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index b86bb1088ec..6b94e5025d1 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -173,7 +173,7 @@ Location::Location(const StackFrame &frame, bool marker) } -LocationMark::LocationMark(DebuggerEngine *engine, const FileName &file, int line) +LocationMark::LocationMark(DebuggerEngine *engine, const FilePath &file, int line) : TextMark(file, line, Constants::TEXT_MARK_CATEGORY_LOCATION), m_engine(engine) { setPriority(TextMark::HighPriority); @@ -454,7 +454,6 @@ public: DebuggerEngine *m_engine = nullptr; // Not owned. QString m_runId; - QPointer<RunConfiguration> m_runConfiguration; // Not owned. QString m_debuggerName; QPointer<Perspective> m_perspective; DebuggerRunParameters m_runParameters; @@ -1010,7 +1009,6 @@ void DebuggerEngine::setRunId(const QString &id) void DebuggerEngine::setRunTool(DebuggerRunTool *runTool) { RunControl *runControl = runTool->runControl(); - d->m_runConfiguration = runControl->runConfiguration(); d->m_device = runControl->device(); if (!d->m_device) d->m_device = d->m_runParameters.inferior.device; @@ -1067,7 +1065,7 @@ void DebuggerEngine::gotoLocation(const Location &loc) editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true); if (loc.needsMarker()) { - d->m_locationMark.reset(new LocationMark(this, FileName::fromString(file), line)); + d->m_locationMark.reset(new LocationMark(this, FilePath::fromString(file), line)); d->m_locationMark->setToolTip(tr("Current debugger location of %1").arg(displayName())); } } @@ -1840,7 +1838,7 @@ QString DebuggerEngine::toFileInProject(const QUrl &fileUrl) d->m_fileFinder.setAdditionalSearchDirectories(rp.additionalSearchDirectories); d->m_fileFinder.setSysroot(rp.sysRoot); - return d->m_fileFinder.findFile(fileUrl); + return d->m_fileFinder.findFile(fileUrl).first().toString(); } QString DebuggerEngine::expand(const QString &string) const @@ -1998,11 +1996,6 @@ void DebuggerEngine::progressPing() d->m_progress.setProgressValue(progress); } -bool DebuggerEngine::isStartupRunConfiguration() const -{ - return d->m_runConfiguration == RunConfiguration::startupRunConfiguration(); -} - void DebuggerEngine::setCompanionEngine(DebuggerEngine *engine) { d->m_companionEngine = engine; @@ -2590,7 +2583,7 @@ QString DebuggerEngine::formatStartParameters() const if (!sp.projectSourceDirectory.isEmpty()) { str << "Project: " << sp.projectSourceDirectory.toUserOutput() << '\n'; str << "Additional Search Directories:"; - for (const FileName &dir : sp.additionalSearchDirectories) + for (const FilePath &dir : sp.additionalSearchDirectories) str << ' ' << dir; str << '\n'; } diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index 736d2b3c03f..78826dd5186 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -34,7 +34,7 @@ #include <coreplugin/icontext.h> #include <projectexplorer/devicesupport/idevice.h> -#include <projectexplorer/runconfiguration.h> +#include <projectexplorer/runcontrol.h> #include <texteditor/textmark.h> #include <utils/fileutils.h> @@ -56,6 +56,36 @@ namespace Debugger { class DebuggerRunTool; +enum DebuggerState +{ + DebuggerNotReady, // Debugger not started + + EngineSetupRequested, // Engine starts + EngineSetupFailed, + EngineSetupOk, + + EngineRunRequested, + EngineRunFailed, + + InferiorUnrunnable, // Used in the core dump adapter + + InferiorRunRequested, // Debuggee requested to run + InferiorRunOk, // Debuggee running + InferiorRunFailed, // Debuggee not running + + InferiorStopRequested, // Debuggee running, stop requested + InferiorStopOk, // Debuggee stopped + InferiorStopFailed, // Debuggee not stopped, will kill debugger + + InferiorShutdownRequested, + InferiorShutdownFinished, + + EngineShutdownRequested, + EngineShutdownFinished, + + DebuggerFinished +}; + DEBUGGER_EXPORT QDebug operator<<(QDebug str, DebuggerState state); namespace Internal { @@ -117,13 +147,13 @@ public: // Used by Android to avoid false positives on warnOnRelease bool skipExecutableValidation = false; bool useTargetAsync = false; - Utils::FileNameList additionalSearchDirectories; + Utils::FilePathList additionalSearchDirectories; // Used by iOS. QString platform; QString deviceSymbolsRoot; bool continueAfterAttach = false; - Utils::FileName sysRoot; + Utils::FilePath sysRoot; // Used by general core file debugging. Public access requested in QTCREATORBUG-17158. QString coreFile; @@ -147,8 +177,8 @@ public: bool isSnapshot = false; // Set if created internally. ProjectExplorer::Abi toolChainAbi; - Utils::FileName projectSourceDirectory; - Utils::FileNameList projectSourceFiles; + Utils::FilePath projectSourceDirectory; + Utils::FilePathList projectSourceFiles; // Used by Script debugging QString interpreter; @@ -237,7 +267,6 @@ public: QString runId() const; const DebuggerRunParameters &runParameters() const; - bool isStartupRunConfiguration() const; void setCompanionEngine(DebuggerEngine *engine); void setSecondaryEngine(); @@ -538,7 +567,7 @@ public: class LocationMark : public TextEditor::TextMark { public: - LocationMark(DebuggerEngine *engine, const Utils::FileName &file, int line); + LocationMark(DebuggerEngine *engine, const Utils::FilePath &file, int line); void removedFromEditor() override { updateLineNumber(0); } void updateIcon(); diff --git a/src/plugins/debugger/debuggericons.cpp b/src/plugins/debugger/debuggericons.cpp index 1c047acc2df..c50f5fdc621 100644 --- a/src/plugins/debugger/debuggericons.cpp +++ b/src/plugins/debugger/debuggericons.cpp @@ -66,8 +66,10 @@ const Icon INTERRUPT( const Icon INTERRUPT_FLAT({ {":/debugger/images/debugger_interrupt_mask.png", Theme::IconsInterruptToolBarColor}, {":/projectexplorer/images/debugger_beetle_mask.png", Theme::IconsDebugColor}}); +const Icon STOP( + ":/debugger/images/debugger_stop.png"); const Icon STOP_FLAT({ - {":/debugger/images/debugger_stop_mask.png", Theme::IconsStopColor}, + {":/debugger/images/debugger_stop_mask.png", Theme::IconsStopToolBarColor}, {":/projectexplorer/images/debugger_beetle_mask.png", Theme::IconsDebugColor}}); const Icon DEBUG_INTERRUPT_SMALL({ {":/utils/images/interrupt_small.png", Theme::IconsInterruptColor}, diff --git a/src/plugins/debugger/debuggericons.h b/src/plugins/debugger/debuggericons.h index 778fb4a33f1..b7d83f27ddf 100644 --- a/src/plugins/debugger/debuggericons.h +++ b/src/plugins/debugger/debuggericons.h @@ -50,6 +50,7 @@ extern const Utils::Icon DEBUG_CONTINUE_SMALL; extern const Utils::Icon DEBUG_CONTINUE_SMALL_TOOLBAR; extern const Utils::Icon INTERRUPT; extern const Utils::Icon INTERRUPT_FLAT; +extern const Utils::Icon STOP; extern const Utils::Icon STOP_FLAT; extern const Utils::Icon DEBUG_INTERRUPT_SMALL; extern const Utils::Icon DEBUG_INTERRUPT_SMALL_TOOLBAR; diff --git a/src/plugins/debugger/debuggerinternalconstants.h b/src/plugins/debugger/debuggerinternalconstants.h index 8f6599b6535..7137a9100c2 100644 --- a/src/plugins/debugger/debuggerinternalconstants.h +++ b/src/plugins/debugger/debuggerinternalconstants.h @@ -28,22 +28,50 @@ #include <QtGlobal> namespace Debugger { + namespace Constants { -const char DEBUGGER_COMMON_SETTINGS_ID[] = "A.Debugger.General"; -const char DEBUGGER_SETTINGS_CATEGORY[] = "O.Debugger"; +// Common actions +const char INTERRUPT[] = "Debugger.Interrupt"; +const char CONTINUE[] = "Debugger.Continue"; +const char STOP[] = "Debugger.Stop"; +const char ABORT[] = "Debugger.Abort"; +const char STEP[] = "Debugger.StepLine"; +const char STEPOUT[] = "Debugger.StepOut"; +const char NEXT[] = "Debugger.NextLine"; +const char RUNTOLINE[] = "Debugger.RunToLine"; +const char RUNTOSELECTEDFUNCTION[] = "Debugger.RunToSelectedFunction"; +const char JUMPTOLINE[] = "Debugger.JumpToLine"; +const char RETURNFROMFUNCTION[] = "Debugger.ReturnFromFunction"; +const char RESET[] = "Debugger.Reset"; +const char WATCH[] = "Debugger.AddToWatch"; +const char DETACH[] = "Debugger.Detach"; +const char OPERATE_BY_INSTRUCTION[] = "Debugger.OperateByInstruction"; +const char OPEN_MEMORY_EDITOR[] = "Debugger.Views.OpenMemoryEditor"; +const char FRAME_UP[] = "Debugger.FrameUp"; +const char FRAME_DOWN[] = "Debugger.FrameDown"; +const char QML_SHOW_APP_ON_TOP[] = "Debugger.QmlShowAppOnTop"; +const char QML_SELECTTOOL[] = "Debugger.QmlSelectTool"; + +const char DEBUGGER_COMMON_SETTINGS_ID[] = "A.Debugger.General"; +const char DEBUGGER_SETTINGS_CATEGORY[] = "O.Debugger"; + +// Contexts +const char C_CPPDEBUGGER[] = "Gdb Debugger"; +const char C_QMLDEBUGGER[] = "Qml/JavaScript Debugger"; +const char C_DEBUGGER_NOTRUNNING[] = "Debugger.NotRunning"; + +const char PRESET_PERSPECTIVE_ID[] = "Debugger.Perspective.Preset"; -namespace Internal { - enum { debug = 0 }; -} // namespace Internal +const char TASK_CATEGORY_DEBUGGER_DEBUGINFO[] = "Debuginfo"; +const char TASK_CATEGORY_DEBUGGER_RUNTIME[] = "DebugRuntime"; -const char OPENED_BY_DEBUGGER[] = "OpenedByDebugger"; -const char OPENED_WITH_DISASSEMBLY[] = "DisassemblerView"; -const char DISASSEMBLER_SOURCE_FILE[] = "DisassemblerSourceFile"; +const char TEXT_MARK_CATEGORY_BREAKPOINT[] = "Debugger.Mark.Breakpoint"; +const char TEXT_MARK_CATEGORY_LOCATION[] = "Debugger.Mark.Location"; -// Debug action -const char DEBUG[] = "Debugger.Debug"; -const int P_ACTION_DEBUG = 90; // Priority for the modemanager. +const char OPENED_BY_DEBUGGER[] = "OpenedByDebugger"; +const char OPENED_WITH_DISASSEMBLY[] = "DisassemblerView"; +const char DISASSEMBLER_SOURCE_FILE[] = "DisassemblerSourceFile"; } // namespace Constants diff --git a/src/plugins/debugger/debuggeritem.cpp b/src/plugins/debugger/debuggeritem.cpp index 2c889a016b7..c17766361c7 100644 --- a/src/plugins/debugger/debuggeritem.cpp +++ b/src/plugins/debugger/debuggeritem.cpp @@ -26,7 +26,6 @@ #include "debuggeritem.h" #include "debuggeritemmanager.h" #include "debuggerkitinformation.h" -#include "debuggerkitconfigwidget.h" #include "debuggerprotocol.h" #include <projectexplorer/abi.h> @@ -107,8 +106,8 @@ DebuggerItem::DebuggerItem(const QVariant &id) DebuggerItem::DebuggerItem(const QVariantMap &data) { m_id = data.value(DEBUGGER_INFORMATION_ID).toString(); - m_command = FileName::fromUserInput(data.value(DEBUGGER_INFORMATION_COMMAND).toString()); - m_workingDirectory = FileName::fromUserInput(data.value(DEBUGGER_INFORMATION_WORKINGDIRECTORY).toString()); + m_command = FilePath::fromUserInput(data.value(DEBUGGER_INFORMATION_COMMAND).toString()); + m_workingDirectory = FilePath::fromUserInput(data.value(DEBUGGER_INFORMATION_WORKINGDIRECTORY).toString()); m_unexpandedDisplayName = data.value(DEBUGGER_INFORMATION_DISPLAYNAME).toString(); m_isAutoDetected = data.value(DEBUGGER_INFORMATION_AUTODETECTED, false).toBool(); m_version = data.value(DEBUGGER_INFORMATION_VERSION).toString(); @@ -303,14 +302,14 @@ QString DebuggerItem::displayName() const return m_unexpandedDisplayName; MacroExpander expander; - expander.registerVariable("Debugger:Type", DebuggerKitInformation::tr("Type of Debugger Backend"), + expander.registerVariable("Debugger:Type", DebuggerKitAspect::tr("Type of Debugger Backend"), [this] { return engineTypeName(); }); - expander.registerVariable("Debugger:Version", DebuggerKitInformation::tr("Debugger"), + expander.registerVariable("Debugger:Version", DebuggerKitAspect::tr("Debugger"), [this] { return !m_version.isEmpty() ? m_version : - DebuggerKitInformation::tr("Unknown debugger version"); }); - expander.registerVariable("Debugger:Abi", DebuggerKitInformation::tr("Debugger"), + DebuggerKitAspect::tr("Unknown debugger version"); }); + expander.registerVariable("Debugger:Abi", DebuggerKitAspect::tr("Debugger"), [this] { return !m_abis.isEmpty() ? abiNames().join(' ') : - DebuggerKitInformation::tr("Unknown debugger ABI"); }); + DebuggerKitAspect::tr("Unknown debugger ABI"); }); return expander.expand(m_unexpandedDisplayName); } @@ -324,7 +323,7 @@ void DebuggerItem::setEngineType(const DebuggerEngineType &engineType) m_engineType = engineType; } -void DebuggerItem::setCommand(const FileName &command) +void DebuggerItem::setCommand(const FilePath &command) { m_command = command; } @@ -344,7 +343,7 @@ void DebuggerItem::setVersion(const QString &version) m_version = version; } -void DebuggerItem::setAbis(const QList<Abi> &abis) +void DebuggerItem::setAbis(const Abis &abis) { m_abis = abis; } diff --git a/src/plugins/debugger/debuggeritem.h b/src/plugins/debugger/debuggeritem.h index 20f141600b5..77e18bff466 100644 --- a/src/plugins/debugger/debuggeritem.h +++ b/src/plugins/debugger/debuggeritem.h @@ -72,8 +72,8 @@ public: DebuggerEngineType engineType() const { return m_engineType; } void setEngineType(const DebuggerEngineType &engineType); - Utils::FileName command() const { return m_command; } - void setCommand(const Utils::FileName &command); + Utils::FilePath command() const { return m_command; } + void setCommand(const Utils::FilePath &command); bool isAutoDetected() const { return m_isAutoDetected; } void setAutoDetected(bool isAutoDetected); @@ -81,8 +81,8 @@ public: QString version() const; void setVersion(const QString &version); - const QList<ProjectExplorer::Abi> &abis() const { return m_abis; } - void setAbis(const QList<ProjectExplorer::Abi> &abis); + const ProjectExplorer::Abis &abis() const { return m_abis; } + void setAbis(const ProjectExplorer::Abis &abis); void setAbi(const ProjectExplorer::Abi &abi); enum MatchLevel { DoesNotMatch, MatchesSomewhat, MatchesWell, MatchesPerfectly, MatchesPerfectlyInPath }; @@ -99,8 +99,8 @@ public: void reinitializeFromFile(); - Utils::FileName workingDirectory() const { return m_workingDirectory; } - void setWorkingDirectory(const Utils::FileName &workingPath) { m_workingDirectory = workingPath; } + Utils::FilePath workingDirectory() const { return m_workingDirectory; } + void setWorkingDirectory(const Utils::FilePath &workingPath) { m_workingDirectory = workingPath; } private: DebuggerItem(const QVariant &id); @@ -109,11 +109,11 @@ private: QVariant m_id; QString m_unexpandedDisplayName; DebuggerEngineType m_engineType = NoEngineType; - Utils::FileName m_command; - Utils::FileName m_workingDirectory; + Utils::FilePath m_command; + Utils::FilePath m_workingDirectory; bool m_isAutoDetected = false; QString m_version; - QList<ProjectExplorer::Abi> m_abis; + ProjectExplorer::Abis m_abis; QDateTime m_lastModified; friend class Internal::DebuggerConfigWidget; diff --git a/src/plugins/debugger/debuggeritemmanager.cpp b/src/plugins/debugger/debuggeritemmanager.cpp index 0b730cb971f..6d1e14cff85 100644 --- a/src/plugins/debugger/debuggeritemmanager.cpp +++ b/src/plugins/debugger/debuggeritemmanager.cpp @@ -71,7 +71,6 @@ namespace Internal { const char DEBUGGER_COUNT_KEY[] = "DebuggerItem.Count"; const char DEBUGGER_DATA_KEY[] = "DebuggerItem."; -const char DEBUGGER_LEGACY_FILENAME[] = "/profiles.xml"; const char DEBUGGER_FILE_VERSION_KEY[] = "Version"; const char DEBUGGER_FILENAME[] = "/debuggers.xml"; const char debuggingToolsWikiLinkC[] = "http://wiki.qt.io/Qt_Creator_Windows_Debugging"; @@ -90,10 +89,9 @@ public: void addDebugger(const DebuggerItem &item); QVariant registerDebugger(const DebuggerItem &item); - void readDebuggers(const FileName &fileName, bool isSystem); + void readDebuggers(const FilePath &fileName, bool isSystem); void autoDetectCdbDebuggers(); void autoDetectGdbOrLldbDebuggers(); - void readLegacyDebuggers(const FileName &file); QString uniqueDisplayName(const QString &base); PersistentSettingsWriter m_writer; @@ -352,7 +350,7 @@ DebuggerItem DebuggerItemConfigWidget::item() const item.setCommand(m_binaryChooser->fileName()); item.setWorkingDirectory(m_workingDirectoryChooser->fileName()); item.setAutoDetected(m_autodetected); - QList<ProjectExplorer::Abi> abiList; + ProjectExplorer::Abis abiList; foreach (const QString &a, m_abis->text().split(QRegExp("[^A-Za-z0-9-_]+"))) { if (a.isNull()) continue; @@ -626,7 +624,7 @@ void DebuggerOptionsPage::finish() void DebuggerItemManagerPrivate::autoDetectCdbDebuggers() { - FileNameList cdbs; + FilePathList cdbs; const QStringList programDirs = { QString::fromLocal8Bit(qgetenv("ProgramFiles")), @@ -655,8 +653,7 @@ void DebuggerItemManagerPrivate::autoDetectCdbDebuggers() // Pre Windows SDK 8: Check 'Debugging Tools for Windows' for (const QFileInfo &fi : dir.entryInfoList({"Debugging Tools for Windows*"}, QDir::Dirs | QDir::NoDotAndDotDot)) { - FileName filePath(fi); - filePath.appendPath("cdb.exe"); + const FilePath filePath = FilePath::fromFileInfo(fi).pathAppended("cdb.exe"); if (!cdbs.contains(filePath)) cdbs.append(filePath); } @@ -679,13 +676,13 @@ void DebuggerItemManagerPrivate::autoDetectCdbDebuggers() const QString path = kitFolderFi.absoluteFilePath(); const QFileInfo cdb32(path + "/Debuggers/x86/cdb.exe"); if (cdb32.isExecutable()) - cdbs.append(FileName::fromString(cdb32.absoluteFilePath())); + cdbs.append(FilePath::fromString(cdb32.absoluteFilePath())); const QFileInfo cdb64(path + "/Debuggers/x64/cdb.exe"); if (cdb64.isExecutable()) - cdbs.append(FileName::fromString(cdb64.absoluteFilePath())); + cdbs.append(FilePath::fromString(cdb64.absoluteFilePath())); } - for (const FileName &cdb : qAsConst(cdbs)) { + for (const FilePath &cdb : qAsConst(cdbs)) { if (DebuggerItemManager::findByCommand(cdb)) continue; DebuggerItem item; @@ -724,7 +721,7 @@ void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers() } */ - FileNameList suspects; + FilePathList suspects; if (HostOsInfo::isMacHost()) { SynchronousProcess lldbInfo; @@ -736,23 +733,23 @@ void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers() if (!lPath.isEmpty()) { const QFileInfo fi(lPath); if (fi.exists() && fi.isExecutable() && !fi.isDir()) - suspects.append(FileName::fromString(fi.absoluteFilePath())); + suspects.append(FilePath::fromString(fi.absoluteFilePath())); } } } - Utils::FileNameList path = Environment::systemEnvironment().path(); + Utils::FilePathList path = Environment::systemEnvironment().path(); path = Utils::filteredUnique(path); QDir dir; dir.setNameFilters(filters); dir.setFilter(QDir::Files | QDir::Executable); - foreach (const Utils::FileName &base, path) { + foreach (const Utils::FilePath &base, path) { dir.setPath(base.toFileInfo().absoluteFilePath()); foreach (const QString &entry, dir.entryList()) - suspects.append(FileName::fromString(dir.absoluteFilePath(entry))); + suspects.append(FilePath::fromString(dir.absoluteFilePath(entry))); } - foreach (const FileName &command, suspects) { + foreach (const FilePath &command, suspects) { const auto commandMatches = [command](const DebuggerTreeItem *titem) { return titem->m_item.command() == command; }; @@ -775,46 +772,9 @@ void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers() } } -void DebuggerItemManagerPrivate::readLegacyDebuggers(const FileName &file) +static FilePath userSettingsFileName() { - PersistentSettingsReader reader; - if (!reader.load(file)) - return; - - foreach (const QVariant &v, reader.restoreValues()) { - QVariantMap data1 = v.toMap(); - QString kitName = data1.value("PE.Profile.Name").toString(); - QVariantMap data2 = data1.value("PE.Profile.Data").toMap(); - QVariant v3 = data2.value(DebuggerKitInformation::id().toString()); - QString fn; - if (v3.type() == QVariant::String) - fn = v3.toString(); - else - fn = v3.toMap().value("Binary").toString(); - if (fn.isEmpty()) - continue; - if (fn.startsWith('{')) - continue; - if (fn == "auto") - continue; - FileName command = FileName::fromUserInput(fn); - if (!command.exists()) - continue; - if (DebuggerItemManager::findByCommand(command)) - continue; - DebuggerItem item; - item.createId(); - item.setCommand(command); - item.setAutoDetected(true); - item.reinitializeFromFile(); - item.setUnexpandedDisplayName(tr("Extracted from Kit %1").arg(kitName)); - m_model->addDebugger(item); - } -} - -static FileName userSettingsFileName() -{ - return FileName::fromString(ICore::userResourcePath() + DEBUGGER_FILENAME); + return FilePath::fromString(ICore::userResourcePath() + DEBUGGER_FILENAME); } DebuggerItemManagerPrivate::DebuggerItemManagerPrivate() @@ -865,7 +825,7 @@ QVariant DebuggerItemManagerPrivate::registerDebugger(const DebuggerItem &item) return di.id(); } -void DebuggerItemManagerPrivate::readDebuggers(const FileName &fileName, bool isSystem) +void DebuggerItemManagerPrivate::readDebuggers(const FilePath &fileName, bool isSystem) { PersistentSettingsReader reader; if (!reader.load(fileName)) @@ -910,7 +870,7 @@ void DebuggerItemManagerPrivate::readDebuggers(const FileName &fileName, bool is void DebuggerItemManagerPrivate::restoreDebuggers() { // Read debuggers from SDK - readDebuggers(FileName::fromString(ICore::installerResourcePath() + DEBUGGER_FILENAME), true); + readDebuggers(FilePath::fromString(ICore::installerResourcePath() + DEBUGGER_FILENAME), true); // Read all debuggers from user file. readDebuggers(userSettingsFileName(), false); @@ -918,10 +878,6 @@ void DebuggerItemManagerPrivate::restoreDebuggers() // Auto detect current. autoDetectCdbDebuggers(); autoDetectGdbOrLldbDebuggers(); - - // Add debuggers from pre-3.x profiles.xml - readLegacyDebuggers(FileName::fromString(ICore::installerResourcePath() + DEBUGGER_LEGACY_FILENAME)); - readLegacyDebuggers(FileName::fromString(ICore::userResourcePath() + DEBUGGER_LEGACY_FILENAME)); } void DebuggerItemManagerPrivate::saveDebuggers() @@ -970,7 +926,7 @@ const QList<DebuggerItem> DebuggerItemManager::debuggers() return result; } -const DebuggerItem *DebuggerItemManager::findByCommand(const FileName &command) +const DebuggerItem *DebuggerItemManager::findByCommand(const FilePath &command) { return findDebugger([command](const DebuggerItem &item) { return item.command() == command; diff --git a/src/plugins/debugger/debuggeritemmanager.h b/src/plugins/debugger/debuggeritemmanager.h index ec2d74c9288..1b2c21e052e 100644 --- a/src/plugins/debugger/debuggeritemmanager.h +++ b/src/plugins/debugger/debuggeritemmanager.h @@ -33,7 +33,7 @@ #include <QString> #include <QCoreApplication> -namespace Utils { class FileName; } +namespace Utils { class FilePath; } namespace Debugger { @@ -52,7 +52,7 @@ public: static QVariant registerDebugger(const DebuggerItem &item); static void deregisterDebugger(const QVariant &id); - static const DebuggerItem *findByCommand(const Utils::FileName &command); + static const DebuggerItem *findByCommand(const Utils::FilePath &command); static const DebuggerItem *findById(const QVariant &id); static const DebuggerItem *findByEngineType(DebuggerEngineType engineType); }; diff --git a/src/plugins/debugger/debuggerkitconfigwidget.cpp b/src/plugins/debugger/debuggerkitconfigwidget.cpp deleted file mode 100644 index d95a2861ac5..00000000000 --- a/src/plugins/debugger/debuggerkitconfigwidget.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "debuggerkitconfigwidget.h" - -#include "debuggeritemmanager.h" -#include "debuggeritem.h" -#include "debuggerkitinformation.h" - -#include <coreplugin/icore.h> - -#include <projectexplorer/abi.h> -#include <projectexplorer/projectexplorerconstants.h> -#include <projectexplorer/toolchain.h> -#include <projectexplorer/toolchainmanager.h> - -#include <utils/elidinglabel.h> -#include <utils/environment.h> -#include <utils/pathchooser.h> -#include <utils/persistentsettings.h> -#include <utils/qtcassert.h> - -#include <QApplication> -#include <QComboBox> -#include <QDirIterator> -#include <QFileInfo> -#include <QFormLayout> -#include <QHeaderView> -#include <QLineEdit> -#include <QPushButton> -#include <QStandardItem> -#include <QStandardItemModel> -#include <QUuid> - -using namespace ProjectExplorer; - -namespace Debugger { -namespace Internal { - -// ----------------------------------------------------------------------- -// DebuggerKitConfigWidget -// ----------------------------------------------------------------------- - -DebuggerKitConfigWidget::DebuggerKitConfigWidget(Kit *workingCopy, const KitInformation *ki) - : KitConfigWidget(workingCopy, ki) -{ - m_comboBox = new QComboBox; - m_comboBox->setSizePolicy(QSizePolicy::Ignored, m_comboBox->sizePolicy().verticalPolicy()); - m_comboBox->setEnabled(true); - - refresh(); - connect(m_comboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), - this, &DebuggerKitConfigWidget::currentDebuggerChanged); - - m_manageButton = new QPushButton(KitConfigWidget::msgManage()); - m_manageButton->setContentsMargins(0, 0, 0, 0); - connect(m_manageButton, &QAbstractButton::clicked, - this, &DebuggerKitConfigWidget::manageDebuggers); -} - -DebuggerKitConfigWidget::~DebuggerKitConfigWidget() -{ - delete m_comboBox; - delete m_manageButton; -} - -QString DebuggerKitConfigWidget::toolTip() const -{ - return tr("The debugger to use for this kit."); -} - -QString DebuggerKitConfigWidget::displayName() const -{ - return tr("Debugger"); -} - -void DebuggerKitConfigWidget::makeReadOnly() -{ - m_manageButton->setEnabled(false); - m_comboBox->setEnabled(false); -} - -void DebuggerKitConfigWidget::refresh() -{ - m_ignoreChanges = true; - m_comboBox->clear(); - m_comboBox->setToolTip(toolTip()); - m_comboBox->addItem(tr("None"), QString()); - for (const DebuggerItem &item : DebuggerItemManager::debuggers()) - m_comboBox->addItem(item.displayName(), item.id()); - - const DebuggerItem *item = DebuggerKitInformation::debugger(m_kit); - updateComboBox(item ? item->id() : QVariant()); - m_ignoreChanges = false; -} - -QWidget *DebuggerKitConfigWidget::buttonWidget() const -{ - return m_manageButton; -} - -QWidget *DebuggerKitConfigWidget::mainWidget() const -{ - return m_comboBox; -} - -void DebuggerKitConfigWidget::manageDebuggers() -{ - Core::ICore::showOptionsDialog(ProjectExplorer::Constants::DEBUGGER_SETTINGS_PAGE_ID, - buttonWidget()); -} - -void DebuggerKitConfigWidget::currentDebuggerChanged(int) -{ - if (m_ignoreChanges) - return; - - int currentIndex = m_comboBox->currentIndex(); - QVariant id = m_comboBox->itemData(currentIndex); - m_kit->setValue(DebuggerKitInformation::id(), id); -} - -QVariant DebuggerKitConfigWidget::currentId() const -{ - return m_comboBox->itemData(m_comboBox->currentIndex()); -} - -void DebuggerKitConfigWidget::updateComboBox(const QVariant &id) -{ - for (int i = 0; i < m_comboBox->count(); ++i) { - if (id == m_comboBox->itemData(i)) { - m_comboBox->setCurrentIndex(i); - return; - } - } - m_comboBox->setCurrentIndex(0); -} - -} // namespace Internal -} // namespace Debugger diff --git a/src/plugins/debugger/debuggerkitconfigwidget.h b/src/plugins/debugger/debuggerkitconfigwidget.h deleted file mode 100644 index e424481bef8..00000000000 --- a/src/plugins/debugger/debuggerkitconfigwidget.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include <coreplugin/dialogs/ioptionspage.h> -#include <projectexplorer/kitconfigwidget.h> -#include <projectexplorer/abi.h> -#include <utils/detailswidget.h> -#include <utils/fileutils.h> -#include <utils/pathchooser.h> - -#include <QDialog> -#include <QStandardItemModel> - -QT_BEGIN_NAMESPACE -class QComboBox; -class QLabel; -class QPushButton; -QT_END_NAMESPACE - -namespace Debugger { -namespace Internal { - -// ----------------------------------------------------------------------- -// DebuggerKitConfigWidget -// ----------------------------------------------------------------------- - -class DebuggerKitConfigWidget : public ProjectExplorer::KitConfigWidget -{ - Q_OBJECT - -public: - DebuggerKitConfigWidget(ProjectExplorer::Kit *workingCopy, - const ProjectExplorer::KitInformation *ki); - ~DebuggerKitConfigWidget() override; - - QString displayName() const override; - QString toolTip() const override; - void makeReadOnly() override; - void refresh() override; - QWidget *buttonWidget() const override; - QWidget *mainWidget() const override; - -private: - void manageDebuggers(); - void currentDebuggerChanged(int idx); - - QVariant currentId() const; - void updateComboBox(const QVariant &id); - - bool m_isReadOnly; - bool m_ignoreChanges = false; - QComboBox *m_comboBox; - QPushButton *m_manageButton; -}; - -} // namespace Internal -} // namespace Debugger diff --git a/src/plugins/debugger/debuggerkitinformation.cpp b/src/plugins/debugger/debuggerkitinformation.cpp index ccf6009d271..412d54b33cd 100644 --- a/src/plugins/debugger/debuggerkitinformation.cpp +++ b/src/plugins/debugger/debuggerkitinformation.cpp @@ -27,17 +27,21 @@ #include "debuggeritemmanager.h" #include "debuggeritem.h" -#include "debuggerkitconfigwidget.h" + +#include <coreplugin/icore.h> #include <projectexplorer/toolchain.h> #include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/runcontrol.h> #include <utils/environment.h> #include <utils/fileutils.h> #include <utils/macroexpander.h> #include <utils/qtcassert.h> +#include <QComboBox> #include <QFileInfo> +#include <QPushButton> #include <utility> using namespace ProjectExplorer; @@ -46,19 +50,109 @@ using namespace Utils; namespace Debugger { // -------------------------------------------------------------------------- -// DebuggerKitInformation +// DebuggerKitAspect // -------------------------------------------------------------------------- -DebuggerKitInformation::DebuggerKitInformation() +namespace Internal { + +class DebuggerKitAspectWidget : public KitAspectWidget +{ + Q_DECLARE_TR_FUNCTIONS(Debugger::DebuggerKitAspect) + +public: + DebuggerKitAspectWidget(Kit *workingCopy, const KitAspect *ki) + : KitAspectWidget(workingCopy, ki) + { + m_comboBox = new QComboBox; + m_comboBox->setSizePolicy(QSizePolicy::Ignored, m_comboBox->sizePolicy().verticalPolicy()); + m_comboBox->setEnabled(true); + + refresh(); + m_comboBox->setToolTip(ki->description()); + connect(m_comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), + this, &DebuggerKitAspectWidget::currentDebuggerChanged); + + m_manageButton = new QPushButton(KitAspectWidget::msgManage()); + m_manageButton->setContentsMargins(0, 0, 0, 0); + connect(m_manageButton, &QAbstractButton::clicked, + this, &DebuggerKitAspectWidget::manageDebuggers); + } + + ~DebuggerKitAspectWidget() override + { + delete m_comboBox; + delete m_manageButton; + } + +private: + QWidget *buttonWidget() const override { return m_manageButton; } + QWidget *mainWidget() const override { return m_comboBox; } + + void makeReadOnly() override + { + m_manageButton->setEnabled(false); + m_comboBox->setEnabled(false); + } + + void refresh() override + { + m_ignoreChanges = true; + m_comboBox->clear(); + m_comboBox->addItem(tr("None"), QString()); + for (const DebuggerItem &item : DebuggerItemManager::debuggers()) + m_comboBox->addItem(item.displayName(), item.id()); + + const DebuggerItem *item = DebuggerKitAspect::debugger(m_kit); + updateComboBox(item ? item->id() : QVariant()); + m_ignoreChanges = false; + } + + void manageDebuggers() + { + Core::ICore::showOptionsDialog(ProjectExplorer::Constants::DEBUGGER_SETTINGS_PAGE_ID, + buttonWidget()); + } + + void currentDebuggerChanged(int idx) + { + Q_UNUSED(idx); + if (m_ignoreChanges) + return; + + int currentIndex = m_comboBox->currentIndex(); + QVariant id = m_comboBox->itemData(currentIndex); + m_kit->setValue(DebuggerKitAspect::id(), id); + } + + QVariant currentId() const { return m_comboBox->itemData(m_comboBox->currentIndex()); } + + void updateComboBox(const QVariant &id) + { + for (int i = 0; i < m_comboBox->count(); ++i) { + if (id == m_comboBox->itemData(i)) { + m_comboBox->setCurrentIndex(i); + return; + } + } + m_comboBox->setCurrentIndex(0); + } + + bool m_ignoreChanges = false; + QComboBox *m_comboBox; + QPushButton *m_manageButton; +}; +} // namespace Internal + +DebuggerKitAspect::DebuggerKitAspect() { - setObjectName("DebuggerKitInformation"); - setId(DebuggerKitInformation::id()); + setObjectName("DebuggerKitAspect"); + setId(DebuggerKitAspect::id()); + setDisplayName(tr("Debugger")); + setDescription(tr("The debugger to use for this kit.")); setPriority(28000); } -QVariant DebuggerKitInformation::defaultValue(const Kit *) const { return QVariant(); } - -void DebuggerKitInformation::setup(Kit *k) +void DebuggerKitAspect::setup(Kit *k) { QTC_ASSERT(k, return); @@ -75,9 +169,9 @@ void DebuggerKitInformation::setup(Kit *k) // <value type="QString" key="Binary">auto</value> // <value type="int" key="EngineType">4</value> // </valuemap> - const QVariant rawId = k->value(DebuggerKitInformation::id()); + const QVariant rawId = k->value(DebuggerKitAspect::id()); - const Abi tcAbi = ToolChainKitInformation::targetAbi(k); + const Abi tcAbi = ToolChainKitAspect::targetAbi(k); // Get the best of the available debugger matching the kit's toolchain. // The general idea is to find an item that exactly matches what @@ -124,7 +218,7 @@ void DebuggerKitInformation::setup(Kit *k) } } else { // We have an executable path. - FileName fileName = FileName::fromUserInput(binary); + FilePath fileName = FilePath::fromUserInput(binary); if (item.command() == fileName) { // And it's is the path of this item. level = std::min(item.matchTarget(tcAbi), DebuggerItem::MatchesSomewhat); @@ -143,17 +237,17 @@ void DebuggerKitInformation::setup(Kit *k) } // Use the best id we found, or an invalid one. - k->setValue(DebuggerKitInformation::id(), bestLevel != DebuggerItem::DoesNotMatch ? bestItem.id() : QVariant()); + k->setValue(DebuggerKitAspect::id(), bestLevel != DebuggerItem::DoesNotMatch ? bestItem.id() : QVariant()); } // This handles the upgrade path from 2.8 to 3.0 -void DebuggerKitInformation::fix(Kit *k) +void DebuggerKitAspect::fix(Kit *k) { QTC_ASSERT(k, return); // This can be Id, binary path, but not "auto" anymore. - const QVariant rawId = k->value(DebuggerKitInformation::id()); + const QVariant rawId = k->value(DebuggerKitAspect::id()); if (rawId.isNull()) // No debugger set, that is fine. return; @@ -162,7 +256,7 @@ void DebuggerKitInformation::fix(Kit *k) if (!DebuggerItemManager::findById(rawId)) { qWarning("Unknown debugger id %s in kit %s", qPrintable(rawId.toString()), qPrintable(k->displayName())); - k->setValue(DebuggerKitInformation::id(), QVariant()); + k->setValue(DebuggerKitAspect::id(), QVariant()); } return; // All fine (now). } @@ -172,30 +266,30 @@ void DebuggerKitInformation::fix(Kit *k) if (binary == "auto") { // This should not happen as "auto" is handled by setup() already. QTC_CHECK(false); - k->setValue(DebuggerKitInformation::id(), QVariant()); + k->setValue(DebuggerKitAspect::id(), QVariant()); return; } - FileName fileName = FileName::fromUserInput(binary); + FilePath fileName = FilePath::fromUserInput(binary); const DebuggerItem *item = DebuggerItemManager::findByCommand(fileName); if (!item) { qWarning("Debugger command %s invalid in kit %s", qPrintable(binary), qPrintable(k->displayName())); - k->setValue(DebuggerKitInformation::id(), QVariant()); + k->setValue(DebuggerKitAspect::id(), QVariant()); return; } - k->setValue(DebuggerKitInformation::id(), item->id()); + k->setValue(DebuggerKitAspect::id(), item->id()); } // Check the configuration errors and return a flag mask. Provide a quick check and // a verbose one with a list of errors. -DebuggerKitInformation::ConfigurationErrors DebuggerKitInformation::configurationErrors(const Kit *k) +DebuggerKitAspect::ConfigurationErrors DebuggerKitAspect::configurationErrors(const Kit *k) { QTC_ASSERT(k, return NoDebugger); - const DebuggerItem *item = DebuggerKitInformation::debugger(k); + const DebuggerItem *item = DebuggerKitAspect::debugger(k); if (!item) return NoDebugger; @@ -209,10 +303,10 @@ DebuggerKitInformation::ConfigurationErrors DebuggerKitInformation::configuratio else if (!fi.isExecutable()) result |= DebuggerNotExecutable; - const Abi tcAbi = ToolChainKitInformation::targetAbi(k); + const Abi tcAbi = ToolChainKitAspect::targetAbi(k); if (item->matchTarget(tcAbi) == DebuggerItem::DoesNotMatch) { // currently restricting the check to desktop devices, may be extended to all device types - const IDevice::ConstPtr device = DeviceKitInformation::device(k); + const IDevice::ConstPtr device = DeviceKitAspect::device(k); if (device && device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) result |= DebuggerDoesNotMatch; } @@ -230,14 +324,14 @@ DebuggerKitInformation::ConfigurationErrors DebuggerKitInformation::configuratio return result; } -const DebuggerItem *DebuggerKitInformation::debugger(const Kit *kit) +const DebuggerItem *DebuggerKitAspect::debugger(const Kit *kit) { QTC_ASSERT(kit, return nullptr); - const QVariant id = kit->value(DebuggerKitInformation::id()); + const QVariant id = kit->value(DebuggerKitAspect::id()); return DebuggerItemManager::findById(id); } -Runnable DebuggerKitInformation::runnable(const Kit *kit) +Runnable DebuggerKitAspect::runnable(const Kit *kit) { Runnable runnable; if (const DebuggerItem *item = debugger(kit)) { @@ -249,9 +343,9 @@ Runnable DebuggerKitInformation::runnable(const Kit *kit) return runnable; } -QList<Task> DebuggerKitInformation::validateDebugger(const Kit *k) +Tasks DebuggerKitAspect::validateDebugger(const Kit *k) { - QList<Task> result; + Tasks result; const ConfigurationErrors errors = configurationErrors(k); if (errors == NoConfigurationError) @@ -263,35 +357,35 @@ QList<Task> DebuggerKitInformation::validateDebugger(const Kit *k) const Core::Id id = ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM; if (errors & NoDebugger) - result << Task(Task::Warning, tr("No debugger set up."), FileName(), -1, id); + result << Task(Task::Warning, tr("No debugger set up."), FilePath(), -1, id); if (errors & DebuggerNotFound) result << Task(Task::Error, tr("Debugger \"%1\" not found.").arg(path), - FileName(), -1, id); + FilePath(), -1, id); if (errors & DebuggerNotExecutable) - result << Task(Task::Error, tr("Debugger \"%1\" not executable.").arg(path), FileName(), -1, id); + result << Task(Task::Error, tr("Debugger \"%1\" not executable.").arg(path), FilePath(), -1, id); if (errors & DebuggerNeedsAbsolutePath) { const QString message = tr("The debugger location must be given as an " "absolute path (%1).").arg(path); - result << Task(Task::Error, message, FileName(), -1, id); + result << Task(Task::Error, message, FilePath(), -1, id); } if (errors & DebuggerDoesNotMatch) { const QString message = tr("The ABI of the selected debugger does not " "match the toolchain ABI."); - result << Task(Task::Warning, message, FileName(), -1, id); + result << Task(Task::Warning, message, FilePath(), -1, id); } return result; } -KitConfigWidget *DebuggerKitInformation::createConfigWidget(Kit *k) const +KitAspectWidget *DebuggerKitAspect::createConfigWidget(Kit *k) const { - return new Internal::DebuggerKitConfigWidget(k, this); + return new Internal::DebuggerKitAspectWidget(k, this); } -void DebuggerKitInformation::addToMacroExpander(Kit *kit, MacroExpander *expander) const +void DebuggerKitAspect::addToMacroExpander(Kit *kit, MacroExpander *expander) const { QTC_ASSERT(kit, return); expander->registerVariable("Debugger:Name", tr("Name of Debugger"), @@ -322,19 +416,19 @@ void DebuggerKitInformation::addToMacroExpander(Kit *kit, MacroExpander *expande }); } -KitInformation::ItemList DebuggerKitInformation::toUserOutput(const Kit *k) const +KitAspect::ItemList DebuggerKitAspect::toUserOutput(const Kit *k) const { - return ItemList() << qMakePair(tr("Debugger"), displayString(k)); + return {{tr("Debugger"), displayString(k)}}; } -DebuggerEngineType DebuggerKitInformation::engineType(const Kit *k) +DebuggerEngineType DebuggerKitAspect::engineType(const Kit *k) { const DebuggerItem *item = debugger(k); QTC_ASSERT(item, return NoEngineType); return item->engineType(); } -QString DebuggerKitInformation::displayString(const Kit *k) +QString DebuggerKitAspect::displayString(const Kit *k) { const DebuggerItem *item = debugger(k); if (!item) @@ -344,15 +438,15 @@ QString DebuggerKitInformation::displayString(const Kit *k) return binary.isEmpty() ? tr("%1 <None>").arg(name) : tr("%1 using \"%2\"").arg(name, binary); } -void DebuggerKitInformation::setDebugger(Kit *k, const QVariant &id) +void DebuggerKitAspect::setDebugger(Kit *k, const QVariant &id) { // Only register reasonably complete debuggers. QTC_ASSERT(DebuggerItemManager::findById(id), return); QTC_ASSERT(k, return); - k->setValue(DebuggerKitInformation::id(), id); + k->setValue(DebuggerKitAspect::id(), id); } -Core::Id DebuggerKitInformation::id() +Core::Id DebuggerKitAspect::id() { return "Debugger.Information"; } diff --git a/src/plugins/debugger/debuggerkitinformation.h b/src/plugins/debugger/debuggerkitinformation.h index 035f00dedf6..3e5bfba1bba 100644 --- a/src/plugins/debugger/debuggerkitinformation.h +++ b/src/plugins/debugger/debuggerkitinformation.h @@ -34,17 +34,15 @@ namespace Debugger { class DebuggerItem; -class DEBUGGER_EXPORT DebuggerKitInformation : public ProjectExplorer::KitInformation +class DEBUGGER_EXPORT DebuggerKitAspect : public ProjectExplorer::KitAspect { Q_OBJECT public: - DebuggerKitInformation(); + DebuggerKitAspect(); - QVariant defaultValue(const ProjectExplorer::Kit *k) const override; - - QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const override - { return DebuggerKitInformation::validateDebugger(k); } + ProjectExplorer::Tasks validate(const ProjectExplorer::Kit *k) const override + { return DebuggerKitAspect::validateDebugger(k); } void setup(ProjectExplorer::Kit *k) override; void fix(ProjectExplorer::Kit *k) override; @@ -63,10 +61,10 @@ public: }; Q_DECLARE_FLAGS(ConfigurationErrors, ConfigurationError) - static QList<ProjectExplorer::Task> validateDebugger(const ProjectExplorer::Kit *k); + static ProjectExplorer::Tasks validateDebugger(const ProjectExplorer::Kit *k); static ConfigurationErrors configurationErrors(const ProjectExplorer::Kit *k); - ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const override; + ProjectExplorer::KitAspectWidget *createConfigWidget(ProjectExplorer::Kit *k) const override; void addToMacroExpander(ProjectExplorer::Kit *kit, Utils::MacroExpander *expander) const override; ItemList toUserOutput(const ProjectExplorer::Kit *k) const override; diff --git a/src/plugins/debugger/debuggermainwindow.cpp b/src/plugins/debugger/debuggermainwindow.cpp index 598344bb25f..82bb009cc2d 100644 --- a/src/plugins/debugger/debuggermainwindow.cpp +++ b/src/plugins/debugger/debuggermainwindow.cpp @@ -161,6 +161,9 @@ public: QList<QPointer<Perspective>> m_perspectives; QSet<QString> m_persistentChangedDocks; + + QHash<QString, QByteArray> m_lastPerspectiveStates; + QHash<QString, QByteArray> m_lastTypePerspectiveStates; }; DebuggerMainWindowPrivate::DebuggerMainWindowPrivate(DebuggerMainWindow *parent) @@ -169,14 +172,14 @@ DebuggerMainWindowPrivate::DebuggerMainWindowPrivate(DebuggerMainWindow *parent) m_centralWidgetStack = new QStackedWidget; m_statusLabel = new Utils::StatusLabel; m_statusLabel->setProperty("panelwidget", true); - m_statusLabel->setIndent(2 * QFontMetrics(q->font()).width(QChar('x'))); + m_statusLabel->setIndent(2 * QFontMetrics(q->font()).horizontalAdvance(QChar('x'))); m_editorPlaceHolder = new EditorManagerPlaceHolder; m_perspectiveChooser = new QComboBox; m_perspectiveChooser->setObjectName("PerspectiveChooser"); m_perspectiveChooser->setProperty("panelwidget", true); m_perspectiveChooser->setSizeAdjustPolicy(QComboBox::AdjustToContents); - connect(m_perspectiveChooser, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), + connect(m_perspectiveChooser, QOverload<int>::of(&QComboBox::activated), this, [this](int item) { Perspective *perspective = Perspective::findPerspective(m_perspectiveChooser->itemData(item).toString()); QTC_ASSERT(perspective, return); @@ -285,13 +288,12 @@ DebuggerMainWindow::DebuggerMainWindow() cmd->setAttribute(Command::CA_Hide); viewsMenu->addAction(cmd, Core::Constants::G_DEFAULT_THREE); - connect(ICore::instance(), &ICore::saveSettingsRequested, this, [this] { + connect(ICore::instance(), &ICore::saveSettingsRequested, this, + [this](ICore::SaveSettingsReason reason) { // There's one saveSettings triggered after plugin loading intentionally. // We do not want to save anything at that time. - static bool firstOne = true; - if (firstOne) { + if (reason == ICore::InitializationDone) { qCDebug(perspectivesLog) << "FIRST SAVE SETTINGS REQUEST IGNORED"; - firstOne = false; } else { qCDebug(perspectivesLog) << "SAVING SETTINGS"; savePersistentSettings(); @@ -431,10 +433,11 @@ void DebuggerMainWindow::restorePersistentSettings() qCDebug(perspectivesLog) << "RESTORE PERSISTENT"; QSettings *settings = ICore::settings(); settings->beginGroup(MAINWINDOW_KEY); - const bool res = theMainWindow->restoreState(settings->value(STATE_KEY).toByteArray(), - SettingsVersion); - if (!res) - qCDebug(perspectivesLog) << "NO READABLE PERSISTENT SETTINGS FOUND, ASSUMING NEW CLEAN SETTINGS"; + + const QHash<QString, QVariant> states = settings->value(STATE_KEY).toHash(); + theMainWindow->d->m_lastTypePerspectiveStates.clear(); + for (const QString &type : states.keys()) + theMainWindow->d->m_lastTypePerspectiveStates.insert(type, states.value(type).toByteArray()); theMainWindow->setAutoHideTitleBars(settings->value(AUTOHIDE_TITLEBARS_KEY, true).toBool()); theMainWindow->showCentralWidget(settings->value(SHOW_CENTRALWIDGET_KEY, true).toBool()); @@ -497,10 +500,14 @@ void DebuggerMainWindow::savePersistentSettings() theMainWindow->d->m_persistentChangedDocks = changedDocks; qCDebug(perspectivesLog) << "CHANGED DOCKS:" << changedDocks; + QVariantHash states; + for (const QString &type : theMainWindow->d->m_lastTypePerspectiveStates.keys()) + states.insert(type, QVariant::fromValue(theMainWindow->d->m_lastTypePerspectiveStates.value(type))); + QSettings *settings = ICore::settings(); settings->beginGroup(MAINWINDOW_KEY); settings->setValue(CHANGED_DOCK_KEY, QStringList(changedDocks.toList())); - settings->setValue(STATE_KEY, theMainWindow->saveState(SettingsVersion)); + settings->setValue(STATE_KEY, states); settings->setValue(AUTOHIDE_TITLEBARS_KEY, theMainWindow->autoHideTitleBars()); settings->setValue(SHOW_CENTRALWIDGET_KEY, theMainWindow->isCentralWidgetShown()); settings->endGroup(); @@ -634,7 +641,8 @@ void DebuggerMainWindowPrivate::updatePerspectiveChooserWidth() if (index != -1) { m_perspectiveChooser->setCurrentIndex(index); - const int contentWidth = m_perspectiveChooser->fontMetrics().width(perspective->d->m_name); + const int contentWidth = + m_perspectiveChooser->fontMetrics().horizontalAdvance(perspective->d->m_name); QStyleOptionComboBox option; option.initFrom(m_perspectiveChooser); const QSize sz(contentWidth, 1); @@ -940,6 +948,13 @@ void PerspectivePrivate::restoreLayout() << (active == op.visibleByDefault ? "DEFAULT USER" : "*** NON-DEFAULT USER"); } } + + QByteArray state; + if (theMainWindow->d->m_lastTypePerspectiveStates.contains(settingsId())) + state = theMainWindow->d->m_lastTypePerspectiveStates.value(settingsId()); + if (theMainWindow->d->m_lastPerspectiveStates.contains(m_id)) + state = theMainWindow->d->m_lastPerspectiveStates.value(m_id); + theMainWindow->restoreState(state); } void PerspectivePrivate::saveLayout() @@ -959,6 +974,8 @@ void PerspectivePrivate::saveLayout() << (active == op.visibleByDefault ? "DEFAULT USER" : "*** NON-DEFAULT USER"); } } + theMainWindow->d->m_lastPerspectiveStates.insert(m_id, theMainWindow->saveState()); + theMainWindow->d->m_lastTypePerspectiveStates.insert(settingsId(), theMainWindow->saveState()); } QString PerspectivePrivate::settingsId() const diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 322a87277ca..699ea751bda 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -28,7 +28,6 @@ #include "debuggeractions.h" #include "debuggerinternalconstants.h" #include "debuggercore.h" -#include "debuggerkitconfigwidget.h" #include "debuggerdialogs.h" #include "debuggerengine.h" #include "debuggericons.h" @@ -396,6 +395,11 @@ namespace Internal { const char DEBUGGER_START[] = "Debugger.Start"; +// Menu Groups +const char MENU_GROUP_GENERAL[] = "Debugger.Group.General"; +const char MENU_GROUP_SPECIAL[] = "Debugger.Group.Special"; +const char MENU_GROUP_START_QML[] = "Debugger.Group.Start.Qml"; + void addCdbOptionPages(QList<IOptionsPage*> *opts); void addGdbOptionPages(QList<IOptionsPage*> *opts); @@ -549,12 +553,12 @@ QWidget *addSearch(BaseTreeView *treeView) static Kit::Predicate cdbPredicate(char wordWidth = 0) { return [wordWidth](const Kit *k) -> bool { - if (DebuggerKitInformation::engineType(k) != CdbEngineType - || DebuggerKitInformation::configurationErrors(k)) { + if (DebuggerKitAspect::engineType(k) != CdbEngineType + || DebuggerKitAspect::configurationErrors(k)) { return false; } if (wordWidth) - return ToolChainKitInformation::targetAbi(k).wordWidth() == wordWidth; + return ToolChainKitAspect::targetAbi(k).wordWidth() == wordWidth; return true; }; } @@ -670,7 +674,7 @@ public: message = tr("0x%1 hit").arg(data.address, 0, 16); } else { //: Message tracepoint: %1 file, %2 line %3 function hit. - message = tr("%1:%2 %3() hit").arg(FileName::fromString(data.fileName).fileName()). + message = tr("%1:%2 %3() hit").arg(FilePath::fromString(data.fileName).fileName()). arg(data.lineNumber). arg(cppFunctionAt(data.fileName, data.lineNumber)); } @@ -770,6 +774,8 @@ public: DebugInfoTaskHandler m_debugInfoTaskHandler; Perspective m_perspective{Constants::PRESET_PERSPECTIVE_ID, tr("Debugger")}; + + DebuggerKitAspect debuggerKitAspect; }; DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin) @@ -801,7 +807,7 @@ static QString msgParameterMissing(const QString &a) return DebuggerPlugin::tr("Option \"%1\" is missing the parameter.").arg(a); } -static Kit *guessKitFromAbis(const QList<Abi> &abis) +static Kit *guessKitFromAbis(const Abis &abis) { Kit *kit = nullptr; @@ -809,14 +815,14 @@ static Kit *guessKitFromAbis(const QList<Abi> &abis) if (!abis.isEmpty()) { // Try exact abis. kit = KitManager::kit([abis](const Kit *k) { - const Abi tcAbi = ToolChainKitInformation::targetAbi(k); - return abis.contains(tcAbi) && !DebuggerKitInformation::configurationErrors(k); + const Abi tcAbi = ToolChainKitAspect::targetAbi(k); + return abis.contains(tcAbi) && !DebuggerKitAspect::configurationErrors(k); }); if (!kit) { // Or something compatible. kit = KitManager::kit([abis](const Kit *k) { - const Abi tcAbi = ToolChainKitInformation::targetAbi(k); - return !DebuggerKitInformation::configurationErrors(k) + const Abi tcAbi = ToolChainKitAspect::targetAbi(k); + return !DebuggerKitAspect::configurationErrors(k) && Utils::contains(abis, [tcAbi](const Abi &a) { return a.isCompatibleWith(tcAbi); }); }); } @@ -879,11 +885,11 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it, } } if (!kit) - kit = guessKitFromAbis(Abi::abisOfBinary(FileName::fromString(executable))); + kit = guessKitFromAbis(Abi::abisOfBinary(FilePath::fromString(executable))); - IDevice::ConstPtr device = DeviceKitInformation::device(kit); - auto runControl = new RunControl(device, ProjectExplorer::Constants::DEBUG_RUN_MODE); - auto debugger = new DebuggerRunTool(runControl, kit); + auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); + runControl->setKit(kit); + auto debugger = new DebuggerRunTool(runControl); debugger->setInferiorExecutable(executable); if (pid) { debugger->setStartMode(AttachExternal); @@ -924,8 +930,9 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it, return false; } qint64 pid = it->section(':', 1, 1).toULongLong(); - auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); - auto debugger = new DebuggerRunTool(runControl, findUniversalCdbKit()); + auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); + runControl->setKit(findUniversalCdbKit()); + auto debugger = new DebuggerRunTool(runControl); debugger->setStartMode(AttachCrashedExternal); debugger->setCrashParameter(it->section(':', 0, 0)); debugger->setAttachPid(pid); @@ -1006,8 +1013,6 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QAction *act; // Populate Windows->Views menu with standard actions. - Context debugcontext(Constants::C_DEBUGMODE); - act = new QAction(tr("Memory..."), this); act->setVisible(false); act->setEnabled(false); @@ -1023,9 +1028,6 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, m_debuggerSettings = new DebuggerSettings; m_debuggerSettings->readSettings(); - const Context cppDebuggercontext(C_CPPDEBUGGER); - const Context qmljsDebuggercontext(C_QMLDEBUGGER); - const auto addLabel = [](QWidget *widget, const QString &text) { auto vbox = qobject_cast<QVBoxLayout *>(widget->layout()); QTC_ASSERT(vbox, return); @@ -1101,15 +1103,16 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, // "Start Debugging" sub-menu // groups: // G_DEFAULT_ONE - // G_START_LOCAL - // G_START_REMOTE - // G_START_QML + // MENU_GROUP_START_LOCAL + // MENU_GROUP_START_REMOTE + // MENU_GROUP_START_QML ActionContainer *mstart = ActionManager::actionContainer(PE::M_DEBUG_STARTDEBUGGING); const QKeySequence startShortcut(useMacShortcuts ? tr("Ctrl+Y") : tr("F5")); - cmd = ActionManager::registerAction(&m_visibleStartAction, Constants::DEBUG); + cmd = ActionManager::registerAction(&m_visibleStartAction, "Debugger.Debug"); + cmd->setDescription(tr("Start Debugging or Continue")); cmd->setAttribute(Command::CA_UpdateText); cmd->setAttribute(Command::CA_UpdateIcon); @@ -1127,7 +1130,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, m_visibleStartAction.setAction(&m_startAction); m_visibleStartAction.setObjectName("Debug"); // used for UI introduction - ModeManager::addAction(&m_visibleStartAction, Constants::P_ACTION_DEBUG); + ModeManager::addAction(&m_visibleStartAction, /*priority*/ 90); m_undisturbableAction.setIcon(interruptIcon(false)); m_undisturbableAction.setEnabled(false); @@ -1140,40 +1143,40 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, cmd = ActionManager::registerAction(&m_attachToRunningApplication, "Debugger.AttachToRemoteProcess"); cmd->setDescription(tr("Attach to Running Application")); - mstart->addAction(cmd, G_GENERAL); + mstart->addAction(cmd, MENU_GROUP_GENERAL); cmd = ActionManager::registerAction(&m_attachToUnstartedApplication, "Debugger.AttachToUnstartedProcess"); cmd->setDescription(tr("Attach to Unstarted Application")); - mstart->addAction(cmd, G_GENERAL); + mstart->addAction(cmd, MENU_GROUP_GENERAL); cmd = ActionManager::registerAction(&m_startAndDebugApplicationAction, "Debugger.StartAndDebugApplication"); cmd->setAttribute(Command::CA_Hide); - mstart->addAction(cmd, G_GENERAL); + mstart->addAction(cmd, MENU_GROUP_GENERAL); cmd = ActionManager::registerAction(&m_attachToCoreAction, "Debugger.AttachCore"); cmd->setAttribute(Command::CA_Hide); - mstart->addAction(cmd, Constants::G_GENERAL); + mstart->addAction(cmd, MENU_GROUP_GENERAL); cmd = ActionManager::registerAction(&m_attachToRemoteServerAction, "Debugger.AttachToRemoteServer"); cmd->setAttribute(Command::CA_Hide); - mstart->addAction(cmd, Constants::G_SPECIAL); + mstart->addAction(cmd, MENU_GROUP_SPECIAL); if (HostOsInfo::isWindowsHost()) { cmd = ActionManager::registerAction(&m_startRemoteCdbAction, "Debugger.AttachRemoteCdb"); cmd->setAttribute(Command::CA_Hide); - mstart->addAction(cmd, Constants::G_SPECIAL); + mstart->addAction(cmd, MENU_GROUP_SPECIAL); } - mstart->addSeparator(Context(CC::C_GLOBAL), Constants::G_START_QML); + mstart->addSeparator(Context(CC::C_GLOBAL), MENU_GROUP_START_QML); cmd = ActionManager::registerAction(&m_attachToQmlPortAction, "Debugger.AttachToQmlPort"); cmd->setAttribute(Command::CA_Hide); - mstart->addAction(cmd, Constants::G_START_QML); + mstart->addAction(cmd, MENU_GROUP_START_QML); act = new QAction(tr("Detach Debugger"), this); act->setEnabled(false); @@ -1199,7 +1202,9 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, touchBar->addAction(cmd); debugMenu->addAction(cmd, CC::G_DEFAULT_ONE); - act = new QAction(Icons::DEBUG_EXIT_SMALL.icon(), tr("Stop Debugger"), this); + const QIcon sidebarStopIcon = Icon::sideBarIcon(Icons::STOP, Icons::STOP_FLAT); + const QIcon stopIcon = Icon::combinedIcon({Icons::DEBUG_EXIT_SMALL.icon(), sidebarStopIcon}); + act = new QAction(stopIcon, tr("Stop Debugger"), this); act->setEnabled(false); cmd = ActionManager::registerAction(act, Constants::STOP); cmd->setTouchBarIcon(Icons::MACOS_TOUCHBAR_DEBUG_EXIT.icon()); @@ -1590,13 +1595,13 @@ void DebuggerPluginPrivate::attachCore() setConfigValue("LastExternalStartScript", dlg.overrideStartScript()); setConfigValue("LastForceLocalCoreFile", dlg.forcesLocalCoreFile()); - IDevice::ConstPtr device = DeviceKitInformation::device(dlg.kit()); - auto runControl = new RunControl(device, ProjectExplorer::Constants::DEBUG_RUN_MODE); - auto debugger = new DebuggerRunTool(runControl, dlg.kit()); + auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); + runControl->setKit(dlg.kit()); + runControl->setDisplayName(tr("Core file \"%1\"") + .arg(dlg.useLocalCoreFile() ? dlg.localCoreFile() : dlg.remoteCoreFile())); + auto debugger = new DebuggerRunTool(runControl); debugger->setInferiorExecutable(dlg.symbolFile()); debugger->setCoreFileName(dlg.localCoreFile()); - debugger->setRunControlName(tr("Core file \"%1\"") - .arg(dlg.useLocalCoreFile() ? dlg.localCoreFile() : dlg.remoteCoreFile())); debugger->setStartMode(AttachCore); debugger->setCloseMode(DetachAtClose); debugger->setOverrideStartScript(dlg.overrideStartScript()); @@ -1618,9 +1623,9 @@ void DebuggerPluginPrivate::startRemoteCdbSession() return; setConfigValue(connectionKey, dlg.connection()); - IDevice::ConstPtr device = DeviceKitInformation::device(kit); - auto runControl = new RunControl(device, ProjectExplorer::Constants::DEBUG_RUN_MODE); - auto debugger = new DebuggerRunTool(runControl, kit); + auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); + runControl->setKit(kit); + auto debugger = new DebuggerRunTool(runControl); debugger->setStartMode(AttachToRemoteServer); debugger->setCloseMode(KillAtClose); debugger->setRemoteChannel(dlg.connection()); @@ -1630,17 +1635,16 @@ void DebuggerPluginPrivate::startRemoteCdbSession() class RemoteAttachRunner : public DebuggerRunTool { public: - RemoteAttachRunner(RunControl *runControl, Kit *kit, int pid) - : DebuggerRunTool(runControl, kit) + RemoteAttachRunner(RunControl *runControl, int pid) + : DebuggerRunTool(runControl) { - IDevice::ConstPtr device = DeviceKitInformation::device(kit); setId("AttachToRunningProcess"); setUsePortsGatherer(true, false); - portsGatherer()->setDevice(device); + portsGatherer()->setDevice(runControl->device()); auto gdbServer = new GdbServerRunner(runControl, portsGatherer()); gdbServer->setUseMulti(false); - gdbServer->setDevice(device); + gdbServer->setDevice(runControl->device()); gdbServer->setAttachPid(ProcessHandle(pid)); addStartDependency(gdbServer); @@ -1669,7 +1673,7 @@ void DebuggerPluginPrivate::attachToRunningApplication() dlg->setAttribute(Qt::WA_DeleteOnClose); Kit *kit = kitChooser->currentKit(); QTC_ASSERT(kit, return); - IDevice::ConstPtr device = DeviceKitInformation::device(kit); + IDevice::ConstPtr device = DeviceKitAspect::device(kit); QTC_ASSERT(device, return); DeviceProcessItem process = dlg->currentProcess(); @@ -1677,8 +1681,11 @@ void DebuggerPluginPrivate::attachToRunningApplication() if (device->type() == PE::DESKTOP_DEVICE_TYPE) { attachToRunningProcess(kit, process, false); } else { - auto runControl = new RunControl(device, ProjectExplorer::Constants::DEBUG_RUN_MODE); - auto debugger = new RemoteAttachRunner(runControl, kit, process.pid); + auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); + runControl->setKit(kit); + //: %1: PID + runControl->setDisplayName(tr("Process %1").arg(process.pid)); + auto debugger = new RemoteAttachRunner(runControl, process.pid); debugger->startRunControl(); } } @@ -1706,14 +1713,14 @@ RunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit, DeviceProcessItem process, bool contAfterAttach) { QTC_ASSERT(kit, return nullptr); - IDevice::ConstPtr device = DeviceKitInformation::device(kit); + IDevice::ConstPtr device = DeviceKitAspect::device(kit); QTC_ASSERT(device, return nullptr); if (process.pid == 0) { AsynchronousMessageBox::warning(tr("Warning"), tr("Cannot attach to process with PID 0")); return nullptr; } - const Abi tcAbi = ToolChainKitInformation::targetAbi(kit); + const Abi tcAbi = ToolChainKitAspect::targetAbi(kit); const bool isWindows = (tcAbi.os() == Abi::WindowsOS); if (isWindows && isWinProcessBeingDebugged(process.pid)) { AsynchronousMessageBox::warning( @@ -1730,10 +1737,12 @@ RunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit, return nullptr; } - auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); - auto debugger = new DebuggerRunTool(runControl, kit); + auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); + runControl->setKit(kit); + //: %1: PID + runControl->setDisplayName(tr("Process %1").arg(process.pid)); + auto debugger = new DebuggerRunTool(runControl); debugger->setAttachPid(ProcessHandle(process.pid)); - debugger->setRunControlName(tr("Process %1").arg(process.pid)); debugger->setInferiorExecutable(process.exe); debugger->setInferiorDevice(device); debugger->setStartMode(AttachExternal); @@ -1748,14 +1757,11 @@ RunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit, void DebuggerPlugin::attachExternalApplication(RunControl *rc) { ProcessHandle pid = rc->applicationProcessHandle(); - RunConfiguration *runConfig = rc->runConfiguration(); - QTC_ASSERT(runConfig, return); - Target *target = runConfig->target(); - QTC_ASSERT(target, return); - auto runControl = new RunControl(runConfig, ProjectExplorer::Constants::DEBUG_RUN_MODE); - auto debugger = new DebuggerRunTool(runControl, target->kit(), false); + auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); + runControl->setTarget(rc->target()); + runControl->setDisplayName(tr("Process %1").arg(pid.pid())); + auto debugger = new DebuggerRunTool(runControl); debugger->setAttachPid(pid); - debugger->setRunControlName(tr("Process %1").arg(pid.pid())); debugger->setStartMode(AttachExternal); debugger->setCloseMode(DetachAtClose); debugger->startRunControl(); @@ -1808,11 +1814,12 @@ void DebuggerPluginPrivate::attachToQmlPort() setConfigValue("LastQmlServerPort", dlg.port()); setConfigValue("LastProfile", kit->id().toSetting()); - IDevice::ConstPtr device = DeviceKitInformation::device(kit); + IDevice::ConstPtr device = DeviceKitAspect::device(kit); QTC_ASSERT(device, return); - auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); - auto debugger = new DebuggerRunTool(runControl, kit); + auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); + runControl->setKit(kit); + auto debugger = new DebuggerRunTool(runControl); QUrl qmlServer = device->toolControlChannel(IDevice::QmlControlChannel); qmlServer.setPort(dlg.port()); @@ -2084,7 +2091,7 @@ void DebuggerPluginPrivate::extensionsInitialized() if (runnable.device && runnable.device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) return true; - if (DeviceTypeKitInformation::deviceTypeId(runConfig->target()->kit()) + if (DeviceTypeKitAspect::deviceTypeId(runConfig->target()->kit()) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) return true; @@ -2254,15 +2261,13 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess // Menu groups ActionContainer *mstart = ActionManager::actionContainer(PE::M_DEBUG_STARTDEBUGGING); - mstart->appendGroup(Constants::G_GENERAL); - mstart->appendGroup(Constants::G_SPECIAL); - mstart->appendGroup(Constants::G_START_QML); + mstart->appendGroup(MENU_GROUP_GENERAL); + mstart->appendGroup(MENU_GROUP_SPECIAL); + mstart->appendGroup(MENU_GROUP_START_QML); // Separators - mstart->addSeparator(Constants::G_GENERAL); - mstart->addSeparator(Constants::G_SPECIAL); - - KitManager::registerKitInformation<DebuggerKitInformation>(); + mstart->addSeparator(MENU_GROUP_GENERAL); + mstart->addSeparator(MENU_GROUP_SPECIAL); // Task integration. //: Category under which Analyzer tasks are listed in Issues view @@ -2458,7 +2463,7 @@ void DebuggerUnitTests::initTestCase() // const QList<Kit *> allKits = KitManager::kits(); // if (allKits.count() != 1) // QSKIP("This test requires exactly one kit to be present"); -// const ToolChain * const toolchain = ToolChainKitInformation::toolChain(allKits.first()); +// const ToolChain * const toolchain = ToolChainKitAspect::toolChain(allKits.first()); // if (!toolchain) // QSKIP("This test requires that there is a kit with a toolchain."); // bool hasClangExecutable; @@ -2497,7 +2502,8 @@ void DebuggerUnitTests::testStateMachine() RunConfiguration *rc = t->activeRunConfiguration(); QVERIFY(rc); - auto runControl = new RunControl(rc, ProjectExplorer::Constants::DEBUG_RUN_MODE); + auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); + runControl->setRunConfiguration(rc); auto debugger = new DebuggerRunTool(runControl); debugger->setInferior(rc->runnable()); @@ -2617,8 +2623,8 @@ void DebuggerUnitTests::testDebuggerMatching() auto expectedLevel = static_cast<DebuggerItem::MatchLevel>(result); - QList<Abi> debuggerAbis; - foreach (const QString &abi, debugger) + Abis debuggerAbis; + for (const QString &abi : qAsConst(debugger)) debuggerAbis << Abi::fromString(abi); DebuggerItem item; @@ -2631,15 +2637,14 @@ void DebuggerUnitTests::testDebuggerMatching() QCOMPARE(expectedLevel, level); } - -QList<QObject *> DebuggerPlugin::createTestObjects() const +QVector<QObject *> DebuggerPlugin::createTestObjects() const { return {new DebuggerUnitTests}; } #else // ^-- if WITH_TESTS else --v -QList<QObject *> DebuggerPlugin::createTestObjects() const +QVector<QObject *> DebuggerPlugin::createTestObjects() const { return {}; } diff --git a/src/plugins/debugger/debuggerplugin.h b/src/plugins/debugger/debuggerplugin.h index 2ecde571dd5..45050f7c4dd 100644 --- a/src/plugins/debugger/debuggerplugin.h +++ b/src/plugins/debugger/debuggerplugin.h @@ -59,7 +59,7 @@ private: // Called from GammaRayIntegration Q_SLOT void getEnginesState(QByteArray *json) const; - QList<QObject *> createTestObjects() const override; + QVector<QObject *> createTestObjects() const override; }; } // namespace Internal diff --git a/src/plugins/debugger/debuggerrunconfigurationaspect.cpp b/src/plugins/debugger/debuggerrunconfigurationaspect.cpp index bd4b09060ff..161c755d101 100644 --- a/src/plugins/debugger/debuggerrunconfigurationaspect.cpp +++ b/src/plugins/debugger/debuggerrunconfigurationaspect.cpp @@ -121,7 +121,7 @@ DebuggerRunConfigWidget::DebuggerRunConfigWidget(DebuggerRunConfigurationAspect this, &DebuggerRunConfigWidget::useQmlDebuggerClicked); connect(m_useCppDebugger, &QAbstractButton::clicked, this, &DebuggerRunConfigWidget::useCppDebuggerClicked); - connect(m_debugServerPort, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), + connect(m_debugServerPort, QOverload<int>::of(&QSpinBox::valueChanged), this, &DebuggerRunConfigWidget::qmlDebugServerPortChanged); connect(m_useMultiProcess, &QAbstractButton::toggled, this, &DebuggerRunConfigWidget::useMultiProcessToggled); @@ -260,11 +260,6 @@ uint DebuggerRunConfigurationAspect::qmlDebugServerPort() const return d.qmlDebugServerPort; } -void DebuggerRunConfigurationAspect::setQmllDebugServerPort(uint port) -{ - d.qmlDebugServerPort = port; -} - bool DebuggerRunConfigurationAspect::useMultiProcess() const { return d.useMultiProcess; @@ -278,7 +273,7 @@ void DebuggerRunConfigurationAspect::setUseMultiProcess(bool value) bool DebuggerRunConfigurationAspect::isQmlDebuggingSpinboxSuppressed() const { Kit *k = m_target->kit(); - IDevice::ConstPtr dev = DeviceKitInformation::device(k); + IDevice::ConstPtr dev = DeviceKitAspect::device(k); if (dev.isNull()) return false; return dev->canAutoDetectPorts(); diff --git a/src/plugins/debugger/debuggerrunconfigurationaspect.h b/src/plugins/debugger/debuggerrunconfigurationaspect.h index a361f234c4f..299b7c11823 100644 --- a/src/plugins/debugger/debuggerrunconfigurationaspect.h +++ b/src/plugins/debugger/debuggerrunconfigurationaspect.h @@ -45,7 +45,10 @@ class DEBUGGER_EXPORT DebuggerRunConfigurationAspectData public: DebuggerLanguageStatus useCppDebugger = AutoEnabledLanguage; DebuggerLanguageStatus useQmlDebugger = AutoEnabledLanguage; - uint qmlDebugServerPort = Constants::QML_DEFAULT_DEBUG_SERVER_PORT; + + const uint QML_DEFAULT_DEBUG_SERVER_PORT = 3768; + uint qmlDebugServerPort = QML_DEFAULT_DEBUG_SERVER_PORT; + bool useMultiProcess = false; }; @@ -64,7 +67,6 @@ public: bool useQmlDebugger() const; void setUseQmlDebugger(bool value); uint qmlDebugServerPort() const; - void setQmllDebugServerPort(uint port); bool useMultiProcess() const; void setUseMultiProcess(bool on); bool isQmlDebuggingSpinboxSuppressed() const; diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index ca76e8cfe1c..f68d637e1f2 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -31,6 +31,7 @@ #include "debuggeractions.h" #include "debuggercore.h" #include "debuggerengine.h" +#include "debuggerinternalconstants.h" #include "debuggerkitinformation.h" #include "debuggerplugin.h" #include "debuggerrunconfigurationaspect.h" @@ -97,8 +98,8 @@ class LocalProcessRunner : public RunWorker Q_DECLARE_TR_FUNCTIONS(Debugger::Internal::LocalProcessRunner) public: - LocalProcessRunner(DebuggerRunTool *runTool, const Runnable &runnable) - : RunWorker(runTool->runControl()), m_runTool(runTool), m_runnable(runnable) + LocalProcessRunner(DebuggerRunTool *runTool, const CommandLine &command) + : RunWorker(runTool->runControl()), m_runTool(runTool), m_command(command) { connect(&m_proc, &QProcess::errorOccurred, this, &LocalProcessRunner::handleError); @@ -112,7 +113,7 @@ public: void start() override { - m_proc.setCommand(m_runnable.executable, m_runnable.commandLineArguments); + m_proc.setCommand(m_command); m_proc.start(); } @@ -180,7 +181,7 @@ public: } QPointer<DebuggerRunTool> m_runTool; - Runnable m_runnable; + CommandLine m_command; Utils::QtcProcess m_proc; }; @@ -310,7 +311,7 @@ void DebuggerRunTool::setAttachPid(qint64 pid) m_runParameters.attachPID = ProcessHandle(pid); } -void DebuggerRunTool::setSysRoot(const Utils::FileName &sysRoot) +void DebuggerRunTool::setSysRoot(const Utils::FilePath &sysRoot) { m_runParameters.sysRoot = sysRoot; } @@ -399,14 +400,12 @@ void DebuggerRunTool::setCommandsForReset(const QString &commands) m_runParameters.commandsForReset = commands; } -void DebuggerRunTool::setServerStartScript(const QString &serverStartScript) +void DebuggerRunTool::setServerStartScript(const FilePath &serverStartScript) { if (!serverStartScript.isEmpty()) { // Provide script information about the environment - Runnable serverStarter; - serverStarter.executable = serverStartScript; - QtcProcess::addArg(&serverStarter.commandLineArguments, m_runParameters.inferior.executable); - QtcProcess::addArg(&serverStarter.commandLineArguments, m_runParameters.remoteChannel); + CommandLine serverStarter(serverStartScript, {}); + serverStarter.addArgs({m_runParameters.inferior.executable, m_runParameters.remoteChannel}); addStartDependency(new LocalProcessRunner(this, serverStarter)); } } @@ -516,15 +515,15 @@ void DebuggerRunTool::addExpectedSignal(const QString &signal) m_runParameters.expectedSignals.append(signal); } -void DebuggerRunTool::addSearchDirectory(const Utils::FileName &dir) +void DebuggerRunTool::addSearchDirectory(const Utils::FilePath &dir) { m_runParameters.additionalSearchDirectories.append(dir); } void DebuggerRunTool::start() { - TaskHub::clearTasks(Debugger::Constants::TASK_CATEGORY_DEBUGGER_DEBUGINFO); - TaskHub::clearTasks(Debugger::Constants::TASK_CATEGORY_DEBUGGER_RUNTIME); + TaskHub::clearTasks(Constants::TASK_CATEGORY_DEBUGGER_DEBUGINFO); + TaskHub::clearTasks(Constants::TASK_CATEGORY_DEBUGGER_RUNTIME); if (d->portsGatherer) { setRemoteChannel(d->portsGatherer->gdbServer()); @@ -648,7 +647,8 @@ void DebuggerRunTool::start() connect(m_engine, &DebuggerEngine::attachToCoreRequested, this, [this](const QString &coreFile) { auto runConfig = runControl()->runConfiguration(); QTC_ASSERT(runConfig, return); - auto rc = new RunControl(runConfig, ProjectExplorer::Constants::DEBUG_RUN_MODE); + auto rc = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); + rc->setRunConfiguration(runConfig); auto name = QString(tr("%1 - Snapshot %2").arg(runControl()->displayName()).arg(++d->snapshotCounter)); auto debugger = new DebuggerRunTool(rc); debugger->setStartMode(AttachCore); @@ -884,7 +884,7 @@ Internal::TerminalRunner *DebuggerRunTool::terminalRunner() const return d->terminalRunner; } -DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTerminal) +DebuggerRunTool::DebuggerRunTool(RunControl *runControl, AllowTerminal allowTerminal) : RunWorker(runControl), d(new DebuggerRunToolPrivate) { setId("DebuggerRunTool"); @@ -897,8 +897,6 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTer d->runId = QString::number(++toolRunCount); - RunConfiguration *runConfig = runControl->runConfiguration(); - runControl->setIcon(ProjectExplorer::Icons::DEBUG_START_SMALL_TOOLBAR); runControl->setPromptToStop([](bool *optionalPrompt) { return RunControl::showPromptToStopDialog( @@ -910,27 +908,25 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTer QString(), QString(), optionalPrompt); }); - if (runConfig) { - m_runParameters.displayName = runConfig->displayName(); - if (auto symbolsAspect = runConfig->aspect<SymbolFileAspect>()) - m_runParameters.symbolFile = symbolsAspect->value(); - if (auto terminalAspect = runConfig->aspect<TerminalAspect>()) - m_runParameters.useTerminal = terminalAspect->useTerminal(); - } + m_runParameters.displayName = runControl->displayName(); - if (runConfig && !kit) - kit = runConfig->target()->kit(); + if (auto symbolsAspect = runControl->aspect<SymbolFileAspect>()) + m_runParameters.symbolFile = symbolsAspect->value(); + if (auto terminalAspect = runControl->aspect<TerminalAspect>()) + m_runParameters.useTerminal = terminalAspect->useTerminal(); + + Kit *kit = runControl->kit(); QTC_ASSERT(kit, return); - m_runParameters.sysRoot = SysRootKitInformation::sysRoot(kit); + m_runParameters.sysRoot = SysRootKitAspect::sysRoot(kit); m_runParameters.macroExpander = kit->macroExpander(); - m_runParameters.debugger = DebuggerKitInformation::runnable(kit); - m_runParameters.cppEngineType = DebuggerKitInformation::engineType(kit); + m_runParameters.debugger = DebuggerKitAspect::runnable(kit); + m_runParameters.cppEngineType = DebuggerKitAspect::engineType(kit); - if (QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(kit)) + if (QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(kit)) m_runParameters.qtPackageSourceLocation = qtVersion->qtPackageSourcePath().toString(); - if (auto aspect = runConfig ? runConfig->aspect<DebuggerRunConfigurationAspect>() : nullptr) { + if (auto aspect = runControl->aspect<DebuggerRunConfigurationAspect>()) { if (!aspect->useCppDebugger()) m_runParameters.cppEngineType = NoEngineType; m_runParameters.isQmlDebugging = aspect->useQmlDebugger(); @@ -941,19 +937,18 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTer // Normalize to work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch'...) m_runParameters.inferior.workingDirectory = FileUtils::normalizePathName(m_runParameters.inferior.workingDirectory); - setUseTerminal(allowTerminal && m_runParameters.useTerminal); + setUseTerminal(allowTerminal == DoAllowTerminal && m_runParameters.useTerminal); const QByteArray envBinary = qgetenv("QTC_DEBUGGER_PATH"); if (!envBinary.isEmpty()) m_runParameters.debugger.executable = QString::fromLocal8Bit(envBinary); - Project *project = runConfig ? runConfig->target()->project() : nullptr; - if (project) { + if (Project *project = runControl->project()) { m_runParameters.projectSourceDirectory = project->projectDirectory(); m_runParameters.projectSourceFiles = project->files(Project::SourceFiles); } - m_runParameters.toolChainAbi = ToolChainKitInformation::targetAbi(kit); + m_runParameters.toolChainAbi = ToolChainKitAspect::targetAbi(kit); bool ok = false; int nativeMixedOverride = qgetenv("QTC_DEBUGGER_NATIVE_MIXED").toInt(&ok); @@ -962,12 +957,13 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTer // This will only be shown in some cases, but we don't want to access // the kit at that time anymore. - const QList<Task> tasks = DebuggerKitInformation::validateDebugger(kit); + const Tasks tasks = DebuggerKitAspect::validateDebugger(kit); for (const Task &t : tasks) { if (t.type != Task::Warning) m_runParameters.validationErrors.append(t.description); } + RunConfiguration *runConfig = runControl->runConfiguration(); if (runConfig && runConfig->property("supportsDebugger").toBool()) { const QString mainScript = runConfig->property("mainScript").toString(); const QString interpreter = runConfig->property("interpreter").toString(); @@ -1015,6 +1011,8 @@ void DebuggerRunTool::showMessage(const QString &msg, int channel, int timeout) if (channel == ConsoleOutput) debuggerConsole()->printItem(ConsoleItem::DefaultType, msg); + QTC_ASSERT(m_engine, qDebug() << msg; return); + m_engine->showMessage(msg, channel, timeout); if (m_engine2) m_engine->showMessage(msg, channel, timeout); diff --git a/src/plugins/debugger/debuggerruncontrol.h b/src/plugins/debugger/debuggerruncontrol.h index cc4a1f191bd..f5512dd9911 100644 --- a/src/plugins/debugger/debuggerruncontrol.h +++ b/src/plugins/debugger/debuggerruncontrol.h @@ -47,9 +47,9 @@ class DEBUGGER_EXPORT DebuggerRunTool : public ProjectExplorer::RunWorker Q_OBJECT public: + enum AllowTerminal { DoAllowTerminal, DoNotAllowTerminal }; explicit DebuggerRunTool(ProjectExplorer::RunControl *runControl, - ProjectExplorer::Kit *kit = nullptr, - bool allowTerminal = true); + AllowTerminal allowTerminal = DoAllowTerminal); ~DebuggerRunTool() override; void startRunControl(); @@ -84,7 +84,7 @@ public: void setCrashParameter(const QString &event); void addExpectedSignal(const QString &signal); - void addSearchDirectory(const Utils::FileName &dir); + void addSearchDirectory(const Utils::FilePath &dir); void setStartMode(DebuggerStartMode startMode); void setCloseMode(DebuggerCloseMode closeMode); @@ -92,7 +92,7 @@ public: void setAttachPid(Utils::ProcessHandle pid); void setAttachPid(qint64 pid); - void setSysRoot(const Utils::FileName &sysRoot); + void setSysRoot(const Utils::FilePath &sysRoot); void setSymbolFile(const QString &symbolFile); void setRemoteChannel(const QString &channel); void setRemoteChannel(const QString &host, int port); @@ -110,7 +110,7 @@ public: void setCommandsAfterConnect(const QString &commands); void setCommandsForReset(const QString &commands); - void setServerStartScript(const QString &serverStartScript); + void setServerStartScript(const Utils::FilePath &serverStartScript); void setDebugInfoLocation(const QString &debugInfoLocation); void setQmlServer(const QUrl &qmlServer); diff --git a/src/plugins/debugger/debuggersourcepathmappingwidget.cpp b/src/plugins/debugger/debuggersourcepathmappingwidget.cpp index 5812763fc4c..8652ff10f80 100644 --- a/src/plugins/debugger/debuggersourcepathmappingwidget.cpp +++ b/src/plugins/debugger/debuggersourcepathmappingwidget.cpp @@ -294,7 +294,7 @@ QString DebuggerSourcePathMappingWidget::editSourceField() const QString DebuggerSourcePathMappingWidget::editTargetField() const { - return m_targetChooser->path(); + return m_targetChooser->rawPath(); } void DebuggerSourcePathMappingWidget::setEditFieldMapping(const Mapping &m) @@ -401,7 +401,7 @@ void DebuggerSourcePathMappingWidget::slotEditTargetFieldChanged() } // Find Qt installation by running qmake -static QString findQtInstallPath(const FileName &qmakePath) +static QString findQtInstallPath(const FilePath &qmakePath) { if (qmakePath.isEmpty()) return QString(); @@ -438,7 +438,7 @@ DebuggerSourcePathMappingWidget::SourcePathMap DebuggerSourcePathMappingWidget::mergePlatformQtPath(const DebuggerRunParameters &sp, const SourcePathMap &in) { - const FileName qmake = BuildableHelperLibrary::findSystemQt(sp.inferior.environment); + const FilePath qmake = BuildableHelperLibrary::findSystemQt(sp.inferior.environment); // FIXME: Get this from the profile? // We could query the QtVersion for this information directly, but then we // will need to add a dependency on QtSupport to the debugger. diff --git a/src/plugins/debugger/debuggertooltipmanager.cpp b/src/plugins/debugger/debuggertooltipmanager.cpp index 6f23a9df629..2ad12ff6827 100644 --- a/src/plugins/debugger/debuggertooltipmanager.cpp +++ b/src/plugins/debugger/debuggertooltipmanager.cpp @@ -624,15 +624,10 @@ void DebuggerToolTipWidget::computeSize() // Add a bit of space to account for tooltip border, and not // touch the border of the screen. QPoint pos(x(), y()); -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) auto screen = QGuiApplication::screenAt(pos); if (!screen) screen = QGuiApplication::primaryScreen(); QRect desktopRect = screen->availableGeometry(); -#else - QTC_ASSERT(QApplication::desktop(), return); - QRect desktopRect = QApplication::desktop()->availableGeometry(); -#endif const int maxWidth = desktopRect.right() - pos.x() - 5 - 5; const int maxHeight = desktopRect.bottom() - pos.y() - 5 - 5; @@ -726,8 +721,8 @@ DebuggerToolTipContext::DebuggerToolTipContext() static bool filesMatch(const QString &file1, const QString &file2) { - return FileName::fromString(QFileInfo(file1).canonicalFilePath()) - == FileName::fromString(QFileInfo(file2).canonicalFilePath()); + return FilePath::fromString(QFileInfo(file1).canonicalFilePath()) + == FilePath::fromString(QFileInfo(file2).canonicalFilePath()); } bool DebuggerToolTipContext::matchesFrame(const StackFrame &frame) const diff --git a/src/plugins/debugger/disassembleragent.cpp b/src/plugins/debugger/disassembleragent.cpp index 8e65cec0511..d8a083b8d53 100644 --- a/src/plugins/debugger/disassembleragent.cpp +++ b/src/plugins/debugger/disassembleragent.cpp @@ -66,7 +66,7 @@ class DisassemblerBreakpointMarker : public TextMark { public: DisassemblerBreakpointMarker(const Breakpoint &bp, int lineNumber) - : TextMark(Utils::FileName(), lineNumber, Constants::TEXT_MARK_CATEGORY_BREAKPOINT), m_bp(bp) + : TextMark(Utils::FilePath(), lineNumber, Constants::TEXT_MARK_CATEGORY_BREAKPOINT), m_bp(bp) { setIcon(bp->icon()); setPriority(TextMark::NormalPriority); @@ -141,7 +141,7 @@ public: DisassemblerAgentPrivate::DisassemblerAgentPrivate(DebuggerEngine *engine) : document(nullptr), engine(engine), - locationMark(engine, Utils::FileName(), 0), + locationMark(engine, Utils::FilePath(), 0), mimeType("text/x-qtcreator-generic-asm"), resetLocationScheduled(false) {} diff --git a/src/plugins/debugger/enginemanager.cpp b/src/plugins/debugger/enginemanager.cpp index 0ca42d64a7d..6050dc50b94 100644 --- a/src/plugins/debugger/enginemanager.cpp +++ b/src/plugins/debugger/enginemanager.cpp @@ -145,7 +145,7 @@ public: if (hideSwitcherUnlessNeeded) m_engineChooser->hide(); - connect(m_engineChooser, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), + connect(m_engineChooser, QOverload<int>::of(&QComboBox::activated), this, &EngineManagerPrivate::activateEngineByIndex); } @@ -377,7 +377,8 @@ void EngineManagerPrivate::selectUiForCurrentEngine() row = m_engineModel.rootItem()->indexOf(m_currentItem); m_engineChooser->setCurrentIndex(row); - const int contentWidth = m_engineChooser->fontMetrics().width(m_engineChooser->currentText() + "xx"); + const int contentWidth = + m_engineChooser->fontMetrics().horizontalAdvance(m_engineChooser->currentText() + "xx"); QStyleOptionComboBox option; option.initFrom(m_engineChooser); const QSize sz(contentWidth, 1); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 796416374ae..204a11698d3 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -61,7 +61,6 @@ #include <app/app_version.h> #include <utils/algorithm.h> #include <utils/hostosinfo.h> -#include <utils/macroexpander.h> #include <utils/qtcassert.h> #include <utils/qtcprocess.h> #include <utils/savedaction.h> @@ -133,7 +132,7 @@ GdbEngine::GdbEngine() connect(&m_gdbProc, &QProcess::errorOccurred, this, &GdbEngine::handleGdbError); - connect(&m_gdbProc, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), + connect(&m_gdbProc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, &GdbEngine::handleGdbFinished); connect(&m_gdbProc, &QtcProcess::readyReadStandardOutput, this, &GdbEngine::readGdbStandardOutput); @@ -356,7 +355,7 @@ void GdbEngine::handleResponse(const QString &buff) Task task(Task::Warning, tr("Missing debug information for %1\nTry: %2") .arg(m_lastMissingDebugInfo).arg(cmd), - FileName(), 0, Debugger::Constants::TASK_CATEGORY_DEBUGGER_DEBUGINFO); + FilePath(), 0, Debugger::Constants::TASK_CATEGORY_DEBUGGER_DEBUGINFO); TaskHub::addTask(task); Internal::addDebugInfoTask(task.taskId, cmd); @@ -1630,7 +1629,7 @@ QString GdbEngine::cleanupFullName(const QString &fileName) } cleanFilePath.clear(); - const QString base = FileName::fromString(fileName).fileName(); + const QString base = FilePath::fromString(fileName).fileName(); QMap<QString, QString>::const_iterator jt = m_baseNameToFullName.constFind(base); while (jt != m_baseNameToFullName.constEnd() && jt.key() == base) { @@ -1701,7 +1700,7 @@ void GdbEngine::setLinuxOsAbi() const DebuggerRunParameters &rp = runParameters(); bool isElf = (rp.toolChainAbi.binaryFormat() == Abi::ElfFormat); if (!isElf && !rp.inferior.executable.isEmpty()) { - isElf = Utils::anyOf(Abi::abisOfBinary(FileName::fromString(rp.inferior.executable)), + isElf = Utils::anyOf(Abi::abisOfBinary(FilePath::fromString(rp.inferior.executable)), [](const Abi &abi) { return abi.binaryFormat() == Abi::ElfFormat; }); @@ -2078,7 +2077,7 @@ QString GdbEngine::breakLocation(const QString &file) const { QString where = m_fullToShortName.value(file); if (where.isEmpty()) - return FileName::fromString(file).fileName(); + return FilePath::fromString(file).fileName(); return where; } @@ -3524,14 +3523,16 @@ void GdbEngine::setupEngine() if (isRemoteEngine() && HostOsInfo::isWindowsHost()) m_gdbProc.setUseCtrlCStub(runParameters().useCtrlCStub); // This is only set for QNX - QStringList gdbArgs; + const DebuggerRunParameters &rp = runParameters(); + CommandLine gdbCommand{FilePath::fromString(rp.debugger.executable), {}}; + if (isPlainEngine()) { if (!m_outputCollector.listen()) { handleAdapterStartFailed(tr("Cannot set up communication with child process: %1") .arg(m_outputCollector.errorString())); return; } - gdbArgs.append("--tty=" + m_outputCollector.serverName()); + gdbCommand.addArg("--tty=" + m_outputCollector.serverName()); } const QString tests = QString::fromLocal8Bit(qgetenv("QTC_DEBUGGER_TESTS")); @@ -3542,7 +3543,6 @@ void GdbEngine::setupEngine() m_expectTerminalTrap = terminal(); - const DebuggerRunParameters &rp = runParameters(); if (rp.debugger.executable.isEmpty()) { handleGdbStartFailed(); handleAdapterStartFailed( @@ -3551,13 +3551,12 @@ void GdbEngine::setupEngine() return; } - gdbArgs << "-i"; - gdbArgs << "mi"; + gdbCommand.addArgs("-i mi"); if (!boolSetting(LoadGdbInit)) - gdbArgs << "-n"; + gdbCommand.addArg("-n"); - showMessage("STARTING " + rp.debugger.executable + " " + gdbArgs.join(' ')); - m_gdbProc.setCommand(rp.debugger.executable, QtcProcess::joinArgs(gdbArgs)); + showMessage("STARTING " + gdbCommand.toUserOutput()); + m_gdbProc.setCommand(gdbCommand); if (QFileInfo(rp.debugger.workingDirectory).isDir()) m_gdbProc.setWorkingDirectory(rp.debugger.workingDirectory); m_gdbProc.setEnvironment(rp.debugger.environment); @@ -3651,7 +3650,7 @@ void GdbEngine::setupEngine() for (auto it = completeSourcePathMap.constBegin(), cend = completeSourcePathMap.constEnd(); it != cend; ++it) { - runCommand({"set substitute-path " + it.key() + " " + it.value()}); + runCommand({"set substitute-path " + it.key() + " " + expand(it.value())}); } // Spaces just will not work. @@ -4258,6 +4257,8 @@ void GdbEngine::handleAttach(const DebuggerResponse &response) notifyEngineRunAndInferiorStopOk(); if (runParameters().continueAfterAttach) continueInferiorInternal(); + else + updateAll(); } break; case ResultError: @@ -4742,6 +4743,7 @@ void GdbEngine::doUpdateLocals(const UpdateParameters ¶ms) cmd.arg("autoderef", boolSetting(AutoDerefPointers)); cmd.arg("dyntype", boolSetting(UseDynamicType)); cmd.arg("qobjectnames", boolSetting(ShowQObjectNames)); + cmd.arg("timestamps", boolSetting(LogTimeStamps)); StackFrame frame = stackHandler()->currentFrame(); cmd.arg("context", frame.context); diff --git a/src/plugins/debugger/images/debugger_stop.png b/src/plugins/debugger/images/debugger_stop.png Binary files differnew file mode 100644 index 00000000000..6d4c3c59e94 --- /dev/null +++ b/src/plugins/debugger/images/debugger_stop.png diff --git a/src/plugins/debugger/images/debugger_stop@2x.png b/src/plugins/debugger/images/debugger_stop@2x.png Binary files differnew file mode 100644 index 00000000000..27f6b3828f4 --- /dev/null +++ b/src/plugins/debugger/images/debugger_stop@2x.png diff --git a/src/plugins/debugger/images/debugger_stop_32.png b/src/plugins/debugger/images/debugger_stop_32.png Binary files differdeleted file mode 100644 index 23ee07ac99d..00000000000 --- a/src/plugins/debugger/images/debugger_stop_32.png +++ /dev/null diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index f91240bb939..3047fb8ad4b 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -100,7 +100,7 @@ LldbEngine::LldbEngine() connect(&m_lldbProc, &QProcess::errorOccurred, this, &LldbEngine::handleLldbError); - connect(&m_lldbProc, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), + connect(&m_lldbProc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, &LldbEngine::handleLldbFinished); connect(&m_lldbProc, &QProcess::readyReadStandardOutput, this, &LldbEngine::readLldbStandardOutput); @@ -207,7 +207,7 @@ void LldbEngine::setupEngine() if (QFileInfo(runParameters().debugger.workingDirectory).isDir()) m_lldbProc.setWorkingDirectory(runParameters().debugger.workingDirectory); - m_lldbProc.setCommand(lldbCmd, QString()); + m_lldbProc.setCommand(CommandLine(FilePath::fromString(lldbCmd), QString())); m_lldbProc.start(); if (!m_lldbProc.waitForStarted()) { @@ -263,7 +263,8 @@ void LldbEngine::setupEngine() for (auto it = sourcePathMap.constBegin(), cend = sourcePathMap.constEnd(); it != cend; ++it) { - executeDebuggerCommand("settings append target.source-map " + it.key() + ' ' + it.value()); + executeDebuggerCommand( + "settings append target.source-map " + it.key() + ' ' + expand(it.value())); } DebuggerCommand cmd2("setupInferior"); @@ -763,6 +764,7 @@ void LldbEngine::doUpdateLocals(const UpdateParameters ¶ms) cmd.arg("dyntype", boolSetting(UseDynamicType)); cmd.arg("partialvar", params.partialVariable); cmd.arg("qobjectnames", boolSetting(ShowQObjectNames)); + cmd.arg("timestamps", boolSetting(LogTimeStamps)); StackFrame frame = stackHandler()->currentFrame(); cmd.arg("context", frame.context); diff --git a/src/plugins/debugger/loadcoredialog.cpp b/src/plugins/debugger/loadcoredialog.cpp index 8bd68aa791d..075cefd595b 100644 --- a/src/plugins/debugger/loadcoredialog.cpp +++ b/src/plugins/debugger/loadcoredialog.cpp @@ -137,7 +137,7 @@ void SelectRemoteFileDialog::attachToDevice(Kit *k) { m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); QTC_ASSERT(k, return); - IDevice::ConstPtr device = DeviceKitInformation::device(k); + IDevice::ConstPtr device = DeviceKitAspect::device(k); QTC_ASSERT(device, return); SshConnectionParameters sshParams = device->sshParameters(); m_fileSystemModel.setSshConnection(sshParams); @@ -352,7 +352,7 @@ bool AttachCoreDialog::isLocalKit() const { Kit *k = d->kitChooser->currentKit(); QTC_ASSERT(k, return false); - IDevice::ConstPtr device = DeviceKitInformation::device(k); + IDevice::ConstPtr device = DeviceKitAspect::device(k); QTC_ASSERT(device, return false); return device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; } @@ -367,12 +367,12 @@ void AttachCoreDialog::coreFileChanged(const QString &core) if (!HostOsInfo::isWindowsHost() && QFile::exists(core)) { Kit *k = d->kitChooser->currentKit(); QTC_ASSERT(k, return); - Runnable debugger = DebuggerKitInformation::runnable(k); + Runnable debugger = DebuggerKitAspect::runnable(k); CoreInfo cinfo = CoreInfo::readExecutableNameFromCore(debugger, core); if (!cinfo.foundExecutableName.isEmpty()) - d->symbolFileName->setFileName(FileName::fromString(cinfo.foundExecutableName)); + d->symbolFileName->setFileName(FilePath::fromString(cinfo.foundExecutableName)); else if (!d->symbolFileName->isValid() && !cinfo.rawStringFromCore.isEmpty()) - d->symbolFileName->setFileName(FileName::fromString(cinfo.rawStringFromCore)); + d->symbolFileName->setFileName(FilePath::fromString(cinfo.rawStringFromCore)); } changed(); } diff --git a/src/plugins/debugger/pdb/pdbengine.cpp b/src/plugins/debugger/pdb/pdbengine.cpp index f422225d452..39acf7df96c 100644 --- a/src/plugins/debugger/pdb/pdbengine.cpp +++ b/src/plugins/debugger/pdb/pdbengine.cpp @@ -118,7 +118,7 @@ void PdbEngine::setupEngine() QString bridge = ICore::resourcePath() + "/debugger/pdbbridge.py"; connect(&m_proc, &QProcess::errorOccurred, this, &PdbEngine::handlePdbError); - connect(&m_proc, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), + connect(&m_proc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, &PdbEngine::handlePdbFinished); connect(&m_proc, &QProcess::readyReadStandardOutput, this, &PdbEngine::readPdbStandardOutput); diff --git a/src/plugins/debugger/qml/qmlcppengine.cpp b/src/plugins/debugger/qml/qmlcppengine.cpp deleted file mode 100644 index 3353712dda3..00000000000 --- a/src/plugins/debugger/qml/qmlcppengine.cpp +++ /dev/null @@ -1,692 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "qmlcppengine.h" -#include "qmlengine.h" - -#include <debugger/debuggercore.h> -#include <debugger/debuggerruncontrol.h> -#include <debugger/debuggertooltipmanager.h> -#include <debugger/breakhandler.h> -#include <debugger/stackhandler.h> -#include <debugger/threaddata.h> -#include <debugger/watchhandler.h> -#include <debugger/console/console.h> - -#include <utils/qtcassert.h> -#include <qmljseditor/qmljseditorconstants.h> -#include <cppeditor/cppeditorconstants.h> - -namespace Debugger { -namespace Internal { - -enum { debug = 0 }; - -#define EDEBUG(s) do { if (debug) qDebug() << s; } while (0) - -#define CHECK_STATE(s) do { checkState(s, __FILE__, __LINE__); } while (0) - -DebuggerEngine *createQmlCppEngine(DebuggerEngine *cppEngine) -{ - return new QmlCppEngine(cppEngine); -} - - -//////////////////////////////////////////////////////////////////////// -// -// QmlCppEngine -// -//////////////////////////////////////////////////////////////////////// - -QmlCppEngine::QmlCppEngine(DebuggerEngine *cppEngine) -{ - setObjectName("QmlCppEngine"); - m_qmlEngine = new QmlEngine; - m_qmlEngine->setMasterEngine(this); - m_cppEngine = cppEngine; - m_cppEngine->setMasterEngine(this); - m_activeEngine = m_cppEngine; -} - -QmlCppEngine::~QmlCppEngine() -{ - delete m_qmlEngine; - delete m_cppEngine; -} - -bool QmlCppEngine::canDisplayTooltip() const -{ - return m_cppEngine->canDisplayTooltip() || m_qmlEngine->canDisplayTooltip(); -} - -bool QmlCppEngine::canHandleToolTip(const DebuggerToolTipContext &ctx) const -{ - bool success = false; - if (ctx.isCppEditor) - success = m_cppEngine->canHandleToolTip(ctx); - else - success = m_qmlEngine->canHandleToolTip(ctx); - return success; -} - -void QmlCppEngine::updateItem(const QString &iname) -{ - if (iname.startsWith("inspect.")) - m_qmlEngine->updateItem(iname); - else - m_activeEngine->updateItem(iname); -} - -void QmlCppEngine::expandItem(const QString &iname) -{ - if (iname.startsWith("inspect.")) - m_qmlEngine->expandItem(iname); - else - m_activeEngine->expandItem(iname); -} - -void QmlCppEngine::selectWatchData(const QString &iname) -{ - if (iname.startsWith("inspect.")) - m_qmlEngine->selectWatchData(iname); -} - -void QmlCppEngine::watchPoint(const QPoint &point) -{ - m_cppEngine->watchPoint(point); -} - -void QmlCppEngine::fetchMemory(MemoryAgent *agent, quint64 addr, quint64 length) -{ - m_cppEngine->fetchMemory(agent, addr, length); -} - -void QmlCppEngine::changeMemory(MemoryAgent *agent, quint64 addr, const QByteArray &data) -{ - m_cppEngine->changeMemory(agent, addr, data); -} - -void QmlCppEngine::fetchDisassembler(DisassemblerAgent *da) -{ - m_cppEngine->fetchDisassembler(da); -} - -void QmlCppEngine::activateFrame(int index) -{ - if (state() != InferiorStopOk && state() != InferiorUnrunnable) - return; - - m_activeEngine->activateFrame(index); - - stackHandler()->setCurrentIndex(index); -} - -void QmlCppEngine::reloadModules() -{ - m_cppEngine->reloadModules(); -} - -void QmlCppEngine::examineModules() -{ - m_cppEngine->examineModules(); -} - -void QmlCppEngine::loadSymbols(const QString &moduleName) -{ - m_cppEngine->loadSymbols(moduleName); -} - -void QmlCppEngine::loadAllSymbols() -{ - m_cppEngine->loadAllSymbols(); -} - -void QmlCppEngine::requestModuleSymbols(const QString &moduleName) -{ - m_cppEngine->requestModuleSymbols(moduleName); -} - -void QmlCppEngine::reloadRegisters() -{ - m_cppEngine->reloadRegisters(); -} - -void QmlCppEngine::reloadSourceFiles() -{ - m_cppEngine->reloadSourceFiles(); -} - -void QmlCppEngine::reloadFullStack() -{ - m_cppEngine->reloadFullStack(); -} - -void QmlCppEngine::setRegisterValue(const QString &name, const QString &value) -{ - m_cppEngine->setRegisterValue(name, value); -} - - -bool QmlCppEngine::hasCapability(unsigned cap) const -{ - // ### this could also be an OR of both engines' capabilities - bool hasCap = m_cppEngine->hasCapability(cap); - if (m_activeEngine != m_cppEngine) { - //Some capabilities cannot be handled by QML Engine - //Expand this list as and when required - if (cap == AddWatcherWhileRunningCapability) - hasCap = hasCap || m_qmlEngine->hasCapability(cap); - if (cap == WatchWidgetsCapability || - cap == DisassemblerCapability || - cap == OperateByInstructionCapability || - cap == ReverseSteppingCapability) - hasCap = hasCap && m_qmlEngine->hasCapability(cap); - } - return hasCap; -} - -QString QmlCppEngine::qtNamespace() const -{ - return m_cppEngine->qtNamespace(); -} - -void QmlCppEngine::createSnapshot() -{ - m_cppEngine->createSnapshot(); -} - -void QmlCppEngine::updateAll() -{ - m_activeEngine->updateAll(); -} - -void QmlCppEngine::attemptBreakpointSynchronization() -{ - m_cppEngine->attemptBreakpointSynchronization(); - - switch (m_qmlEngine->state()) { - case InferiorRunOk: - case InferiorRunRequested: - case InferiorStopOk: // fall through - case InferiorStopRequested: - m_qmlEngine->attemptBreakpointSynchronization(); - break; - default: - break; - } -} - -void QmlCppEngine::doUpdateLocals(const UpdateParameters &up) -{ - m_activeEngine->doUpdateLocals(up); -} - -bool QmlCppEngine::acceptsBreakpoint(Breakpoint bp) const -{ - return m_cppEngine->acceptsBreakpoint(bp) - || m_qmlEngine->acceptsBreakpoint(bp); -} - -void QmlCppEngine::selectThread(ThreadId threadId) -{ - m_activeEngine->selectThread(threadId); -} - -void QmlCppEngine::assignValueInDebugger(WatchItem *item, - const QString &expr, const QVariant &value) -{ - if (item->isInspect()) - m_qmlEngine->assignValueInDebugger(item, expr, value); - else - m_activeEngine->assignValueInDebugger(item, expr, value); -} - -void QmlCppEngine::notifyInferiorIll() -{ - //Call notifyInferiorIll of cpp engine - //as qml engine will follow state transitions - //of cpp engine - m_cppEngine->notifyInferiorIll(); -} - -void QmlCppEngine::detachDebugger() -{ - m_qmlEngine->detachDebugger(); - m_cppEngine->detachDebugger(); -} - -void QmlCppEngine::executeStep() -{ - notifyInferiorRunRequested(); - m_activeEngine->executeStep(); -} - -void QmlCppEngine::executeStepOut() -{ - notifyInferiorRunRequested(); - m_activeEngine->executeStepOut(); -} - -void QmlCppEngine::executeNext() -{ - notifyInferiorRunRequested(); - m_activeEngine->executeNext(); -} - -void QmlCppEngine::executeStepI() -{ - notifyInferiorRunRequested(); - m_activeEngine->executeStepI(); -} - -void QmlCppEngine::executeNextI() -{ - notifyInferiorRunRequested(); - m_activeEngine->executeNextI(); -} - -void QmlCppEngine::executeReturn() -{ - notifyInferiorRunRequested(); - m_activeEngine->executeReturn(); -} - -void QmlCppEngine::continueInferior() -{ - EDEBUG("\nMASTER CONTINUE INFERIOR" - << state() << m_qmlEngine->state()); - notifyInferiorRunRequested(); - if (m_cppEngine->state() == InferiorStopOk) { - m_cppEngine->continueInferior(); - } else if (m_qmlEngine->state() == InferiorStopOk) { - m_qmlEngine->continueInferior(); - } else { - QTC_ASSERT(false, qDebug() << "MASTER CANNOT CONTINUE INFERIOR" - << m_cppEngine->state() << m_qmlEngine->state()); - notifyEngineIll(); - } -} - -void QmlCppEngine::interruptInferior() -{ - EDEBUG("\nMASTER INTERRUPT INFERIOR"); - m_activeEngine->setState(InferiorStopRequested); - m_activeEngine->interruptInferior(); -} - -void QmlCppEngine::executeRunToLine(const ContextData &data) -{ - m_activeEngine->executeRunToLine(data); -} - -void QmlCppEngine::executeRunToFunction(const QString &functionName) -{ - m_activeEngine->executeRunToFunction(functionName); -} - -void QmlCppEngine::executeJumpToLine(const ContextData &data) -{ - m_activeEngine->executeJumpToLine(data); -} - -void QmlCppEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages languages) -{ - m_qmlEngine->executeDebuggerCommand(command, languages); - m_cppEngine->executeDebuggerCommand(command, languages); -} - -///////////////////////////////////////////////////////// - -void QmlCppEngine::setupEngine() -{ - EDEBUG("\nMASTER SETUP ENGINE"); - m_activeEngine = m_cppEngine; - m_qmlEngine->setupSlaveEngine(); - m_cppEngine->setupSlaveEngine(); -} - -void QmlCppEngine::runEngine() -{ - EDEBUG("\nMASTER RUN ENGINE"); - m_qmlEngine->runSlaveEngine(); - m_cppEngine->runSlaveEngine(); -} - -void QmlCppEngine::shutdownInferior() -{ - EDEBUG("\nMASTER SHUTDOWN INFERIOR"); - m_cppEngine->shutdownInferior(); -} - -void QmlCppEngine::shutdownEngine() -{ - EDEBUG("\nMASTER SHUTDOWN ENGINE"); - m_qmlEngine->shutdownSlaveEngine(); - m_cppEngine->shutdownSlaveEngine(); -} - -void QmlCppEngine::quitDebugger() -{ - EDEBUG("\nMASTER QUIT DEBUGGER"); - m_cppEngine->quitDebugger(); -} - -void QmlCppEngine::abortDebuggerProcess() -{ - EDEBUG("\nMASTER ABORT DEBUGGER"); - m_cppEngine->abortDebuggerProcess(); -} - -void QmlCppEngine::setState(DebuggerState newState, bool forced) -{ - EDEBUG("SET MASTER STATE: " << newState); - EDEBUG(" CPP STATE: " << m_cppEngine->state()); - EDEBUG(" QML STATE: " << m_qmlEngine->state()); - DebuggerEngine::setState(newState, forced); -} - -void QmlCppEngine::slaveEngineStateChanged - (DebuggerEngine *slaveEngine, const DebuggerState newState) -{ - DebuggerEngine *otherEngine = (slaveEngine == m_cppEngine) - ? m_qmlEngine.data() : m_cppEngine.data(); - - QTC_ASSERT(otherEngine, return); - QTC_CHECK(otherEngine != slaveEngine); - - if (debug) { - EDEBUG("GOT SLAVE STATE: " << slaveEngine << newState); - EDEBUG(" OTHER ENGINE: " << otherEngine << otherEngine->state()); - EDEBUG(" COMBINED ENGINE: " << this << state() << isDying()); - } - - if (state() == DebuggerFinished) { - // We are done and don't care about slave state changes anymore. - return; - } - - // Idea is to follow the state of the cpp engine, except where we are stepping in QML. - // That is, when the QmlEngine moves between InferiorStopOk, and InferiorRunOk, InferiorStopOk ... - // - // Accordingly, the 'active engine' is the cpp engine until the qml engine enters the - // InferiorStopOk state. The cpp engine becomes the active one again as soon as it itself enters - // the InferiorStopOk state. - - if (slaveEngine == m_cppEngine) { - switch (newState) { - case DebuggerNotReady: { - // Can this ever happen? - break; - } - case EngineSetupRequested: { - // Set by queueSetupEngine() - CHECK_STATE(EngineSetupRequested); - break; - } - case EngineSetupFailed: { - m_qmlEngine->quitDebugger(); - notifyEngineSetupFailed(); - break; - } - case EngineSetupOk: { - notifyEngineSetupOk(); - break; - } - case EngineRunRequested: { - // set by queueRunEngine() - break; - } - case EngineRunFailed: { - m_qmlEngine->quitDebugger(); - notifyEngineRunFailed(); - break; - } - case InferiorUnrunnable: { - m_qmlEngine->quitDebugger(); - notifyEngineRunOkAndInferiorUnrunnable(); - break; - } - case InferiorRunRequested: { - // Might be set already by notifyInferiorRunRequested() - if (state() != InferiorRunRequested) { - CHECK_STATE(InferiorStopOk); - notifyInferiorRunRequested(); - } - break; - } - case InferiorRunOk: { - if (state() == EngineRunRequested) { - notifyEngineRunAndInferiorRunOk(); - } else if (state() == InferiorRunRequested) { - notifyInferiorRunOk(); - } else if (state() == InferiorStopOk) { - notifyInferiorRunRequested(); - notifyInferiorRunOk(); - } else { - QTC_ASSERT(false, qDebug() << state()); - } - - if (m_qmlEngine->state() == InferiorStopOk) { - // track qml engine again - setState(InferiorStopRequested); - notifyInferiorStopOk(); - setActiveEngine(m_qmlEngine); - } - break; - } - case InferiorRunFailed: { - m_qmlEngine->quitDebugger(); - notifyInferiorRunFailed(); - break; - } - case InferiorStopRequested: { - if (m_activeEngine == cppEngine()) { - if (state() == InferiorRunOk) { - setState(InferiorStopRequested); - } else { - // Might be set by doInterruptInferior() - CHECK_STATE(InferiorStopRequested); - } - } else { - // We're debugging qml, but got an interrupt, or abort - if (state() == InferiorRunOk) { - setState(InferiorStopRequested); - } else if (state() == InferiorStopOk) { - if (!isDying()) { - notifyInferiorRunRequested(); - notifyInferiorRunOk(); - setState(InferiorStopRequested); - } - } else if (state() == InferiorRunRequested) { - notifyInferiorRunOk(); - setState(InferiorStopRequested); - } else { - QTC_ASSERT(false, qDebug() << state()); - } - // now track cpp engine - setActiveEngine(m_cppEngine); - } - break; - } - case InferiorStopOk: { - if (isDying()) { - EDEBUG("... CPP ENGINE STOPPED DURING SHUTDOWN "); - QTC_ASSERT(state() == InferiorStopRequested - || state() == InferiorRunOk - || state() == InferiorStopOk, qDebug() << state()); - - // Just to make sure, we're shutting down anyway ... - m_activeEngine = m_cppEngine; - - if (state() == InferiorStopRequested) - setState(InferiorStopOk); - // otherwise we're probably inside notifyInferiorStopOk already - } else { - if (m_activeEngine != cppEngine()) { - showStatusMessage(tr("C++ debugger activated")); - setActiveEngine(m_cppEngine); - } - switch (state()) { - case InferiorStopRequested: - EDEBUG("... CPP ENGINE STOPPED EXPECTEDLY"); - notifyInferiorStopOk(); - break; - case EngineRunRequested: - EDEBUG("... CPP ENGINE STOPPED ON STARTUP"); - notifyEngineRunAndInferiorStopOk(); - break; - case InferiorRunOk: - EDEBUG("... CPP ENGINE STOPPED SPONTANEOUSLY"); - notifyInferiorSpontaneousStop(); - break; - case InferiorRunRequested: - // can happen if qml engine was active - notifyInferiorRunFailed(); - break; - default: - CHECK_STATE(InferiorStopOk); - break; - } - } - break; - } - case InferiorStopFailed: { - CHECK_STATE(InferiorStopRequested); - notifyInferiorStopFailed(); - break; - } - case InferiorShutdownRequested: { - if (state() == InferiorStopOk) { - setState(InferiorShutdownRequested); - } else { - // might be set by queueShutdownInferior() already - CHECK_STATE(InferiorShutdownRequested); - } - m_qmlEngine->quitDebugger(); - break; - } - case InferiorShutdownFinished: { - if (state() == InferiorShutdownRequested) { - notifyInferiorShutdownFinished(); - } else { - // we got InferiorExitOk before, but ignored it ... - notifyInferiorExited(); - } - break; - } - case EngineShutdownRequested: { - // set by queueShutdownEngine() - CHECK_STATE(EngineShutdownRequested); - break; - } - case EngineShutdownFinished: { - CHECK_STATE(EngineShutdownRequested); - notifyEngineShutdownFinished(); - break; - } - case DebuggerFinished: { - // set by queueFinishDebugger() - CHECK_STATE(DebuggerFinished); - break; - } - } - } else { - // QML engine state change - if (newState == InferiorStopOk) { - if (isDying()) { - EDEBUG("... QML ENGINE STOPPED DURING SHUTDOWN "); - - // Just to make sure, we're shutting down anyway ... - setActiveEngine(m_cppEngine); - - if (state() == InferiorStopRequested) - notifyInferiorStopOk(); - // otherwise we're probably inside notifyInferiorStopOk already - } else { - if (m_activeEngine != m_qmlEngine) { - showStatusMessage(tr("QML debugger activated")); - setActiveEngine(m_qmlEngine); - } - - if (state() == InferiorRunOk) - notifyInferiorSpontaneousStop(); - else if (state() == InferiorStopRequested) - notifyInferiorStopOk(); - else - CHECK_STATE(InferiorShutdownRequested); - } - - } else if (newState == InferiorRunOk) { - if (m_activeEngine == m_qmlEngine) { - CHECK_STATE(InferiorRunRequested); - notifyInferiorRunOk(); - } - } - } -} - -void QmlCppEngine::resetLocation() -{ - if (m_qmlEngine) - m_qmlEngine->resetLocation(); - if (m_cppEngine) - m_cppEngine->resetLocation(); - - DebuggerEngine::resetLocation(); -} - -void QmlCppEngine::reloadDebuggingHelpers() -{ - if (m_cppEngine) - m_cppEngine->reloadDebuggingHelpers(); -} - -void QmlCppEngine::debugLastCommand() -{ - if (m_cppEngine) - m_cppEngine->debugLastCommand(); -} - -void QmlCppEngine::setRunTool(DebuggerRunTool *runTool) -{ - DebuggerEngine::setRunTool(runTool); - m_qmlEngine->setRunTool(runTool); - m_cppEngine->setRunTool(runTool); -} - -void QmlCppEngine::setActiveEngine(DebuggerEngine *engine) -{ - m_activeEngine = engine; - updateViews(); -} - -void QmlCppEngine::loadAdditionalQmlStack() -{ - if (m_cppEngine) - m_cppEngine->loadAdditionalQmlStack(); -} - -} // namespace Internal -} // namespace Debugger diff --git a/src/plugins/debugger/qml/qmlcppengine.h b/src/plugins/debugger/qml/qmlcppengine.h deleted file mode 100644 index fffd08a89aa..00000000000 --- a/src/plugins/debugger/qml/qmlcppengine.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include <debugger/debuggerengine.h> - -namespace Debugger { -namespace Internal { - -class QmlEngine; - -class QmlCppEngine : public DebuggerEngine -{ - Q_OBJECT - -public: - explicit QmlCppEngine(DebuggerEngine *cppEngine); - ~QmlCppEngine() override; - - bool canDisplayTooltip() const override; - bool canHandleToolTip(const DebuggerToolTipContext &) const override; - void updateItem(const QString &iname) override; - void expandItem(const QString &iname) override; - void selectWatchData(const QString &iname) override; - - void watchPoint(const QPoint &) override; - void fetchMemory(MemoryAgent *, quint64 addr, quint64 length) override; - void changeMemory(MemoryAgent *, quint64 addr, const QByteArray &data) override; - void fetchDisassembler(DisassemblerAgent *) override; - void activateFrame(int index) override; - - void reloadModules() override; - void examineModules() override; - void loadSymbols(const QString &moduleName) override; - void loadAllSymbols() override; - void requestModuleSymbols(const QString &moduleName) override; - - void reloadRegisters() override; - void reloadSourceFiles() override; - void reloadFullStack() override; - - void setRegisterValue(const QString &name, const QString &value) override; - bool hasCapability(unsigned cap) const override; - - QString qtNamespace() const override; - - void createSnapshot() override; - void updateAll() override; - - void attemptBreakpointSynchronization() override; - bool acceptsBreakpoint(Breakpoint bp) const override; - void selectThread(ThreadId threadId) override; - - void assignValueInDebugger(WatchItem *item, - const QString &expr, const QVariant &value) override; - - DebuggerEngine *cppEngine() override { return m_cppEngine; } - DebuggerEngine *activeEngine() override { return m_activeEngine; } - void setRunTool(DebuggerRunTool *runTool) override; - - void resetLocation() override; - void notifyInferiorIll() override; - -protected: - void detachDebugger() override; - void reloadDebuggingHelpers() override; - void debugLastCommand() override; - void executeStep() override; - void executeStepOut() override; - void executeNext() override; - void executeStepI() override; - void executeNextI() override; - void executeReturn() override; - void continueInferior() override; - void interruptInferior() override; - - void executeRunToLine(const ContextData &data) override; - void executeRunToFunction(const QString &functionName) override; - void executeJumpToLine(const ContextData &data) override; - void executeDebuggerCommand(const QString &command, DebuggerLanguages languages) override; - void doUpdateLocals(const UpdateParameters &up) override; - - void setupEngine() override; - void runEngine() override; - void shutdownInferior() override; - void shutdownEngine() override; - void quitDebugger() override; - void abortDebuggerProcess() override; - - void loadAdditionalQmlStack() override; - -private: - void engineStateChanged(DebuggerState newState); - void setState(DebuggerState newState, bool forced = false) override; - void slaveEngineStateChanged(DebuggerEngine *slaveEngine, DebuggerState state) override; - - void setActiveEngine(DebuggerEngine *engine); - -private: - QPointer<QmlEngine> m_qmlEngine; - QPointer<DebuggerEngine> m_cppEngine; - QPointer<DebuggerEngine> m_activeEngine; -}; - -} // namespace Internal -} // namespace Debugger diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index 7f5971e2be4..255052936e0 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -1419,7 +1419,7 @@ void QmlEnginePrivate::setBreakpoint(const QString type, const QString target, cmd.arg(ENABLED, enabled); if (type == SCRIPTREGEXP) - cmd.arg(TARGET, Utils::FileName::fromString(target).fileName()); + cmd.arg(TARGET, Utils::FilePath::fromString(target).fileName()); else cmd.arg(TARGET, target); diff --git a/src/plugins/debugger/qml/qmlinspectoragent.cpp b/src/plugins/debugger/qml/qmlinspectoragent.cpp index 36272270c9e..86d429749e9 100644 --- a/src/plugins/debugger/qml/qmlinspectoragent.cpp +++ b/src/plugins/debugger/qml/qmlinspectoragent.cpp @@ -29,6 +29,7 @@ #include <debugger/debuggeractions.h> #include <debugger/debuggercore.h> #include <debugger/debuggerengine.h> +#include <debugger/debuggerinternalconstants.h> #include <debugger/debuggerruncontrol.h> #include <debugger/watchhandler.h> diff --git a/src/plugins/debugger/registerhandler.cpp b/src/plugins/debugger/registerhandler.cpp index 0e066afade6..7614bc413ca 100644 --- a/src/plugins/debugger/registerhandler.cpp +++ b/src/plugins/debugger/registerhandler.cpp @@ -119,7 +119,7 @@ public: painter->setPen(lightColor); // FIXME: performance? this changes only on real font changes. QFontMetrics fm(option.font); - int charWidth = qMax(fm.width('x'), fm.width('0')); + int charWidth = qMax(fm.horizontalAdvance('x'), fm.horizontalAdvance('0')); QString str = index.data(Qt::DisplayRole).toString(); int x = option.rect.x(); bool light = !paintRed; diff --git a/src/plugins/debugger/sourceagent.cpp b/src/plugins/debugger/sourceagent.cpp index 074806c5bb0..565144dac49 100644 --- a/src/plugins/debugger/sourceagent.cpp +++ b/src/plugins/debugger/sourceagent.cpp @@ -104,7 +104,7 @@ void SourceAgent::setContent(const QString &filePath, const QString &content) if (!d->editor) { QString titlePattern = d->producer + ": " - + Utils::FileName::fromString(filePath).fileName(); + + Utils::FilePath::fromString(filePath).fileName(); d->editor = qobject_cast<BaseTextEditor *>( EditorManager::openEditorWithContents( CppEditor::Constants::CPPEDITOR_ID, @@ -137,7 +137,7 @@ void SourceAgent::updateLocationMarker() if (d->engine->stackHandler()->currentFrame().file == d->path) { int lineNumber = d->engine->stackHandler()->currentFrame().line; - d->locationMark = new TextMark(Utils::FileName(), lineNumber, + d->locationMark = new TextMark(Utils::FilePath(), lineNumber, Constants::TEXT_MARK_CATEGORY_LOCATION); d->locationMark->setIcon(Icons::LOCATION.icon()); d->locationMark->setPriority(TextMark::HighPriority); diff --git a/src/plugins/debugger/stackhandler.cpp b/src/plugins/debugger/stackhandler.cpp index 4d134792bd6..bd57ea0c6d5 100644 --- a/src/plugins/debugger/stackhandler.cpp +++ b/src/plugins/debugger/stackhandler.cpp @@ -112,7 +112,7 @@ QVariant StackHandler::data(const QModelIndex &index, int role) const case StackFunctionNameColumn: return simplifyType(frame.function); case StackFileNameColumn: - return frame.file.isEmpty() ? frame.module : FileName::fromString(frame.file).fileName(); + return frame.file.isEmpty() ? frame.module : FilePath::fromString(frame.file).fileName(); case StackLineNumberColumn: return frame.line > 0 ? QVariant(frame.line) : QVariant(); case StackAddressColumn: diff --git a/src/plugins/debugger/terminal.h b/src/plugins/debugger/terminal.h index d6caa55f98e..8f23242c8a4 100644 --- a/src/plugins/debugger/terminal.h +++ b/src/plugins/debugger/terminal.h @@ -28,7 +28,7 @@ #include <QCoreApplication> #include <QSocketNotifier> -#include <projectexplorer/runconfiguration.h> +#include <projectexplorer/runcontrol.h> #include <utils/consoleprocess.h> diff --git a/src/plugins/debugger/unstartedappwatcherdialog.cpp b/src/plugins/debugger/unstartedappwatcherdialog.cpp index 8a52c57e1d6..25cfe10d7b8 100644 --- a/src/plugins/debugger/unstartedappwatcherdialog.cpp +++ b/src/plugins/debugger/unstartedappwatcherdialog.cpp @@ -59,7 +59,7 @@ static bool isLocal(RunConfiguration *runConfiguration) { Target *target = runConfiguration ? runConfiguration->target() : nullptr; Kit *kit = target ? target->kit() : nullptr; - return DeviceTypeKitInformation::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; + return DeviceTypeKitAspect::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; } /*! @@ -275,7 +275,7 @@ void UnstartedAppWatcherDialog::stopAndCheckExecutable() void UnstartedAppWatcherDialog::kitChanged() { - const DebuggerItem *debugger = DebuggerKitInformation::debugger(m_kitChooser->currentKit()); + const DebuggerItem *debugger = DebuggerKitAspect::debugger(m_kitChooser->currentKit()); if (!debugger) return; if (debugger->engineType() == Debugger::CdbEngineType) { diff --git a/src/plugins/debugger/watchdata.cpp b/src/plugins/debugger/watchdata.cpp index c37e9d46a2b..7abde55e875 100644 --- a/src/plugins/debugger/watchdata.cpp +++ b/src/plugins/debugger/watchdata.cpp @@ -363,6 +363,10 @@ void WatchItem::parseHelper(const GdbMi &input, bool maySort) if (mi.isValid()) exp = mi.data(); + mi = input["time"]; + if (mi.isValid()) + time = mi.data().toFloat(); + mi = input["sortgroup"]; if (mi.isValid()) sortGroup = mi.toInt(); @@ -462,6 +466,8 @@ void WatchItem::parse(const GdbMi &data, bool maySort) if (wname.isValid()) exp = name; + + time = data["time"].data().toFloat(); } // Format a tooltip row with aligned colon. @@ -508,6 +514,7 @@ QString WatchItem::toToolTip() const if (size) formatToolTipRow(str, tr("Static Object Size"), tr("%n bytes", nullptr, size)); formatToolTipRow(str, tr("Internal ID"), internalName()); + formatToolTipRow(str, tr("Creation Time in ms"), QString::number(int(time * 1000))); str << "</table></body></html>"; return res; } diff --git a/src/plugins/debugger/watchdata.h b/src/plugins/debugger/watchdata.h index e6131c39cdc..15146d9616e 100644 --- a/src/plugins/debugger/watchdata.h +++ b/src/plugins/debugger/watchdata.h @@ -99,6 +99,7 @@ public: bool valueEnabled; // Value will be enabled or not bool valueEditable; // Value will be editable bool outdated; // \internal item is to be removed. + double time = 0; // Time used on the dumper side to produce this item private: void parseHelper(const GdbMi &input, bool maySort); diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 8087e776387..3e95668d52d 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -484,7 +484,7 @@ WatchModel::WatchModel(WatchHandler *handler, DebuggerEngine *engine) m_contentsValid = true; - setHeader({tr("Name"), tr("Value"), tr("Type")}); + setHeader({tr("Name"), tr("Time"), tr("Value"), tr("Type")}); m_localsRoot = new WatchItem; m_localsRoot->iname = "local"; m_localsRoot->name = tr("Locals"); @@ -901,7 +901,7 @@ static QColor valueColor(const WatchItem *item, int column) if (const WatchModel *model = watchModel(item)) { if (!model->m_contentsValid && !item->isInspect()) { color = Theme::Debugger_WatchItem_ValueInvalid; - } else if (column == 1) { + } else if (column == WatchModel::ValueColumn) { if (!item->valueEnabled) color = Theme::Debugger_WatchItem_ValueInvalid; else if (!model->m_contentsValid && !item->isInspect()) @@ -1011,11 +1011,13 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const case Qt::EditRole: { switch (column) { - case 0: + case TimeColumn: + return item->time; + case NameColumn: return item->expression(); - case 1: + case ValueColumn: return item->editValue(); - case 2: + case TypeColumn: return item->type; } break; @@ -1023,11 +1025,13 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const case Qt::DisplayRole: { switch (column) { - case 0: + case TimeColumn: + return int(1000 * item->time); + case NameColumn: return displayName(item); - case 1: + case ValueColumn: return displayValue(item); - case 2: + case TypeColumn: return displayType(item); } break; @@ -1129,14 +1133,14 @@ bool WatchModel::setData(const QModelIndex &idx, const QVariant &value, int role switch (role) { case Qt::EditRole: switch (idx.column()) { - case 0: { + case NameColumn: { m_handler->updateWatchExpression(item, value.toString().trimmed()); break; } - case 1: // Change value + case ValueColumn: // Change value m_engine->assignValueInDebugger(item, item->expression(), value); break; - case 2: // TODO: Implement change type. + case TypeColumn: // TODO: Implement change type. m_engine->assignValueInDebugger(item, item->expression(), value); break; } @@ -1206,20 +1210,20 @@ Qt::ItemFlags WatchModel::flags(const QModelIndex &idx) const if (item->isWatcher()) { if (state == InferiorUnrunnable) - return (column == 0 && item->iname.count('.') == 1) ? editable : notEditable; + return (column == NameColumn && item->iname.count('.') == 1) ? editable : notEditable; if (isRunning && !m_engine->hasCapability(AddWatcherWhileRunningCapability)) return notEditable; - if (column == 0 && item->iname.count('.') == 1) + if (column == NameColumn && item->iname.count('.') == 1) return editable; // Watcher names are editable. - if (column == 1 && item->arrayIndex >= 0) + if (column == ValueColumn && item->arrayIndex >= 0) return editable; if (!item->name.isEmpty()) { // FIXME: Forcing types is not implemented yet. //if (idx.column() == 2) // return editable; // Watcher types can be set by force. - if (column == 1 && item->valueEditable && !item->elided) + if (column == ValueColumn && item->valueEditable && !item->elided) return editable; // Watcher values are sometimes editable. } } else if (item->isLocal()) { @@ -1227,12 +1231,12 @@ Qt::ItemFlags WatchModel::flags(const QModelIndex &idx) const return notEditable; if (isRunning && !m_engine->hasCapability(AddWatcherWhileRunningCapability)) return notEditable; - if (column == 1 && item->valueEditable && !item->elided) + if (column == ValueColumn && item->valueEditable && !item->elided) return editable; // Locals values are sometimes editable. - if (column == 1 && item->arrayIndex >= 0) + if (column == ValueColumn && item->arrayIndex >= 0) return editable; } else if (item->isInspect()) { - if (column == 1 && item->valueEditable) + if (column == ValueColumn && item->valueEditable) return editable; // Inspector values are sometimes editable. } return notEditable; diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index 5be7c7f58ec..39c8630d751 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -46,6 +46,8 @@ class WatchModelBase : public Utils::TreeModel<WatchItem, WatchItem> public: WatchModelBase() = default; + enum { NameColumn, TimeColumn, ValueColumn, TypeColumn }; + signals: void currentIndexRequested(const QModelIndex &idx); void itemIsExpanded(const QModelIndex &idx); diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index cf31ff71870..9da95b351e9 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -53,6 +53,9 @@ WatchTreeView::WatchTreeView(WatchType type) connect(this, &QTreeView::expanded, this, &WatchTreeView::expandNode); connect(this, &QTreeView::collapsed, this, &WatchTreeView::collapseNode); + + connect(action(LogTimeStamps), &QAction::triggered, + this, &WatchTreeView::updateTimeColumn); } void WatchTreeView::expandNode(const QModelIndex &idx) @@ -96,6 +99,14 @@ void WatchTreeView::setModel(QAbstractItemModel *model) connect(watchModel, &WatchModelBase::updateFinished, this, &WatchTreeView::hideProgressIndicator); } + + updateTimeColumn(); +} + +void WatchTreeView::updateTimeColumn() +{ + if (header()) + header()->setSectionHidden(WatchModelBase::TimeColumn, !boolSetting(LogTimeStamps)); } void WatchTreeView::handleItemIsExpanded(const QModelIndex &idx) diff --git a/src/plugins/debugger/watchwindow.h b/src/plugins/debugger/watchwindow.h index bd75e005491..a2ede3cbe4b 100644 --- a/src/plugins/debugger/watchwindow.h +++ b/src/plugins/debugger/watchwindow.h @@ -56,6 +56,7 @@ private: void resetHelper(); void expandNode(const QModelIndex &idx); void collapseNode(const QModelIndex &idx); + void updateTimeColumn(); void adjustSlider(); void doItemsLayout() override; |