ValueObjectDynamicValue::GetTypeImpl ()
{
const bool success = UpdateValueIfNeeded(false);
- if (success)
+ if (success && m_type_impl.IsValid())
{
return m_type_impl;
}
m_update_point.SetUpdated();
- // if the runtime only vended a ClangASTType, then we have an hollow type that we don't want to use
- // but we save it for the TypeImpl, which can still use an hollow type for some questions
- if (found_dynamic_type && class_type_or_name.HasType() && !class_type_or_name.HasTypeSP())
+ if (found_dynamic_type)
+ {
+ if (class_type_or_name.HasType())
+ {
+ // TypeSP are always generated from debug info
+ if (!class_type_or_name.HasTypeSP() && class_type_or_name.GetClangASTType().IsRuntimeGeneratedType())
+ {
+ m_type_impl = TypeImpl(m_parent->GetClangType(),FixupTypeAndOrName(class_type_or_name, *m_parent).GetClangASTType());
+ class_type_or_name.SetClangASTType(ClangASTType());
+ }
+ else
+ {
+ m_type_impl = TypeImpl(FixupTypeAndOrName(class_type_or_name, *m_parent).GetClangASTType());
+ }
+ }
+ else
+ {
+ m_type_impl.Clear();
+ }
+ }
+ else
{
- m_type_impl = TypeImpl(m_parent->GetClangType(),FixupTypeAndOrName(class_type_or_name, *m_parent).GetClangASTType());
- class_type_or_name.SetClangASTType(ClangASTType());
+ m_type_impl.Clear();
}
// If we don't have a dynamic type, then make ourselves just a echo of our parent.
"""
-Test that we are able to properly report a usable dynamic type for NSImage
+Test that we are able to properly report a usable dynamic type
"""
import os, time
@dsym_test
@skipIfi386
def test_nsimage_dyn_with_dsym(self):
- """Test that we are able to properly report a usable dynamic type for NSImage."""
+ """Test that we are able to properly report a usable dynamic type."""
d = {'EXE': self.exe_name}
self.buildDsym(dictionary=d)
self.setTearDownCleanup(dictionary=d)
@dwarf_test
@skipIfi386
def test_nsimage_dyn_with_dwarf(self):
- """Test that we are able to properly report a usable dynamic type for NSImage."""
+ """Test that we are able to properly report a usable dynamic type."""
d = {'EXE': self.exe_name}
self.buildDwarf(dictionary=d)
self.setTearDownCleanup(dictionary=d)
self.line = line_number(self.main_source, '// Set breakpoint here.')
def nsimage_dyn(self, exe_name):
- """Test that we are able to properly report a usable dynamic type for NSImage."""
+ """Test that we are able to properly report a usable dynamic type."""
exe = os.path.join(os.getcwd(), exe_name)
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
self.assertTrue(image_pointee_type.GetName() == "NSImage", "The dynamic type figures out its pointee type just fine")
self.assertTrue(image_pointee_type.GetDirectBaseClassAtIndex(0).GetName() == "NSObject", "The dynamic type can go back to its base class")
+ v_object = self.frame().FindVariable("object").GetDynamicValue(lldb.eDynamicCanRunTarget)
+ v_base = self.frame().FindVariable("base").GetDynamicValue(lldb.eDynamicCanRunTarget)
+ self.assertTrue(v_object.GetTypeName() == "MyDerivedClass *", "The NSObject is properly type-named")
+ self.assertTrue(v_base.GetTypeName() == "MyDerivedClass *", "The Base is properly type-named")
+ object_type = v_object.GetType()
+ base_type = v_base.GetType()
+ self.assertTrue(object_type.GetName() == "MyDerivedClass *", "The dynamic SBType for NSObject is for the correct type")
+ self.assertTrue(base_type.GetName() == "MyDerivedClass *", "The dynamic SBType for Base is for the correct type")
+ object_pointee_type = object_type.GetPointeeType()
+ base_pointee_type = base_type.GetPointeeType()
+ self.assertTrue(object_pointee_type.GetName() == "MyDerivedClass", "The dynamic type for NSObject figures out its pointee type just fine")
+ self.assertTrue(base_pointee_type.GetName() == "MyDerivedClass", "The dynamic type for Base figures out its pointee type just fine")
+
+ self.assertTrue(object_pointee_type.GetDirectBaseClassAtIndex(0).GetName() == "MyBaseClass", "The dynamic type for NSObject can go back to its base class")
+ self.assertTrue(base_pointee_type.GetDirectBaseClassAtIndex(0).GetName() == "MyBaseClass", "The dynamic type for Base can go back to its base class")
+
+ self.assertTrue(object_pointee_type.GetDirectBaseClassAtIndex(0).GetType().GetDirectBaseClassAtIndex(0).GetName() == "NSObject", "The dynamic type for NSObject can go up the hierarchy")
+ self.assertTrue(base_pointee_type.GetDirectBaseClassAtIndex(0).GetType().GetDirectBaseClassAtIndex(0).GetName() == "NSObject", "The dynamic type for Base can go up the hierarchy")
+
+ self.assertTrue(object_pointee_type.GetNumberOfFields() == 2, "The dynamic type for NSObject has 2 fields")
+ self.assertTrue(base_pointee_type.GetNumberOfFields() == 2, "The dynamic type for Base has 2 fields")
if __name__ == '__main__':
import atexit
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
+@interface MyBaseClass : NSObject
+{}
+-(id) init;
+-(int) getInt;
+@end
+
+@implementation MyBaseClass
+- (id) init {
+ return (self = [super init]);
+}
+
+- (int) getInt {
+ return 1;
+}
+@end
+
+@interface MyDerivedClass : MyBaseClass
+{
+ int x;
+ int y;
+}
+-(id) init;
+-(int) getInt;
+@end
+
+@implementation MyDerivedClass
+- (id) init {
+ self = [super init];
+ if (self) {
+ self-> x = 0;
+ self->y = 1;
+ }
+ return self;
+}
+
+- (int) getInt {
+ y = x++;
+ return x;
+}
+@end
+
+
int main (int argc, char const *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSSize size = {10,10};
NSImage *image = [[NSImage alloc] initWithSize:size];
+
+ NSObject* object = [[MyDerivedClass alloc] init];
+ MyBaseClass* base = [[MyDerivedClass alloc] init];
+
[pool release]; // Set breakpoint here.
return 0;
}