aprantl updated this revision to Diff 199862. aprantl added a comment. Added test for raw pointer values.
CHANGES SINCE LAST ACTION https://reviews.llvm.org/D62015/new/ https://reviews.llvm.org/D62015 Files: lldb/packages/Python/lldbsuite/test/lang/objcxx/cxx-bridged-po/Makefile lldb/packages/Python/lldbsuite/test/lang/objcxx/cxx-bridged-po/TestObjCXXBridgedPO.py lldb/packages/Python/lldbsuite/test/lang/objcxx/cxx-bridged-po/main.mm lldb/source/Core/ValueObject.cpp
Index: lldb/source/Core/ValueObject.cpp =================================================================== --- lldb/source/Core/ValueObject.cpp +++ lldb/source/Core/ValueObject.cpp @@ -1086,44 +1086,46 @@ } const char *ValueObject::GetObjectDescription() { - if (!UpdateValueIfNeeded(true)) - return NULL; + return nullptr; + // Return cached value. if (!m_object_desc_str.empty()) return m_object_desc_str.c_str(); ExecutionContext exe_ctx(GetExecutionContextRef()); Process *process = exe_ctx.GetProcessPtr(); - if (process == NULL) - return NULL; - - StreamString s; - - LanguageType language = GetObjectRuntimeLanguage(); - LanguageRuntime *runtime = process->GetLanguageRuntime(language); + if (!process) + return nullptr; - if (runtime == NULL) { - // Aw, hell, if the things a pointer, or even just an integer, let's try - // ObjC anyway... - CompilerType compiler_type = GetCompilerType(); - if (compiler_type) { - bool is_signed; - if (compiler_type.IsIntegerType(is_signed) || - compiler_type.IsPointerType()) { - runtime = process->GetLanguageRuntime(eLanguageTypeObjC); + // Returns the object description produced by one language runtime. + auto get_object_description = [&](LanguageType language) -> const char * { + if (LanguageRuntime *runtime = process->GetLanguageRuntime(language)) { + StreamString s; + if (runtime->GetObjectDescription(s, *this)) { + m_object_desc_str.append(s.GetString()); + return m_object_desc_str.c_str(); } } + return nullptr; + }; + + // Try the native language runtime first. + LanguageType native_language = GetObjectRuntimeLanguage(); + if (const char *desc = get_object_description(native_language)) + return desc; + + switch (native_language) { + case eLanguageTypeC: + case eLanguageTypeC_plus_plus: + case eLanguageTypeObjC: + case eLanguageTypeObjC_plus_plus: + // Try the Objective-C language runtime. This fallback is necessary + // for Objective-C++ and mixed Objective-C / C++ programs. + return get_object_description(eLanguageTypeObjC); + default: + return nullptr; } - - if (runtime && runtime->GetObjectDescription(s, *this)) { - m_object_desc_str.append(s.GetString()); - } - - if (m_object_desc_str.empty()) - return NULL; - else - return m_object_desc_str.c_str(); } bool ValueObject::GetValueAsCString(const lldb_private::TypeFormatImpl &format, Index: lldb/packages/Python/lldbsuite/test/lang/objcxx/cxx-bridged-po/main.mm =================================================================== --- /dev/null +++ lldb/packages/Python/lldbsuite/test/lang/objcxx/cxx-bridged-po/main.mm @@ -0,0 +1,12 @@ +#include <CoreFoundation/CoreFoundation.h> + +void stop() {} + +int main(int argc, char **argv) +{ + int value = 42; + CFNumberRef num; + num = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &value); + stop(); // break here + return 0; +} Index: lldb/packages/Python/lldbsuite/test/lang/objcxx/cxx-bridged-po/TestObjCXXBridgedPO.py =================================================================== --- /dev/null +++ lldb/packages/Python/lldbsuite/test/lang/objcxx/cxx-bridged-po/TestObjCXXBridgedPO.py @@ -0,0 +1,24 @@ +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbutil as lldbutil + +class TestObjCXXBridgedPO(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + TestBase.setUp(self) + + @skipUnlessDarwin + def test_bridged_type_po(self): + self.build() + lldbutil.run_to_source_breakpoint( + self, 'break here', lldb.SBFileSpec('main.mm')) + self.expect('po num', + "did not get the Objective-C object description", + substrs=['CFNumber', '0x', '42']) + pointer_val = str(self.frame().FindVariable('num').GetValue()) + self.expect('po '+pointer_val, + "did not get the Objective-C object description", + substrs=['CFNumber', '0x', '42']) Index: lldb/packages/Python/lldbsuite/test/lang/objcxx/cxx-bridged-po/Makefile =================================================================== --- /dev/null +++ lldb/packages/Python/lldbsuite/test/lang/objcxx/cxx-bridged-po/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +OBJCXX_SOURCES := main.mm +LDFLAGS = $(CFLAGS) -lobjc -framework CoreFoundation + +include $(LEVEL)/Makefile.rules
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits