From d7b8b291a9b7ad7acb6afc86c2a40385e36bfa7e Mon Sep 17 00:00:00 2001
From: hjk <hjk121@nokiamail.com>
Date: Thu, 7 Nov 2013 16:07:21 +0100
Subject: [PATCH] Debugger: Handle tooltip data in LLDB backend

Task-number: QTCREATORBUG-10690
Change-Id: I5deecfed4c525fd6c3cd75f510e7662e469f99ea
Reviewed-by: hjk <hjk121@nokiamail.com>
---
 share/qtcreator/debugger/lldbbridge.py   |  9 ++--
 src/plugins/debugger/lldb/lldbengine.cpp | 57 +++++++++++++-----------
 src/plugins/debugger/lldb/lldbengine.h   |  1 +
 3 files changed, 38 insertions(+), 29 deletions(-)

diff --git a/share/qtcreator/debugger/lldbbridge.py b/share/qtcreator/debugger/lldbbridge.py
index 78af716ae48..f6d41fdddce 100644
--- a/share/qtcreator/debugger/lldbbridge.py
+++ b/share/qtcreator/debugger/lldbbridge.py
@@ -979,18 +979,19 @@ class Dumper(DumperBase):
         if not self.dummyValue is None:
             for watcher in self.currentWatchers:
                 iname = watcher['iname']
-                index = iname[iname.find('.') + 1:]
+                # could be 'watch.0' or 'tooltip.deadbead'
+                (base, component) = iname.split('.')
                 exp = binascii.unhexlify(watcher['exp'])
                 if exp == "":
                     self.put('type="",value="",exp=""')
                     continue
 
                 value = self.dummyValue.CreateValueFromExpression(iname, exp)
-                self.currentIName = 'watch'
-                with SubItem(self, index):
+                self.currentIName = base
+                with SubItem(self, component):
                     self.put('exp="%s",' % exp)
                     self.put('wname="%s",' % binascii.hexlify(exp))
-                    self.put('iname="%s",' % self.currentIName)
+                    self.put('iname="%s",' % iname)
                     self.putItem(value)
 
         self.put(']')
diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp
index 1ca0ddfd6e3..0e15848e638 100644
--- a/src/plugins/debugger/lldb/lldbengine.cpp
+++ b/src/plugins/debugger/lldb/lldbengine.cpp
@@ -120,29 +120,6 @@ void LldbEngine::runCommand(const Command &command)
     m_lldbProc.write(cmd);
 }
 
-void LldbEngine::showToolTip()
-{
-    if (m_toolTipContext.isNull())
-        return;
-    const QString expression = m_toolTipContext->expression;
-    if (DebuggerToolTipManager::debug())
-        qDebug() << "GdbEngine::showToolTip " << expression << m_toolTipContext->iname << (*m_toolTipContext);
-
-    if (m_toolTipContext->iname.startsWith("tooltip")
-        && (!debuggerCore()->boolSetting(UseToolTipsInMainEditor)
-            || !watchHandler()->isValidToolTip(m_toolTipContext->iname))) {
-        watchHandler()->removeData(m_toolTipContext->iname);
-        return;
-    }
-
-    DebuggerToolTipWidget *tw = new DebuggerToolTipWidget;
-    tw->setContext(*m_toolTipContext);
-    tw->acquireEngine(this);
-    DebuggerToolTipManager::showToolTip(m_toolTipContext->mousePosition, tw);
-    // Prevent tooltip from re-occurring (classic GDB, QTCREATORBUG-4711).
-    m_toolTipContext.reset();
-}
-
 void LldbEngine::shutdownInferior()
 {
     QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state());
@@ -664,6 +641,35 @@ static WatchData m_toolTip;
 static QPoint m_toolTipPos;
 static QHash<QString, WatchData> m_toolTipCache;
 
+void LldbEngine::showToolTip()
+{
+    if (m_toolTipContext.isNull())
+        return;
+    const QString expression = m_toolTipContext->expression;
+    if (DebuggerToolTipManager::debug())
+        qDebug() << "LldbEngine::showToolTip " << expression << m_toolTipContext->iname << (*m_toolTipContext);
+
+    if (m_toolTipContext->iname.startsWith("tooltip")
+        && (!debuggerCore()->boolSetting(UseToolTipsInMainEditor)
+            || !watchHandler()->isValidToolTip(m_toolTipContext->iname))) {
+        watchHandler()->removeData(m_toolTipContext->iname);
+        return;
+    }
+
+    DebuggerToolTipWidget *tw = new DebuggerToolTipWidget;
+    tw->setContext(*m_toolTipContext);
+    tw->acquireEngine(this);
+    DebuggerToolTipManager::showToolTip(m_toolTipContext->mousePosition, tw);
+    // Prevent tooltip from re-occurring (classic GDB, QTCREATORBUG-4711).
+    m_toolTipContext.reset();
+}
+
+void LldbEngine::resetLocation()
+{
+    m_toolTipContext.reset();
+    DebuggerEngine::resetLocation();
+}
+
 bool LldbEngine::setToolTipExpression(const QPoint &mousePos,
     TextEditor::ITextEditor *editor, const DebuggerToolTipContext &contextIn)
 {
@@ -814,8 +820,6 @@ void LldbEngine::doUpdateLocals(UpdateParameters params)
     }
     cmd.endList();
 
-    //cmd.arg("partial", ??)
-    //cmd.arg("tooltipOnly", ??)
     //cmd.arg("resultvarname", m_resultVarName);
 
     runCommand(cmd);
@@ -912,6 +916,7 @@ void LldbEngine::refreshLocals(const GdbMi &vars)
     //if (!partial) {
         list.append(*handler->findData("local"));
         list.append(*handler->findData("watch"));
+        list.append(*handler->findData("tooltip"));
         list.append(*handler->findData("return"));
     //}
 
@@ -929,6 +934,8 @@ void LldbEngine::refreshLocals(const GdbMi &vars)
         parseWatchData(handler->expandedINames(), dummy, child, &list);
     }
     handler->insertData(list);
+
+    showToolTip();
  }
 
 void LldbEngine::refreshStack(const GdbMi &stack)
diff --git a/src/plugins/debugger/lldb/lldbengine.h b/src/plugins/debugger/lldb/lldbengine.h
index 3dd3d69bc3d..22d05cb2937 100644
--- a/src/plugins/debugger/lldb/lldbengine.h
+++ b/src/plugins/debugger/lldb/lldbengine.h
@@ -102,6 +102,7 @@ private:
     void shutdownInferior();
     void shutdownEngine();
     void abortDebugger();
+    void resetLocation();
 
     bool setToolTipExpression(const QPoint &mousePos,
         TextEditor::ITextEditor *editor, const DebuggerToolTipContext &);
-- 
GitLab