Update Go OS Plugin for newer runtimes.
authorRyan Brown <ribrdb@google.com>
Thu, 21 Apr 2016 20:57:28 +0000 (20:57 +0000)
committerRyan Brown <ribrdb@google.com>
Thu, 21 Apr 2016 20:57:28 +0000 (20:57 +0000)
Differential Revision: http://reviews.llvm.org/D19273

llvm-svn: 267048

lldb/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp

index 4f4d476..c8ed821 100644 (file)
@@ -249,8 +249,19 @@ OperatingSystemGo::Init(ThreadList &threads)
     TargetSP target_sp = m_process->CalculateTarget();
     if (!target_sp)
         return false;
-    m_allg_sp = FindGlobal(target_sp, "runtime.allg");
-    m_allglen_sp = FindGlobal(target_sp, "runtime.allglen");
+    // Go 1.6 stores goroutines in a slice called runtime.allgs
+    ValueObjectSP allgs_sp = FindGlobal(target_sp, "runtime.allgs");
+    if (allgs_sp)
+    {
+        m_allg_sp = allgs_sp->GetChildMemberWithName(ConstString("array"), true);
+        m_allglen_sp = allgs_sp->GetChildMemberWithName(ConstString("len"), true);
+    }
+    else
+    {
+        // Go 1.4 stores goroutines in the variable runtime.allg.
+        m_allg_sp = FindGlobal(target_sp, "runtime.allg");
+        m_allglen_sp = FindGlobal(target_sp, "runtime.allglen");
+    }
 
     if (m_allg_sp && !m_allglen_sp)
     {