[Lldb-commits] [lldb] r268101 - Fix TestGetVariables.py so it works correctly. We had duplicate static values showing up as we would find static variables in the Block and also in the compile unit. We now make sure a variable hasn't been added to the list before we add it.

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 29 14:00:38 PDT 2016


Author: gclayton
Date: Fri Apr 29 16:00:38 2016
New Revision: 268101

URL: http://llvm.org/viewvc/llvm-project?rev=268101&view=rev
Log:
Fix TestGetVariables.py so it works correctly. We had duplicate static values showing up as we would find static variables in the Block and also in the compile unit. We now make sure a variable hasn't been added to the list before we add it.


Modified:
    lldb/trunk/source/API/SBFrame.cpp

Modified: lldb/trunk/source/API/SBFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=268101&r1=268100&r2=268101&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFrame.cpp (original)
+++ lldb/trunk/source/API/SBFrame.cpp Fri Apr 29 16:00:38 2016
@@ -10,6 +10,7 @@
 // C Includes
 // C++ Includes
 #include <algorithm>
+#include <set>
 #include <string>
 
 // Other libraries and framework includes
@@ -1142,7 +1143,8 @@ SBFrame::GetVariables (const lldb::SBVar
                      arguments, locals,
                      statics, in_scope_only,
                      include_runtime_support_values, use_dynamic);
-    
+
+    std::set<VariableSP> variable_set;
     Process *process = exe_ctx.GetProcessPtr();
     if (target && process)
     {
@@ -1186,6 +1188,12 @@ SBFrame::GetVariables (const lldb::SBVar
                                 }
                                 if (add_variable)
                                 {
+                                    // Only add variables once so we don't end up with duplicates
+                                    if (variable_set.find(variable_sp) == variable_set.end())
+                                        variable_set.insert(variable_sp);
+                                    else
+                                        continue;
+
                                     if (in_scope_only && !variable_sp->IsInScope(frame))
                                         continue;
 




More information about the lldb-commits mailing list