[Lldb-commits] [lldb] r181462 - <rdar://problem/13621080>

Enrico Granata egranata at apple.com
Wed May 8 13:27:37 PDT 2013


Author: enrico
Date: Wed May  8 15:27:37 2013
New Revision: 181462

URL: http://llvm.org/viewvc/llvm-project?rev=181462&view=rev
Log:
<rdar://problem/13621080>

This commit changes the ${function.name-with-args} prompt keyword to also tackle structs
Previously, since aggregates have no values, this would show up as foo=(null)
This checkin changes that to instead print foo=(Foo at 0x123) (i.e. typename at address)
There are other potential choices here (summary, one-liner printout of all members, ...) and I would love to hear feedback about better options, if any


Modified:
    lldb/trunk/include/lldb/Symbol/VariableList.h
    lldb/trunk/source/Core/Debugger.cpp
    lldb/trunk/source/Symbol/VariableList.cpp

Modified: lldb/trunk/include/lldb/Symbol/VariableList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/VariableList.h?rev=181462&r1=181461&r2=181462&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/VariableList.h (original)
+++ lldb/trunk/include/lldb/Symbol/VariableList.h Wed May  8 15:27:37 2013
@@ -62,6 +62,11 @@ public:
     AppendVariablesIfUnique (const RegularExpression& regex, 
                              VariableList &var_list, 
                              size_t& total_matches);
+    
+    size_t
+    AppendVariablesWithScope (lldb::ValueType type,
+                              VariableList &var_list,
+                              bool if_unique = true);
 
     uint32_t
     FindIndexForVariable (Variable* variable);

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=181462&r1=181461&r2=181462&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Wed May  8 15:27:37 2013
@@ -2251,16 +2251,7 @@ Debugger::FormatPrompt
                                                 
                                                 VariableList args;
                                                 if (variable_list_sp)
-                                                {
-                                                    const size_t num_variables = variable_list_sp->GetSize();
-                                                    for (size_t var_idx = 0; var_idx < num_variables; ++var_idx)
-                                                    {
-                                                        VariableSP var_sp (variable_list_sp->GetVariableAtIndex(var_idx));
-                                                        if (var_sp->GetScope() == eValueTypeVariableArgument)
-                                                            args.AddVariable (var_sp);
-                                                    }
-
-                                                }
+                                                    variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument, args);
                                                 if (args.GetSize() > 0)
                                                 {
                                                     const char *open_paren = strchr (cstr, '(');
@@ -2294,7 +2285,12 @@ Debugger::FormatPrompt
                                                         if (arg_idx > 0)
                                                             s.PutCString (", ");
                                                         if (var_value_sp->GetError().Success())
-                                                            s.Printf ("%s=%s", var_name, var_value);
+                                                        {
+                                                            if (var_value)
+                                                                s.Printf ("%s=%s", var_name, var_value);
+                                                            else
+                                                                s.Printf ("%s=%s at %s", var_name, var_value_sp->GetTypeName().GetCString(), var_value_sp->GetLocationAsCString());
+                                                        }
                                                         else
                                                             s.Printf ("%s=<unavailable>", var_name);
                                                     }

Modified: lldb/trunk/source/Symbol/VariableList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/VariableList.cpp?rev=181462&r1=181461&r2=181462&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/VariableList.cpp (original)
+++ lldb/trunk/source/Symbol/VariableList.cpp Wed May  8 15:27:37 2013
@@ -134,6 +134,27 @@ VariableList::AppendVariablesIfUnique (c
     return var_list.GetSize() - initial_size;
 }
 
+size_t
+VariableList::AppendVariablesWithScope (lldb::ValueType type,
+                                        VariableList &var_list,
+                                        bool if_unique)
+{
+    const size_t initial_size = var_list.GetSize();
+    iterator pos, end = m_variables.end();
+    for (pos = m_variables.begin(); pos != end; ++pos)
+    {
+        if ((*pos)->GetScope() == type)
+        {
+            if (if_unique)
+                var_list.AddVariableIfUnique (*pos);
+            else
+                var_list.AddVariable(*pos);
+        }
+    }
+    // Return the number of new unique variables added to "var_list"
+    return var_list.GetSize() - initial_size;
+}
+
 uint32_t
 VariableList::FindIndexForVariable (Variable* variable)
 {





More information about the lldb-commits mailing list