From 038f3c0c49f8b6ba64d9f87d5a3d38e7575eca21 Mon Sep 17 00:00:00 2001
From: hjk <hjk121@nokiamail.com>
Date: Thu, 2 May 2013 14:57:06 +0200
Subject: [PATCH] Debugger: Work around missing features in LLDB-167.2 on Mac

Change-Id: I357afd09e56f6be74187d2a5a647681dad698f98
Reviewed-by: hjk <hjk121@nokiamail.com>
---
 share/qtcreator/dumper/lbridge.py | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/share/qtcreator/dumper/lbridge.py b/share/qtcreator/dumper/lbridge.py
index 04b264815f6..110376725cc 100755
--- a/share/qtcreator/dumper/lbridge.py
+++ b/share/qtcreator/dumper/lbridge.py
@@ -1,11 +1,18 @@
 #!/usr/bin/env python
 
 import sys
-sys.path.append("/data/dev/llvm-git/build/Debug+Asserts/lib/python2.7/site-packages")
-
 import cmd
 import inspect
 import os
+import platform
+
+uname = platform.uname()[0]
+if uname == 'Linux':
+    sys.path.append('/data/dev/llvm-git/build/Debug+Asserts/lib/python2.7/site-packages')
+else:
+    base = '/Applications/Xcode.app/Contents/'
+    sys.path.append(base + 'SharedFrameworks/LLDB.framework/Resources/Python')
+    sys.path.append(base + 'Library/PrivateFrameworks/LLDB.framework/Resources/Python')
 
 import lldb
 
@@ -336,14 +343,12 @@ class Debugger(cmd.Cmd):
 
     def reportThreads(self):
         result = 'threads={threads=['
-        for thread in self.process.threads:
-            result += '{id="%d"' % thread.id
-            result += ',index="%s"' % thread.idx
-            result += ',stop-reason="%s"' % thread.stop_reason
-
-            if not thread.name is None:
-                result += ',name="%s"' % thread.name
-
+        for i in xrange(1, self.process.GetNumThreads()):
+            thread = self.process.GetThreadAtIndex(i)
+            result += '{id="%d"' % thread.GetThreadId()
+            result += ',index="%s"' % thread.GetThreadId()
+            result += ',stop-reason="%s"' % thread.GetStopReason()
+            result += ',name="%s"' % thread.GetName()
             result += ',frame={'
             frame = thread.GetFrameAtIndex(0)
             result += 'pc="0x%x"' % frame.pc
@@ -380,9 +385,11 @@ class Debugger(cmd.Cmd):
             self.report(result)
 
     def putItem(self, value, tryDynamic=True):
-        val = value.GetDynamicValue(lldb.eDynamicCanRunTarget)
+        #val = value.GetDynamicValue(lldb.eDynamicCanRunTarget)
+        val = value
         v = val.GetValue()
-        numchild = 1 if val.MightHaveChildren() else 0
+        #numchild = 1 if val.MightHaveChildren() else 0
+        numchild = val.GetNumChildren()
         self.put('iname="%s",' % self.currentIName)
         self.put('type="%s",' % val.GetTypeName())
         #self.put('vtype="%s",' % val.GetValueType())
-- 
GitLab