diff options
-rw-r--r-- | lldb/include/lldb/Target/ObjCLanguageRuntime.h | 20 | ||||
-rw-r--r-- | lldb/scripts/build-llvm.pl | 5 | ||||
-rw-r--r-- | lldb/source/Expression/ClangExpressionDeclMap.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Expression/ClangExpressionParser.cpp | 13 | ||||
-rw-r--r-- | lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp | 18 | ||||
-rw-r--r-- | lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h | 3 | ||||
-rw-r--r-- | lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp | 11 | ||||
-rw-r--r-- | lldb/source/Target/ObjCLanguageRuntime.cpp | 3 | ||||
-rw-r--r-- | lldb/source/Target/StackFrame.cpp | 22 | ||||
-rw-r--r-- | lldb/test/lang/c/blocks/TestBlocks.py | 2 | ||||
-rw-r--r-- | lldb/test/lang/objc/objc-new-syntax/Makefile | 7 | ||||
-rw-r--r-- | lldb/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py | 124 | ||||
-rw-r--r-- | lldb/test/lang/objc/objc-new-syntax/main.m | 19 |
13 files changed, 232 insertions, 17 deletions
diff --git a/lldb/include/lldb/Target/ObjCLanguageRuntime.h b/lldb/include/lldb/Target/ObjCLanguageRuntime.h index fe120472d1f..ec921525c70 100644 --- a/lldb/include/lldb/Target/ObjCLanguageRuntime.h +++ b/lldb/include/lldb/Target/ObjCLanguageRuntime.h @@ -191,11 +191,30 @@ public: return false; } + bool + HasNewLiteralsAndIndexing () + { + if (m_has_new_literals_and_indexing == eLazyBoolCalculate) + { + if (CalculateHasNewLiteralsAndIndexing()) + m_has_new_literals_and_indexing = eLazyBoolYes; + else + m_has_new_literals_and_indexing = eLazyBoolNo; + } + + return (m_has_new_literals_and_indexing == eLazyBoolYes); + } + protected: //------------------------------------------------------------------ // Classes that inherit from ObjCLanguageRuntime can see and modify these //------------------------------------------------------------------ ObjCLanguageRuntime(Process *process); + + virtual bool CalculateHasNewLiteralsAndIndexing() + { + return false; + } private: // We keep a map of <Class,Selector>->Implementation so we don't have to call the resolver // function over and over. @@ -246,6 +265,7 @@ private: typedef std::map<ClassAndSel,lldb::addr_t> MsgImplMap; MsgImplMap m_impl_cache; + LazyBool m_has_new_literals_and_indexing; protected: typedef std::map<lldb::addr_t,TypeAndOrName> ClassNameMap; typedef ClassNameMap::iterator ClassNameIterator; diff --git a/lldb/scripts/build-llvm.pl b/lldb/scripts/build-llvm.pl index 35d5108d261..4fd457b13be 100644 --- a/lldb/scripts/build-llvm.pl +++ b/lldb/scripts/build-llvm.pl @@ -21,8 +21,8 @@ our ($llvm_clang_basename, $llvm_clang_dirname) = fileparse ($llvm_clang_outfile our $llvm_configuration = $ENV{LLVM_CONFIGURATION}; -our $llvm_revision = "151777"; -our $clang_revision = "151777"; +our $llvm_revision = "152265"; +our $clang_revision = "152265"; our $SRCROOT = "$ENV{SRCROOT}"; our $llvm_dstroot_zip = "$SRCROOT/llvm.zip"; @@ -52,6 +52,7 @@ our @archive_files = ( "$llvm_configuration/lib/libclangAST.a", "$llvm_configuration/lib/libclangBasic.a", "$llvm_configuration/lib/libclangCodeGen.a", + "$llvm_configuration/lib/libclangEdit.a", "$llvm_configuration/lib/libclangFrontend.a", "$llvm_configuration/lib/libclangDriver.a", "$llvm_configuration/lib/libclangIndex.a", diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp index 12b35f99793..1f46ff08385 100644 --- a/lldb/source/Expression/ClangExpressionDeclMap.cpp +++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp @@ -2807,9 +2807,7 @@ ClangExpressionDeclMap::GetVariableValue return NULL; } -#ifdef EXPRESSION_PARSER_SUPPORTS_BLOCKS var_opaque_type = MaybePromoteToBlockPointerType (ast, var_opaque_type); -#endif DWARFExpression &var_location_expr = var->LocationExpression(); diff --git a/lldb/source/Expression/ClangExpressionParser.cpp b/lldb/source/Expression/ClangExpressionParser.cpp index 311914649ca..0df6a67c3a0 100644 --- a/lldb/source/Expression/ClangExpressionParser.cpp +++ b/lldb/source/Expression/ClangExpressionParser.cpp @@ -224,6 +224,10 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope, break; } + m_compiler->getLangOpts().DebuggerSupport = true; // Features specifically for debugger clients + if (expr.DesiredResultType() == ClangExpression::eResultTypeId) + m_compiler->getLangOpts().DebuggerCastResultToId = true; + lldb::ProcessSP process_sp; if (exe_scope) process_sp = exe_scope->CalculateProcess(); @@ -237,6 +241,11 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope, m_compiler->getLangOpts().ObjCNonFragileABI = true; // NOT i386 m_compiler->getLangOpts().ObjCNonFragileABI2 = true; // NOT i386 } + + if (process_sp->GetObjCLanguageRuntime()->HasNewLiteralsAndIndexing()) + { + m_compiler->getLangOpts().DebuggerObjCLiteral = true; + } } } @@ -244,10 +253,6 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope, m_compiler->getLangOpts().AccessControl = false; // Debuggers get universal access m_compiler->getLangOpts().DollarIdents = true; // $ indicates a persistent variable name - m_compiler->getLangOpts().DebuggerSupport = true; // Features specifically for debugger clients - if (expr.DesiredResultType() == ClangExpression::eResultTypeId) - m_compiler->getLangOpts().DebuggerCastResultToId = true; - // Set CodeGen options m_compiler->getCodeGenOpts().EmitDeclMetadata = true; m_compiler->getCodeGenOpts().InstrumentFunctions = false; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index 90fd352c3a0..84042b4b850 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -352,3 +352,21 @@ AppleObjCRuntime::ExceptionBreakpointsExplainStop (lldb::StopInfoSP stop_reason) return false; } + +bool +AppleObjCRuntime::CalculateHasNewLiteralsAndIndexing() +{ + if (!m_process) + return false; + + Target &target(m_process->GetTarget()); + + static ConstString s_method_signature("-[NSDictionary objectForKeyedSubscript:]"); + + SymbolContextList sc_list; + + if (target.GetImages().FindSymbolsWithNameAndType(s_method_signature, eSymbolTypeCode, sc_list)) + return true; + else + return false; +} diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h index bda16e28277..3db7477c031 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h @@ -94,6 +94,9 @@ public: // you can't make an instance of this generic runtime. protected: + virtual bool + CalculateHasNewLiteralsAndIndexing(); + static bool AppleIsModuleObjCLibrary (const lldb::ModuleSP &module_sp); diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index e5e0473f9de..ac03b177c1b 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -2217,6 +2217,17 @@ ObjectFileMachO::GetEntryPointAddress () } } break; + case LoadCommandMain: + { + ConstString text_segment_name ("__TEXT"); + uint64_t entryoffset = m_data.GetU64(&offset); + SectionSP text_segment_sp = GetSectionList()->FindSectionByName(text_segment_name); + if (text_segment_sp) + { + done = true; + start_address = text_segment_sp->GetFileAddress() + entryoffset; + } + } default: break; diff --git a/lldb/source/Target/ObjCLanguageRuntime.cpp b/lldb/source/Target/ObjCLanguageRuntime.cpp index 0076ff04ca7..6d6caefa64f 100644 --- a/lldb/source/Target/ObjCLanguageRuntime.cpp +++ b/lldb/source/Target/ObjCLanguageRuntime.cpp @@ -27,7 +27,8 @@ ObjCLanguageRuntime::~ObjCLanguageRuntime() } ObjCLanguageRuntime::ObjCLanguageRuntime (Process *process) : - LanguageRuntime (process) + LanguageRuntime (process), + m_has_new_literals_and_indexing (eLazyBoolCalculate) { } diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index 1d6cb93b154..4b462ee4ebe 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -724,13 +724,23 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, if (valobj_sp->IsPointerType ()) { - if (no_synth_child == false - && - ClangASTType::GetMinimumLanguage(valobj_sp->GetClangAST(), - valobj_sp->GetClangType()) == eLanguageTypeObjC /* is ObjC pointer */ - && - ClangASTContext::IsPointerType(ClangASTType::GetPointeeType(valobj_sp->GetClangType())) == false /* is not double-ptr */) + bool is_objc_pointer = true; + + if (ClangASTType::GetMinimumLanguage(valobj_sp->GetClangAST(), valobj_sp->GetClangType()) != eLanguageTypeObjC) + is_objc_pointer = false; + else if (!ClangASTContext::IsPointerType(valobj_sp->GetClangType())) + is_objc_pointer = false; + + if (no_synth_child && is_objc_pointer) { + error.SetErrorStringWithFormat("\"(%s) %s\" is an Objective-C pointer, and cannot be subscripted", + valobj_sp->GetTypeName().AsCString("<invalid type>"), + var_expr_path_strm.GetString().c_str()); + + return ValueObjectSP(); + } + else if (is_objc_pointer) + { // dereferencing ObjC variables is not valid.. so let's try and recur to synthetic children ValueObjectSP synthetic = valobj_sp->GetSyntheticValue(eUseSyntheticFilter); if (synthetic.get() == NULL /* no synthetic */ diff --git a/lldb/test/lang/c/blocks/TestBlocks.py b/lldb/test/lang/c/blocks/TestBlocks.py index fbcada47449..32a404589a7 100644 --- a/lldb/test/lang/c/blocks/TestBlocks.py +++ b/lldb/test/lang/c/blocks/TestBlocks.py @@ -48,8 +48,6 @@ class AnonymousTestCase(TestBase): substrs = ['stopped', 'stop reason = breakpoint']) - # <rdar://problem/10413887> - @unittest2.expectedFailure def expr(self): self.common_setup() diff --git a/lldb/test/lang/objc/objc-new-syntax/Makefile b/lldb/test/lang/objc/objc-new-syntax/Makefile new file mode 100644 index 00000000000..ad3cb3fadcd --- /dev/null +++ b/lldb/test/lang/objc/objc-new-syntax/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/objc-new-syntax/TestObjCNewSyntax.py b/lldb/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py new file mode 100644 index 00000000000..8c33a95105c --- /dev/null +++ b/lldb/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py @@ -0,0 +1,124 @@ +"""Test that the Objective-C syntax for dictionary/array literals and indexing works""" + +import os, time +import unittest2 +import lldb +import platform + +from distutils.version import StrictVersion + +from lldbtest import * + +class ObjCNewSyntaxTestCase(TestBase): + + mydir = os.path.join("lang", "objc", "objc-new-syntax") + + def test_expr_with_dsym(self): + self.buildDsym() + self.expr() + + def test_expr_with_dwarf(self): + self.buildDwarf() + self.expr() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break inside main(). + self.line = line_number('main.m', '// Set breakpoint 0 here.') + + def applies(self): + if platform.system() != "Darwin": + return False + if StrictVersion('12.0.0') > platform.release(): + return False + + return True + + def common_setup(self): + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Break inside the foo function which takes a bar_ptr argument. + self.expect("breakpoint set -f main.m -l %d" % self.line, BREAKPOINT_CREATED, + startstr = "Breakpoint created") + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # The breakpoint should have a hit count of 1. + self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, + substrs = [' resolved, hit count = 1']) + + def expr(self): + if not self.applies(): + return + + print "Hello!" + + self.common_setup() + + self.expect("expr -o -- immutable_array[0]", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ["foo"]) + + self.expect("expr -o -- mutable_array[0]", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ["foo"]) + + self.expect("expr -o -- mutable_array[0] = @\"bar\"", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ["bar"]) + + self.expect("expr -o -- mutable_array[0]", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ["bar"]) + + self.expect("expr -o -- immutable_dictionary[@\"key\"]", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ["value"]) + + self.expect("expr -o -- mutable_dictionary[@\"key\"]", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ["value"]) + + self.expect("expr -o -- mutable_dictionary[@\"key\"] = @\"object\"", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ["object"]) + + self.expect("expr -o -- mutable_dictionary[@\"key\"]", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ["object"]) + + self.expect("expr -o -- @[ @\"foo\", @\"bar\" ]", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ["NSArray", "foo", "bar"]) + + self.expect("expr -o -- @{ @\"key\" : @\"object\" }", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ["NSDictionary", "key", "object"]) + + self.expect("expr -o -- @'a'", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ["NSNumber", str(ord('a'))]) + + self.expect("expr -o -- @1", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ["NSNumber", "1"]) + + self.expect("expr -o -- @1l", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ["NSNumber", "1"]) + + self.expect("expr -o -- @1ul", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ["NSNumber", "1"]) + + self.expect("expr -o -- @1ll", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ["NSNumber", "1"]) + + self.expect("expr -o -- @1ull", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ["NSNumber", "1"]) + + #<rdar://problem/10924364> + #self.expect("expr -o -- @123.45", VARIABLES_DISPLAYED_CORRECTLY, + # substrs = ["NSNumber", "123.45"]) + #self.expect("expr -o -- @123.45f", VARIABLES_DISPLAYED_CORRECTLY, + # substrs = ["NSNumber", "123.45"]) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() diff --git a/lldb/test/lang/objc/objc-new-syntax/main.m b/lldb/test/lang/objc/objc-new-syntax/main.m new file mode 100644 index 00000000000..8b4073ee011 --- /dev/null +++ b/lldb/test/lang/objc/objc-new-syntax/main.m @@ -0,0 +1,19 @@ +#import <Foundation/Foundation.h> + +int main() +{ + @autoreleasepool + { + // NSArrays + NSArray *immutable_array = @[ @"foo", @"bar" ]; + NSMutableArray *mutable_array = [NSMutableArray arrayWithCapacity:2]; + [mutable_array addObjectsFromArray:immutable_array]; + + // NSDictionaries + NSDictionary *immutable_dictionary = @{ @"key" : @"value" }; + NSMutableDictionary *mutable_dictionary = [NSMutableDictionary dictionaryWithCapacity:1]; + [mutable_dictionary addEntriesFromDictionary:immutable_dictionary]; + + NSLog(@"Stop here"); // Set breakpoint 0 here. + } +} |