<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Good to know.</div><div><br></div><div>Yes it's not a good thing to have lurking around. I assume it hasn't caused issues (yet) because I was exclusively testing with a v2 runtime anyway.</div><div><br></div><div>It seems a reasonable requirement to want Describe() to be const in general (I definitely want that in the v2 runtime - or at least it makes my life *a lot* simpler to have such guarantee)</div><div><br></div><div>Will fix tomorrow morning by making the base class function const too, unless there are objections!</div><div><br></div><div>Thanks for pointing this one out!</div><div><br>Sent from my iPhone</div><div><br>On Aug 19, 2014, at 5:00 PM, Zachary Turner <<a href="mailto:zturner@google.com">zturner@google.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">clang on Linux gives me this warning:<div><br></div><div><div>[2287/2447] Building CXX object tools/lldb/source/Plugins/LanguageRunt...eFiles/lldbPluginAppleObjCRuntime.dir/AppleObjCClassDescriptorV2.cpp.o</div>
<div>In file included from ../../tools/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp:10:</div><div>../../tools/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h:73:5: warning: 'lldb_private::ClassDescriptorV2::Describe' hides overloaded virtual function [-Woverloaded-virtual]</div>
<div>    Describe (std::function <void (ObjCLanguageRuntime::ObjCISA)> const &superclass_func,</div><div>    ^</div><div>../../tools/lldb/include/lldb/Target/ObjCLanguageRuntime.h:222:9: note: hidden overloaded virtual function 'lldb_private::ObjCLanguageRuntime::ClassDescriptor::Describe' declared here: different qualifiers (none vs const)</div>
<div>        Describe (std::function <void (ObjCISA)> const &superclass_func,</div><div>        ^</div><div>1 warning generated.</div></div><div><br></div><div><br></div><div>Doesn't seem entirely benign, so I figured I would let you know in case this is a real bug.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Aug 19, 2014 at 2:46 PM, Enrico Granata <span dir="ltr"><<a href="mailto:egranata@apple.com" target="_blank">egranata@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: enrico<br>
Date: Tue Aug 19 16:46:37 2014<br>
New Revision: 216026<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=216026&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=216026&view=rev</a><br>
Log:<br>
This is a fairly bulky patch, but a lot of it involves rearranging existing code<br>
What it does:<br>
<br>
- it introduces a concept of EncodingToType to the ObjCLanguageRuntime<br>
  The ObjC runtime has a "type encoding" feature that describes types as strings<br>
  The EncodingToType is a decoder for that format, making types out of type encoding strings<br>
This feature already existed in some shape as we were using it to create method signatures out of the runtime, but this checkin extends the parser to support the full syntax, and moves things so that more parts of LLDB have access to this decoder<br>

<br>
- it splits the ClassDescriptorV2 object to its own file, it was starting to grow too large<br>
<br>
- it adds to the ClassDescriptor mechanism a notion of ivar storage; the ObjC runtime vends ivar information as well as method information<br>
While ivar information is not ready for prime type (i.e. we don't want to add it to the runtime generated types for expression evaluator usage), there are potentially useful scenarios in which realizing ivar types could be useful. For now, the ClassDescriptor is going to hold ivar information directly. Existing code already allows describing ivars, this patch hooks those moving parts up so that one can actually ask a ClassDescriptor about ivars for the class it represents<br>

<br>
and as a couple minor niceties:<br>
- it makes it possible to retrieve the LLDB ClangASTContext that is associated to a clang::ASTContext<br>
- it extends the ValueObject-to-ClassDescriptor API in the language runtime to deal correctly with base-class hierarchies<br>
<br>
<br>
Added:<br>
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp<br>
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h<br>
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp<br>
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h<br>
Modified:<br>
    lldb/trunk/include/lldb/Symbol/ClangASTContext.h<br>
    lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h<br>
    lldb/trunk/lldb.xcodeproj/project.pbxproj<br>
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp<br>
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h<br>
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp<br>
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.h<br>
    lldb/trunk/source/Symbol/ClangASTContext.cpp<br>
    lldb/trunk/source/Target/ObjCLanguageRuntime.cpp<br>
<br>
Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=216026&r1=216025&r2=216026&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=216026&r1=216025&r2=216026&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)<br>
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Aug 19 16:46:37 2014<br>
@@ -43,6 +43,9 @@ public:<br>
     ClangASTContext (const char *triple = NULL);<br>
<br>
     ~ClangASTContext();<br>
+<br>
+    static ClangASTContext*<br>
+    GetASTContext (clang::ASTContext* ast_ctx);<br>
<br>
     clang::ASTContext *<br>
     getASTContext();<br>
<br>
Modified: lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h?rev=216026&r1=216025&r2=216026&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h?rev=216026&r1=216025&r2=216026&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h (original)<br>
+++ lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h Tue Aug 19 16:46:37 2014<br>
@@ -20,6 +20,7 @@<br>
 // Project includes<br>
 #include "lldb/lldb-private.h"<br>
 #include "lldb/Core/PluginInterface.h"<br>
+#include "lldb/Symbol/ClangASTType.h"<br>
 #include "lldb/Symbol/Type.h"<br>
 #include "lldb/Symbol/TypeVendor.h"<br>
 #include "lldb/Target/LanguageRuntime.h"<br>
@@ -238,6 +239,25 @@ public:<br>
             m_type_wp = type_sp;<br>
         }<br>
<br>
+        struct iVarDescriptor {<br>
+            ConstString m_name;<br>
+            ClangASTType m_type;<br>
+            uint64_t m_size;<br>
+            int32_t m_offset;<br>
+        };<br>
+<br>
+        virtual size_t<br>
+        GetNumIVars ()<br>
+        {<br>
+            return 0;<br>
+        }<br>
+<br>
+        virtual iVarDescriptor<br>
+        GetIVarAtIndex (size_t idx)<br>
+        {<br>
+            return iVarDescriptor();<br>
+        }<br>
+<br>
     protected:<br>
         bool<br>
         IsPointerValid (lldb::addr_t value,<br>
@@ -252,6 +272,25 @@ public:<br>
         lldb::TypeWP m_type_wp;<br>
     };<br>
<br>
+    class EncodingToType<br>
+    {<br>
+    public:<br>
+        virtual ClangASTType RealizeType (ClangASTContext& ast_ctx, const char* name, bool allow_unknownanytype);<br>
+        virtual ClangASTType RealizeType (const char* name, bool allow_unknownanytype);<br>
+<br>
+        virtual ClangASTType RealizeType (clang::ASTContext& ast_ctx, const char* name, bool allow_unknownanytype) = 0;<br>
+<br>
+        virtual ~EncodingToType();<br>
+<br>
+    protected:<br>
+        std::unique_ptr<ClangASTContext> m_scratch_ast_ctx_ap;<br>
+    };<br>
+<br>
+    typedef std::shared_ptr<EncodingToType> EncodingToTypeSP;<br>
+<br>
+    virtual EncodingToTypeSP<br>
+    GetEncodingToType ();<br>
+<br>
     virtual ClassDescriptorSP<br>
     GetClassDescriptor (ValueObject& in_value);<br>
<br>
<br>
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=216026&r1=216025&r2=216026&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=216026&r1=216025&r2=216026&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)<br>
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Aug 19 16:46:37 2014<br>
@@ -664,6 +664,8 @@<br>
                94CD704E16F8DDEA00CF1E42 /* Cocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CD704C16F8DDEA00CF1E42 /* Cocoa.cpp */; };<br>
                94CD705016F8DF1C00CF1E42 /* LibCxxList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CD704F16F8DF1C00CF1E42 /* LibCxxList.cpp */; };<br>
                94CD705216F8F5BC00CF1E42 /* LibCxxMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CD705116F8F5BC00CF1E42 /* LibCxxMap.cpp */; };<br>
+               94CD7D0919A3FBA300908B7C /* AppleObjCClassDescriptorV2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CD7D0819A3FBA300908B7C /* AppleObjCClassDescriptorV2.cpp */; };<br>
+               94CD7D0C19A3FBCE00908B7C /* AppleObjCTypeEncodingParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CD7D0B19A3FBCE00908B7C /* AppleObjCTypeEncodingParser.cpp */; };<br>
                94D0B10C16D5535900EA9C70 /* LibCxx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94D0B10A16D5535900EA9C70 /* LibCxx.cpp */; };<br>
                94D0B10D16D5535900EA9C70 /* LibStdcpp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94D0B10B16D5535900EA9C70 /* LibStdcpp.cpp */; };<br>
                94D6A0AA16CEB55F00833B6E /* NSArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94D6A0A716CEB55F00833B6E /* NSArray.cpp */; };<br>
@@ -1970,6 +1972,10 @@<br>
                94CD704C16F8DDEA00CF1E42 /* Cocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Cocoa.cpp; path = source/DataFormatters/Cocoa.cpp; sourceTree = "<group>"; };<br>

                94CD704F16F8DF1C00CF1E42 /* LibCxxList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibCxxList.cpp; path = source/DataFormatters/LibCxxList.cpp; sourceTree = "<group>"; };<br>

                94CD705116F8F5BC00CF1E42 /* LibCxxMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibCxxMap.cpp; path = source/DataFormatters/LibCxxMap.cpp; sourceTree = "<group>"; };<br>

+               94CD7D0719A3FB8600908B7C /* AppleObjCClassDescriptorV2.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppleObjCClassDescriptorV2.h; sourceTree = "<group>"; };<br>

+               94CD7D0819A3FBA300908B7C /* AppleObjCClassDescriptorV2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppleObjCClassDescriptorV2.cpp; sourceTree = "<group>"; };<br>

+               94CD7D0A19A3FBC300908B7C /* AppleObjCTypeEncodingParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppleObjCTypeEncodingParser.h; sourceTree = "<group>"; };<br>

+               94CD7D0B19A3FBCE00908B7C /* AppleObjCTypeEncodingParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppleObjCTypeEncodingParser.cpp; sourceTree = "<group>"; };<br>

                94D0B10A16D5535900EA9C70 /* LibCxx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibCxx.cpp; path = source/DataFormatters/LibCxx.cpp; sourceTree = "<group>"; };<br>

                94D0B10B16D5535900EA9C70 /* LibStdcpp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibStdcpp.cpp; path = source/DataFormatters/LibStdcpp.cpp; sourceTree = "<group>"; };<br>

                94D6A0A716CEB55F00833B6E /* NSArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NSArray.cpp; path = source/DataFormatters/NSArray.cpp; sourceTree = "<group>"; };<br>

@@ -4045,6 +4051,8 @@<br>
                4CCA644113B40B82003BDF98 /* AppleObjCRuntime */ = {<br>
                        isa = PBXGroup;<br>
                        children = (<br>
+                               94CD7D0719A3FB8600908B7C /* AppleObjCClassDescriptorV2.h */,<br>
+                               94CD7D0819A3FBA300908B7C /* AppleObjCClassDescriptorV2.cpp */,<br>
                                4CCA644213B40B82003BDF98 /* AppleObjCRuntime.cpp */,<br>
                                4CCA644313B40B82003BDF98 /* AppleObjCRuntime.h */,<br>
                                4CCA644413B40B82003BDF98 /* AppleObjCRuntimeV1.cpp */,<br>
@@ -4053,6 +4061,8 @@<br>
                                4CCA644713B40B82003BDF98 /* AppleObjCRuntimeV2.h */,<br>
                                4CCA644813B40B82003BDF98 /* AppleObjCTrampolineHandler.cpp */,<br>
                                4CCA644913B40B82003BDF98 /* AppleObjCTrampolineHandler.h */,<br>
+                               94CD7D0A19A3FBC300908B7C /* AppleObjCTypeEncodingParser.h */,<br>
+                               94CD7D0B19A3FBCE00908B7C /* AppleObjCTypeEncodingParser.cpp */,<br>
                                49DA65041485C942005FF180 /* AppleObjCTypeVendor.h */,<br>
                                49DA65021485C92A005FF180 /* AppleObjCTypeVendor.cpp */,<br>
                                4CCA644A13B40B82003BDF98 /* AppleThreadPlanStepThroughObjCTrampoline.cpp */,<br>
@@ -5143,11 +5153,13 @@<br>
                                26957D9813D381C900670048 /* RegisterContextDarwin_arm.cpp in Sources */,<br>
                                26957D9A13D381C900670048 /* RegisterContextDarwin_i386.cpp in Sources */,<br>
                                26957D9C13D381C900670048 /* RegisterContextDarwin_x86_64.cpp in Sources */,<br>
+                               94CD7D0919A3FBA300908B7C /* AppleObjCClassDescriptorV2.cpp in Sources */,<br>
                                265205A813D3E3F700132FE2 /* RegisterContextKDP_arm.cpp in Sources */,<br>
                                265205AA13D3E3F700132FE2 /* RegisterContextKDP_i386.cpp in Sources */,<br>
                                265205AC13D3E3F700132FE2 /* RegisterContextKDP_x86_64.cpp in Sources */,<br>
                                2628A4D513D4977900F5487A /* ThreadKDP.cpp in Sources */,<br>
                                26D7E45D13D5E30A007FD12B /* SocketAddress.cpp in Sources */,<br>
+                               94CD7D0C19A3FBCE00908B7C /* AppleObjCTypeEncodingParser.cpp in Sources */,<br>
                                94B6E76213D88365005F417F /* ValueObjectSyntheticFilter.cpp in Sources */,<br>
                                262D24E613FB8710002D1960 /* RegisterContextMemory.cpp in Sources */,<br>
                                26F4A21C13FBA31A0064B613 /* ThreadMemory.cpp in Sources */,<br>
<br>
Added: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp?rev=216026&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp?rev=216026&view=auto</a><br>

==============================================================================<br>
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp (added)<br>
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp Tue Aug 19 16:46:37 2014<br>
@@ -0,0 +1,526 @@<br>
+//===-- AppleObjCClassDescriptorV2.cpp -----------------------------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "AppleObjCClassDescriptorV2.h"<br>
+<br>
+using namespace lldb;<br>
+using namespace lldb_private;<br>
+<br>
+bool<br>
+ClassDescriptorV2::Read_objc_class (Process* process, std::unique_ptr<objc_class_t> &objc_class) const<br>
+{<br>
+    objc_class.reset(new objc_class_t);<br>
+<br>
+    bool ret = objc_class->Read (process, m_objc_class_ptr);<br>
+<br>
+    if (!ret)<br>
+        objc_class.reset();<br>
+<br>
+    return ret;<br>
+}<br>
+<br>
+bool<br>
+ClassDescriptorV2::objc_class_t::Read(Process *process, lldb::addr_t addr)<br>
+{<br>
+    size_t ptr_size = process->GetAddressByteSize();<br>
+<br>
+    size_t objc_class_size = ptr_size   // uintptr_t isa;<br>
+    + ptr_size   // Class superclass;<br>
+    + ptr_size   // void *cache;<br>
+    + ptr_size   // IMP *vtable;<br>
+    + ptr_size;  // uintptr_t data_NEVER_USE;<br>
+<br>
+    DataBufferHeap objc_class_buf (objc_class_size, '\0');<br>
+    Error error;<br>
+<br>
+    process->ReadMemory(addr, objc_class_buf.GetBytes(), objc_class_size, error);<br>
+    if (error.Fail())<br>
+    {<br>
+        return false;<br>
+    }<br>
+<br>
+    DataExtractor extractor(objc_class_buf.GetBytes(), objc_class_size, process->GetByteOrder(), process->GetAddressByteSize());<br>
+<br>
+    lldb::offset_t cursor = 0;<br>
+<br>
+    m_isa           = extractor.GetAddress_unchecked(&cursor);   // uintptr_t isa;<br>
+    m_superclass    = extractor.GetAddress_unchecked(&cursor);   // Class superclass;<br>
+    m_cache_ptr     = extractor.GetAddress_unchecked(&cursor);   // void *cache;<br>
+    m_vtable_ptr    = extractor.GetAddress_unchecked(&cursor);   // IMP *vtable;<br>
+    lldb::addr_t data_NEVER_USE = extractor.GetAddress_unchecked(&cursor);   // uintptr_t data_NEVER_USE;<br>
+<br>
+    m_flags         = (uint8_t)(data_NEVER_USE & (lldb::addr_t)3);<br>
+    m_data_ptr      = data_NEVER_USE & ~(lldb::addr_t)3;<br>
+<br>
+    return true;<br>
+}<br>
+<br>
+bool<br>
+ClassDescriptorV2::class_rw_t::Read(Process *process, lldb::addr_t addr)<br>
+{<br>
+    size_t ptr_size = process->GetAddressByteSize();<br>
+<br>
+    size_t size = sizeof(uint32_t)  // uint32_t flags;<br>
+    + sizeof(uint32_t)  // uint32_t version;<br>
+    + ptr_size          // const class_ro_t *ro;<br>
+    + ptr_size          // union { method_list_t **method_lists; method_list_t *method_list; };<br>
+    + ptr_size          // struct chained_property_list *properties;<br>
+    + ptr_size          // const protocol_list_t **protocols;<br>
+    + ptr_size          // Class firstSubclass;<br>
+    + ptr_size;         // Class nextSiblingClass;<br>
+<br>
+    DataBufferHeap buffer (size, '\0');<br>
+    Error error;<br>
+<br>
+    process->ReadMemory(addr, buffer.GetBytes(), size, error);<br>
+    if (error.Fail())<br>
+    {<br>
+        return false;<br>
+    }<br>
+<br>
+    DataExtractor extractor(buffer.GetBytes(), size, process->GetByteOrder(), process->GetAddressByteSize());<br>
+<br>
+    lldb::offset_t cursor = 0;<br>
+<br>
+    m_flags             = extractor.GetU32_unchecked(&cursor);<br>
+    m_version           = extractor.GetU32_unchecked(&cursor);<br>
+    m_ro_ptr            = extractor.GetAddress_unchecked(&cursor);<br>
+    m_method_list_ptr   = extractor.GetAddress_unchecked(&cursor);<br>
+    m_properties_ptr    = extractor.GetAddress_unchecked(&cursor);<br>
+    m_firstSubclass     = extractor.GetAddress_unchecked(&cursor);<br>
+    m_nextSiblingClass  = extractor.GetAddress_unchecked(&cursor);<br>
+<br>
+    return true;<br>
+}<br>
+<br>
+bool<br>
+ClassDescriptorV2::class_ro_t::Read(Process *process, lldb::addr_t addr)<br>
+{<br>
+    size_t ptr_size = process->GetAddressByteSize();<br>
+<br>
+    size_t size = sizeof(uint32_t)             // uint32_t flags;<br>
+    + sizeof(uint32_t)                         // uint32_t instanceStart;<br>
+    + sizeof(uint32_t)                         // uint32_t instanceSize;<br>
+    + (ptr_size == 8 ? sizeof(uint32_t) : 0)   // uint32_t reserved; // __LP64__ only<br>
+    + ptr_size                                 // const uint8_t *ivarLayout;<br>
+    + ptr_size                                 // const char *name;<br>
+    + ptr_size                                 // const method_list_t *baseMethods;<br>
+    + ptr_size                                 // const protocol_list_t *baseProtocols;<br>
+    + ptr_size                                 // const ivar_list_t *ivars;<br>
+    + ptr_size                                 // const uint8_t *weakIvarLayout;<br>
+    + ptr_size;                                // const property_list_t *baseProperties;<br>
+<br>
+    DataBufferHeap buffer (size, '\0');<br>
+    Error error;<br>
+<br>
+    process->ReadMemory(addr, buffer.GetBytes(), size, error);<br>
+    if (error.Fail())<br>
+    {<br>
+        return false;<br>
+    }<br>
+<br>
+    DataExtractor extractor(buffer.GetBytes(), size, process->GetByteOrder(), process->GetAddressByteSize());<br>
+<br>
+    lldb::offset_t cursor = 0;<br>
+<br>
+    m_flags             = extractor.GetU32_unchecked(&cursor);<br>
+    m_instanceStart     = extractor.GetU32_unchecked(&cursor);<br>
+    m_instanceSize      = extractor.GetU32_unchecked(&cursor);<br>
+    if (ptr_size == 8)<br>
+        m_reserved      = extractor.GetU32_unchecked(&cursor);<br>
+    else<br>
+        m_reserved      = 0;<br>
+    m_ivarLayout_ptr     = extractor.GetAddress_unchecked(&cursor);<br>
+    m_name_ptr           = extractor.GetAddress_unchecked(&cursor);<br>
+    m_baseMethods_ptr    = extractor.GetAddress_unchecked(&cursor);<br>
+    m_baseProtocols_ptr  = extractor.GetAddress_unchecked(&cursor);<br>
+    m_ivars_ptr          = extractor.GetAddress_unchecked(&cursor);<br>
+    m_weakIvarLayout_ptr = extractor.GetAddress_unchecked(&cursor);<br>
+    m_baseProperties_ptr = extractor.GetAddress_unchecked(&cursor);<br>
+<br>
+    DataBufferHeap name_buf(1024, '\0');<br>
+<br>
+    process->ReadCStringFromMemory(m_name_ptr, (char*)name_buf.GetBytes(), name_buf.GetByteSize(), error);<br>
+<br>
+    if (error.Fail())<br>
+    {<br>
+        return false;<br>
+    }<br>
+<br>
+    m_name.assign((char*)name_buf.GetBytes());<br>
+<br>
+    return true;<br>
+}<br>
+<br>
+bool<br>
+ClassDescriptorV2::Read_class_row (Process* process, const objc_class_t &objc_class, std::unique_ptr<class_ro_t> &class_ro, std::unique_ptr<class_rw_t> &class_rw) const<br>
+{<br>
+    class_ro.reset();<br>
+    class_rw.reset();<br>
+<br>
+    Error error;<br>
+    uint32_t class_row_t_flags = process->ReadUnsignedIntegerFromMemory(objc_class.m_data_ptr, sizeof(uint32_t), 0, error);<br>
+    if (!error.Success())<br>
+        return false;<br>
+<br>
+    if (class_row_t_flags & RW_REALIZED)<br>
+    {<br>
+        class_rw.reset(new class_rw_t);<br>
+<br>
+        if (!class_rw->Read(process, objc_class.m_data_ptr))<br>
+        {<br>
+            class_rw.reset();<br>
+            return false;<br>
+        }<br>
+<br>
+        class_ro.reset(new class_ro_t);<br>
+<br>
+        if (!class_ro->Read(process, class_rw->m_ro_ptr))<br>
+        {<br>
+            class_rw.reset();<br>
+            class_ro.reset();<br>
+            return false;<br>
+        }<br>
+    }<br>
+    else<br>
+    {<br>
+        class_ro.reset(new class_ro_t);<br>
+<br>
+        if (!class_ro->Read(process, objc_class.m_data_ptr))<br>
+        {<br>
+            class_ro.reset();<br>
+            return false;<br>
+        }<br>
+    }<br>
+<br>
+    return true;<br>
+}<br>
+<br>
+bool<br>
+ClassDescriptorV2::method_list_t::Read(Process *process, lldb::addr_t addr)<br>
+{<br>
+    size_t size = sizeof(uint32_t)  // uint32_t entsize_NEVER_USE;<br>
+    + sizeof(uint32_t); // uint32_t count;<br>
+<br>
+    DataBufferHeap buffer (size, '\0');<br>
+    Error error;<br>
+<br>
+    process->ReadMemory(addr, buffer.GetBytes(), size, error);<br>
+    if (error.Fail())<br>
+    {<br>
+        return false;<br>
+    }<br>
+<br>
+    DataExtractor extractor(buffer.GetBytes(), size, process->GetByteOrder(), process->GetAddressByteSize());<br>
+<br>
+    lldb::offset_t cursor = 0;<br>
+<br>
+    m_entsize   = extractor.GetU32_unchecked(&cursor) & ~(uint32_t)3;<br>
+    m_count     = extractor.GetU32_unchecked(&cursor);<br>
+    m_first_ptr  = addr + cursor;<br>
+<br>
+    return true;<br>
+}<br>
+<br>
+bool<br>
+ClassDescriptorV2::method_t::Read(Process *process, lldb::addr_t addr)<br>
+{<br>
+    size_t size = GetSize(process);<br>
+<br>
+    DataBufferHeap buffer (size, '\0');<br>
+    Error error;<br>
+<br>
+    process->ReadMemory(addr, buffer.GetBytes(), size, error);<br>
+    if (error.Fail())<br>
+    {<br>
+        return false;<br>
+    }<br>
+<br>
+    DataExtractor extractor(buffer.GetBytes(), size, process->GetByteOrder(), process->GetAddressByteSize());<br>
+<br>
+    lldb::offset_t cursor = 0;<br>
+<br>
+    m_name_ptr   = extractor.GetAddress_unchecked(&cursor);<br>
+    m_types_ptr  = extractor.GetAddress_unchecked(&cursor);<br>
+    m_imp_ptr    = extractor.GetAddress_unchecked(&cursor);<br>
+<br>
+    const size_t buffer_size = 1024;<br>
+    size_t count;<br>
+<br>
+    DataBufferHeap string_buf(buffer_size, 0);<br>
+<br>
+    count = process->ReadCStringFromMemory(m_name_ptr, (char*)string_buf.GetBytes(), buffer_size, error);<br>
+    m_name.assign((char*)string_buf.GetBytes(), count);<br>
+<br>
+    count = process->ReadCStringFromMemory(m_types_ptr, (char*)string_buf.GetBytes(), buffer_size, error);<br>
+    m_types.assign((char*)string_buf.GetBytes(), count);<br>
+<br>
+    return true;<br>
+}<br>
+<br>
+bool<br>
+ClassDescriptorV2::ivar_list_t::Read(Process *process, lldb::addr_t addr)<br>
+{<br>
+    size_t size = sizeof(uint32_t)  // uint32_t entsize;<br>
+    + sizeof(uint32_t); // uint32_t count;<br>
+<br>
+    DataBufferHeap buffer (size, '\0');<br>
+    Error error;<br>
+<br>
+    process->ReadMemory(addr, buffer.GetBytes(), size, error);<br>
+    if (error.Fail())<br>
+    {<br>
+        return false;<br>
+    }<br>
+<br>
+    DataExtractor extractor(buffer.GetBytes(), size, process->GetByteOrder(), process->GetAddressByteSize());<br>
+<br>
+    lldb::offset_t cursor = 0;<br>
+<br>
+    m_entsize   = extractor.GetU32_unchecked(&cursor);<br>
+    m_count     = extractor.GetU32_unchecked(&cursor);<br>
+    m_first_ptr = addr + cursor;<br>
+<br>
+    return true;<br>
+}<br>
+<br>
+bool<br>
+ClassDescriptorV2::ivar_t::Read(Process *process, lldb::addr_t addr)<br>
+{<br>
+    size_t size = GetSize(process);<br>
+<br>
+    DataBufferHeap buffer (size, '\0');<br>
+    Error error;<br>
+<br>
+    process->ReadMemory(addr, buffer.GetBytes(), size, error);<br>
+    if (error.Fail())<br>
+    {<br>
+        return false;<br>
+    }<br>
+<br>
+    DataExtractor extractor(buffer.GetBytes(), size, process->GetByteOrder(), process->GetAddressByteSize());<br>
+<br>
+    lldb::offset_t cursor = 0;<br>
+<br>
+    m_offset_ptr = extractor.GetAddress_unchecked(&cursor);<br>
+    m_name_ptr   = extractor.GetAddress_unchecked(&cursor);<br>
+    m_type_ptr   = extractor.GetAddress_unchecked(&cursor);<br>
+    m_alignment  = extractor.GetU32_unchecked(&cursor);<br>
+    m_size       = extractor.GetU32_unchecked(&cursor);<br>
+<br>
+    const size_t buffer_size = 1024;<br>
+    size_t count;<br>
+<br>
+    DataBufferHeap string_buf(buffer_size, 0);<br>
+<br>
+    count = process->ReadCStringFromMemory(m_name_ptr, (char*)string_buf.GetBytes(), buffer_size, error);<br>
+    m_name.assign((char*)string_buf.GetBytes(), count);<br>
+<br>
+    count = process->ReadCStringFromMemory(m_type_ptr, (char*)string_buf.GetBytes(), buffer_size, error);<br>
+    m_type.assign((char*)string_buf.GetBytes(), count);<br>
+<br>
+    return true;<br>
+}<br>
+<br>
+bool<br>
+ClassDescriptorV2::Describe (std::function <void (ObjCLanguageRuntime::ObjCISA)> const &superclass_func,<br>
+                             std::function <bool (const char *, const char *)> const &instance_method_func,<br>
+                             std::function <bool (const char *, const char *)> const &class_method_func,<br>
+                             std::function <bool (const char *, const char *, lldb::addr_t, uint64_t)> const &ivar_func) const<br>
+{<br>
+    lldb_private::Process *process = m_runtime.GetProcess();<br>
+<br>
+    std::unique_ptr<objc_class_t> objc_class;<br>
+    std::unique_ptr<class_ro_t> class_ro;<br>
+    std::unique_ptr<class_rw_t> class_rw;<br>
+<br>
+    if (!Read_objc_class(process, objc_class))<br>
+        return 0;<br>
+    if (!Read_class_row(process, *objc_class, class_ro, class_rw))<br>
+        return 0;<br>
+<br>
+    static ConstString NSObject_name("NSObject");<br>
+<br>
+    if (m_name != NSObject_name && superclass_func)<br>
+        superclass_func(objc_class->m_superclass);<br>
+<br>
+    if (instance_method_func)<br>
+    {<br>
+        std::unique_ptr<method_list_t> base_method_list;<br>
+<br>
+        base_method_list.reset(new method_list_t);<br>
+        if (!base_method_list->Read(process, class_ro->m_baseMethods_ptr))<br>
+            return false;<br>
+<br>
+        if (base_method_list->m_entsize != method_t::GetSize(process))<br>
+            return false;<br>
+<br>
+        std::unique_ptr<method_t> method;<br>
+        method.reset(new method_t);<br>
+<br>
+        for (uint32_t i = 0, e = base_method_list->m_count; i < e; ++i)<br>
+        {<br>
+            method->Read(process, base_method_list->m_first_ptr + (i * base_method_list->m_entsize));<br>
+<br>
+            if (instance_method_func(method->m_name.c_str(), method->m_types.c_str()))<br>
+                break;<br>
+        }<br>
+    }<br>
+<br>
+    if (class_method_func)<br>
+    {<br>
+        ClassDescriptorV2 metaclass(m_runtime, objc_class->m_isa, NULL); // The metaclass is not in the cache<br>
+<br>
+        // We don't care about the metaclass's superclass, or its class methods.  Its instance methods are<br>
+        // our class methods.<br>
+<br>
+        metaclass.Describe(std::function <void (ObjCLanguageRuntime::ObjCISA)> (nullptr),<br>
+                           class_method_func,<br>
+                           std::function <bool (const char *, const char *)> (nullptr),<br>
+                           std::function <bool (const char *, const char *, lldb::addr_t, uint64_t)> (nullptr));<br>
+    }<br>
+<br>
+    if (ivar_func)<br>
+    {<br>
+        ivar_list_t ivar_list;<br>
+        if (!ivar_list.Read(process, class_ro->m_ivars_ptr))<br>
+            return false;<br>
+<br>
+        if (ivar_list.m_entsize != ivar_t::GetSize(process))<br>
+            return false;<br>
+<br>
+        ivar_t ivar;<br>
+<br>
+        for (uint32_t i = 0, e = ivar_list.m_count; i < e; ++i)<br>
+        {<br>
+            ivar.Read(process, ivar_list.m_first_ptr + (i * ivar_list.m_entsize));<br>
+<br>
+            if (ivar_func(ivar.m_name.c_str(), ivar.m_type.c_str(), ivar.m_offset_ptr, ivar.m_size))<br>
+                break;<br>
+        }<br>
+    }<br>
+<br>
+    return true;<br>
+}<br>
+<br>
+ConstString<br>
+ClassDescriptorV2::GetClassName ()<br>
+{<br>
+    if (!m_name)<br>
+    {<br>
+        lldb_private::Process *process = m_runtime.GetProcess();<br>
+<br>
+        if (process)<br>
+        {<br>
+            std::unique_ptr<objc_class_t> objc_class;<br>
+            std::unique_ptr<class_ro_t> class_ro;<br>
+            std::unique_ptr<class_rw_t> class_rw;<br>
+<br>
+            if (!Read_objc_class(process, objc_class))<br>
+                return m_name;<br>
+            if (!Read_class_row(process, *objc_class, class_ro, class_rw))<br>
+                return m_name;<br>
+<br>
+            m_name = ConstString(class_ro->m_name.c_str());<br>
+        }<br>
+    }<br>
+    return m_name;<br>
+}<br>
+<br>
+ObjCLanguageRuntime::ClassDescriptorSP<br>
+ClassDescriptorV2::GetSuperclass ()<br>
+{<br>
+    lldb_private::Process *process = m_runtime.GetProcess();<br>
+<br>
+    if (!process)<br>
+        return ObjCLanguageRuntime::ClassDescriptorSP();<br>
+<br>
+    std::unique_ptr<objc_class_t> objc_class;<br>
+<br>
+    if (!Read_objc_class(process, objc_class))<br>
+        return ObjCLanguageRuntime::ClassDescriptorSP();<br>
+<br>
+    return m_runtime.ObjCLanguageRuntime::GetClassDescriptorFromISA(objc_class->m_superclass);<br>
+}<br>
+<br>
+uint64_t<br>
+ClassDescriptorV2::GetInstanceSize ()<br>
+{<br>
+    lldb_private::Process *process = m_runtime.GetProcess();<br>
+<br>
+    if (process)<br>
+    {<br>
+        std::unique_ptr<objc_class_t> objc_class;<br>
+        std::unique_ptr<class_ro_t> class_ro;<br>
+        std::unique_ptr<class_rw_t> class_rw;<br>
+<br>
+        if (!Read_objc_class(process, objc_class))<br>
+            return 0;<br>
+        if (!Read_class_row(process, *objc_class, class_ro, class_rw))<br>
+            return 0;<br>
+<br>
+        return class_ro->m_instanceSize;<br>
+    }<br>
+<br>
+    return 0;<br>
+}<br>
+<br>
+ClassDescriptorV2::iVarsStorage::iVarsStorage ():<br>
+m_filled(false),<br>
+m_ivars(),<br>
+m_mutex(Mutex::eMutexTypeRecursive)<br>
+{}<br>
+<br>
+size_t<br>
+ClassDescriptorV2::iVarsStorage::size ()<br>
+{<br>
+    return m_ivars.size();<br>
+}<br>
+<br>
+ClassDescriptorV2::iVarDescriptor&<br>
+ClassDescriptorV2::iVarsStorage::operator[] (size_t idx)<br>
+{<br>
+    return m_ivars[idx];<br>
+}<br>
+<br>
+void<br>
+ClassDescriptorV2::iVarsStorage::fill (AppleObjCRuntimeV2& runtime, ClassDescriptorV2& descriptor)<br>
+{<br>
+    if (m_filled)<br>
+        return;<br>
+    Mutex::Locker lock(m_mutex);<br>
+    m_filled = true;<br>
+    ObjCLanguageRuntime::EncodingToTypeSP encoding_to_type_sp(runtime.GetEncodingToType());<br>
+    Process* process(runtime.GetProcess());<br>
+    if (!encoding_to_type_sp)<br>
+        return;<br>
+    descriptor.Describe(nullptr,<br>
+                        nullptr,<br>
+                        nullptr,<br>
+                        [this,process,encoding_to_type_sp](const char * name, const char * type, lldb::addr_t offset_ptr, uint64_t size) -> bool {<br>
+                 const bool allow_unknownanytype = false;<br>
+                 const bool stop_loop = false;<br>
+                 ClangASTType ivar_type = encoding_to_type_sp->RealizeType(type, allow_unknownanytype);<br>
+                 if (ivar_type)<br>
+                 {<br>
+                     Scalar offset_scalar;<br>
+                     Error error;<br>
+                     size_t read = process->ReadScalarIntegerFromMemory(offset_ptr, 4, true, offset_scalar, error);<br>
+                     if (error.Success() && 4 == read)<br>
+                         m_ivars.push_back({ ConstString(name), ivar_type, size, offset_scalar.SInt() });<br>
+                 }<br>
+                 return stop_loop;<br>
+             });<br>
+}<br>
+<br>
+void<br>
+ClassDescriptorV2::GetIVarInformation ()<br>
+{<br>
+    m_ivars_storage.fill(m_runtime, *this);<br>
+}<br>
<br>
Added: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h?rev=216026&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h?rev=216026&view=auto</a><br>

==============================================================================<br>
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h (added)<br>
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h Tue Aug 19 16:46:37 2014<br>
@@ -0,0 +1,411 @@<br>
+//===-- AppleObjCClassDescriptorV2.h --------------------------------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#ifndef liblldb_AppleObjCClassDescriptorV2_h_<br>
+#define liblldb_AppleObjCClassDescriptorV2_h_<br>
+<br>
+// C Includes<br>
+// C++ Includes<br>
+// Other libraries and framework includes<br>
+<br>
+// Project includes<br>
+#include "lldb/lldb-private.h"<br>
+#include "lldb/Host/Mutex.h"<br>
+#include "lldb/Target/ObjCLanguageRuntime.h"<br>
+#include "AppleObjCRuntimeV2.h"<br>
+<br>
+namespace lldb_private {<br>
+<br>
+class ClassDescriptorV2 : public ObjCLanguageRuntime::ClassDescriptor<br>
+{<br>
+public:<br>
+    friend class lldb_private::AppleObjCRuntimeV2;<br>
+<br>
+private:<br>
+    // The constructor should only be invoked by the runtime as it builds its caches<br>
+    // or populates them.  A ClassDescriptorV2 should only ever exist in a cache.<br>
+    ClassDescriptorV2 (AppleObjCRuntimeV2 &runtime, ObjCLanguageRuntime::ObjCISA isa, const char *name) :<br>
+    m_runtime (runtime),<br>
+    m_objc_class_ptr (isa),<br>
+    m_name (name),<br>
+    m_ivars_storage()<br>
+    {<br>
+    }<br>
+<br>
+public:<br>
+    virtual ConstString<br>
+    GetClassName ();<br>
+<br>
+    virtual ObjCLanguageRuntime::ClassDescriptorSP<br>
+    GetSuperclass ();<br>
+<br>
+    virtual bool<br>
+    IsValid ()<br>
+    {<br>
+        return true;    // any Objective-C v2 runtime class descriptor we vend is valid<br>
+    }<br>
+<br>
+    // a custom descriptor is used for tagged pointers<br>
+    virtual bool<br>
+    GetTaggedPointerInfo (uint64_t* info_bits = NULL,<br>
+                          uint64_t* value_bits = NULL,<br>
+                          uint64_t* payload = NULL)<br>
+    {<br>
+        return false;<br>
+    }<br>
+<br>
+    virtual uint64_t<br>
+    GetInstanceSize ();<br>
+<br>
+    virtual ObjCLanguageRuntime::ObjCISA<br>
+    GetISA ()<br>
+    {<br>
+        return m_objc_class_ptr;<br>
+    }<br>
+<br>
+    virtual bool<br>
+    Describe (std::function <void (ObjCLanguageRuntime::ObjCISA)> const &superclass_func,<br>
+              std::function <bool (const char *, const char *)> const &instance_method_func,<br>
+              std::function <bool (const char *, const char *)> const &class_method_func,<br>
+              std::function <bool (const char *, const char *, lldb::addr_t, uint64_t)> const &ivar_func) const;<br>
+<br>
+    virtual<br>
+    ~ClassDescriptorV2 ()<br>
+    {<br>
+    }<br>
+<br>
+    virtual size_t<br>
+    GetNumIVars ()<br>
+    {<br>
+        GetIVarInformation();<br>
+        return m_ivars_storage.size();<br>
+    }<br>
+<br>
+    virtual iVarDescriptor<br>
+    GetIVarAtIndex (size_t idx)<br>
+    {<br>
+        if (idx >= GetNumIVars())<br>
+            return iVarDescriptor();<br>
+        return m_ivars_storage[idx];<br>
+    }<br>
+<br>
+protected:<br>
+    void<br>
+    GetIVarInformation ();<br>
+<br>
+private:<br>
+    static const uint32_t RW_REALIZED = (1 << 31);<br>
+<br>
+    struct objc_class_t {<br>
+        ObjCLanguageRuntime::ObjCISA    m_isa;              // The class's metaclass.<br>
+        ObjCLanguageRuntime::ObjCISA    m_superclass;<br>
+        lldb::addr_t                    m_cache_ptr;<br>
+        lldb::addr_t                    m_vtable_ptr;<br>
+        lldb::addr_t                    m_data_ptr;<br>
+        uint8_t                         m_flags;<br>
+<br>
+        objc_class_t () :<br>
+        m_isa (0),<br>
+        m_superclass (0),<br>
+        m_cache_ptr (0),<br>
+        m_vtable_ptr (0),<br>
+        m_data_ptr (0),<br>
+        m_flags (0)<br>
+        {<br>
+        }<br>
+<br>
+        void<br>
+        Clear()<br>
+        {<br>
+            m_isa = 0;<br>
+            m_superclass = 0;<br>
+            m_cache_ptr = 0;<br>
+            m_vtable_ptr = 0;<br>
+            m_data_ptr = 0;<br>
+            m_flags = 0;<br>
+        }<br>
+<br>
+        bool<br>
+        Read(Process *process, lldb::addr_t addr);<br>
+    };<br>
+<br>
+    struct class_ro_t {<br>
+        uint32_t                        m_flags;<br>
+        uint32_t                        m_instanceStart;<br>
+        uint32_t                        m_instanceSize;<br>
+        uint32_t                        m_reserved;<br>
+<br>
+        lldb::addr_t                    m_ivarLayout_ptr;<br>
+        lldb::addr_t                    m_name_ptr;<br>
+        lldb::addr_t                    m_baseMethods_ptr;<br>
+        lldb::addr_t                    m_baseProtocols_ptr;<br>
+        lldb::addr_t                    m_ivars_ptr;<br>
+<br>
+        lldb::addr_t                    m_weakIvarLayout_ptr;<br>
+        lldb::addr_t                    m_baseProperties_ptr;<br>
+<br>
+        std::string                     m_name;<br>
+<br>
+        bool<br>
+        Read(Process *process, lldb::addr_t addr);<br>
+    };<br>
+<br>
+    struct class_rw_t {<br>
+        uint32_t                        m_flags;<br>
+        uint32_t                        m_version;<br>
+<br>
+        lldb::addr_t                    m_ro_ptr;<br>
+        union {<br>
+            lldb::addr_t                m_method_list_ptr;<br>
+            lldb::addr_t                m_method_lists_ptr;<br>
+        };<br>
+        lldb::addr_t                    m_properties_ptr;<br>
+        lldb::addr_t                    m_protocols_ptr;<br>
+<br>
+        ObjCLanguageRuntime::ObjCISA    m_firstSubclass;<br>
+        ObjCLanguageRuntime::ObjCISA    m_nextSiblingClass;<br>
+<br>
+        bool<br>
+        Read(Process *process, lldb::addr_t addr);<br>
+    };<br>
+<br>
+    struct method_list_t<br>
+    {<br>
+        uint32_t        m_entsize;<br>
+        uint32_t        m_count;<br>
+        lldb::addr_t    m_first_ptr;<br>
+<br>
+        bool<br>
+        Read(Process *process, lldb::addr_t addr);<br>
+    };<br>
+<br>
+    struct method_t<br>
+    {<br>
+        lldb::addr_t    m_name_ptr;<br>
+        lldb::addr_t    m_types_ptr;<br>
+        lldb::addr_t    m_imp_ptr;<br>
+<br>
+        std::string     m_name;<br>
+        std::string     m_types;<br>
+<br>
+        static size_t GetSize(Process *process)<br>
+        {<br>
+            size_t ptr_size = process->GetAddressByteSize();<br>
+<br>
+            return ptr_size     // SEL name;<br>
+            + ptr_size   // const char *types;<br>
+            + ptr_size;  // IMP imp;<br>
+        }<br>
+<br>
+        bool<br>
+        Read(Process *process, lldb::addr_t addr);<br>
+    };<br>
+<br>
+    struct ivar_list_t<br>
+    {<br>
+        uint32_t        m_entsize;<br>
+        uint32_t        m_count;<br>
+        lldb::addr_t    m_first_ptr;<br>
+<br>
+        bool Read(Process *process, lldb::addr_t addr);<br>
+    };<br>
+<br>
+    struct ivar_t<br>
+    {<br>
+        lldb::addr_t    m_offset_ptr;<br>
+        lldb::addr_t    m_name_ptr;<br>
+        lldb::addr_t    m_type_ptr;<br>
+        uint32_t        m_alignment;<br>
+        uint32_t        m_size;<br>
+<br>
+        std::string     m_name;<br>
+        std::string     m_type;<br>
+<br>
+        static size_t GetSize(Process *process)<br>
+        {<br>
+            size_t ptr_size = process->GetAddressByteSize();<br>
+<br>
+            return ptr_size             // uintptr_t *offset;<br>
+            + ptr_size             // const char *name;<br>
+            + ptr_size             // const char *type;<br>
+            + sizeof(uint32_t)     // uint32_t alignment;<br>
+            + sizeof(uint32_t);    // uint32_t size;<br>
+        }<br>
+<br>
+        bool<br>
+        Read(Process *process, lldb::addr_t addr);<br>
+    };<br>
+<br>
+    class iVarsStorage<br>
+    {<br>
+    public:<br>
+        iVarsStorage ();<br>
+<br>
+        size_t<br>
+        size ();<br>
+<br>
+        iVarDescriptor&<br>
+        operator[] (size_t idx);<br>
+<br>
+        void<br>
+        fill (AppleObjCRuntimeV2& runtime, ClassDescriptorV2& descriptor);<br>
+<br>
+    private:<br>
+        bool m_filled;<br>
+        std::vector<iVarDescriptor> m_ivars;<br>
+        Mutex m_mutex;<br>
+    };<br>
+<br>
+    bool<br>
+    Read_objc_class (Process* process, std::unique_ptr<objc_class_t> &objc_class) const;<br>
+<br>
+    bool<br>
+    Read_class_row (Process* process, const objc_class_t &objc_class, std::unique_ptr<class_ro_t> &class_ro, std::unique_ptr<class_rw_t> &class_rw) const;<br>
+<br>
+    AppleObjCRuntimeV2 &m_runtime;          // The runtime, so we can read information lazily.<br>
+    lldb::addr_t        m_objc_class_ptr;   // The address of the objc_class_t.  (I.e., objects of this class type have this as their ISA)<br>
+    ConstString         m_name;             // May be NULL<br>
+    iVarsStorage        m_ivars_storage;<br>
+};<br>
+<br>
+// tagged pointer descriptor<br>
+class ClassDescriptorV2Tagged : public ObjCLanguageRuntime::ClassDescriptor<br>
+{<br>
+public:<br>
+    ClassDescriptorV2Tagged (ConstString class_name,<br>
+                             uint64_t payload)<br>
+    {<br>
+        m_name = class_name;<br>
+        if (!m_name)<br>
+        {<br>
+            m_valid = false;<br>
+            return;<br>
+        }<br>
+        m_valid = true;<br>
+        m_payload = payload;<br>
+        m_info_bits = (m_payload & 0xF0ULL) >> 4;<br>
+        m_value_bits = (m_payload & ~0x0000000000000000FFULL) >> 8;<br>
+    }<br>
+<br>
+    ClassDescriptorV2Tagged (ObjCLanguageRuntime::ClassDescriptorSP actual_class_sp,<br>
+                             uint64_t payload)<br>
+    {<br>
+        if (!actual_class_sp)<br>
+        {<br>
+            m_valid = false;<br>
+            return;<br>
+        }<br>
+        m_name = actual_class_sp->GetClassName();<br>
+        if (!m_name)<br>
+        {<br>
+            m_valid = false;<br>
+            return;<br>
+        }<br>
+        m_valid = true;<br>
+        m_payload = payload;<br>
+        m_info_bits = (m_payload & 0x0FULL);<br>
+        m_value_bits = (m_payload & ~0x0FULL) >> 4;<br>
+    }<br>
+<br>
+    virtual ConstString<br>
+    GetClassName ()<br>
+    {<br>
+        return m_name;<br>
+    }<br>
+<br>
+    virtual ObjCLanguageRuntime::ClassDescriptorSP<br>
+    GetSuperclass ()<br>
+    {<br>
+        // tagged pointers can represent a class that has a superclass, but since that information is not<br>
+        // stored in the object itself, we would have to query the runtime to discover the hierarchy<br>
+        // for the time being, we skip this step in the interest of static discovery<br>
+        return ObjCLanguageRuntime::ClassDescriptorSP();<br>
+    }<br>
+<br>
+    virtual bool<br>
+    IsValid ()<br>
+    {<br>
+        return m_valid;<br>
+    }<br>
+<br>
+    virtual bool<br>
+    IsKVO ()<br>
+    {<br>
+        return false; // tagged pointers are not KVO'ed<br>
+    }<br>
+<br>
+    virtual bool<br>
+    IsCFType ()<br>
+    {<br>
+        return false; // tagged pointers are not CF objects<br>
+    }<br>
+<br>
+    virtual bool<br>
+    GetTaggedPointerInfo (uint64_t* info_bits = NULL,<br>
+                          uint64_t* value_bits = NULL,<br>
+                          uint64_t* payload = NULL)<br>
+    {<br>
+        if (info_bits)<br>
+            *info_bits = GetInfoBits();<br>
+        if (value_bits)<br>
+            *value_bits = GetValueBits();<br>
+        if (payload)<br>
+            *payload = GetPayload();<br>
+        return true;<br>
+    }<br>
+<br>
+    virtual uint64_t<br>
+    GetInstanceSize ()<br>
+    {<br>
+        return (IsValid() ? m_pointer_size : 0);<br>
+    }<br>
+<br>
+    virtual ObjCLanguageRuntime::ObjCISA<br>
+    GetISA ()<br>
+    {<br>
+        return 0; // tagged pointers have no ISA<br>
+    }<br>
+<br>
+    // these calls are not part of any formal tagged pointers specification<br>
+    virtual uint64_t<br>
+    GetValueBits ()<br>
+    {<br>
+        return (IsValid() ? m_value_bits : 0);<br>
+    }<br>
+<br>
+    virtual uint64_t<br>
+    GetInfoBits ()<br>
+    {<br>
+        return (IsValid() ? m_info_bits : 0);<br>
+    }<br>
+<br>
+    virtual uint64_t<br>
+    GetPayload ()<br>
+    {<br>
+        return (IsValid() ? m_payload : 0);<br>
+    }<br>
+<br>
+    virtual<br>
+    ~ClassDescriptorV2Tagged ()<br>
+    {}<br>
+<br>
+private:<br>
+    ConstString m_name;<br>
+    uint8_t m_pointer_size;<br>
+    bool m_valid;<br>
+    uint64_t m_info_bits;<br>
+    uint64_t m_value_bits;<br>
+    uint64_t m_payload;<br>
+<br>
+};<br>
+<br>
+} // namespace lldb_private<br>
+<br>
+#endif  // liblldb_AppleObjCRuntime_h_<br>
+<br>
<br>
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=216026&r1=216025&r2=216026&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=216026&r1=216025&r2=216026&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)<br>
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Tue Aug 19 16:46:37 2014<br>
@@ -42,9 +42,13 @@<br>
 #include "lldb/Target/Thread.h"<br>
<br>
 #include "AppleObjCRuntimeV2.h"<br>
+#include "AppleObjCClassDescriptorV2.h"<br>
+#include "AppleObjCTypeEncodingParser.h"<br>
 #include "AppleObjCTypeVendor.h"<br>
 #include "AppleObjCTrampolineHandler.h"<br>
<br>
+#include "clang/AST/ASTContext.h"<br>
+<br>
 #include <vector><br>
<br>
 using namespace lldb;<br>
@@ -348,7 +352,8 @@ AppleObjCRuntimeV2::AppleObjCRuntimeV2 (<br>
     m_has_object_getClass (false),<br>
     m_loaded_objc_opt (false),<br>
     m_non_pointer_isa_cache_ap(NonPointerISACache::CreateInstance(*this,objc_module_sp)),<br>
-    m_tagged_pointer_vendor_ap(TaggedPointerVendor::CreateInstance(*this,objc_module_sp))<br>
+    m_tagged_pointer_vendor_ap(TaggedPointerVendor::CreateInstance(*this,objc_module_sp)),<br>
+    m_encoding_to_type_sp()<br>
 {<br>
     static const ConstString g_gdb_object_getClass("gdb_object_getClass");<br>
     m_has_object_getClass = (objc_module_sp->FindFirstSymbolWithNameAndType(g_gdb_object_getClass, eSymbolTypeCode) != NULL);<br>
@@ -855,757 +860,6 @@ AppleObjCRuntimeV2::HashTableSignature::<br>
     return true;<br>
 }<br>
<br>
-class ClassDescriptorV2 : public ObjCLanguageRuntime::ClassDescriptor<br>
-{<br>
-public:<br>
-    friend class lldb_private::AppleObjCRuntimeV2;<br>
-<br>
-private:<br>
-    // The constructor should only be invoked by the runtime as it builds its caches<br>
-    // or populates them.  A ClassDescriptorV2 should only ever exist in a cache.<br>
-    ClassDescriptorV2 (AppleObjCRuntimeV2 &runtime, ObjCLanguageRuntime::ObjCISA isa, const char *name) :<br>
-        m_runtime (runtime),<br>
-        m_objc_class_ptr (isa),<br>
-        m_name (name)<br>
-    {<br>
-    }<br>
-<br>
-public:<br>
-    virtual ConstString<br>
-    GetClassName ()<br>
-    {<br>
-        if (!m_name)<br>
-        {<br>
-            lldb_private::Process *process = m_runtime.GetProcess();<br>
-<br>
-            if (process)<br>
-            {<br>
-                std::unique_ptr<objc_class_t> objc_class;<br>
-                std::unique_ptr<class_ro_t> class_ro;<br>
-                std::unique_ptr<class_rw_t> class_rw;<br>
-<br>
-                if (!Read_objc_class(process, objc_class))<br>
-                    return m_name;<br>
-                if (!Read_class_row(process, *objc_class, class_ro, class_rw))<br>
-                    return m_name;<br>
-<br>
-                m_name = ConstString(class_ro->m_name.c_str());<br>
-            }<br>
-        }<br>
-        return m_name;<br>
-    }<br>
-<br>
-    virtual ObjCLanguageRuntime::ClassDescriptorSP<br>
-    GetSuperclass ()<br>
-    {<br>
-        lldb_private::Process *process = m_runtime.GetProcess();<br>
-<br>
-        if (!process)<br>
-            return ObjCLanguageRuntime::ClassDescriptorSP();<br>
-<br>
-        std::unique_ptr<objc_class_t> objc_class;<br>
-<br>
-        if (!Read_objc_class(process, objc_class))<br>
-            return ObjCLanguageRuntime::ClassDescriptorSP();<br>
-<br>
-        return m_runtime.ObjCLanguageRuntime::GetClassDescriptorFromISA(objc_class->m_superclass);<br>
-    }<br>
-<br>
-    virtual bool<br>
-    IsValid ()<br>
-    {<br>
-        return true;    // any Objective-C v2 runtime class descriptor we vend is valid<br>
-    }<br>
-<br>
-    // a custom descriptor is used for tagged pointers<br>
-    virtual bool<br>
-    GetTaggedPointerInfo (uint64_t* info_bits = NULL,<br>
-                          uint64_t* value_bits = NULL,<br>
-                          uint64_t* payload = NULL)<br>
-    {<br>
-        return false;<br>
-    }<br>
-<br>
-    virtual uint64_t<br>
-    GetInstanceSize ()<br>
-    {<br>
-        lldb_private::Process *process = m_runtime.GetProcess();<br>
-<br>
-        if (process)<br>
-        {<br>
-            std::unique_ptr<objc_class_t> objc_class;<br>
-            std::unique_ptr<class_ro_t> class_ro;<br>
-            std::unique_ptr<class_rw_t> class_rw;<br>
-<br>
-            if (!Read_objc_class(process, objc_class))<br>
-                return 0;<br>
-            if (!Read_class_row(process, *objc_class, class_ro, class_rw))<br>
-                return 0;<br>
-<br>
-            return class_ro->m_instanceSize;<br>
-        }<br>
-<br>
-        return 0;<br>
-    }<br>
-<br>
-    virtual ObjCLanguageRuntime::ObjCISA<br>
-    GetISA ()<br>
-    {<br>
-        return m_objc_class_ptr;<br>
-    }<br>
-<br>
-    virtual bool<br>
-    Describe (std::function <void (ObjCLanguageRuntime::ObjCISA)> const &superclass_func,<br>
-              std::function <bool (const char *, const char *)> const &instance_method_func,<br>
-              std::function <bool (const char *, const char *)> const &class_method_func,<br>
-              std::function <bool (const char *, const char *, lldb::addr_t, uint64_t)> const &ivar_func)<br>
-    {<br>
-        lldb_private::Process *process = m_runtime.GetProcess();<br>
-<br>
-        std::unique_ptr<objc_class_t> objc_class;<br>
-        std::unique_ptr<class_ro_t> class_ro;<br>
-        std::unique_ptr<class_rw_t> class_rw;<br>
-<br>
-        if (!Read_objc_class(process, objc_class))<br>
-            return 0;<br>
-        if (!Read_class_row(process, *objc_class, class_ro, class_rw))<br>
-            return 0;<br>
-<br>
-        static ConstString NSObject_name("NSObject");<br>
-<br>
-        if (m_name != NSObject_name && superclass_func)<br>
-            superclass_func(objc_class->m_superclass);<br>
-<br>
-        if (instance_method_func)<br>
-        {<br>
-            std::unique_ptr<method_list_t> base_method_list;<br>
-<br>
-            base_method_list.reset(new method_list_t);<br>
-            if (!base_method_list->Read(process, class_ro->m_baseMethods_ptr))<br>
-                return false;<br>
-<br>
-            if (base_method_list->m_entsize != method_t::GetSize(process))<br>
-                return false;<br>
-<br>
-            std::unique_ptr<method_t> method;<br>
-            method.reset(new method_t);<br>
-<br>
-            for (uint32_t i = 0, e = base_method_list->m_count; i < e; ++i)<br>
-            {<br>
-                method->Read(process, base_method_list->m_first_ptr + (i * base_method_list->m_entsize));<br>
-<br>
-                if (instance_method_func(method->m_name.c_str(), method->m_types.c_str()))<br>
-                    break;<br>
-            }<br>
-        }<br>
-<br>
-        if (class_method_func)<br>
-        {<br>
-            ClassDescriptorV2 metaclass(m_runtime, objc_class->m_isa, NULL); // The metaclass is not in the cache<br>
-<br>
-            // We don't care about the metaclass's superclass, or its class methods.  Its instance methods are<br>
-            // our class methods.<br>
-<br>
-            metaclass.Describe(std::function <void (ObjCLanguageRuntime::ObjCISA)> (nullptr),<br>
-                               class_method_func,<br>
-                               std::function <bool (const char *, const char *)> (nullptr),<br>
-                               std::function <bool (const char *, const char *, lldb::addr_t, uint64_t)> (nullptr));<br>
-        }<br>
-<br>
-        if (ivar_func)<br>
-        {<br>
-            ivar_list_t ivar_list;<br>
-            if (!ivar_list.Read(process, class_ro->m_ivars_ptr))<br>
-                return false;<br>
-<br>
-            if (ivar_list.m_entsize != ivar_t::GetSize(process))<br>
-                return false;<br>
-<br>
-            ivar_t ivar;<br>
-<br>
-            for (uint32_t i = 0, e = ivar_list.m_count; i < e; ++i)<br>
-            {<br>
-                ivar.Read(process, ivar_list.m_first_ptr + (i * ivar_list.m_entsize));<br>
-<br>
-                if (ivar_func(ivar.m_name.c_str(), ivar.m_type.c_str(), ivar.m_offset_ptr, ivar.m_size))<br>
-                    break;<br>
-            }<br>
-        }<br>
-<br>
-        return true;<br>
-    }<br>
-<br>
-    virtual<br>
-    ~ClassDescriptorV2 ()<br>
-    {<br>
-    }<br>
-<br>
-private:<br>
-    static const uint32_t RW_REALIZED = (1 << 31);<br>
-<br>
-    struct objc_class_t {<br>
-        ObjCLanguageRuntime::ObjCISA    m_isa;              // The class's metaclass.<br>
-        ObjCLanguageRuntime::ObjCISA    m_superclass;<br>
-        lldb::addr_t                    m_cache_ptr;<br>
-        lldb::addr_t                    m_vtable_ptr;<br>
-        lldb::addr_t                    m_data_ptr;<br>
-        uint8_t                         m_flags;<br>
-<br>
-        objc_class_t () :<br>
-            m_isa (0),<br>
-            m_superclass (0),<br>
-            m_cache_ptr (0),<br>
-            m_vtable_ptr (0),<br>
-            m_data_ptr (0),<br>
-            m_flags (0)<br>
-        {<br>
-        }<br>
-<br>
-        void<br>
-        Clear()<br>
-        {<br>
-            m_isa = 0;<br>
-            m_superclass = 0;<br>
-            m_cache_ptr = 0;<br>
-            m_vtable_ptr = 0;<br>
-            m_data_ptr = 0;<br>
-            m_flags = 0;<br>
-        }<br>
-<br>
-        bool Read(Process *process, lldb::addr_t addr)<br>
-        {<br>
-            size_t ptr_size = process->GetAddressByteSize();<br>
-<br>
-            size_t objc_class_size = ptr_size   // uintptr_t isa;<br>
-            + ptr_size   // Class superclass;<br>
-            + ptr_size   // void *cache;<br>
-            + ptr_size   // IMP *vtable;<br>
-            + ptr_size;  // uintptr_t data_NEVER_USE;<br>
-<br>
-            DataBufferHeap objc_class_buf (objc_class_size, '\0');<br>
-            Error error;<br>
-<br>
-            process->ReadMemory(addr, objc_class_buf.GetBytes(), objc_class_size, error);<br>
-            if (error.Fail())<br>
-            {<br>
-                return false;<br>
-            }<br>
-<br>
-            DataExtractor extractor(objc_class_buf.GetBytes(), objc_class_size, process->GetByteOrder(), process->GetAddressByteSize());<br>
-<br>
-            lldb::offset_t cursor = 0;<br>
-<br>
-            m_isa           = extractor.GetAddress_unchecked(&cursor);   // uintptr_t isa;<br>
-            m_superclass    = extractor.GetAddress_unchecked(&cursor);   // Class superclass;<br>
-            m_cache_ptr     = extractor.GetAddress_unchecked(&cursor);   // void *cache;<br>
-            m_vtable_ptr    = extractor.GetAddress_unchecked(&cursor);   // IMP *vtable;<br>
-            lldb::addr_t data_NEVER_USE = extractor.GetAddress_unchecked(&cursor);   // uintptr_t data_NEVER_USE;<br>
-<br>
-            m_flags         = (uint8_t)(data_NEVER_USE & (lldb::addr_t)3);<br>
-            m_data_ptr      = data_NEVER_USE & ~(lldb::addr_t)3;<br>
-<br>
-            return true;<br>
-        }<br>
-    };<br>
-<br>
-    struct class_ro_t {<br>
-        uint32_t                        m_flags;<br>
-        uint32_t                        m_instanceStart;<br>
-        uint32_t                        m_instanceSize;<br>
-        uint32_t                        m_reserved;<br>
-<br>
-        lldb::addr_t                    m_ivarLayout_ptr;<br>
-        lldb::addr_t                    m_name_ptr;<br>
-        lldb::addr_t                    m_baseMethods_ptr;<br>
-        lldb::addr_t                    m_baseProtocols_ptr;<br>
-        lldb::addr_t                    m_ivars_ptr;<br>
-<br>
-        lldb::addr_t                    m_weakIvarLayout_ptr;<br>
-        lldb::addr_t                    m_baseProperties_ptr;<br>
-<br>
-        std::string                     m_name;<br>
-<br>
-        bool Read(Process *process, lldb::addr_t addr)<br>
-        {<br>
-            size_t ptr_size = process->GetAddressByteSize();<br>
-<br>
-            size_t size = sizeof(uint32_t)             // uint32_t flags;<br>
-            + sizeof(uint32_t)                         // uint32_t instanceStart;<br>
-            + sizeof(uint32_t)                         // uint32_t instanceSize;<br>
-            + (ptr_size == 8 ? sizeof(uint32_t) : 0)   // uint32_t reserved; // __LP64__ only<br>
-            + ptr_size                                 // const uint8_t *ivarLayout;<br>
-            + ptr_size                                 // const char *name;<br>
-            + ptr_size                                 // const method_list_t *baseMethods;<br>
-            + ptr_size                                 // const protocol_list_t *baseProtocols;<br>
-            + ptr_size                                 // const ivar_list_t *ivars;<br>
-            + ptr_size                                 // const uint8_t *weakIvarLayout;<br>
-            + ptr_size;                                // const property_list_t *baseProperties;<br>
-<br>
-            DataBufferHeap buffer (size, '\0');<br>
-            Error error;<br>
-<br>
-            process->ReadMemory(addr, buffer.GetBytes(), size, error);<br>
-            if (error.Fail())<br>
-            {<br>
-                return false;<br>
-            }<br>
-<br>
-            DataExtractor extractor(buffer.GetBytes(), size, process->GetByteOrder(), process->GetAddressByteSize());<br>
-<br>
-            lldb::offset_t cursor = 0;<br>
-<br>
-            m_flags             = extractor.GetU32_unchecked(&cursor);<br>
-            m_instanceStart     = extractor.GetU32_unchecked(&cursor);<br>
-            m_instanceSize      = extractor.GetU32_unchecked(&cursor);<br>
-            if (ptr_size == 8)<br>
-                m_reserved      = extractor.GetU32_unchecked(&cursor);<br>
-            else<br>
-                m_reserved      = 0;<br>
-            m_ivarLayout_ptr     = extractor.GetAddress_unchecked(&cursor);<br>
-            m_name_ptr           = extractor.GetAddress_unchecked(&cursor);<br>
-            m_baseMethods_ptr    = extractor.GetAddress_unchecked(&cursor);<br>
-            m_baseProtocols_ptr  = extractor.GetAddress_unchecked(&cursor);<br>
-            m_ivars_ptr          = extractor.GetAddress_unchecked(&cursor);<br>
-            m_weakIvarLayout_ptr = extractor.GetAddress_unchecked(&cursor);<br>
-            m_baseProperties_ptr = extractor.GetAddress_unchecked(&cursor);<br>
-<br>
-            DataBufferHeap name_buf(1024, '\0');<br>
-<br>
-            process->ReadCStringFromMemory(m_name_ptr, (char*)name_buf.GetBytes(), name_buf.GetByteSize(), error);<br>
-<br>
-            if (error.Fail())<br>
-            {<br>
-                return false;<br>
-            }<br>
-<br>
-            m_name.assign((char*)name_buf.GetBytes());<br>
-<br>
-            return true;<br>
-        }<br>
-    };<br>
-<br>
-    struct class_rw_t {<br>
-        uint32_t                        m_flags;<br>
-        uint32_t                        m_version;<br>
-<br>
-        lldb::addr_t                    m_ro_ptr;<br>
-        union {<br>
-            lldb::addr_t                m_method_list_ptr;<br>
-            lldb::addr_t                m_method_lists_ptr;<br>
-        };<br>
-        lldb::addr_t                    m_properties_ptr;<br>
-        lldb::addr_t                    m_protocols_ptr;<br>
-<br>
-        ObjCLanguageRuntime::ObjCISA    m_firstSubclass;<br>
-        ObjCLanguageRuntime::ObjCISA    m_nextSiblingClass;<br>
-<br>
-        bool Read(Process *process, lldb::addr_t addr)<br>
-        {<br>
-            size_t ptr_size = process->GetAddressByteSize();<br>
-<br>
-            size_t size = sizeof(uint32_t)  // uint32_t flags;<br>
-            + sizeof(uint32_t)  // uint32_t version;<br>
-            + ptr_size          // const class_ro_t *ro;<br>
-            + ptr_size          // union { method_list_t **method_lists; method_list_t *method_list; };<br>
-            + ptr_size          // struct chained_property_list *properties;<br>
-            + ptr_size          // const protocol_list_t **protocols;<br>
-            + ptr_size          // Class firstSubclass;<br>
-            + ptr_size;         // Class nextSiblingClass;<br>
-<br>
-            DataBufferHeap buffer (size, '\0');<br>
-            Error error;<br>
-<br>
-            process->ReadMemory(addr, buffer.GetBytes(), size, error);<br>
-            if (error.Fail())<br>
-            {<br>
-                return false;<br>
-            }<br>
-<br>
-            DataExtractor extractor(buffer.GetBytes(), size, process->GetByteOrder(), process->GetAddressByteSize());<br>
-<br>
-            lldb::offset_t cursor = 0;<br>
-<br>
-            m_flags             = extractor.GetU32_unchecked(&cursor);<br>
-            m_version           = extractor.GetU32_unchecked(&cursor);<br>
-            m_ro_ptr            = extractor.GetAddress_unchecked(&cursor);<br>
-            m_method_list_ptr   = extractor.GetAddress_unchecked(&cursor);<br>
-            m_properties_ptr    = extractor.GetAddress_unchecked(&cursor);<br>
-            m_firstSubclass     = extractor.GetAddress_unchecked(&cursor);<br>
-            m_nextSiblingClass  = extractor.GetAddress_unchecked(&cursor);<br>
-<br>
-            return true;<br>
-        }<br>
-    };<br>
-<br>
-    struct method_list_t<br>
-    {<br>
-        uint32_t        m_entsize;<br>
-        uint32_t        m_count;<br>
-        lldb::addr_t    m_first_ptr;<br>
-<br>
-        bool Read(Process *process, lldb::addr_t addr)<br>
-        {<br>
-            size_t size = sizeof(uint32_t)  // uint32_t entsize_NEVER_USE;<br>
-            + sizeof(uint32_t); // uint32_t count;<br>
-<br>
-            DataBufferHeap buffer (size, '\0');<br>
-            Error error;<br>
-<br>
-            process->ReadMemory(addr, buffer.GetBytes(), size, error);<br>
-            if (error.Fail())<br>
-            {<br>
-                return false;<br>
-            }<br>
-<br>
-            DataExtractor extractor(buffer.GetBytes(), size, process->GetByteOrder(), process->GetAddressByteSize());<br>
-<br>
-            lldb::offset_t cursor = 0;<br>
-<br>
-            m_entsize   = extractor.GetU32_unchecked(&cursor) & ~(uint32_t)3;<br>
-            m_count     = extractor.GetU32_unchecked(&cursor);<br>
-            m_first_ptr  = addr + cursor;<br>
-<br>
-            return true;<br>
-        }<br>
-    };<br>
-<br>
-    struct method_t<br>
-    {<br>
-        lldb::addr_t    m_name_ptr;<br>
-        lldb::addr_t    m_types_ptr;<br>
-        lldb::addr_t    m_imp_ptr;<br>
-<br>
-        std::string     m_name;<br>
-        std::string     m_types;<br>
-<br>
-        static size_t GetSize(Process *process)<br>
-        {<br>
-            size_t ptr_size = process->GetAddressByteSize();<br>
-<br>
-            return ptr_size     // SEL name;<br>
-            + ptr_size   // const char *types;<br>
-            + ptr_size;  // IMP imp;<br>
-        }<br>
-<br>
-        bool Read(Process *process, lldb::addr_t addr)<br>
-        {<br>
-            size_t size = GetSize(process);<br>
-<br>
-            DataBufferHeap buffer (size, '\0');<br>
-            Error error;<br>
-<br>
-            process->ReadMemory(addr, buffer.GetBytes(), size, error);<br>
-            if (error.Fail())<br>
-            {<br>
-                return false;<br>
-            }<br>
-<br>
-            DataExtractor extractor(buffer.GetBytes(), size, process->GetByteOrder(), process->GetAddressByteSize());<br>
-<br>
-            lldb::offset_t cursor = 0;<br>
-<br>
-            m_name_ptr   = extractor.GetAddress_unchecked(&cursor);<br>
-            m_types_ptr  = extractor.GetAddress_unchecked(&cursor);<br>
-            m_imp_ptr    = extractor.GetAddress_unchecked(&cursor);<br>
-<br>
-            const size_t buffer_size = 1024;<br>
-            size_t count;<br>
-<br>
-            DataBufferHeap string_buf(buffer_size, 0);<br>
-<br>
-            count = process->ReadCStringFromMemory(m_name_ptr, (char*)string_buf.GetBytes(), buffer_size, error);<br>
-            m_name.assign((char*)string_buf.GetBytes(), count);<br>
-<br>
-            count = process->ReadCStringFromMemory(m_types_ptr, (char*)string_buf.GetBytes(), buffer_size, error);<br>
-            m_types.assign((char*)string_buf.GetBytes(), count);<br>
-<br>
-            return true;<br>
-        }<br>
-    };<br>
-<br>
-    struct ivar_list_t<br>
-    {<br>
-        uint32_t        m_entsize;<br>
-        uint32_t        m_count;<br>
-        lldb::addr_t    m_first_ptr;<br>
-<br>
-        bool Read(Process *process, lldb::addr_t addr)<br>
-        {<br>
-            size_t size = sizeof(uint32_t)  // uint32_t entsize;<br>
-                        + sizeof(uint32_t); // uint32_t count;<br>
-<br>
-            DataBufferHeap buffer (size, '\0');<br>
-            Error error;<br>
-<br>
-            process->ReadMemory(addr, buffer.GetBytes(), size, error);<br>
-            if (error.Fail())<br>
-            {<br>
-                return false;<br>
-            }<br>
-<br>
-            DataExtractor extractor(buffer.GetBytes(), size, process->GetByteOrder(), process->GetAddressByteSize());<br>
-<br>
-            lldb::offset_t cursor = 0;<br>
-<br>
-            m_entsize   = extractor.GetU32_unchecked(&cursor);<br>
-            m_count     = extractor.GetU32_unchecked(&cursor);<br>
-            m_first_ptr = addr + cursor;<br>
-<br>
-            return true;<br>
-        }<br>
-    };<br>
-<br>
-    struct ivar_t<br>
-    {<br>
-        lldb::addr_t    m_offset_ptr;<br>
-        lldb::addr_t    m_name_ptr;<br>
-        lldb::addr_t    m_type_ptr;<br>
-        uint32_t        m_alignment;<br>
-        uint32_t        m_size;<br>
-<br>
-        std::string     m_name;<br>
-        std::string     m_type;<br>
-<br>
-        static size_t GetSize(Process *process)<br>
-        {<br>
-            size_t ptr_size = process->GetAddressByteSize();<br>
-<br>
-            return ptr_size             // uintptr_t *offset;<br>
-                 + ptr_size             // const char *name;<br>
-                 + ptr_size             // const char *type;<br>
-                 + sizeof(uint32_t)     // uint32_t alignment;<br>
-                 + sizeof(uint32_t);    // uint32_t size;<br>
-        }<br>
-<br>
-        bool Read(Process *process, lldb::addr_t addr)<br>
-        {<br>
-            size_t size = GetSize(process);<br>
-<br>
-            DataBufferHeap buffer (size, '\0');<br>
-            Error error;<br>
-<br>
-            process->ReadMemory(addr, buffer.GetBytes(), size, error);<br>
-            if (error.Fail())<br>
-            {<br>
-                return false;<br>
-            }<br>
-<br>
-            DataExtractor extractor(buffer.GetBytes(), size, process->GetByteOrder(), process->GetAddressByteSize());<br>
-<br>
-            lldb::offset_t cursor = 0;<br>
-<br>
-            m_offset_ptr = extractor.GetAddress_unchecked(&cursor);<br>
-            m_name_ptr   = extractor.GetAddress_unchecked(&cursor);<br>
-            m_type_ptr   = extractor.GetAddress_unchecked(&cursor);<br>
-            m_alignment  = extractor.GetU32_unchecked(&cursor);<br>
-            m_size       = extractor.GetU32_unchecked(&cursor);<br>
-<br>
-            const size_t buffer_size = 1024;<br>
-            size_t count;<br>
-<br>
-            DataBufferHeap string_buf(buffer_size, 0);<br>
-<br>
-            count = process->ReadCStringFromMemory(m_name_ptr, (char*)string_buf.GetBytes(), buffer_size, error);<br>
-            m_name.assign((char*)string_buf.GetBytes(), count);<br>
-<br>
-            count = process->ReadCStringFromMemory(m_type_ptr, (char*)string_buf.GetBytes(), buffer_size, error);<br>
-            m_type.assign((char*)string_buf.GetBytes(), count);<br>
-<br>
-            return true;<br>
-        }<br>
-    };<br>
-<br>
-    bool Read_objc_class (Process* process, std::unique_ptr<objc_class_t> &objc_class)<br>
-    {<br>
-        objc_class.reset(new objc_class_t);<br>
-<br>
-        bool ret = objc_class->Read (process, m_objc_class_ptr);<br>
-<br>
-        if (!ret)<br>
-            objc_class.reset();<br>
-<br>
-        return ret;<br>
-    }<br>
-<br>
-    bool Read_class_row (Process* process, const objc_class_t &objc_class, std::unique_ptr<class_ro_t> &class_ro, std::unique_ptr<class_rw_t> &class_rw)<br>
-    {<br>
-        class_ro.reset();<br>
-        class_rw.reset();<br>
-<br>
-        Error error;<br>
-        uint32_t class_row_t_flags = process->ReadUnsignedIntegerFromMemory(objc_class.m_data_ptr, sizeof(uint32_t), 0, error);<br>
-        if (!error.Success())<br>
-            return false;<br>
-<br>
-        if (class_row_t_flags & RW_REALIZED)<br>
-        {<br>
-            class_rw.reset(new class_rw_t);<br>
-<br>
-            if (!class_rw->Read(process, objc_class.m_data_ptr))<br>
-            {<br>
-                class_rw.reset();<br>
-                return false;<br>
-            }<br>
-<br>
-            class_ro.reset(new class_ro_t);<br>
-<br>
-            if (!class_ro->Read(process, class_rw->m_ro_ptr))<br>
-            {<br>
-                class_rw.reset();<br>
-                class_ro.reset();<br>
-                return false;<br>
-            }<br>
-        }<br>
-        else<br>
-        {<br>
-            class_ro.reset(new class_ro_t);<br>
-<br>
-            if (!class_ro->Read(process, objc_class.m_data_ptr))<br>
-            {<br>
-                class_ro.reset();<br>
-                return false;<br>
-            }<br>
-        }<br>
-<br>
-        return true;<br>
-    }<br>
-<br>
-    AppleObjCRuntimeV2 &m_runtime;          // The runtime, so we can read information lazily.<br>
-    lldb::addr_t        m_objc_class_ptr;   // The address of the objc_class_t.  (I.e., objects of this class type have this as their ISA)<br>
-    ConstString         m_name;             // May be NULL<br>
-};<br>
-<br>
-// tagged pointer descriptor<br>
-class ClassDescriptorV2Tagged : public ObjCLanguageRuntime::ClassDescriptor<br>
-{<br>
-public:<br>
-    ClassDescriptorV2Tagged (ConstString class_name,<br>
-                             uint64_t payload)<br>
-    {<br>
-        m_name = class_name;<br>
-        if (!m_name)<br>
-        {<br>
-            m_valid = false;<br>
-            return;<br>
-        }<br>
-        m_valid = true;<br>
-        m_payload = payload;<br>
-        m_info_bits = (m_payload & 0xF0ULL) >> 4;<br>
-        m_value_bits = (m_payload & ~0x0000000000000000FFULL) >> 8;<br>
-    }<br>
-<br>
-    ClassDescriptorV2Tagged (ObjCLanguageRuntime::ClassDescriptorSP actual_class_sp,<br>
-                             uint64_t payload)<br>
-    {<br>
-        if (!actual_class_sp)<br>
-        {<br>
-            m_valid = false;<br>
-            return;<br>
-        }<br>
-        m_name = actual_class_sp->GetClassName();<br>
-        if (!m_name)<br>
-        {<br>
-            m_valid = false;<br>
-            return;<br>
-        }<br>
-        m_valid = true;<br>
-        m_payload = payload;<br>
-        m_info_bits = (m_payload & 0x0FULL);<br>
-        m_value_bits = (m_payload & ~0x0FULL) >> 4;<br>
-    }<br>
-<br>
-    virtual ConstString<br>
-    GetClassName ()<br>
-    {<br>
-        return m_name;<br>
-    }<br>
-<br>
-    virtual ObjCLanguageRuntime::ClassDescriptorSP<br>
-    GetSuperclass ()<br>
-    {<br>
-        // tagged pointers can represent a class that has a superclass, but since that information is not<br>
-        // stored in the object itself, we would have to query the runtime to discover the hierarchy<br>
-        // for the time being, we skip this step in the interest of static discovery<br>
-        return ObjCLanguageRuntime::ClassDescriptorSP();<br>
-    }<br>
-<br>
-    virtual bool<br>
-    IsValid ()<br>
-    {<br>
-        return m_valid;<br>
-    }<br>
-<br>
-    virtual bool<br>
-    IsKVO ()<br>
-    {<br>
-        return false; // tagged pointers are not KVO'ed<br>
-    }<br>
-<br>
-    virtual bool<br>
-    IsCFType ()<br>
-    {<br>
-        return false; // tagged pointers are not CF objects<br>
-    }<br>
-<br>
-    virtual bool<br>
-    GetTaggedPointerInfo (uint64_t* info_bits = NULL,<br>
-                          uint64_t* value_bits = NULL,<br>
-                          uint64_t* payload = NULL)<br>
-    {<br>
-        if (info_bits)<br>
-            *info_bits = GetInfoBits();<br>
-        if (value_bits)<br>
-            *value_bits = GetValueBits();<br>
-        if (payload)<br>
-            *payload = GetPayload();<br>
-        return true;<br>
-    }<br>
-<br>
-    virtual uint64_t<br>
-    GetInstanceSize ()<br>
-    {<br>
-        return (IsValid() ? m_pointer_size : 0);<br>
-    }<br>
-<br>
-    virtual ObjCLanguageRuntime::ObjCISA<br>
-    GetISA ()<br>
-    {<br>
-        return 0; // tagged pointers have no ISA<br>
-    }<br>
-<br>
-    // these calls are not part of any formal tagged pointers specification<br>
-    virtual uint64_t<br>
-    GetValueBits ()<br>
-    {<br>
-        return (IsValid() ? m_value_bits : 0);<br>
-    }<br>
-<br>
-    virtual uint64_t<br>
-    GetInfoBits ()<br>
-    {<br>
-        return (IsValid() ? m_info_bits : 0);<br>
-    }<br>
-<br>
-    virtual uint64_t<br>
-    GetPayload ()<br>
-    {<br>
-        return (IsValid() ? m_payload : 0);<br>
-    }<br>
-<br>
-    virtual<br>
-    ~ClassDescriptorV2Tagged ()<br>
-    {}<br>
-<br>
-private:<br>
-    ConstString m_name;<br>
-    uint8_t m_pointer_size;<br>
-    bool m_valid;<br>
-    uint64_t m_info_bits;<br>
-    uint64_t m_value_bits;<br>
-    uint64_t m_payload;<br>
-<br>
-};<br>
-<br>
 ObjCLanguageRuntime::ClassDescriptorSP<br>
 AppleObjCRuntimeV2::GetClassDescriptorFromISA (ObjCISA isa)<br>
 {<br>
@@ -1621,6 +875,18 @@ ObjCLanguageRuntime::ClassDescriptorSP<br>
 AppleObjCRuntimeV2::GetClassDescriptor (ValueObject& valobj)<br>
 {<br>
     ClassDescriptorSP objc_class_sp;<br>
+    if (valobj.IsBaseClass())<br>
+    {<br>
+        ValueObject *parent = valobj.GetParent();<br>
+        // if I am my own parent, bail out of here fast..<br>
+        if (parent && parent != &valobj)<br>
+        {<br>
+            ClassDescriptorSP parent_descriptor_sp = GetClassDescriptor(*parent);<br>
+            if (parent_descriptor_sp)<br>
+                return parent_descriptor_sp->GetSuperclass();<br>
+        }<br>
+        return nullptr;<br>
+    }<br>
     // if we get an invalid VO (which might still happen when playing around<br>
     // with pointers returned by the expression parser, don't consider this<br>
     // a valid ObjC object)<br>
@@ -2651,3 +1917,11 @@ AppleObjCRuntimeV2::NonPointerISACache::<br>
     }<br>
     return false;<br>
 }<br>
+<br>
+ObjCLanguageRuntime::EncodingToTypeSP<br>
+AppleObjCRuntimeV2::GetEncodingToType ()<br>
+{<br>
+    if (!m_encoding_to_type_sp)<br>
+        m_encoding_to_type_sp.reset(new AppleObjCTypeEncodingParser(*this));<br>
+    return m_encoding_to_type_sp;<br>
+}<br>
<br>
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h?rev=216026&r1=216025&r2=216026&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h?rev=216026&r1=216025&r2=216026&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h (original)<br>
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h Tue Aug 19 16:46:37 2014<br>
@@ -105,6 +105,9 @@ public:<br>
     virtual lldb::addr_t<br>
     LookupRuntimeSymbol (const ConstString &name);<br>
<br>
+    virtual EncodingToTypeSP<br>
+    GetEncodingToType ();<br>
+<br>
 protected:<br>
     virtual lldb::BreakpointResolverSP<br>
     CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bool throw_bp);<br>
@@ -277,6 +280,7 @@ private:<br>
     bool                                    m_loaded_objc_opt;<br>
     std::unique_ptr<NonPointerISACache>       m_non_pointer_isa_cache_ap;<br>
     std::unique_ptr<TaggedPointerVendor>    m_tagged_pointer_vendor_ap;<br>
+    EncodingToTypeSP                        m_encoding_to_type_sp;<br>
 };<br>
<br>
 } // namespace lldb_private<br>
<br>
Added: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp?rev=216026&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp?rev=216026&view=auto</a><br>

==============================================================================<br>
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp (added)<br>
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp Tue Aug 19 16:46:37 2014<br>
@@ -0,0 +1,275 @@<br>
+//===-- AppleObjCTypeEncodingParser.cpp -------------------------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "AppleObjCTypeEncodingParser.h"<br>
+<br>
+#include "lldb/Symbol/ClangASTContext.h"<br>
+#include "lldb/Symbol/ClangASTType.h"<br>
+#include "lldb/Target/Process.h"<br>
+#include "lldb/Target/Target.h"<br>
+#include "lldb/Utility/StringLexer.h"<br>
+<br>
+#include <vector><br>
+<br>
+using namespace lldb_private;<br>
+using namespace lldb_utility;<br>
+<br>
+AppleObjCTypeEncodingParser::AppleObjCTypeEncodingParser (ObjCLanguageRuntime& runtime) :<br>
+ObjCLanguageRuntime::EncodingToType()<br>
+{<br>
+    if (!m_scratch_ast_ctx_ap)<br>
+        m_scratch_ast_ctx_ap.reset(new ClangASTContext(runtime.GetProcess()->GetTarget().GetArchitecture().GetTriple().str().c_str()));<br>
+}<br>
+<br>
+std::string<br>
+AppleObjCTypeEncodingParser::ReadStructName(lldb_utility::StringLexer& type)<br>
+{<br>
+    StreamString buffer;<br>
+    while (type.HasAtLeast(1) && type.Peek() != '=')<br>
+        buffer.Printf("%c",type.Next());<br>
+    return buffer.GetString();<br>
+}<br>
+<br>
+std::string<br>
+AppleObjCTypeEncodingParser::ReadStructElementName(lldb_utility::StringLexer& type)<br>
+{<br>
+    StreamString buffer;<br>
+    while (type.HasAtLeast(1) && type.Peek() != '"')<br>
+        buffer.Printf("%c",type.Next());<br>
+    return buffer.GetString();<br>
+}<br>
+<br>
+uint<br>
+AppleObjCTypeEncodingParser::ReadNumber (lldb_utility::StringLexer& type)<br>
+{<br>
+    uint total = 0;<br>
+    while (type.HasAtLeast(1) && isdigit(type.Peek()))<br>
+           total = 10*total + (type.Next() - '0');<br>
+    return total;<br>
+}<br>
+<br>
+// as an extension to the published grammar recent runtimes emit structs like this:<br>
+// "{CGRect=\"origin\"{CGPoint=\"x\"d\"y\"d}\"size\"{CGSize=\"width\"d\"height\"d}}"<br>
+<br>
+AppleObjCTypeEncodingParser::StructElement::StructElement() :<br>
+name(""),<br>
+type(clang::QualType()),<br>
+bitfield(0)<br>
+{}<br>
+<br>
+AppleObjCTypeEncodingParser::StructElement<br>
+AppleObjCTypeEncodingParser::ReadStructElement (clang::ASTContext &ast_ctx, lldb_utility::StringLexer& type, bool allow_unknownanytype)<br>
+{<br>
+    StructElement retval;<br>
+    if (type.NextIf('"'))<br>
+        <a href="http://retval.name" target="_blank">retval.name</a> = ReadStructElementName(type);<br>
+    if (!type.NextIf('"'))<br>
+        return retval;<br>
+    uint32_t bitfield_size = 0;<br>
+    retval.type = BuildType(ast_ctx, type, allow_unknownanytype, &bitfield_size);<br>
+    retval.bitfield = bitfield_size;<br>
+    return retval;<br>
+}<br>
+<br>
+clang::QualType<br>
+AppleObjCTypeEncodingParser::BuildStruct (clang::ASTContext &ast_ctx, lldb_utility::StringLexer& type, bool allow_unknownanytype)<br>
+{<br>
+    return BuildAggregate(ast_ctx, type, allow_unknownanytype, '{', '}', clang::TTK_Struct);<br>
+}<br>
+<br>
+clang::QualType<br>
+AppleObjCTypeEncodingParser::BuildUnion (clang::ASTContext &ast_ctx, lldb_utility::StringLexer& type, bool allow_unknownanytype)<br>
+{<br>
+    return BuildAggregate(ast_ctx, type, allow_unknownanytype, '(', ')', clang::TTK_Union);<br>
+}<br>
+<br>
+clang::QualType<br>
+AppleObjCTypeEncodingParser::BuildAggregate (clang::ASTContext &ast_ctx, lldb_utility::StringLexer& type, bool allow_unknownanytype, char opener, char closer, uint kind)<br>
+{<br>
+    if (!type.NextIf(opener))<br>
+        return clang::QualType();<br>
+    std::string name(ReadStructName(type));<br>
+    if (!type.NextIf('='))<br>
+        return clang::QualType();<br>
+    bool in_union = true;<br>
+    std::vector<StructElement> elements;<br>
+    while (in_union && type.HasAtLeast(1))<br>
+    {<br>
+        if (type.NextIf(closer))<br>
+        {<br>
+            in_union = false;<br>
+            break;<br>
+        }<br>
+        else<br>
+        {<br>
+            auto element = ReadStructElement(ast_ctx, type, allow_unknownanytype);<br>
+            if (element.type.isNull())<br>
+                break;<br>
+            else<br>
+                elements.push_back(element);<br>
+        }<br>
+    }<br>
+    if (in_union)<br>
+        return clang::QualType();<br>
+    ClangASTContext *lldb_ctx = ClangASTContext::GetASTContext(&ast_ctx);<br>
+    if (!lldb_ctx)<br>
+        return clang::QualType();<br>
+    ClangASTType union_type(lldb_ctx->CreateRecordType(nullptr, lldb::eAccessPublic, name.c_str(), kind, lldb::eLanguageTypeC));<br>
+    if (union_type)<br>
+    {<br>
+        union_type.StartTagDeclarationDefinition();<br>
+<br>
+        unsigned int count = 0;<br>
+        for (auto element: elements)<br>
+        {<br>
+            if (element.name.empty())<br>
+            {<br>
+                StreamString elem_name;<br>
+                elem_name.Printf("__unnamed_%u",count);<br>
+                <a href="http://element.name" target="_blank">element.name</a> = std::string(elem_name.GetData());<br>
+            }<br>
+            union_type.AddFieldToRecordType(element.name.c_str(), ClangASTType(&ast_ctx,element.type.getAsOpaquePtr()), lldb::eAccessPublic, element.bitfield);<br>
+            ++count;<br>
+        }<br>
+<br>
+        union_type.CompleteTagDeclarationDefinition();<br>
+    }<br>
+    return union_type.GetQualType();<br>
+}<br>
+<br>
+clang::QualType<br>
+AppleObjCTypeEncodingParser::BuildArray (clang::ASTContext &ast_ctx, lldb_utility::StringLexer& type, bool allow_unknownanytype)<br>
+{<br>
+    if (!type.NextIf('['))<br>
+        return clang::QualType();<br>
+    uint size = ReadNumber(type);<br>
+    clang::QualType element_type(BuildType(ast_ctx, type, allow_unknownanytype));<br>
+    if (!type.NextIf(']'))<br>
+        return clang::QualType();<br>
+    ClangASTContext *lldb_ctx = ClangASTContext::GetASTContext(&ast_ctx);<br>
+    if (!lldb_ctx)<br>
+        return clang::QualType();<br>
+    ClangASTType array_type(lldb_ctx->CreateArrayType(ClangASTType(&ast_ctx,element_type.getAsOpaquePtr()), size, false));<br>
+    return array_type.GetQualType();<br>
+}<br>
+<br>
+clang::QualType<br>
+AppleObjCTypeEncodingParser::BuildType (clang::ASTContext &ast_ctx, StringLexer& type, bool allow_unknownanytype, uint32_t *bitfield_bit_size)<br>
+{<br>
+    if (!type.HasAtLeast(1))<br>
+        return clang::QualType();<br>
+<br>
+    if (type.NextIf('c'))<br>
+        return ast_ctx.CharTy;<br>
+    if (type.NextIf('i'))<br>
+        return ast_ctx.IntTy;<br>
+    if (type.NextIf('s'))<br>
+        return ast_ctx.ShortTy;<br>
+    if (type.NextIf('l'))<br>
+    {<br>
+        ClangASTContext *lldb_ctx = ClangASTContext::GetASTContext(&ast_ctx);<br>
+        if (!lldb_ctx)<br>
+            return clang::QualType();<br>
+        return lldb_ctx->GetIntTypeFromBitSize(32, true).GetQualType();<br>
+    }<br>
+    if (type.NextIf('q'))<br>
+        return ast_ctx.LongLongTy;<br>
+    if (type.NextIf('C'))<br>
+        return ast_ctx.UnsignedCharTy;<br>
+    if (type.NextIf('I'))<br>
+        return ast_ctx.UnsignedIntTy;<br>
+    if (type.NextIf('S'))<br>
+        return ast_ctx.UnsignedShortTy;<br>
+    if (type.NextIf('L'))<br>
+    {<br>
+        ClangASTContext *lldb_ctx = ClangASTContext::GetASTContext(&ast_ctx);<br>
+        if (!lldb_ctx)<br>
+            return clang::QualType();<br>
+        return lldb_ctx->GetIntTypeFromBitSize(32, false).GetQualType();<br>
+    }<br>
+    if (type.NextIf('Q'))<br>
+        return ast_ctx.UnsignedLongLongTy;<br>
+    if (type.NextIf('f'))<br>
+        return ast_ctx.FloatTy;<br>
+    if (type.NextIf('d'))<br>
+        return ast_ctx.DoubleTy;<br>
+    if (type.NextIf('B'))<br>
+        return ast_ctx.BoolTy;<br>
+    if (type.NextIf('v'))<br>
+        return ast_ctx.VoidTy;<br>
+    if (type.NextIf('*'))<br>
+        return ast_ctx.getPointerType(ast_ctx.CharTy);<br>
+    if (type.NextIf('@'))<br>
+        return ast_ctx.getObjCIdType();<br>
+    if (type.NextIf('#'))<br>
+        return ast_ctx.getObjCClassType();<br>
+    if (type.NextIf(':'))<br>
+        return ast_ctx.getObjCSelType();<br>
+<br>
+    if (type.NextIf('b'))<br>
+    {<br>
+        uint size = ReadNumber(type);<br>
+        if (bitfield_bit_size)<br>
+        {<br>
+            *bitfield_bit_size = size;<br>
+            return ast_ctx.UnsignedIntTy; // FIXME: the spec is fairly vague here.<br>
+        }<br>
+        else<br>
+            return clang::QualType();<br>
+    }<br>
+<br>
+    if (type.NextIf('r'))<br>
+    {<br>
+        clang::QualType target_type = BuildType(ast_ctx, type, allow_unknownanytype);<br>
+        if (target_type.isNull())<br>
+            return clang::QualType();<br>
+        else if (target_type == ast_ctx.UnknownAnyTy)<br>
+            return ast_ctx.UnknownAnyTy;<br>
+        else<br>
+            return ast_ctx.getConstType(target_type);<br>
+    }<br>
+<br>
+    if (type.NextIf('^'))<br>
+    {<br>
+        clang::QualType target_type = BuildType(ast_ctx, type, allow_unknownanytype);<br>
+        if (target_type.isNull())<br>
+            return clang::QualType();<br>
+        else if (target_type == ast_ctx.UnknownAnyTy)<br>
+            return ast_ctx.UnknownAnyTy;<br>
+        else<br>
+            return ast_ctx.getPointerType(target_type);<br>
+    }<br>
+<br>
+    if (type.NextIf('?'))<br>
+        return allow_unknownanytype ? ast_ctx.UnknownAnyTy : clang::QualType();<br>
+<br>
+    if (type.Peek() == '{')<br>
+        return BuildStruct(ast_ctx, type, allow_unknownanytype);<br>
+<br>
+    if (type.Peek() == '[')<br>
+        return BuildArray(ast_ctx, type, allow_unknownanytype);<br>
+<br>
+    if (type.Peek() == '(')<br>
+        return BuildUnion(ast_ctx, type, allow_unknownanytype);<br>
+<br>
+    return clang::QualType();<br>
+}<br>
+<br>
+ClangASTType<br>
+AppleObjCTypeEncodingParser::RealizeType (clang::ASTContext &ast_ctx, const char* name, bool allow_unknownanytype)<br>
+{<br>
+    if (name && name[0])<br>
+    {<br>
+        StringLexer lexer(name);<br>
+        clang::QualType qual_type = BuildType(ast_ctx, lexer, allow_unknownanytype);<br>
+        return ClangASTType(&ast_ctx, qual_type.getAsOpaquePtr());<br>
+    }<br>
+    return ClangASTType();<br>
+}<br>
+<br>
<br>
Added: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h?rev=216026&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h?rev=216026&view=auto</a><br>

==============================================================================<br>
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h (added)<br>
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h Tue Aug 19 16:46:37 2014<br>
@@ -0,0 +1,78 @@<br>
+//===-- AppleObjCTypeEncodingParser.h ---------------------------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#ifndef liblldb_AppleObjCTypeEncodingParser_h_<br>
+#define liblldb_AppleObjCTypeEncodingParser_h_<br>
+<br>
+// C Includes<br>
+// C++ Includes<br>
+<br>
+// Other libraries and framework includes<br>
+<br>
+// Project includes<br>
+#include "lldb/lldb-private.h"<br>
+#include "lldb/Target/ObjCLanguageRuntime.h"<br>
+<br>
+#include "clang/AST/ASTContext.h"<br>
+<br>
+namespace lldb_utility {<br>
+    class StringLexer;<br>
+}<br>
+<br>
+namespace lldb_private {<br>
+<br>
+    class AppleObjCTypeEncodingParser : public ObjCLanguageRuntime::EncodingToType<br>
+    {<br>
+    public:<br>
+        AppleObjCTypeEncodingParser (ObjCLanguageRuntime& runtime);<br>
+        virtual ClangASTType RealizeType (clang::ASTContext &ast_ctx, const char* name, bool allow_unknownanytype);<br>
+        virtual ~AppleObjCTypeEncodingParser() {}<br>
+<br>
+    private:<br>
+        struct StructElement {<br>
+            std::string name;<br>
+            clang::QualType type;<br>
+            uint32_t bitfield;<br>
+<br>
+            StructElement ();<br>
+            ~StructElement () = default;<br>
+        };<br>
+<br>
+        clang::QualType<br>
+        BuildType (clang::ASTContext &ast_ctx, lldb_utility::StringLexer& type, bool allow_unknownanytype, uint32_t *bitfield_bit_size = nullptr);<br>
+<br>
+        clang::QualType<br>
+        BuildStruct (clang::ASTContext &ast_ctx, lldb_utility::StringLexer& type, bool allow_unknownanytype);<br>
+<br>
+        clang::QualType<br>
+        BuildAggregate (clang::ASTContext &ast_ctx, lldb_utility::StringLexer& type, bool allow_unknownanytype, char opener, char closer, uint kind);<br>
+<br>
+        clang::QualType<br>
+        BuildUnion (clang::ASTContext &ast_ctx, lldb_utility::StringLexer& type, bool allow_unknownanytype);<br>
+<br>
+        clang::QualType<br>
+        BuildArray (clang::ASTContext &ast_ctx, lldb_utility::StringLexer& type, bool allow_unknownanytype);<br>
+<br>
+        std::string<br>
+        ReadStructName(lldb_utility::StringLexer& type);<br>
+<br>
+        StructElement<br>
+        ReadStructElement (clang::ASTContext &ast_ctx, lldb_utility::StringLexer& type, bool allow_unknownanytype);<br>
+<br>
+        std::string<br>
+        ReadStructElementName(lldb_utility::StringLexer& type);<br>
+<br>
+        uint<br>
+        ReadNumber (lldb_utility::StringLexer& type);<br>
+<br>
+    };<br>
+<br>
+} // namespace lldb_private<br>
+<br>
+#endif  // liblldb_AppleObjCTypeEncodingParser_h_<br>
<br>
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp?rev=216026&r1=216025&r2=216026&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp?rev=216026&r1=216025&r2=216026&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp (original)<br>
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp Tue Aug 19 16:46:37 2014<br>
@@ -164,7 +164,8 @@ private:<br>
 AppleObjCTypeVendor::AppleObjCTypeVendor(ObjCLanguageRuntime &runtime) :<br>
     TypeVendor(),<br>
     m_runtime(runtime),<br>
-    m_ast_ctx(runtime.GetProcess()->GetTarget().GetArchitecture().GetTriple().getTriple().c_str())<br>
+    m_ast_ctx(runtime.GetProcess()->GetTarget().GetArchitecture().GetTriple().getTriple().c_str()),<br>
+    m_type_realizer_sp(m_runtime.GetEncodingToType())<br>
 {<br>
     m_external_source = new AppleObjCExternalASTSource (*this);<br>
     llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> external_source_owning_ptr (m_external_source);<br>
@@ -323,7 +324,7 @@ public:<br>
         }<br>
     }<br>
<br>
-    clang::ObjCMethodDecl *BuildMethod (clang::ObjCInterfaceDecl *interface_decl, const char *name, bool instance)<br>
+    clang::ObjCMethodDecl *BuildMethod (clang::ObjCInterfaceDecl *interface_decl, const char *name, bool instance, ObjCLanguageRuntime::EncodingToTypeSP type_realizer_sp)<br>
     {<br>
         if (!m_is_valid || m_type_vector.size() < 3)<br>
             return NULL;<br>
@@ -339,12 +340,14 @@ public:<br>
         const bool isDefined = false;<br>
         const clang::ObjCMethodDecl::ImplementationControl impControl = clang::ObjCMethodDecl::None;<br>
         const bool HasRelatedResultType = false;<br>
+        const bool allow_unknownanytype = true;<br>
<br>
         std::vector <clang::IdentifierInfo *> selector_components;<br>
<br>
         const char *name_cursor = name;<br>
         bool is_zero_argument = true;<br>
<br>
+<br>
         while (*name_cursor != '\0')<br>
         {<br>
             const char *colon_loc = strchr(name_cursor, ':');<br>
@@ -363,7 +366,7 @@ public:<br>
<br>
         clang::Selector sel = ast_ctx.Selectors.getSelector(is_zero_argument ? 0 : selector_components.size(), selector_components.data());<br>
<br>
-        clang::QualType ret_type = BuildType(ast_ctx, m_type_vector[0].c_str());<br>
+        clang::QualType ret_type = type_realizer_sp->RealizeType(interface_decl->getASTContext(), m_type_vector[0].c_str(), allow_unknownanytype).GetQualType();<br>
<br>
         if (ret_type.isNull())<br>
             return NULL;<br>
@@ -389,7 +392,8 @@ public:<br>
              ai != ae;<br>
              ++ai)<br>
         {<br>
-            clang::QualType arg_type = BuildType(ast_ctx, m_type_vector[ai].c_str());<br>
+            const bool allow_unknownanytype = true;<br>
+            clang::QualType arg_type = type_realizer_sp->RealizeType(ast_ctx, m_type_vector[ai].c_str(), allow_unknownanytype).GetQualType();<br>
<br>
             if (arg_type.isNull())<br>
                 return NULL; // well, we just wasted a bunch of time.  Wish we could delete the stuff we'd just made!<br>
@@ -410,81 +414,6 @@ public:<br>
         return ret;<br>
     }<br>
 private:<br>
-    clang::QualType BuildType (clang::ASTContext &ast_ctx, const char *type)<br>
-    {<br>
-        if (!type)<br>
-            return clang::QualType();<br>
-<br>
-        switch (*type)<br>
-        {<br>
-        default:<br>
-            return ast_ctx.UnknownAnyTy;<br>
-        case 'r':<br>
-            {<br>
-                clang::QualType target_type = BuildType(ast_ctx, type+1);<br>
-                if (target_type.isNull())<br>
-                    return clang::QualType();<br>
-                else if (target_type == ast_ctx.UnknownAnyTy)<br>
-                    return ast_ctx.UnknownAnyTy;<br>
-                else<br>
-                    return ast_ctx.getConstType(target_type);<br>
-            }<br>
-        case '^':<br>
-        {<br>
-            clang::QualType target_type = BuildType(ast_ctx, type+1);<br>
-            if (target_type.isNull())<br>
-                return clang::QualType();<br>
-            else if (target_type == ast_ctx.UnknownAnyTy)<br>
-                return ast_ctx.UnknownAnyTy;<br>
-            else<br>
-                return ast_ctx.getPointerType(target_type);<br>
-        }<br>
-        case 'c':<br>
-            return ast_ctx.CharTy;<br>
-        case 'i':<br>
-            return ast_ctx.IntTy;<br>
-        case 's':<br>
-            return ast_ctx.ShortTy;<br>
-        case 'l':<br>
-            if (ast_ctx.getTypeSize(ast_ctx.VoidTy) == 64)<br>
-                return ast_ctx.IntTy;<br>
-            else<br>
-                return ast_ctx.LongTy;<br>
-        case 'q':<br>
-            return ast_ctx.LongLongTy;<br>
-        case 'C':<br>
-            return ast_ctx.UnsignedCharTy;<br>
-        case 'I':<br>
-            return ast_ctx.UnsignedIntTy;<br>
-        case 'S':<br>
-            return ast_ctx.UnsignedShortTy;<br>
-        case 'L':<br>
-            if (ast_ctx.getTypeSize(ast_ctx.VoidTy) == 64)<br>
-                return ast_ctx.UnsignedIntTy;<br>
-            else<br>
-                return ast_ctx.UnsignedLongTy;<br>
-        case 'Q':<br>
-            return ast_ctx.UnsignedLongLongTy;<br>
-        case 'f':<br>
-            return ast_ctx.FloatTy;<br>
-        case 'd':<br>
-            return ast_ctx.DoubleTy;<br>
-        case 'B':<br>
-            return ast_ctx.BoolTy;<br>
-        case 'v':<br>
-            return ast_ctx.VoidTy;<br>
-        case '*':<br>
-            return ast_ctx.getPointerType(ast_ctx.CharTy);<br>
-        case '@':<br>
-            return ast_ctx.getObjCIdType();<br>
-        case '#':<br>
-            return ast_ctx.getObjCClassType();<br>
-        case ':':<br>
-            return ast_ctx.getObjCSelType();<br>
-        }<br>
-        return clang::QualType();<br>
-    }<br>
-<br>
     typedef std::vector <std::string> TypeVector;<br>
<br>
     TypeVector  m_type_vector;<br>
@@ -532,7 +461,7 @@ AppleObjCTypeVendor::FinishDecl(clang::O<br>
<br>
         ObjCRuntimeMethodType method_type(types);<br>
<br>
-        clang::ObjCMethodDecl *method_decl = method_type.BuildMethod (interface_decl, name, true);<br>
+        clang::ObjCMethodDecl *method_decl = method_type.BuildMethod (interface_decl, name, true, m_type_realizer_sp);<br>
<br>
         if (log)<br>
             log->Printf("[  AOTV::FD] Instance method [%s] [%s]", name, types);<br>
@@ -550,7 +479,7 @@ AppleObjCTypeVendor::FinishDecl(clang::O<br>
<br>
         ObjCRuntimeMethodType method_type(types);<br>
<br>
-        clang::ObjCMethodDecl *method_decl = method_type.BuildMethod (interface_decl, name, false);<br>
+        clang::ObjCMethodDecl *method_decl = method_type.BuildMethod (interface_decl, name, false, m_type_realizer_sp);<br>
<br>
         if (log)<br>
             log->Printf("[  AOTV::FD] Class method [%s] [%s]", name, types);<br>
<br>
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.h?rev=216026&r1=216025&r2=216026&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.h?rev=216026&r1=216025&r2=216026&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.h (original)<br>
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.h Tue Aug 19 16:46:37 2014<br>
@@ -51,6 +51,7 @@ private:<br>
<br>
     ObjCLanguageRuntime        &m_runtime;<br>
     ClangASTContext             m_ast_ctx;<br>
+    ObjCLanguageRuntime::EncodingToTypeSP m_type_realizer_sp;<br>
     AppleObjCExternalASTSource *m_external_source;<br>
<br>
     typedef llvm::DenseMap<ObjCLanguageRuntime::ObjCISA, clang::ObjCInterfaceDecl *> ISAToInterfaceMap;<br>
<br>
Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=216026&r1=216025&r2=216026&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=216026&r1=216025&r2=216026&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)<br>
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Aug 19 16:46:37 2014<br>
@@ -79,6 +79,16 @@ using namespace lldb_private;<br>
 using namespace llvm;<br>
 using namespace clang;<br>
<br>
+typedef llvm::DenseMap<clang::ASTContext *, ClangASTContext*> ClangASTMap;<br>
+<br>
+static ClangASTMap &<br>
+GetASTMap()<br>
+{<br>
+    static ClangASTMap g_map;<br>
+    return g_map;<br>
+}<br>
+<br>
+<br>
 clang::AccessSpecifier<br>
 ClangASTContext::ConvertAccessTypeToAccessSpecifier (AccessType access)<br>
 {<br>
@@ -291,6 +301,11 @@ ClangASTContext::ClangASTContext (const<br>
 //----------------------------------------------------------------------<br>
 ClangASTContext::~ClangASTContext()<br>
 {<br>
+    if (m_ast_ap.get())<br>
+    {<br>
+        GetASTMap().erase(m_ast_ap.get());<br>
+    }<br>
+<br>
     m_builtins_ap.reset();<br>
     m_selector_table_ap.reset();<br>
     m_identifier_table_ap.reset();<br>
@@ -393,10 +408,19 @@ ClangASTContext::getASTContext()<br>
         }<br>
<br>
         m_ast_ap->getDiagnostics().setClient(getDiagnosticConsumer(), false);<br>
+<br>
+        GetASTMap().insert(std::make_pair(m_ast_ap.get(), this));<br>
     }<br>
     return m_ast_ap.get();<br>
 }<br>
<br>
+ClangASTContext*<br>
+ClangASTContext::GetASTContext (clang::ASTContext* ast)<br>
+{<br>
+    ClangASTContext *clang_ast = GetASTMap().lookup(ast);<br>
+    return clang_ast;<br>
+}<br>
+<br>
 Builtin::Context *<br>
 ClangASTContext::getBuiltinContext()<br>
 {<br>
<br>
Modified: lldb/trunk/source/Target/ObjCLanguageRuntime.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ObjCLanguageRuntime.cpp?rev=216026&r1=216025&r2=216026&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ObjCLanguageRuntime.cpp?rev=216026&r1=216025&r2=216026&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/source/Target/ObjCLanguageRuntime.cpp (original)<br>
+++ lldb/trunk/source/Target/ObjCLanguageRuntime.cpp Tue Aug 19 16:46:37 2014<br>
@@ -602,4 +602,27 @@ ObjCLanguageRuntime::GetNonKVOClassDescr<br>
 }<br>
<br>
<br>
+ClangASTType<br>
+ObjCLanguageRuntime::EncodingToType::RealizeType (const char* name, bool allow_unknownanytype)<br>
+{<br>
+    if (m_scratch_ast_ctx_ap)<br>
+        return RealizeType(*m_scratch_ast_ctx_ap, name, allow_unknownanytype);<br>
+    return ClangASTType();<br>
+}<br>
+<br>
+ClangASTType<br>
+ObjCLanguageRuntime::EncodingToType::RealizeType (ClangASTContext& ast_ctx, const char* name, bool allow_unknownanytype)<br>
+{<br>
+    clang::ASTContext *clang_ast = ast_ctx.getASTContext();<br>
+    if (!clang_ast)<br>
+        return ClangASTType();<br>
+    return RealizeType(*clang_ast, name, allow_unknownanytype);<br>
+}<br>
<br>
+ObjCLanguageRuntime::EncodingToType::~EncodingToType() {}<br>
+<br>
+ObjCLanguageRuntime::EncodingToTypeSP<br>
+ObjCLanguageRuntime::GetEncodingToType ()<br>
+{<br>
+    return nullptr;<br>
+}<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@cs.uiuc.edu">lldb-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits</a><br>
</blockquote></div><br></div>
</div></blockquote></body></html>