summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Core/ValueObject.h3
-rw-r--r--lldb/include/lldb/Target/Process.h3
-rw-r--r--lldb/source/Core/ValueObject.cpp46
-rw-r--r--lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp4
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp9
-rw-r--r--lldb/source/Target/Process.cpp21
-rw-r--r--lldb/test/lang/objc/rdar-11355592/Makefile7
-rw-r--r--lldb/test/lang/objc/rdar-11355592/TestRdar11355592.py82
-rw-r--r--lldb/test/lang/objc/rdar-11355592/main.m37
9 files changed, 165 insertions, 47 deletions
diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h
index 225d89f4f21..c34fd497b3d 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -600,9 +600,6 @@ public:
IsPointerOrReferenceType ();
virtual bool
- IsPossibleCPlusPlusDynamicType ();
-
- virtual bool
IsPossibleDynamicType ();
virtual bool
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index 4a29bc192a7..2c71f49a180 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -3088,6 +3088,9 @@ public:
GetObjCLanguageRuntime (bool retry_if_null = true);
bool
+ IsPossibleDynamicValue (ValueObject& in_value);
+
+ bool
IsRunning () const;
DynamicCheckerFunctions *GetDynamicCheckers()
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 4d8610fb222..07af307d755 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -1766,15 +1766,14 @@ ValueObject::IsPointerOrReferenceType ()
}
bool
-ValueObject::IsPossibleCPlusPlusDynamicType ()
-{
- return ClangASTContext::IsPossibleCPlusPlusDynamicType (GetClangAST (), GetClangType());
-}
-
-bool
ValueObject::IsPossibleDynamicType ()
{
- return ClangASTContext::IsPossibleDynamicType (GetClangAST (), GetClangType());
+ ExecutionContext exe_ctx (GetExecutionContextRef());
+ Process *process = exe_ctx.GetProcessPtr();
+ if (process)
+ return process->IsPossibleDynamicValue(*this);
+ else
+ return ClangASTContext::IsPossibleDynamicType (GetClangAST (), GetClangType());
}
ValueObjectSP
@@ -2058,37 +2057,8 @@ ValueObject::CalculateDynamicValue (DynamicValueType use_dynamic)
{
ExecutionContext exe_ctx (GetExecutionContextRef());
Process *process = exe_ctx.GetProcessPtr();
- if (process)
- {
- bool worth_having_dynamic_value = false;
-
-
- // FIXME: Process should have some kind of "map over Runtimes" so we don't have to
- // hard code this everywhere.
- LanguageType known_type = GetObjectRuntimeLanguage();
- if (known_type != eLanguageTypeUnknown && known_type != eLanguageTypeC)
- {
- LanguageRuntime *runtime = process->GetLanguageRuntime (known_type);
- if (runtime)
- worth_having_dynamic_value = runtime->CouldHaveDynamicValue(*this);
- }
- else
- {
- LanguageRuntime *cpp_runtime = process->GetLanguageRuntime (eLanguageTypeC_plus_plus);
- if (cpp_runtime)
- worth_having_dynamic_value = cpp_runtime->CouldHaveDynamicValue(*this);
-
- if (!worth_having_dynamic_value)
- {
- LanguageRuntime *objc_runtime = process->GetLanguageRuntime (eLanguageTypeObjC);
- if (objc_runtime)
- worth_having_dynamic_value = objc_runtime->CouldHaveDynamicValue(*this);
- }
- }
-
- if (worth_having_dynamic_value)
- m_dynamic_value = new ValueObjectDynamicValue (*this, use_dynamic);
- }
+ if (process && process->IsPossibleDynamicValue(*this))
+ m_dynamic_value = new ValueObjectDynamicValue (*this, use_dynamic);
}
}
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
index 0c9efcc8d8a..869868546bd 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
@@ -38,7 +38,9 @@ static const char *vtable_demangled_prefix = "vtable for ";
bool
ItaniumABILanguageRuntime::CouldHaveDynamicValue (ValueObject &in_value)
{
- return in_value.IsPossibleCPlusPlusDynamicType();
+ return ClangASTContext::IsPossibleDynamicType(in_value.GetClangAST(), in_value.GetClangType(), NULL,
+ true, // check for C++
+ false); // do not check for ObjC
}
bool
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index 1840a07de2c..a0cd14fe6c6 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -193,11 +193,10 @@ AppleObjCRuntime::GetPrintForDebuggerAddr()
bool
AppleObjCRuntime::CouldHaveDynamicValue (ValueObject &in_value)
{
- lldb::LanguageType known_type = in_value.GetObjectRuntimeLanguage();
- if (known_type == lldb::eLanguageTypeObjC)
- return in_value.IsPossibleDynamicType ();
- else
- return in_value.IsPointerType();
+ return ClangASTContext::IsPossibleDynamicType(in_value.GetClangAST(), in_value.GetClangType(),
+ NULL,
+ false, // do not check C++
+ true); // check ObjC
}
bool
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 5827b3d2604..658204cfbd6 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1573,6 +1573,27 @@ Process::GetObjCLanguageRuntime (bool retry_if_null)
return NULL;
}
+bool
+Process::IsPossibleDynamicValue (ValueObject& in_value)
+{
+ if (in_value.IsDynamic())
+ return false;
+ LanguageType known_type = in_value.GetObjectRuntimeLanguage();
+
+ if (known_type != eLanguageTypeUnknown && known_type != eLanguageTypeC)
+ {
+ LanguageRuntime *runtime = GetLanguageRuntime (known_type);
+ return runtime ? runtime->CouldHaveDynamicValue(in_value) : false;
+ }
+
+ LanguageRuntime *cpp_runtime = GetLanguageRuntime (eLanguageTypeC_plus_plus);
+ if (cpp_runtime && cpp_runtime->CouldHaveDynamicValue(in_value))
+ return true;
+
+ LanguageRuntime *objc_runtime = GetLanguageRuntime (eLanguageTypeObjC);
+ return objc_runtime ? objc_runtime->CouldHaveDynamicValue(in_value) : false;
+}
+
BreakpointSiteList &
Process::GetBreakpointSiteList()
{
diff --git a/lldb/test/lang/objc/rdar-11355592/Makefile b/lldb/test/lang/objc/rdar-11355592/Makefile
new file mode 100644
index 00000000000..ad3cb3fadcd
--- /dev/null
+++ b/lldb/test/lang/objc/rdar-11355592/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../make
+
+OBJC_SOURCES := main.m
+
+include $(LEVEL)/Makefile.rules
+
+LDFLAGS += -framework Foundation
diff --git a/lldb/test/lang/objc/rdar-11355592/TestRdar11355592.py b/lldb/test/lang/objc/rdar-11355592/TestRdar11355592.py
new file mode 100644
index 00000000000..79f0b56767d
--- /dev/null
+++ b/lldb/test/lang/objc/rdar-11355592/TestRdar11355592.py
@@ -0,0 +1,82 @@
+"""
+Test that we do not attempt to make a dynamic type for a 'const char*'
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+
+@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+class Rdar10967107TestCase(TestBase):
+
+ mydir = os.path.join("lang", "objc", "rdar-11355592")
+
+ @dsym_test
+ def test_charstar_dyntype_with_dsym(self):
+ """Test that we do not attempt to make a dynamic type for a 'const char*'"""
+ d = {'EXE': self.exe_name}
+ self.buildDsym(dictionary=d)
+ self.setTearDownCleanup(dictionary=d)
+ self.charstar_dyntype(self.exe_name)
+
+ @dwarf_test
+ def test_charstar_dyntype_with_dwarf(self):
+ """Test that we do not attempt to make a dynamic type for a 'const char*'"""
+ d = {'EXE': self.exe_name}
+ self.buildDwarf(dictionary=d)
+ self.setTearDownCleanup(dictionary=d)
+ self.charstar_dyntype(self.exe_name)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # We'll use the test method name as the exe_name.
+ self.exe_name = self.testMethodName
+ # Find the line number to break inside main().
+ self.main_source = "main.m"
+ self.line = line_number(self.main_source, '// Set breakpoint here.')
+
+ def charstar_dyntype(self, exe_name):
+ """Test that we do not attempt to make a dynamic type for a 'const char*'"""
+ exe = os.path.join(os.getcwd(), exe_name)
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ self.expect("breakpoint set -f %s -l %d" % (self.main_source, self.line),
+ BREAKPOINT_CREATED,
+ startstr = "Breakpoint created: 1: file ='%s', line = %d, locations = 1" %
+ (self.main_source, self.line))
+
+ self.runCmd("run", RUN_SUCCEEDED)
+ # check that we correctly see the const char*, even with dynamic types on
+ self.expect("frame variable my_string", substrs = ['const char *'])
+ self.expect("frame variable my_string -d run-target", substrs = ['const char *'])
+ # check that expr also gets it right
+ self.expect("expr my_string", substrs = ['const char *'])
+ self.expect("expr -d true -- my_string", substrs = ['const char *'])
+ # but check that we get the real Foolie as such
+ self.expect("frame variable my_foolie", substrs = ['FoolMeOnce *'])
+ self.expect("frame variable my_foolie -d run-target", substrs = ['FoolMeOnce *'])
+ # check that expr also gets it right
+ self.expect("expr my_foolie", substrs = ['FoolMeOnce *'])
+ self.expect("expr -d true -- my_foolie", substrs = ['FoolMeOnce *'])
+ # now check that assigning a true string does not break anything
+ self.runCmd("next")
+ # check that we correctly see the const char*, even with dynamic types on
+ self.expect("frame variable my_string", substrs = ['const char *'])
+ self.expect("frame variable my_string -d run-target", substrs = ['const char *'])
+ # check that expr also gets it right
+ self.expect("expr my_string", substrs = ['const char *'])
+ self.expect("expr -d true -- my_string", substrs = ['const char *'])
+ # but check that we get the real Foolie as such
+ self.expect("frame variable my_foolie", substrs = ['FoolMeOnce *'])
+ self.expect("frame variable my_foolie -d run-target", substrs = ['FoolMeOnce *'])
+ # check that expr also gets it right
+ self.expect("expr my_foolie", substrs = ['FoolMeOnce *'])
+ self.expect("expr -d true -- my_foolie", substrs = ['FoolMeOnce *'])
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
diff --git a/lldb/test/lang/objc/rdar-11355592/main.m b/lldb/test/lang/objc/rdar-11355592/main.m
new file mode 100644
index 00000000000..29d1d3ba3b6
--- /dev/null
+++ b/lldb/test/lang/objc/rdar-11355592/main.m
@@ -0,0 +1,37 @@
+#import <Foundation/Foundation.h>
+
+@interface FoolMeOnce : NSObject
+{
+ int32_t value_one; // ivars needed to make 32-bit happy
+ int32_t value_two;
+}
+- (FoolMeOnce *) initWithFirst: (int32_t) first andSecond: (int32_t) second;
+
+@property int32_t value_one;
+@property int32_t value_two;
+
+@end
+
+@implementation FoolMeOnce
+@synthesize value_one;
+@synthesize value_two;
+- (FoolMeOnce *) initWithFirst: (int32_t) first andSecond: (int32_t) second
+{
+ value_one = first;
+ value_two = second;
+ return self;
+}
+@end
+
+int main (int argc, char const *argv[])
+{
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+ FoolMeOnce *my_foolie = [[FoolMeOnce alloc] initWithFirst: 20 andSecond: 55];
+ const char *my_string = (char *) my_foolie;
+// Set breakpoint here.
+ my_string = "Now this is a REAL string...";
+
+ [pool release];
+ return 0;
+}
OpenPOWER on IntegriCloud