diff --git a/lldb/examples/summaries/cocoa/objc_runtime.py b/lldb/examples/summaries/cocoa/objc_runtime.py index beeec6dd115a..22052d54ae15 100644 --- a/lldb/examples/summaries/cocoa/objc_runtime.py +++ b/lldb/examples/summaries/cocoa/objc_runtime.py @@ -593,6 +593,12 @@ class ObjCRuntime: return 1 return 2 + @staticmethod + def runtime_from_isa(isa): + runtime = ObjCRuntime(isa) + runtime.isa = isa + return runtime + def __init__(self,valobj): self.valobj = valobj self.adjust_for_architecture() diff --git a/lldb/scripts/Python/finish-swig-Python-LLDB.sh b/lldb/scripts/Python/finish-swig-Python-LLDB.sh index b2c194984af6..c3d54691ba54 100755 --- a/lldb/scripts/Python/finish-swig-Python-LLDB.sh +++ b/lldb/scripts/Python/finish-swig-Python-LLDB.sh @@ -452,6 +452,20 @@ else fi fi +if [ -f "${SRC_ROOT}/examples/summaries/cocoa/Class.py" ] +then + if [ $Debug == 1 ] + then + echo "Copying Class.py to ${framework_python_dir}" + fi + cp "${SRC_ROOT}/examples/summaries/cocoa/Class.py" "${framework_python_dir}" +else + if [ $Debug == 1 ] + then + echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/Class.py" + fi +fi + if [ -f "${SRC_ROOT}/examples/summaries/cocoa/cache.py" ] then if [ $Debug == 1 ] diff --git a/lldb/source/Core/FormatManager.cpp b/lldb/source/Core/FormatManager.cpp index 693ae263c96d..a14203fd7a04 100644 --- a/lldb/source/Core/FormatManager.cpp +++ b/lldb/source/Core/FormatManager.cpp @@ -796,6 +796,7 @@ FormatManager::LoadObjCFormatters() AddScriptSummary(objc_category_sp, "Selector.SEL_Summary", ConstString("struct objc_selector"), objc_flags); AddScriptSummary(objc_category_sp, "Selector.SEL_Summary", ConstString("objc_selector"), objc_flags); AddScriptSummary(objc_category_sp, "Selector.SELPointer_Summary", ConstString("objc_selector *"), objc_flags); + AddScriptSummary(objc_category_sp, "Class.Class_Summary", ConstString("Class"), objc_flags); objc_flags.SetSkipPointers(false); TypeCategoryImpl::SharedPointer corefoundation_category_sp = GetCategory(m_corefoundation_category_name); diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index 9c84eab00d2d..42053bbf16c5 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -303,7 +303,7 @@ ScriptInterpreterPython::ScriptInterpreterPython (CommandInterpreter &interprete // WARNING: temporary code that loads Cocoa formatters - this should be done on a per-platform basis rather than loading the whole set // and letting the individual formatter classes exploit APIs to check whether they can/cannot do their task run_string.Clear(); - run_string.Printf ("run_one_line (%s, 'import CFString, CFArray, CFDictionary, NSData, NSMachPort, NSSet, NSNotification, NSException, CFBag, CFBinaryHeap, NSURL, NSBundle, NSNumber, NSDate, NSIndexSet, Selector, CFBitVector')", m_dictionary_name.c_str()); + run_string.Printf ("run_one_line (%s, 'import CFString, CFArray, CFDictionary, NSData, NSMachPort, NSSet, NSNotification, NSException, CFBag, CFBinaryHeap, NSURL, NSBundle, NSNumber, NSDate, NSIndexSet, Selector, Class, CFBitVector')", m_dictionary_name.c_str()); PyRun_SimpleString (run_string.GetData()); int new_count = Debugger::TestDebuggerRefCount(); diff --git a/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py b/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py index 44bbc4aa8c5b..baeff4c3a9ac 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py +++ b/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py @@ -297,6 +297,20 @@ class ObjCDataFormatterTestCase(TestBase): '@"Europe/Paris"']) + self.runCmd('type category list') + self.runCmd('type summary list') + self.expect('frame variable myclass', + substrs = ['(Class) myclass = NSValue']) + self.expect('frame variable myclass2', + substrs = ['(Class) myclass2 = __NSCFConstantString']) + self.expect('frame variable myclass3', + substrs = ['(Class) myclass3 = Molecule']) + self.expect('frame variable myclass4', + substrs = ['(Class) myclass4 = NSMutableArray']) + self.expect('frame variable myclass5', + substrs = ['(Class) myclass5 = ']) + + def expr_objc_data_formatter_commands(self): """Test common cases of expression parser <--> formatters interaction.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) diff --git a/lldb/test/functionalities/data-formatter/data-formatter-objc/main.m b/lldb/test/functionalities/data-formatter/data-formatter-objc/main.m index a19c5d77f001..c6fea2b7ed11 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-objc/main.m +++ b/lldb/test/functionalities/data-formatter/data-formatter-objc/main.m @@ -631,6 +631,12 @@ int main (int argc, const char * argv[]) Molecule *molecule = [Molecule new]; + Class myclass = NSClassFromString(@"NSValue"); + Class myclass2 = [str0 class]; + Class myclass3 = [molecule class]; + Class myclass4 = NSClassFromString(@"NSMutableArray"); + Class myclass5 = [nil class]; + // Set break point at this line. [molecule addObserver:[My_KVO_Observer new] forKeyPath:@"atoms" options:0 context:NULL];