[Lldb-commits] [lldb] r183766 - <rdar://problem/13779789>

Enrico Granata egranata at apple.com
Tue Jun 11 11:47:55 PDT 2013


Author: enrico
Date: Tue Jun 11 13:47:55 2013
New Revision: 183766

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

Allow memory read -t to take persistent types (those defined with expression struct $....)


Modified:
    lldb/trunk/source/Commands/CommandObjectMemory.cpp
    lldb/trunk/test/expression_command/persistent_types/TestPersistentTypes.py
    lldb/trunk/test/expression_command/persistent_types/main.c

Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=183766&r1=183765&r2=183766&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Tue Jun 11 13:47:55 2013
@@ -521,17 +521,31 @@ protected:
                                                type_list);
             }
             
-            if (type_list.GetSize() == 0)
+            if (type_list.GetSize() == 0 && lookup_type_name.GetCString() && *lookup_type_name.GetCString() == '$')
             {
-                result.AppendErrorWithFormat ("unable to find any types that match the raw type '%s' for full type '%s'\n", 
-                                              lookup_type_name.GetCString(), 
-                                              view_as_type_cstr);
-                result.SetStatus(eReturnStatusFailed);
-                return false;
+                clang::TypeDecl *tdecl = target->GetPersistentVariables().GetPersistentType(ConstString(lookup_type_name));
+                if (tdecl)
+                {
+                    clang_ast_type.SetClangType(&tdecl->getASTContext(),(lldb::clang_type_t)tdecl->getTypeForDecl());
+                }
             }
             
-            TypeSP type_sp (type_list.GetTypeAtIndex(0));
-            clang_ast_type.SetClangType (type_sp->GetClangAST(), type_sp->GetClangFullType());
+            if (clang_ast_type.IsValid() == false)
+            {
+                if (type_list.GetSize() == 0)
+                {
+                    result.AppendErrorWithFormat ("unable to find any types that match the raw type '%s' for full type '%s'\n",
+                                                  lookup_type_name.GetCString(),
+                                                  view_as_type_cstr);
+                    result.SetStatus(eReturnStatusFailed);
+                    return false;
+                }
+                else
+                {
+                    TypeSP type_sp (type_list.GetTypeAtIndex(0));
+                    clang_ast_type.SetClangType (type_sp->GetClangAST(), type_sp->GetClangFullType());
+                }
+            }
             
             while (pointer_count > 0)
             {

Modified: lldb/trunk/test/expression_command/persistent_types/TestPersistentTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/persistent_types/TestPersistentTypes.py?rev=183766&r1=183765&r2=183766&view=diff
==============================================================================
--- lldb/trunk/test/expression_command/persistent_types/TestPersistentTypes.py (original)
+++ lldb/trunk/test/expression_command/persistent_types/TestPersistentTypes.py Tue Jun 11 13:47:55 2013
@@ -34,6 +34,16 @@ class PersistenttypesTestCase(TestBase):
         self.expect("expression $bar i = 5; i",
                     startstr = "($bar) $1 = 5")
 
+        self.runCmd("expression struct $foobar { char a; char b; char c; char d; };")
+        self.runCmd("next")
+
+        self.expect("memory read foo -t $foobar",
+                    substrs = ['($foobar) 0x', ' = {', "a = 'H'","b = 'e'","c = 'l'","d = 'l'"]) # persistent types are OK to use for memory read
+
+        self.expect("memory read foo -t foobar",
+                    substrs = ['($foobar) 0x', ' = {', "a = 'H'","b = 'e'","c = 'l'","d = 'l'"],matching=False,error=True) # the type name is $foobar, make sure we settle for nothing less
+
+
 if __name__ == '__main__':
     import atexit
     lldb.SBDebugger.Initialize()

Modified: lldb/trunk/test/expression_command/persistent_types/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/persistent_types/main.c?rev=183766&r1=183765&r2=183766&view=diff
==============================================================================
--- lldb/trunk/test/expression_command/persistent_types/main.c (original)
+++ lldb/trunk/test/expression_command/persistent_types/main.c Tue Jun 11 13:47:55 2013
@@ -9,5 +9,6 @@
 
 int main (int argc, char const *argv[])
 {
+	const char* foo = "Hello world";
     return 0;
 }





More information about the lldb-commits mailing list