From b63034b551f08ef3e1bf921b3c531e2ce65c266b Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 19 Sep 2019 16:36:43 +0200 Subject: [PATCH] Debugger: Move showModule{Sections,Symbols} to DebuggerEngine A bit closer to where the functions are used. No real change. Change-Id: Icbad68bd31d85caa59980316537ee532faf2d7ef Reviewed-by: Christian Stenger --- src/plugins/debugger/debuggercore.h | 7 --- src/plugins/debugger/debuggerengine.cpp | 67 ++++++++++++++++++++++++ src/plugins/debugger/debuggerengine.h | 10 ++-- src/plugins/debugger/debuggerplugin.cpp | 67 ------------------------ src/plugins/debugger/gdb/gdbengine.cpp | 4 +- src/plugins/debugger/lldb/lldbengine.cpp | 4 +- src/plugins/debugger/pdb/pdbengine.cpp | 2 +- src/plugins/debugger/sourceutils.cpp | 4 +- 8 files changed, 81 insertions(+), 84 deletions(-) diff --git a/src/plugins/debugger/debuggercore.h b/src/plugins/debugger/debuggercore.h index 60bd22f3731..f14884d3e3b 100644 --- a/src/plugins/debugger/debuggercore.h +++ b/src/plugins/debugger/debuggercore.h @@ -50,9 +50,6 @@ class SavedAction; namespace Debugger { namespace Internal { -class Console; -class Symbol; -class Section; class GlobalDebuggerOptions; enum TestCases @@ -64,15 +61,11 @@ enum TestCases // Some convenience. void openTextEditor(const QString &titlePattern, const QString &contents); -void showModuleSymbols(const QString &moduleName, const QVector &symbols); -void showModuleSections(const QString &moduleName, const QVector §ions); - QSharedPointer globalDebuggerOptions(); bool isTestRun(); Utils::SavedAction *action(int code); -Console *console(); bool boolSetting(int code); QString stringSetting(int code); diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 0dd02e1b63f..9d59cc0fe07 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -2619,6 +2619,73 @@ QString DebuggerEngine::formatStartParameters() const return rc; } +static void createNewDock(QWidget *widget) +{ + auto dockWidget = new QDockWidget; + dockWidget->setWidget(widget); + dockWidget->setWindowTitle(widget->windowTitle()); + dockWidget->setFeatures(QDockWidget::DockWidgetClosable); + dockWidget->show(); +} + +void DebuggerEngine::showModuleSymbols(const QString &moduleName, const Symbols &symbols) +{ + auto w = new QTreeWidget; + w->setUniformRowHeights(true); + w->setColumnCount(5); + w->setRootIsDecorated(false); + w->setAlternatingRowColors(true); + w->setSortingEnabled(true); + w->setObjectName("Symbols." + moduleName); + QStringList header; + header.append(tr("Symbol")); + header.append(tr("Address")); + header.append(tr("Code")); + header.append(tr("Section")); + header.append(tr("Name")); + w->setHeaderLabels(header); + w->setWindowTitle(tr("Symbols in \"%1\"").arg(moduleName)); + for (const Symbol &s : symbols) { + auto it = new QTreeWidgetItem; + it->setData(0, Qt::DisplayRole, s.name); + it->setData(1, Qt::DisplayRole, s.address); + it->setData(2, Qt::DisplayRole, s.state); + it->setData(3, Qt::DisplayRole, s.section); + it->setData(4, Qt::DisplayRole, s.demangled); + w->addTopLevelItem(it); + } + createNewDock(w); +} + +void DebuggerEngine::showModuleSections(const QString &moduleName, const Sections §ions) +{ + auto w = new QTreeWidget; + w->setUniformRowHeights(true); + w->setColumnCount(5); + w->setRootIsDecorated(false); + w->setAlternatingRowColors(true); + w->setSortingEnabled(true); + w->setObjectName("Sections." + moduleName); + QStringList header; + header.append(tr("Name")); + header.append(tr("From")); + header.append(tr("To")); + header.append(tr("Address")); + header.append(tr("Flags")); + w->setHeaderLabels(header); + w->setWindowTitle(tr("Sections in \"%1\"").arg(moduleName)); + for (const Section &s : sections) { + auto it = new QTreeWidgetItem; + it->setData(0, Qt::DisplayRole, s.name); + it->setData(1, Qt::DisplayRole, s.from); + it->setData(2, Qt::DisplayRole, s.to); + it->setData(3, Qt::DisplayRole, s.address); + it->setData(4, Qt::DisplayRole, s.flags); + w->addTopLevelItem(it); + } + createNewDock(w); +} + // CppDebuggerEngine Context CppDebuggerEngine::languageContext() const diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index f4ba9e47cb0..32c8e7481b5 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -102,9 +102,11 @@ class LogWindow; class ModulesHandler; class RegisterHandler; class PeripheralRegisterHandler; -class StackHandler; -class StackFrame; +class Section; class SourceFilesHandler; +class StackFrame; +class StackHandler; +class Symbol; class WatchHandler; class WatchTreeView; class DebuggerToolTipContext; @@ -460,6 +462,9 @@ public: void openMemoryEditor(); + static void showModuleSymbols(const QString &moduleName, const QVector &symbols); + static void showModuleSections(const QString &moduleName, const QVector
§ions); + void handleExecDetach(); void handleExecContinue(); void handleExecInterrupt(); @@ -546,7 +551,6 @@ protected: bool isNativeMixedActiveFrame() const; void startDying() const; -protected: ProjectExplorer::IDevice::ConstPtr device() const; DebuggerEngine *companionEngine() const; diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 0bf371835d3..b224572bba6 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -2015,15 +2015,6 @@ void DebuggerPluginPrivate::aboutToShutdown() m_shutdownTimer.start(); } -static void createNewDock(QWidget *widget) -{ - auto dockWidget = new QDockWidget; - dockWidget->setWidget(widget); - dockWidget->setWindowTitle(widget->windowTitle()); - dockWidget->setFeatures(QDockWidget::DockWidgetClosable); - dockWidget->show(); -} - void DebuggerPluginPrivate::remoteCommand(const QStringList &options) { if (options.isEmpty()) @@ -2117,64 +2108,6 @@ QStringList stringListSetting(int code) return action(code)->value().toStringList(); } -void showModuleSymbols(const QString &moduleName, const Symbols &symbols) -{ - auto w = new QTreeWidget; - w->setUniformRowHeights(true); - w->setColumnCount(5); - w->setRootIsDecorated(false); - w->setAlternatingRowColors(true); - w->setSortingEnabled(true); - w->setObjectName("Symbols." + moduleName); - QStringList header; - header.append(DebuggerPlugin::tr("Symbol")); - header.append(DebuggerPlugin::tr("Address")); - header.append(DebuggerPlugin::tr("Code")); - header.append(DebuggerPlugin::tr("Section")); - header.append(DebuggerPlugin::tr("Name")); - w->setHeaderLabels(header); - w->setWindowTitle(DebuggerPlugin::tr("Symbols in \"%1\"").arg(moduleName)); - for (const Symbol &s : symbols) { - auto it = new QTreeWidgetItem; - it->setData(0, Qt::DisplayRole, s.name); - it->setData(1, Qt::DisplayRole, s.address); - it->setData(2, Qt::DisplayRole, s.state); - it->setData(3, Qt::DisplayRole, s.section); - it->setData(4, Qt::DisplayRole, s.demangled); - w->addTopLevelItem(it); - } - createNewDock(w); -} - -void showModuleSections(const QString &moduleName, const Sections §ions) -{ - auto w = new QTreeWidget; - w->setUniformRowHeights(true); - w->setColumnCount(5); - w->setRootIsDecorated(false); - w->setAlternatingRowColors(true); - w->setSortingEnabled(true); - w->setObjectName("Sections." + moduleName); - QStringList header; - header.append(DebuggerPlugin::tr("Name")); - header.append(DebuggerPlugin::tr("From")); - header.append(DebuggerPlugin::tr("To")); - header.append(DebuggerPlugin::tr("Address")); - header.append(DebuggerPlugin::tr("Flags")); - w->setHeaderLabels(header); - w->setWindowTitle(DebuggerPlugin::tr("Sections in \"%1\"").arg(moduleName)); - for (const Section &s : sections) { - auto it = new QTreeWidgetItem; - it->setData(0, Qt::DisplayRole, s.name); - it->setData(1, Qt::DisplayRole, s.from); - it->setData(2, Qt::DisplayRole, s.to); - it->setData(3, Qt::DisplayRole, s.address); - it->setData(4, Qt::DisplayRole, s.flags); - w->addTopLevelItem(it); - } - createNewDock(w); -} - void openTextEditor(const QString &titlePattern0, const QString &contents) { if (dd->m_shuttingDown) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 5a40aa2ee0c..dda518ceea5 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -2651,7 +2651,7 @@ static void handleShowModuleSymbols(const DebuggerResponse &response, } file.close(); file.remove(); - Internal::showModuleSymbols(modulePath, symbols); + DebuggerEngine::showModuleSymbols(modulePath, symbols); } else { AsynchronousMessageBox::critical(GdbEngine::tr("Cannot Read Symbols"), GdbEngine::tr("Cannot read symbols for module \"%1\".").arg(fileName)); @@ -2716,7 +2716,7 @@ void GdbEngine::handleShowModuleSections(const DebuggerResponse &response, } } if (!sections.isEmpty()) - Internal::showModuleSections(moduleName, sections); + DebuggerEngine::showModuleSections(moduleName, sections); } } diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index d60b0951e7a..f75c491d5de 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -669,7 +669,7 @@ void LldbEngine::requestModuleSymbols(const QString &moduleName) { DebuggerCommand cmd("fetchSymbols"); cmd.arg("module", moduleName); - cmd.callback = [moduleName](const DebuggerResponse &response) { + cmd.callback = [this, moduleName](const DebuggerResponse &response) { const GdbMi &symbols = response.data["symbols"]; QString moduleName = response.data["module"].data(); Symbols syms; @@ -682,7 +682,7 @@ void LldbEngine::requestModuleSymbols(const QString &moduleName) symbol.demangled = item["demangled"].data(); syms.append(symbol); } - Internal::showModuleSymbols(moduleName, syms); + showModuleSymbols(moduleName, syms); }; runCommand(cmd); } diff --git a/src/plugins/debugger/pdb/pdbengine.cpp b/src/plugins/debugger/pdb/pdbengine.cpp index defd54050be..8d86407a4db 100644 --- a/src/plugins/debugger/pdb/pdbengine.cpp +++ b/src/plugins/debugger/pdb/pdbengine.cpp @@ -369,7 +369,7 @@ void PdbEngine::refreshSymbols(const GdbMi &symbols) symbol.name = item["name"].data(); syms.append(symbol); } - Internal::showModuleSymbols(moduleName, syms); + showModuleSymbols(moduleName, syms); } bool PdbEngine::canHandleToolTip(const DebuggerToolTipContext &) const diff --git a/src/plugins/debugger/sourceutils.cpp b/src/plugins/debugger/sourceutils.cpp index a08221c4e14..ea50eca8bd6 100644 --- a/src/plugins/debugger/sourceutils.cpp +++ b/src/plugins/debugger/sourceutils.cpp @@ -161,7 +161,7 @@ static void blockRecursion(const Overview &overview, // Go backwards in case someone has identical variables in the same scope. // Fixme: loop variables or similar are currently seen in the outer scope for (int s = scope->memberCount() - 1; s >= 0; --s){ - const Symbol *symbol = scope->memberAt(s); + const CPlusPlus::Symbol *symbol = scope->memberAt(s); if (symbol->isDeclaration()) { // Find out about shadowed symbols by bookkeeping // the already seen occurrences in a hash. @@ -197,7 +197,7 @@ QStringList getUninitializedVariables(const Snapshot &snapshot, const Document::Ptr doc = docIt.value(); // Look at symbol at line and find its function. Either it is the // function itself or some expression/variable. - const Symbol *symbolAtLine = doc->lastVisibleSymbolAt(line, 0); + const CPlusPlus::Symbol *symbolAtLine = doc->lastVisibleSymbolAt(line, 0); if (!symbolAtLine) return result; // First figure out the function to do a safety name check