From 7ac99044e8fe1a8e4a9064fb7b1251c88eaff7d0 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 14 Sep 2015 12:53:35 +0200 Subject: [PATCH] Debugger: Merge watcher request creation ... of {Gdb,Lldb,Pdb}Engine. Code is the same nowadays. Change-Id: I874b1ddfd813c15cc16c9b91bd894c7c42b56e93 Reviewed-by: Niels Weber Reviewed-by: David Schulz --- src/plugins/debugger/gdb/gdbengine.cpp | 22 +--------------------- src/plugins/debugger/lldb/lldbengine.cpp | 24 +----------------------- src/plugins/debugger/pdb/pdbengine.cpp | 24 +----------------------- src/plugins/debugger/watchhandler.cpp | 23 +++++++++++++++++++++++ src/plugins/debugger/watchhandler.h | 4 +++- 5 files changed, 29 insertions(+), 68 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index af1334c1ce..35e8cca3ca 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -4669,31 +4669,11 @@ void GdbEngine::doUpdateLocals(const UpdateParameters ¶ms) DebuggerCommand cmd("showData"); watchHandler()->appendFormatRequests(&cmd); + watchHandler()->appendWatchersAndTooltipRequests(&cmd); cmd.arg("stringcutoff", action(MaximalStringLength)->value().toByteArray()); cmd.arg("displaystringlimit", action(DisplayStringLimit)->value().toByteArray()); - // Re-create tooltip items that are not filters on existing local variables in - // the tooltip model. - cmd.beginList("watchers"); - DebuggerToolTipContexts toolTips = DebuggerToolTipManager::pendingTooltips(this); - foreach (const DebuggerToolTipContext &p, toolTips) { - cmd.beginGroup(); - cmd.arg("iname", p.iname); - cmd.arg("exp", p.expression.toLatin1().toHex()); - cmd.endGroup(); - } - - QHashIterator it(WatchHandler::watcherNames()); - while (it.hasNext()) { - it.next(); - cmd.beginGroup(); - cmd.arg("iname", "watch." + QByteArray::number(it.value())); - cmd.arg("exp", it.key().toHex()); - cmd.endGroup(); - } - cmd.endList(); - const static bool alwaysVerbose = !qgetenv("QTC_DEBUGGER_PYTHON_VERBOSE").isEmpty(); cmd.arg("passExceptions", alwaysVerbose); diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index ceb135f313..8b8e0823fb 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -826,6 +826,7 @@ void LldbEngine::doUpdateLocals(const UpdateParameters ¶ms) DebuggerCommand cmd("fetchLocals"); cmd.arg("nativeMixed", isNativeMixedActive()); watchHandler()->appendFormatRequests(&cmd); + watchHandler()->appendWatchersAndTooltipRequests(&cmd); const static bool alwaysVerbose = !qgetenv("QTC_DEBUGGER_PYTHON_VERBOSE").isEmpty(); cmd.arg("passexceptions", alwaysVerbose); @@ -835,29 +836,6 @@ void LldbEngine::doUpdateLocals(const UpdateParameters ¶ms) cmd.arg("partialVariable", params.partialVariable); cmd.arg("sortStructMembers", boolSetting(SortStructMembers)); - cmd.beginList("watchers"); - - // Watchers - QHashIterator it(WatchHandler::watcherNames()); - while (it.hasNext()) { - it.next(); - cmd.beginGroup(); - cmd.arg("iname", "watch." + QByteArray::number(it.value())); - cmd.arg("exp", it.key().toHex()); - cmd.endGroup(); - } - - // Tooltips - DebuggerToolTipContexts toolTips = DebuggerToolTipManager::pendingTooltips(this); - foreach (const DebuggerToolTipContext &p, toolTips) { - cmd.beginGroup(); - cmd.arg("iname", p.iname); - cmd.arg("exp", p.expression.toLatin1().toHex()); - cmd.endGroup(); - } - - cmd.endList(); - //cmd.arg("resultvarname", m_resultVarName); m_lastDebuggableCommand = cmd; diff --git a/src/plugins/debugger/pdb/pdbengine.cpp b/src/plugins/debugger/pdb/pdbengine.cpp index 8cf784eaae..976cf95877 100644 --- a/src/plugins/debugger/pdb/pdbengine.cpp +++ b/src/plugins/debugger/pdb/pdbengine.cpp @@ -571,34 +571,12 @@ void PdbEngine::updateLocals() DebuggerCommand cmd("updateData"); cmd.arg("nativeMixed", isNativeMixedActive()); watchHandler()->appendFormatRequests(&cmd); + watchHandler()->appendWatchersAndTooltipRequests(&cmd); const static bool alwaysVerbose = !qgetenv("QTC_DEBUGGER_PYTHON_VERBOSE").isEmpty(); cmd.arg("passexceptions", alwaysVerbose); cmd.arg("fancy", boolSetting(UseDebuggingHelpers)); - cmd.beginList("watchers"); - - // Watchers - QHashIterator it(WatchHandler::watcherNames()); - while (it.hasNext()) { - it.next(); - cmd.beginGroup(); - cmd.arg("iname", "watch." + QByteArray::number(it.value())); - cmd.arg("exp", it.key().toHex()); - cmd.endGroup(); - } - - // Tooltips - DebuggerToolTipContexts toolTips = DebuggerToolTipManager::pendingTooltips(this); - foreach (const DebuggerToolTipContext &p, toolTips) { - cmd.beginGroup(); - cmd.arg("iname", p.iname); - cmd.arg("exp", p.expression.toLatin1().toHex()); - cmd.endGroup(); - } - - cmd.endList(); - //cmd.arg("resultvarname", m_resultVarName); //m_lastDebuggableCommand = cmd; //m_lastDebuggableCommand.args.replace("\"passexceptions\":0", "\"passexceptions\":1"); diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index a53a8eda14..ad6fbbf5d2 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -37,6 +37,7 @@ #include "debuggerengine.h" #include "debuggerinternalconstants.h" #include "debuggerprotocol.h" +#include "debuggertooltipmanager.h" #include "simplifytype.h" #include "imageviewer.h" #include "watchutils.h" @@ -1621,6 +1622,28 @@ void WatchHandler::appendFormatRequests(DebuggerCommand *cmd) cmd->endGroup(); } +void WatchHandler::appendWatchersAndTooltipRequests(DebuggerCommand *cmd) +{ + cmd->beginList("watchers"); + DebuggerToolTipContexts toolTips = DebuggerToolTipManager::pendingTooltips(m_model->m_engine); + foreach (const DebuggerToolTipContext &p, toolTips) { + cmd->beginGroup(); + cmd->arg("iname", p.iname); + cmd->arg("exp", p.expression.toLatin1().toHex()); + cmd->endGroup(); + } + + QHashIterator it(WatchHandler::watcherNames()); + while (it.hasNext()) { + it.next(); + cmd->beginGroup(); + cmd->arg("iname", "watch." + QByteArray::number(it.value())); + cmd->arg("exp", it.key().toHex()); + cmd->endGroup(); + } + cmd->endList(); +} + void WatchHandler::addDumpers(const GdbMi &dumpers) { foreach (const GdbMi &dumper, dumpers.children()) { diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index 65a37e06ec..7a746e82b8 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -130,6 +130,9 @@ public: static QStringList watchedExpressions(); static QHash watcherNames(); + void appendFormatRequests(DebuggerCommand *cmd); + void appendWatchersAndTooltipRequests(DebuggerCommand *cmd); + QByteArray typeFormatRequests() const; QByteArray individualFormatRequests() const; @@ -150,7 +153,6 @@ public: void setCurrentItem(const QByteArray &iname); void updateWatchersWindow(); - void appendFormatRequests(DebuggerCommand *cmd); void insertItem(WatchItem *item); // Takes ownership. void removeItemByIName(const QByteArray &iname); -- GitLab