summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2020-08-03 14:33:06 +0000
committerpatrick <patrick@openbsd.org>2020-08-03 14:33:06 +0000
commit061da546b983eb767bad15e67af1174fb0bcf31c (patch)
tree83c78b820819d70aa40c36d90447978b300078c5 /gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc
parentImport LLVM 10.0.0 release including clang, lld and lldb. (diff)
downloadwireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.tar.xz
wireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.zip
Import LLVM 10.0.0 release including clang, lld and lldb.
ok hackroom tested by plenty
Diffstat (limited to 'gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc')
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/.categories1
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/TestBitfieldIvars.py12
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/main.m51
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py131
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/ivars-in-blocks.h11
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/ivars-in-blocks.m57
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/main.m10
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Makefile23
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Test/Foo.h9
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Test/Test.h10
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Test/Test.m8
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestConflictingDefinition.py50
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestExt/Foo.h9
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestExt/TestExt.h7
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestExt/TestExt.m8
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/main.m10
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/Makefile8
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py206
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/main.mm62
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/Container.h13
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/Container.m27
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/Makefile8
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/TestForwardDecl.py69
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/main.m14
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/Makefile7
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py57
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py151
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py325
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py40
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethodsNSArray.py36
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethodsNSError.py49
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethodsString.py53
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py75
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py59
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py68
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/const-strings.m24
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/main.m141
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/my-base.h8
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/my-base.m10
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/global_ptrs/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py57
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/global_ptrs/main.m11
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/InternalDefiner.h11
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/InternalDefiner.m31
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/Makefile7
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/TestHiddenIvars.py238
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/main.m54
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/Makefile13
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py48
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/myclass.h6
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/myclass.m16
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/repro.m7
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/Makefile5
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/TestClangModulesAppUpdate.py57
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/foo.m7
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/main.m17
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/module.modulemap4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/umbrella.h1
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/Makefile5
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py48
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/main.m7
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/Makefile2
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/TestClangModulesCache.py35
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/f.h1
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/main.m5
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/module.modulemap3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-hash-mismatch/Makefile16
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-hash-mismatch/TestClangModulesHashMismatch.py45
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-hash-mismatch/main.m6
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-hash-mismatch/other.m4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/Makefile5
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/TestIncompleteModules.py61
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/main.m7
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/minmax.h2
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/module.map9
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/myModule.h5
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/myModule.m8
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/Makefile7
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py38
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/main.m9
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/module.map4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/myModule.c7
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/myModule.h7
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/TestClangModulesUpdate.py65
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/first.m5
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/module.modulemap4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/second.m5
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/umbrella.h1
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules/Makefile6
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py79
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules/main.m12
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc++/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc++/TestObjCXX.py33
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc++/main.mm19
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py64
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/main.m22
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py61
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/main.cpp9
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-checker/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-checker/TestObjCCheckers.py90
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-checker/main.m47
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-class-method/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-class-method/TestObjCClassMethod.py66
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-class-method/class.m24
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/.categories1
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/Makefile5
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py90
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/main.m53
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py207
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/dynamic-value.m147
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-foundation-dictionary-empty/TestNSDictionary0.py7
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-foundation-dictionary-empty/main.m7
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py83
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/main.m15
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.h27
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.m19
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-protocols/TestIvarProtocols.py7
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-protocols/main.m33
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/Makefile13
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py67
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/main.m33
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/Makefile6
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/ObjCNewSyntaxTest.py29
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntaxArray.py58
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntaxDictionary.py57
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntaxLiteral.py78
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/main.m21
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-optimized/Makefile6
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py72
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-optimized/main.m44
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py135
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m113
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/TestRuntimeIvars.py8
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/main.m10
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/Makefile14
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py77
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/static.m29
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method/TestObjCStaticMethod.py72
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method/static.m29
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py220
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/stepping-tests.m138
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py66
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/test.m40
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/TestObjCStructReturn.py59
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/test.m23
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-super/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-super/TestObjCSuper.py64
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-super/class.m39
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/TestObjCDirectMethods.py5
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/main.m92
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/orderedset/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/orderedset/TestOrderedSet.py18
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/orderedset/main.m8
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/print-obj/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/print-obj/TestPrintObj.py91
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/print-obj/blocked.m72
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ptr_refs/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ptr_refs/TestPtrRefsObjC.py47
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ptr_refs/main.m38
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/radar-9691614/Makefile6
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py45
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/radar-9691614/main.m67
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/Makefile6
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/TestRdar10967107.py70
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/main.m13
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/Makefile6
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/TestRdar11355592.py79
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/main.m37
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/Makefile9
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py69
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/main.m24
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Bar.h12
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Bar.m43
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Foo.h11
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Foo.m25
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/TestRealDefinition.py98
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/main.m13
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/sample/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/sample/main.m70
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py39
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/main.m53
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/Makefile6
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py74
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/main.m7
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py6
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m5
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/variadic_methods/TestVariadicMethods.py7
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/variadic_methods/main.m30
203 files changed, 7180 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/.categories b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/.categories
new file mode 100644
index 00000000000..72cf07c1efe
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/.categories
@@ -0,0 +1 @@
+objc
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/TestBitfieldIvars.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/TestBitfieldIvars.py
new file mode 100644
index 00000000000..c0d006ee53a
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/TestBitfieldIvars.py
@@ -0,0 +1,12 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(
+ __file__,
+ globals(),
+ [
+ # This is a Darwin-only failure related to incorrect expression-
+ # evaluation for single-bit ObjC bitfields.
+ decorators.skipUnlessDarwin,
+ decorators.expectedFailureAll(
+ bugnumber="rdar://problem/17990991")])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/main.m
new file mode 100644
index 00000000000..e19f291ecf9
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/main.m
@@ -0,0 +1,51 @@
+//===-- main.m -------------------------------------------*- Objective-C-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#import <Foundation/Foundation.h>
+
+@interface HasBitfield : NSObject {
+@public
+ unsigned field1 : 1;
+ unsigned field2 : 1;
+};
+
+-(id)init;
+@end
+
+@implementation HasBitfield
+-(id)init {
+ self = [super init];
+ field1 = 0;
+ field2 = 1;
+ return self;
+}
+@end
+
+@interface ContainsAHasBitfield : NSObject {
+@public
+ HasBitfield *hb;
+};
+-(id)init;
+@end
+
+@implementation ContainsAHasBitfield
+-(id)init {
+ self = [super init];
+ hb = [[HasBitfield alloc] init];
+ return self;
+}
+
+@end
+
+int main(int argc, const char * argv[]) {
+ ContainsAHasBitfield *chb = [[ContainsAHasBitfield alloc] init];
+ printf("%d\n", chb->hb->field2); //% self.expect("expression -- chb->hb->field1", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["= 0"])
+ //% self.expect("expression -- chb->hb->field2", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["= 1"]) # this must happen second
+ return 0;
+}
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/Makefile
new file mode 100644
index 00000000000..df76ed3069f
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := ivars-in-blocks.m main.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py
new file mode 100644
index 00000000000..e790e6e9d96
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py
@@ -0,0 +1,131 @@
+"""Test printing ivars and ObjC objects captured in blocks that are made in methods of an ObjC class."""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestObjCIvarsInBlocks(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers to break inside main().
+ self.main_source = "main.m"
+ self.class_source = "ivars-in-blocks.m"
+ self.class_source_file_spec = lldb.SBFileSpec(self.class_source)
+
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ @skipIf(dwarf_version=['<', '4'])
+ @expectedFailureAll(
+ archs=["i[3-6]86"],
+ bugnumber="This test requires the 2.0 runtime, so it will fail on i386")
+ def test_with_python_api(self):
+ """Test printing the ivars of the self when captured in blocks"""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ breakpoint = target.BreakpointCreateBySourceRegex(
+ '// Break here inside the block.', self.class_source_file_spec)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
+
+ breakpoint_two = target.BreakpointCreateBySourceRegex(
+ '// Break here inside the class method block.', self.class_source_file_spec)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
+
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertTrue(process, "Created a process.")
+ self.assertTrue(
+ process.GetState() == lldb.eStateStopped,
+ "Stopped it too.")
+
+ thread_list = lldbutil.get_threads_stopped_at_breakpoint(
+ process, breakpoint)
+ self.assertTrue(len(thread_list) == 1)
+ thread = thread_list[0]
+
+ frame = thread.GetFrameAtIndex(0)
+ self.assertTrue(frame, "frame 0 is valid")
+
+ # First use the FindVariable API to see if we can find the ivar by
+ # undecorated name:
+ direct_blocky = frame.GetValueForVariablePath("blocky_ivar")
+ self.assertTrue(direct_blocky, "Found direct access to blocky_ivar.")
+
+ # Now get it as a member of "self" and make sure the two values are
+ # equal:
+ self_var = frame.GetValueForVariablePath("self")
+ self.assertTrue(self_var, "Found self in block.")
+ indirect_blocky = self_var.GetChildMemberWithName("blocky_ivar")
+ self.assertTrue(indirect_blocky, "Found blocky_ivar through self")
+
+ error = lldb.SBError()
+ direct_value = direct_blocky.GetValueAsSigned(error)
+ self.assertTrue(error.Success(), "Got direct value for blocky_ivar")
+
+ indirect_value = indirect_blocky.GetValueAsSigned(error)
+ self.assertTrue(error.Success(), "Got indirect value for blocky_ivar")
+
+ self.assertTrue(
+ direct_value == indirect_value,
+ "Direct and indirect values are equal.")
+
+ # Now make sure that we can get at the captured ivar through the expression parser.
+ # Doing a little trivial math will force this into the real expression
+ # parser:
+ direct_expr = frame.EvaluateExpression("blocky_ivar + 10")
+ self.assertTrue(
+ direct_expr,
+ "Got blocky_ivar through the expression parser")
+
+ # Again, get the value through self directly and make sure they are the
+ # same:
+ indirect_expr = frame.EvaluateExpression("self->blocky_ivar + 10")
+ self.assertTrue(
+ indirect_expr,
+ "Got blocky ivar through expression parser using self.")
+
+ direct_value = direct_expr.GetValueAsSigned(error)
+ self.assertTrue(
+ error.Success(),
+ "Got value from direct use of expression parser")
+
+ indirect_value = indirect_expr.GetValueAsSigned(error)
+ self.assertTrue(
+ error.Success(),
+ "Got value from indirect access using the expression parser")
+
+ self.assertTrue(
+ direct_value == indirect_value,
+ "Direct ivar access and indirect through expression parser produce same value.")
+
+ process.Continue()
+ self.assertTrue(
+ process.GetState() == lldb.eStateStopped,
+ "Stopped at the second breakpoint.")
+
+ thread_list = lldbutil.get_threads_stopped_at_breakpoint(
+ process, breakpoint_two)
+ self.assertTrue(len(thread_list) == 1)
+ thread = thread_list[0]
+
+ frame = thread.GetFrameAtIndex(0)
+ self.assertTrue(frame, "frame 0 is valid")
+
+ expr = frame.EvaluateExpression("(ret)")
+ self.assertTrue(
+ expr, "Successfully got a local variable in a block in a class method.")
+
+ ret_value_signed = expr.GetValueAsSigned(error)
+ # print('ret_value_signed = %i' % (ret_value_signed))
+ self.assertTrue(
+ ret_value_signed == 5,
+ "The local variable in the block was what we expected.")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/ivars-in-blocks.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/ivars-in-blocks.h
new file mode 100644
index 00000000000..1ceac3361ac
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/ivars-in-blocks.h
@@ -0,0 +1,11 @@
+#import <Foundation/Foundation.h>
+
+@interface IAmBlocky : NSObject
+{
+ @public
+ int blocky_ivar;
+}
++ (void) classMethod;
+- (IAmBlocky *) init;
+- (int) callABlock: (int) block_value;
+@end
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/ivars-in-blocks.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/ivars-in-blocks.m
new file mode 100644
index 00000000000..1098a9136ae
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/ivars-in-blocks.m
@@ -0,0 +1,57 @@
+#import "ivars-in-blocks.h"
+
+typedef int (^my_block_ptr_type) (int);
+
+@interface IAmBlocky()
+{
+ int _hidden_ivar;
+ my_block_ptr_type _block_ptr;
+}
+
+@end
+
+@implementation IAmBlocky
+
++ (int) addend
+{
+ return 3;
+}
+
++ (void) classMethod
+{
+ int (^my_block)(int) = ^(int foo)
+ {
+ int ret = foo + [self addend];
+ return ret; // Break here inside the class method block.
+ };
+ printf("%d\n", my_block(2));
+}
+
+- (void) makeBlockPtr;
+{
+ _block_ptr = ^(int inval)
+ {
+ _hidden_ivar += inval;
+ return blocky_ivar * inval; // Break here inside the block.
+ };
+}
+
+- (IAmBlocky *) init
+{
+ blocky_ivar = 10;
+ _hidden_ivar = 20;
+ // Interesting... Apparently you can't make a block in your init method. This crashes...
+ // [self makeBlockPtr];
+ return self;
+}
+
+- (int) callABlock: (int) block_value
+{
+ if (_block_ptr == NULL)
+ [self makeBlockPtr];
+ int ret = _block_ptr (block_value);
+ [IAmBlocky classMethod];
+ return ret;
+}
+@end
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/main.m
new file mode 100644
index 00000000000..0c56f45da46
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/main.m
@@ -0,0 +1,10 @@
+#import "ivars-in-blocks.h"
+
+int
+main (int argc, char **argv)
+{
+ IAmBlocky *my_blocky = [[IAmBlocky alloc] init];
+ int blocky_value;
+ blocky_value = [my_blocky callABlock: 33];
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Makefile
new file mode 100644
index 00000000000..00a0769a086
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Makefile
@@ -0,0 +1,23 @@
+LD_EXTRAS := -lobjc -framework Foundation -L. -lTest -lTestExt
+OBJC_SOURCES := main.m
+
+all: a.out
+
+a.out: libTest.dylib libTestExt.dylib
+
+include Makefile.rules
+
+libTest.dylib: Test/Test.m
+ mkdir -p Test
+ $(MAKE) MAKE_DSYM=YES -f $(MAKEFILE_RULES) \
+ DYLIB_ONLY=YES DYLIB_NAME=Test DYLIB_OBJC_SOURCES=Test/Test.m \
+ LD_EXTRAS="-lobjc -framework Foundation" \
+ CFLAGS_EXTRAS=-I$(SRCDIR)
+
+libTestExt.dylib: TestExt/TestExt.m
+ mkdir -p TestExt
+ $(MAKE) MAKE_DSYM=YES -f $(MAKEFILE_RULES) \
+ DYLIB_ONLY=YES DYLIB_NAME=TestExt DYLIB_OBJC_SOURCES=TestExt/TestExt.m \
+ LD_EXTRAS="-lobjc -framework Foundation -lTest -L." \
+ CFLAGS_EXTRAS=-I$(SRCDIR)
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Test/Foo.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Test/Foo.h
new file mode 100644
index 00000000000..db07f50d5d6
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Test/Foo.h
@@ -0,0 +1,9 @@
+#ifndef __Foo_h__
+#define __Foo_h__
+
+typedef struct {
+ float start;
+ float duration;
+} CMTimeRange;
+
+#endif
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Test/Test.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Test/Test.h
new file mode 100644
index 00000000000..73928c5fb0d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Test/Test.h
@@ -0,0 +1,10 @@
+#import <Foundation/Foundation.h>
+#import <Test/Foo.h>
+
+@interface Test : NSObject {
+@public
+ CMTimeRange _range;
+}
+- (void) doTest;
+@end
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Test/Test.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Test/Test.m
new file mode 100644
index 00000000000..6b2cb3af808
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Test/Test.m
@@ -0,0 +1,8 @@
+#import "Test.h"
+
+@implementation Test
+- (void) doTest {
+ NSLog(@"-[Test doTest]");
+}
+@end
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestConflictingDefinition.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestConflictingDefinition.py
new file mode 100644
index 00000000000..f49858ca4f3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestConflictingDefinition.py
@@ -0,0 +1,50 @@
+"""Test that types defined in shared libraries work correctly."""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestRealDefinition(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ def test_frame_var_after_stop_at_implementation(self):
+ """Test that we can find the implementation for an objective C type"""
+ if self.getArchitecture() == 'i386':
+ self.skipTest("requires modern objc runtime")
+ self.build()
+ self.shlib_names = ["libTestExt.dylib", "libTest.dylib"]
+ self.common_setup()
+
+ line = line_number('TestExt/TestExt.m', '// break here')
+ lldbutil.run_break_set_by_file_and_line(
+ self, 'TestExt.m', line, num_expected_locations=1, loc_exact=True)
+
+ 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'])
+
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ # This should display correctly.
+ self.expect(
+ "expr 42",
+ "A simple expression should execute correctly",
+ substrs=[
+ "42"])
+
+ def common_setup(self):
+ exe = self.getBuildArtifact("a.out")
+ target = self.dbg.CreateTarget(exe)
+ self.registerSharedLibrariesWithTarget(target, self.shlib_names)
+
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestExt/Foo.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestExt/Foo.h
new file mode 100644
index 00000000000..7c90e6ca8e3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestExt/Foo.h
@@ -0,0 +1,9 @@
+#ifndef __Foo_h__
+#define __Foo_h__
+
+typedef struct {
+ float s;
+ float d;
+} CMTimeRange;
+
+#endif
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestExt/TestExt.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestExt/TestExt.h
new file mode 100644
index 00000000000..243443c647b
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestExt/TestExt.h
@@ -0,0 +1,7 @@
+#import <TestExt/Foo.h>
+#import <Test/Test.h>
+struct CMTimeRange;
+
+@interface Test (Stuff)
+- (void)doSomethingElse: (CMTimeRange *)range_ptr;
+@end
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestExt/TestExt.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestExt/TestExt.m
new file mode 100644
index 00000000000..a14c702787d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestExt/TestExt.m
@@ -0,0 +1,8 @@
+#import "TestExt.h"
+#import "Foo.h"
+
+@implementation Test (Stuff)
+- (void)doSomethingElse: (CMTimeRange *)range_ptr {
+ NSLog(@"doSomethingElse: %p", range_ptr); // break here
+}
+@end
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/main.m
new file mode 100644
index 00000000000..6a714577a35
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/main.m
@@ -0,0 +1,10 @@
+#import <Test/Test.h>
+#import <TestExt/TestExt.h>
+
+int main() {
+ @autoreleasepool {
+ Test *test = [[Test alloc] init];
+ [test doSomethingElse:&test->_range];
+ }
+}
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/Makefile
new file mode 100644
index 00000000000..876340159d9
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/Makefile
@@ -0,0 +1,8 @@
+OBJCXX_SOURCES := main.mm
+
+CFLAGS_EXTRAS := -w
+
+
+
+LD_EXTRAS := -framework Foundation
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
new file mode 100644
index 00000000000..ce9ee8e027f
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
@@ -0,0 +1,206 @@
+# encoding: utf-8
+"""
+Test lldb Obj-C exception support.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ObjCExceptionsTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ def test_objc_exceptions_at_throw(self):
+ self.build()
+
+ target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+ self.assertTrue(target, VALID_TARGET)
+
+ launch_info = lldb.SBLaunchInfo(["a.out", "0"])
+ lldbutil.run_to_name_breakpoint(self, "objc_exception_throw", launch_info=launch_info)
+
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped', 'stop reason = breakpoint'])
+
+ self.expect('thread exception', substrs=[
+ '(NSException *) exception = ',
+ '"SomeReason"',
+ ])
+
+ target = self.dbg.GetSelectedTarget()
+ thread = target.GetProcess().GetSelectedThread()
+ frame = thread.GetSelectedFrame()
+
+ opts = lldb.SBVariablesOptions()
+ opts.SetIncludeRecognizedArguments(True)
+ variables = frame.GetVariables(opts)
+
+ self.assertEqual(variables.GetSize(), 1)
+ self.assertEqual(variables.GetValueAtIndex(0).name, "exception")
+ self.assertEqual(variables.GetValueAtIndex(0).GetValueType(), lldb.eValueTypeVariableArgument)
+
+ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.mm"), launch_info=launch_info)
+
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped', 'stop reason = breakpoint'])
+
+ target = self.dbg.GetSelectedTarget()
+ thread = target.GetProcess().GetSelectedThread()
+ frame = thread.GetSelectedFrame()
+
+ # No exception being currently thrown/caught at this point
+ self.assertFalse(thread.GetCurrentException().IsValid())
+ self.assertFalse(thread.GetCurrentExceptionBacktrace().IsValid())
+
+ self.expect(
+ 'frame variable e1',
+ substrs=[
+ '(NSException *) e1 = ',
+ '"SomeReason"'
+ ])
+
+ self.expect(
+ 'frame variable --dynamic-type no-run-target *e1',
+ substrs=[
+ '(NSException) *e1 = ',
+ 'name = ', '"ExceptionName"',
+ 'reason = ', '"SomeReason"',
+ 'userInfo = ', '1 key/value pair',
+ 'reserved = ', 'nil',
+ ])
+
+ e1 = frame.FindVariable("e1")
+ self.assertTrue(e1)
+ self.assertEqual(e1.type.name, "NSException *")
+ self.assertEqual(e1.GetSummary(), '"SomeReason"')
+ self.assertEqual(e1.GetChildMemberWithName("name").description, "ExceptionName")
+ self.assertEqual(e1.GetChildMemberWithName("reason").description, "SomeReason")
+ userInfo = e1.GetChildMemberWithName("userInfo").dynamic
+ self.assertEqual(userInfo.summary, "1 key/value pair")
+ self.assertEqual(userInfo.GetChildAtIndex(0).GetChildAtIndex(0).description, "some_key")
+ self.assertEqual(userInfo.GetChildAtIndex(0).GetChildAtIndex(1).description, "some_value")
+ self.assertEqual(e1.GetChildMemberWithName("reserved").description, "<nil>")
+
+ self.expect(
+ 'frame variable e2',
+ substrs=[
+ '(NSException *) e2 = ',
+ '"SomeReason"'
+ ])
+
+ self.expect(
+ 'frame variable --dynamic-type no-run-target *e2',
+ substrs=[
+ '(NSException) *e2 = ',
+ 'name = ', '"ThrownException"',
+ 'reason = ', '"SomeReason"',
+ 'userInfo = ', '1 key/value pair',
+ 'reserved = ',
+ ])
+
+ e2 = frame.FindVariable("e2")
+ self.assertTrue(e2)
+ self.assertEqual(e2.type.name, "NSException *")
+ self.assertEqual(e2.GetSummary(), '"SomeReason"')
+ self.assertEqual(e2.GetChildMemberWithName("name").description, "ThrownException")
+ self.assertEqual(e2.GetChildMemberWithName("reason").description, "SomeReason")
+ userInfo = e2.GetChildMemberWithName("userInfo").dynamic
+ self.assertEqual(userInfo.summary, "1 key/value pair")
+ self.assertEqual(userInfo.GetChildAtIndex(0).GetChildAtIndex(0).description, "some_key")
+ self.assertEqual(userInfo.GetChildAtIndex(0).GetChildAtIndex(1).description, "some_value")
+ reserved = e2.GetChildMemberWithName("reserved").dynamic
+ self.assertGreater(reserved.num_children, 0)
+ callStackReturnAddresses = [reserved.GetChildAtIndex(i).GetChildAtIndex(1) for i in range(0, reserved.GetNumChildren())
+ if reserved.GetChildAtIndex(i).GetChildAtIndex(0).description == "callStackReturnAddresses"][0].dynamic
+ children = [callStackReturnAddresses.GetChildAtIndex(i) for i in range(0, callStackReturnAddresses.num_children)]
+
+ pcs = [i.unsigned for i in children]
+ names = [target.ResolveSymbolContextForAddress(lldb.SBAddress(pc, target), lldb.eSymbolContextSymbol).GetSymbol().name for pc in pcs]
+ for n in ["objc_exception_throw", "foo(int)", "main"]:
+ self.assertTrue(n in names, "%s is in the exception backtrace (%s)" % (n, names))
+
+ @skipUnlessDarwin
+ def test_objc_exceptions_at_abort(self):
+ self.build()
+
+ target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+ self.assertTrue(target, VALID_TARGET)
+
+ self.runCmd("run 0")
+
+ # We should be stopped at pthread_kill because of an unhandled exception
+ self.expect("thread list",
+ substrs=['stopped', 'stop reason = signal SIGABRT'])
+
+ self.expect('thread exception', substrs=[
+ '(NSException *) exception = ',
+ '"SomeReason"',
+ 'libobjc.A.dylib`objc_exception_throw',
+ 'a.out`foo', 'at main.mm:24',
+ 'a.out`rethrow', 'at main.mm:35',
+ 'a.out`main',
+ ])
+
+ process = self.dbg.GetSelectedTarget().process
+ thread = process.GetSelectedThread()
+
+ # There is an exception being currently processed at this point
+ self.assertTrue(thread.GetCurrentException().IsValid())
+ self.assertTrue(thread.GetCurrentExceptionBacktrace().IsValid())
+
+ history_thread = thread.GetCurrentExceptionBacktrace()
+ self.assertGreaterEqual(history_thread.num_frames, 4)
+ for n in ["objc_exception_throw", "foo(int)", "rethrow(int)", "main"]:
+ self.assertEqual(len([f for f in history_thread.frames if f.GetFunctionName() == n]), 1)
+
+ self.runCmd("kill")
+
+ self.runCmd("run 1")
+ # We should be stopped at pthread_kill because of an unhandled exception
+ self.expect("thread list",
+ substrs=['stopped', 'stop reason = signal SIGABRT'])
+
+ self.expect('thread exception', substrs=[
+ '(MyCustomException *) exception = ',
+ 'libobjc.A.dylib`objc_exception_throw',
+ 'a.out`foo', 'at main.mm:26',
+ 'a.out`rethrow', 'at main.mm:35',
+ 'a.out`main',
+ ])
+
+ process = self.dbg.GetSelectedTarget().process
+ thread = process.GetSelectedThread()
+
+ history_thread = thread.GetCurrentExceptionBacktrace()
+ self.assertGreaterEqual(history_thread.num_frames, 4)
+ for n in ["objc_exception_throw", "foo(int)", "rethrow(int)", "main"]:
+ self.assertEqual(len([f for f in history_thread.frames if f.GetFunctionName() == n]), 1)
+
+ @skipUnlessDarwin
+ def test_cxx_exceptions_at_abort(self):
+ self.build()
+
+ target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+ self.assertTrue(target, VALID_TARGET)
+
+ self.runCmd("run 2")
+
+ # We should be stopped at pthread_kill because of an unhandled exception
+ self.expect("thread list",
+ substrs=['stopped', 'stop reason = signal SIGABRT'])
+
+ self.expect('thread exception', substrs=['exception ='])
+
+ process = self.dbg.GetSelectedTarget().process
+ thread = process.GetSelectedThread()
+
+ self.assertTrue(thread.GetCurrentException().IsValid())
+
+ # C++ exception backtraces are not exposed in the API (yet).
+ self.assertFalse(thread.GetCurrentExceptionBacktrace().IsValid())
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/main.mm b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/main.mm
new file mode 100644
index 00000000000..b5c71f9fcf9
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/main.mm
@@ -0,0 +1,62 @@
+//===-- main.m ------------------------------------------------*- ObjC -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#import <Foundation/Foundation.h>
+
+#import <exception>
+#import <stdexcept>
+
+@interface MyCustomException: NSException
+@end
+@implementation MyCustomException
+@end
+
+void foo(int n)
+{
+ NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:@"some_value", @"some_key", nil];
+ switch (n) {
+ case 0:
+ @throw [[NSException alloc] initWithName:@"ThrownException" reason:@"SomeReason" userInfo:info];
+ case 1:
+ @throw [[MyCustomException alloc] initWithName:@"ThrownException" reason:@"SomeReason" userInfo:info];
+ case 2:
+ throw std::runtime_error("C++ exception");
+ }
+}
+
+void rethrow(int n)
+{
+ @try {
+ foo(n);
+ } @catch(NSException *e) {
+ @throw;
+ }
+}
+
+int main(int argc, const char * argv[])
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:@"some_value", @"some_key", nil];
+ NSException *e1 = [[NSException alloc] initWithName:@"ExceptionName" reason:@"SomeReason" userInfo:info];
+ NSException *e2;
+
+ @try {
+ foo(atoi(argv[1]));
+ } @catch(NSException *e) {
+ e2 = e;
+ }
+
+ NSLog(@"1"); // Set break point at this line.
+
+ rethrow(atoi(argv[1]));
+
+ [pool drain];
+ return 0;
+}
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/Container.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/Container.h
new file mode 100644
index 00000000000..85bbd06b161
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/Container.h
@@ -0,0 +1,13 @@
+#import <Foundation/Foundation.h>
+
+@class ForwardDeclaredClass;
+
+@interface Container : NSObject {
+@public
+ ForwardDeclaredClass *member;
+}
+
+-(id)init;
+-(ForwardDeclaredClass*)getMember;
+
+@end
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/Container.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/Container.m
new file mode 100644
index 00000000000..4d2139ff5fc
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/Container.m
@@ -0,0 +1,27 @@
+#import "Container.h"
+
+@interface ForwardDeclaredClass : NSObject
+{
+ int a;
+ int b;
+}
+@end
+
+@implementation ForwardDeclaredClass
+
+@end
+
+@implementation Container
+
+-(id)init
+{
+ member = [ForwardDeclaredClass alloc];
+ return [super init];
+}
+
+-(ForwardDeclaredClass *)getMember
+{
+ return member;
+}
+
+@end
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/Makefile
new file mode 100644
index 00000000000..cfae251ead4
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/Makefile
@@ -0,0 +1,8 @@
+DYLIB_NAME := Container
+DYLIB_OBJC_SOURCES := Container.m
+OBJC_SOURCES := main.m
+
+
+
+LD_EXTRAS := -framework Foundation
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/TestForwardDecl.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/TestForwardDecl.py
new file mode 100644
index 00000000000..fd35d64c191
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/TestForwardDecl.py
@@ -0,0 +1,69 @@
+"""Test that a forward-declared class works when its complete definition is in a library"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ForwardDeclTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.source = 'main.m'
+ self.line = line_number(self.source, '// Set breakpoint 0 here.')
+ self.shlib_names = ["Container"]
+
+ def do_test(self, dictionary=None):
+ self.build(dictionary=dictionary)
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+ self.assertTrue(target, VALID_TARGET)
+
+ # Create the breakpoint inside function 'main'.
+ breakpoint = target.BreakpointCreateByLocation(self.source, self.line)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
+
+ # Register our shared libraries for remote targets so they get
+ # automatically uploaded
+ environment = self.registerSharedLibrariesWithTarget(
+ target, self.shlib_names)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, environment, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # 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'])
+
+ # This should display correctly.
+ self.expect("expression [j getMember]", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["= 0x"])
+
+ @skipUnlessDarwin
+ def test_expr(self):
+ self.do_test()
+
+ @no_debug_info_test
+ @skipUnlessDarwin
+ @skipIf(compiler=no_match("clang"))
+ @skipIf(compiler_version=["<", "7.0"])
+ def test_debug_names(self):
+ """Test that we are able to find complete types when using DWARF v5
+ accelerator tables"""
+ self.do_test(
+ dict(CFLAGS_EXTRAS="-dwarf-version=5 -mllvm -accel-tables=Dwarf"))
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/main.m
new file mode 100644
index 00000000000..8e5256e9523
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/main.m
@@ -0,0 +1,14 @@
+#import <Foundation/Foundation.h>
+#import "Container.h"
+
+int main(int argc, const char * argv[])
+{
+
+ @autoreleasepool {
+ Container *j = [[Container alloc] init];
+
+ printf("member value = %p", [j getMember]); // Set breakpoint 0 here.
+ }
+ return 0;
+}
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/Makefile
new file mode 100644
index 00000000000..e95ebd94a94
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/Makefile
@@ -0,0 +1,7 @@
+OBJC_SOURCES := main.m my-base.m
+#OBJC_SOURCES := const-strings.m
+
+
+
+LD_EXTRAS := -framework Foundation
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py
new file mode 100644
index 00000000000..6e8e9898e19
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py
@@ -0,0 +1,57 @@
+"""
+Test that objective-c constant strings are generated correctly by the expression
+parser.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ConstStringTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ d = {'OBJC_SOURCES': 'const-strings.m'}
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.main_source = "const-strings.m"
+ self.line = line_number(self.main_source, '// Set breakpoint here.')
+
+ @skipUnlessDarwin
+ def test_break(self):
+ """Test constant string generation amd comparison by the expression parser."""
+ self.build(dictionary=self.d)
+ self.setTearDownCleanup(self.d)
+
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ self.main_source,
+ self.line,
+ num_expected_locations=1,
+ loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+ self.expect("process status", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=[" at %s:%d" % (self.main_source, self.line),
+ "stop reason = breakpoint"])
+
+ self.expect('expression (int)[str compare:@"hello"]',
+ startstr="(int) $0 = 0")
+ self.expect('expression (int)[str compare:@"world"]',
+ startstr="(int) $1 = -1")
+
+ # Test empty strings, too.
+ self.expect('expression (int)[@"" length]',
+ startstr="(int) $2 = 0")
+
+ self.expect('expression (int)[@"123" length]',
+ startstr="(int) $3 = 3")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py
new file mode 100644
index 00000000000..9e39a735f8b
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py
@@ -0,0 +1,151 @@
+"""
+Test the lldb disassemble command on foundation framework.
+"""
+
+import unittest2
+import os
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipUnlessDarwin
+class FoundationDisassembleTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ NO_DEBUG_INFO_TESTCASE = True
+
+ @skipIfAsan
+ def test_foundation_disasm(self):
+ """Do 'disassemble -n func' on each and every 'Code' symbol entry from the Foundation.framework."""
+ self.build()
+
+ # Enable synchronous mode
+ self.dbg.SetAsync(False)
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+ self.assertTrue(target, VALID_TARGET)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ foundation_framework = None
+ for module in target.modules:
+ if module.file.basename == "Foundation":
+ foundation_framework = module.file.fullpath
+ break
+
+ self.assertTrue(
+ foundation_framework is not None,
+ "Foundation.framework path located")
+ self.runCmd("image dump symtab '%s'" % foundation_framework)
+ raw_output = self.res.GetOutput()
+ # Now, grab every 'Code' symbol and feed it into the command:
+ # 'disassemble -n func'.
+ #
+ # The symbol name is on the last column and trails the flag column which
+ # looks like '0xhhhhhhhh', i.e., 8 hexadecimal digits.
+ codeRE = re.compile(r"""
+ \ Code\ {9} # ' Code' followed by 9 SPCs,
+ .* # the wildcard chars,
+ 0x[0-9a-f]{8} # the flag column, and
+ \ (.+)$ # finally the function symbol.
+ """, re.VERBOSE)
+ for line in raw_output.split(os.linesep):
+ match = codeRE.search(line)
+ if match:
+ func = match.group(1)
+ self.runCmd('image lookup -s "%s"' % func)
+ self.runCmd('disassemble -n "%s"' % func)
+
+ @skipIfAsan
+ def test_simple_disasm(self):
+ """Test the lldb 'disassemble' command"""
+ self.build()
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+ self.assertTrue(target, VALID_TARGET)
+
+ # Stop at +[NSString stringWithFormat:].
+ symbol_name = "+[NSString stringWithFormat:]"
+ break_results = lldbutil.run_break_set_command(
+ self, "_regexp-break %s" % (symbol_name))
+
+ lldbutil.check_breakpoint_result(
+ self,
+ break_results,
+ symbol_name=symbol_name,
+ num_locations=1)
+
+ # Stop at -[MyString initWithNSString:].
+ lldbutil.run_break_set_by_symbol(
+ self,
+ '-[MyString initWithNSString:]',
+ num_expected_locations=1,
+ sym_exact=True)
+
+ # Stop at the "description" selector.
+ lldbutil.run_break_set_by_selector(
+ self,
+ 'description',
+ num_expected_locations=1,
+ module_name='a.out')
+
+ # Stop at -[NSAutoreleasePool release].
+ break_results = lldbutil.run_break_set_command(
+ self, "_regexp-break -[NSAutoreleasePool release]")
+ lldbutil.check_breakpoint_result(
+ self,
+ break_results,
+ symbol_name='-[NSAutoreleasePool release]',
+ num_locations=1)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # First stop is +[NSString stringWithFormat:].
+ self.expect(
+ "thread backtrace",
+ "Stop at +[NSString stringWithFormat:]",
+ substrs=["Foundation`+[NSString stringWithFormat:]"])
+
+ # Do the disassemble for the currently stopped function.
+ self.runCmd("disassemble -f")
+
+ self.runCmd("process continue")
+ # Skip another breakpoint for +[NSString stringWithFormat:].
+ self.runCmd("process continue")
+
+ # Followed by a.out`-[MyString initWithNSString:].
+ self.expect(
+ "thread backtrace",
+ "Stop at a.out`-[MyString initWithNSString:]",
+ substrs=["a.out`-[MyString initWithNSString:]"])
+
+ # Do the disassemble for the currently stopped function.
+ self.runCmd("disassemble -f")
+
+ self.runCmd("process continue")
+
+ # Followed by -[MyString description].
+ self.expect("thread backtrace", "Stop at -[MyString description]",
+ substrs=["a.out`-[MyString description]"])
+
+ # Do the disassemble for the currently stopped function.
+ self.runCmd("disassemble -f")
+
+ self.runCmd("process continue")
+ # Skip another breakpoint for -[MyString description].
+ self.runCmd("process continue")
+
+ # Followed by -[NSAutoreleasePool release].
+ self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]",
+ substrs=["Foundation`-[NSAutoreleasePool release]"])
+
+ # Do the disassemble for the currently stopped function.
+ self.runCmd("disassemble -f")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py
new file mode 100644
index 00000000000..7d4990c4f38
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py
@@ -0,0 +1,325 @@
+"""
+Set breakpoints on objective-c class and instance methods in foundation.
+Also lookup objective-c data types and evaluate expressions.
+"""
+
+from __future__ import print_function
+
+
+import os
+import os.path
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+file_index = 0
+
+
+@skipUnlessDarwin
+class FoundationTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.main_source = "main.m"
+ self.line = line_number(
+ self.main_source,
+ '// Set break point at this line.')
+
+ def test_break(self):
+ """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Stop at +[NSString stringWithFormat:].
+ break_results = lldbutil.run_break_set_command(
+ self, "_regexp-break +[NSString stringWithFormat:]")
+ lldbutil.check_breakpoint_result(
+ self,
+ break_results,
+ symbol_name='+[NSString stringWithFormat:]',
+ num_locations=1)
+
+ # Stop at -[MyString initWithNSString:].
+ lldbutil.run_break_set_by_symbol(
+ self,
+ '-[MyString initWithNSString:]',
+ num_expected_locations=1,
+ sym_exact=True)
+
+ # Stop at the "description" selector.
+ lldbutil.run_break_set_by_selector(
+ self,
+ 'description',
+ num_expected_locations=1,
+ module_name='a.out')
+
+ # Stop at -[NSAutoreleasePool release].
+ break_results = lldbutil.run_break_set_command(
+ self, "_regexp-break -[NSAutoreleasePool release]")
+ lldbutil.check_breakpoint_result(
+ self,
+ break_results,
+ symbol_name='-[NSAutoreleasePool release]',
+ num_locations=1)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # First stop is +[NSString stringWithFormat:].
+ self.expect(
+ "thread backtrace",
+ "Stop at +[NSString stringWithFormat:]",
+ substrs=["Foundation`+[NSString stringWithFormat:]"])
+
+ self.runCmd("process continue")
+
+ # Second stop is still +[NSString stringWithFormat:].
+ self.expect(
+ "thread backtrace",
+ "Stop at +[NSString stringWithFormat:]",
+ substrs=["Foundation`+[NSString stringWithFormat:]"])
+
+ self.runCmd("process continue")
+
+ # Followed by a.out`-[MyString initWithNSString:].
+ self.expect(
+ "thread backtrace",
+ "Stop at a.out`-[MyString initWithNSString:]",
+ substrs=["a.out`-[MyString initWithNSString:]"])
+
+ self.runCmd("process continue")
+
+ # Followed by -[MyString description].
+ self.expect("thread backtrace", "Stop at -[MyString description]",
+ substrs=["a.out`-[MyString description]"])
+
+ self.runCmd("process continue")
+
+ # Followed by the same -[MyString description].
+ self.expect("thread backtrace", "Stop at -[MyString description]",
+ substrs=["a.out`-[MyString description]"])
+
+ self.runCmd("process continue")
+
+ # Followed by -[NSAutoreleasePool release].
+ self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]",
+ substrs=["Foundation`-[NSAutoreleasePool release]"])
+
+ # rdar://problem/8542091
+ # rdar://problem/8492646
+ def test_data_type_and_expr(self):
+ """Lookup objective-c data types and evaluate expressions."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Stop at -[MyString description].
+ lldbutil.run_break_set_by_symbol(
+ self,
+ '-[MyString description]',
+ num_expected_locations=1,
+ sym_exact=True)
+# self.expect("breakpoint set -n '-[MyString description]", BREAKPOINT_CREATED,
+# startstr = "Breakpoint created: 1: name = '-[MyString description]',
+# locations = 1")
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The backtrace should show we stop at -[MyString description].
+ self.expect("thread backtrace", "Stop at -[MyString description]",
+ substrs=["a.out`-[MyString description]"])
+
+ # Lookup objc data type MyString and evaluate some expressions.
+
+ self.expect("image lookup -t NSString", DATA_TYPES_DISPLAYED_CORRECTLY,
+ substrs=['name = "NSString"',
+ 'compiler_type = "@interface NSString'])
+
+ self.expect("image lookup -t MyString", DATA_TYPES_DISPLAYED_CORRECTLY,
+ substrs=['name = "MyString"',
+ 'compiler_type = "@interface MyString',
+ 'NSString * str;',
+ 'NSDate * date;'])
+
+ self.expect(
+ "frame variable --show-types --scope",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["ARG: (MyString *) self"],
+ patterns=[
+ "ARG: \(.*\) _cmd",
+ "(objc_selector *)|(SEL)"])
+
+ # rdar://problem/8651752
+ # don't crash trying to ask clang how many children an empty record has
+ self.runCmd("frame variable *_cmd")
+
+ # rdar://problem/8492646
+ # test/foundation fails after updating to tot r115023
+ # self->str displays nothing as output
+ self.expect(
+ "frame variable --show-types self->str",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ startstr="(NSString *) self->str")
+
+ # rdar://problem/8447030
+ # 'frame variable self->date' displays the wrong data member
+ self.expect(
+ "frame variable --show-types self->date",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ startstr="(NSDate *) self->date")
+
+ # This should display the str and date member fields as well.
+ self.expect(
+ "frame variable --show-types *self",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "(MyString) *self",
+ "(NSString *) str",
+ "(NSDate *) date"])
+
+ # isa should be accessible.
+ self.expect("expression self->isa", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["(Class)"])
+
+ # This should fail expectedly.
+ self.expect(
+ "expression self->non_existent_member",
+ COMMAND_FAILED_AS_EXPECTED,
+ error=True,
+ substrs=["error:", "'MyString' does not have a member named 'non_existent_member'"])
+
+ # Use expression parser.
+ self.runCmd("expression self->str")
+ self.runCmd("expression self->date")
+
+ # (lldb) expression self->str
+ # error: instance variable 'str' is protected
+ # error: 1 errors parsing expression
+ #
+ # (lldb) expression self->date
+ # error: instance variable 'date' is protected
+ # error: 1 errors parsing expression
+ #
+
+ self.runCmd("breakpoint delete 1")
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("process continue")
+
+ # rdar://problem/8542091
+ # test/foundation: expr -o -- my not working?
+ #
+ # Test new feature with r115115:
+ # Add "-o" option to "expression" which prints the object description
+ # if available.
+ self.expect(
+ "expression --object-description -- my",
+ "Object description displayed correctly",
+ patterns=["Hello from.*a.out.*with timestamp: "])
+
+ @add_test_categories(['pyapi'])
+ def test_print_ivars_correctly(self):
+ self.build()
+ # See: <rdar://problem/8717050> lldb needs to use the ObjC runtime symbols for ivar offsets
+ # Only fails for the ObjC 2.0 runtime.
+ exe = self.getBuildArtifact("a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ break1 = target.BreakpointCreateByLocation(self.main_source, self.line)
+ self.assertTrue(break1, VALID_BREAKPOINT)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ thread = process.GetThreadAtIndex(0)
+ if thread.GetStopReason() != lldb.eStopReasonBreakpoint:
+ from lldbsuite.test.lldbutil import stop_reason_to_str
+ self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS %
+ stop_reason_to_str(thread.GetStopReason()))
+
+ # Make sure we stopped at the first breakpoint.
+
+ cur_frame = thread.GetFrameAtIndex(0)
+
+ line_number = cur_frame.GetLineEntry().GetLine()
+ self.assertTrue(line_number == self.line, "Hit the first breakpoint.")
+
+ my_var = cur_frame.FindVariable("my")
+ self.assertTrue(my_var, "Made a variable object for my")
+
+ str_var = cur_frame.FindVariable("str")
+ self.assertTrue(str_var, "Made a variable object for str")
+
+ # Now make sure that the my->str == str:
+
+ my_str_var = my_var.GetChildMemberWithName("str")
+ self.assertTrue(my_str_var, "Found a str ivar in my")
+
+ str_value = int(str_var.GetValue(), 0)
+
+ my_str_value = int(my_str_var.GetValue(), 0)
+
+ self.assertTrue(
+ str_value == my_str_value,
+ "Got the correct value for my->str")
+
+ def test_expression_lookups_objc(self):
+ """Test running an expression detect spurious debug info lookups (DWARF)."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Stop at -[MyString initWithNSString:].
+ lldbutil.run_break_set_by_symbol(
+ self,
+ '-[MyString initWithNSString:]',
+ num_expected_locations=1,
+ sym_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ global file_index
+ # Log any DWARF lookups
+ ++file_index
+ logfile = os.path.join(
+ self.getBuildDir(),
+ "dwarf-lookups-" +
+ self.getArchitecture() +
+ "-" +
+ str(file_index) +
+ ".txt")
+ self.runCmd("log enable -f %s dwarf lookups" % (logfile))
+ self.runCmd("expr self")
+ self.runCmd("log disable dwarf lookups")
+
+ def cleanup():
+ if os.path.exists(logfile):
+ os.unlink(logfile)
+
+ self.addTearDownHook(cleanup)
+
+ if os.path.exists(logfile):
+ f = open(logfile)
+ lines = f.readlines()
+ num_errors = 0
+ for line in lines:
+ if "$__lldb" in line:
+ if num_errors == 0:
+ print(
+ "error: found spurious name lookups when evaluating an expression:")
+ num_errors += 1
+ print(line, end='')
+ self.assertTrue(num_errors == 0, "Spurious lookups detected")
+ f.close()
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py
new file mode 100644
index 00000000000..b2d0d190eb0
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py
@@ -0,0 +1,40 @@
+"""
+Test more expression command sequences with objective-c.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipUnlessDarwin
+class FoundationTestCase2(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_expr_commands(self):
+ """More expression commands for objective-c."""
+ self.build()
+ main_spec = lldb.SBFileSpec("main.m")
+
+ (target, process, thread, bp) = lldbutil.run_to_source_breakpoint(
+ self, "Break here for selector: tests", main_spec)
+
+ # Test_Selector:
+ self.expect("expression (char *)sel_getName(sel)",
+ substrs=["(char *)",
+ "length"])
+
+ desc_bkpt = target.BreakpointCreateBySourceRegex("Break here for description test",
+ main_spec)
+ self.assertEqual(desc_bkpt.GetNumLocations(), 1, "description breakpoint has a location")
+ lldbutil.continue_to_breakpoint(process, desc_bkpt)
+
+ self.expect("expression (char *)sel_getName(_cmd)",
+ substrs=["(char *)",
+ "description"])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethodsNSArray.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethodsNSArray.py
new file mode 100644
index 00000000000..8080029ef02
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethodsNSArray.py
@@ -0,0 +1,36 @@
+"""
+Test more expression command sequences with objective-c.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipUnlessDarwin
+class FoundationTestCaseNSArray(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def test_NSArray_expr_commands(self):
+ """Test expression commands for NSArray."""
+ self.build()
+ self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+ self, '// Break here for NSArray tests',
+ lldb.SBFileSpec('main.m', False))
+
+ self.runCmd("thread backtrace")
+ self.expect("expression (int)[nil_mutable_array count]",
+ patterns=["\(int\) \$.* = 0"])
+ self.expect("expression (int)[array1 count]",
+ patterns=["\(int\) \$.* = 3"])
+ self.expect("expression (int)[array2 count]",
+ patterns=["\(int\) \$.* = 3"])
+ self.expect("expression (int)array1.count",
+ patterns=["\(int\) \$.* = 3"])
+ self.expect("expression (int)array2.count",
+ patterns=["\(int\) \$.* = 3"])
+ self.runCmd("process continue")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethodsNSError.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethodsNSError.py
new file mode 100644
index 00000000000..07717926b5e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethodsNSError.py
@@ -0,0 +1,49 @@
+"""
+Test more expression command sequences with objective-c.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipUnlessDarwin
+class FoundationTestCaseNSError(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @expectedFailureAll(archs=["i[3-6]86"], bugnumber="<rdar://problem/28814052>")
+ def test_runtime_types(self):
+ """Test commands that require runtime types"""
+ self.build()
+ self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+ self, '// Break here for NSString tests',
+ lldb.SBFileSpec('main.m', False))
+
+ # Test_NSString:
+ self.runCmd("thread backtrace")
+ self.expect("expression [str length]",
+ patterns=["\(NSUInteger\) \$.* ="])
+ self.expect("expression str.length")
+ self.expect('expression str = [NSString stringWithCString: "new"]')
+ self.expect(
+ 'po [NSError errorWithDomain:@"Hello" code:35 userInfo:@{@"NSDescription" : @"be completed."}]',
+ substrs=[
+ "Error Domain=Hello",
+ "Code=35",
+ "be completed."])
+ self.runCmd("process continue")
+
+ @expectedFailureAll(archs=["i[3-6]86"], bugnumber="<rdar://problem/28814052>")
+ def test_NSError_p(self):
+ """Test that p of the result of an unknown method does require a cast."""
+ self.build()
+ self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+ self, '// Set break point at this line',
+ lldb.SBFileSpec('main.m', False))
+ self.expect("p [NSError thisMethodIsntImplemented:0]", error=True, patterns=[
+ "no known method", "cast the message send to the method's return type"])
+ self.runCmd("process continue")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethodsString.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethodsString.py
new file mode 100644
index 00000000000..65ccb0c19b5
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethodsString.py
@@ -0,0 +1,53 @@
+"""
+Test more expression command sequences with objective-c.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipUnlessDarwin
+class FoundationTestCaseString(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def test_NSString_expr_commands(self):
+ """Test expression commands for NSString."""
+ self.build()
+ self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+ self, '// Break here for NSString tests',
+ lldb.SBFileSpec('main.m', False))
+
+ # Test_NSString:
+ self.runCmd("thread backtrace")
+ self.expect("expression (int)[str length]",
+ patterns=["\(int\) \$.* ="])
+ self.expect("expression (int)[str_id length]",
+ patterns=["\(int\) \$.* ="])
+ self.expect("expression (id)[str description]",
+ patterns=["\(id\) \$.* = 0x"])
+ self.expect("expression (id)[str_id description]",
+ patterns=["\(id\) \$.* = 0x"])
+ self.expect("expression str.length")
+ self.expect('expression str = @"new"')
+ self.runCmd("image lookup -t NSString")
+ self.expect('expression str = (id)[NSString stringWithCString: "new"]')
+ self.runCmd("process continue")
+
+ @expectedFailureAll(archs=["i[3-6]86"], bugnumber="<rdar://problem/28814052>")
+ def test_MyString_dump_with_runtime(self):
+ """Test dump of a known Objective-C object by dereferencing it."""
+ self.build()
+ self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+ self, '// Set break point at this line',
+ lldb.SBFileSpec('main.m', False))
+ self.expect(
+ "expression --show-types -- *my",
+ patterns=[
+ "\(MyString\) \$.* = ",
+ "\(MyBase\)"])
+ self.runCmd("process continue")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py
new file mode 100644
index 00000000000..803cbfe1218
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py
@@ -0,0 +1,75 @@
+"""
+Test SBValue.GetObjectDescription() with the value from SBTarget.FindGlobalVariables().
+"""
+
+from __future__ import print_function
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ObjectDescriptionAPITestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.source = 'main.m'
+ self.line = line_number(
+ self.source, '// Set break point at this line.')
+
+ # rdar://problem/10857337
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ def test_find_global_variables_then_object_description(self):
+ """Exercise SBTarget.FindGlobalVariables() API."""
+ d = {'EXE': 'b.out'}
+ self.build(dictionary=d)
+ self.setTearDownCleanup(dictionary=d)
+ exe = self.getBuildArtifact('b.out')
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ breakpoint = target.BreakpointCreateByLocation(self.source, self.line)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+ # Make sure we hit our breakpoint:
+ thread_list = lldbutil.get_threads_stopped_at_breakpoint(
+ process, breakpoint)
+ self.assertTrue(len(thread_list) == 1)
+
+ thread = thread_list[0]
+ frame0 = thread.GetFrameAtIndex(0)
+
+ # Note my_global_str's object description prints fine here.
+ value_list1 = frame0.GetVariables(True, True, True, True)
+ for v in value_list1:
+ self.DebugSBValue(v)
+ if self.TraceOn():
+ print("val:", v)
+ print("object description:", v.GetObjectDescription())
+ if v.GetName() == 'my_global_str':
+ self.assertTrue(v.GetObjectDescription() ==
+ 'This is a global string')
+
+ # But not here!
+ value_list2 = target.FindGlobalVariables('my_global_str', 3)
+ for v in value_list2:
+ self.DebugSBValue(v)
+ if self.TraceOn():
+ print("val:", v)
+ print("object description:", v.GetObjectDescription())
+ if v.GetName() == 'my_global_str':
+ self.assertTrue(v.GetObjectDescription() ==
+ 'This is a global string')
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py
new file mode 100644
index 00000000000..f5cb75b4a6d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py
@@ -0,0 +1,59 @@
+"""
+Test that Objective-C methods from the runtime work correctly.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipUnlessDarwin
+class RuntimeTypesTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @expectedFailureAll(
+ oslist=["macosx"],
+ debug_info="gmodules",
+ bugnumber="llvm.org/pr27862")
+ def test_break(self):
+ """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'."""
+ if self.getArchitecture() != 'x86_64':
+ self.skipTest("This only applies to the v2 runtime")
+
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Stop at -[MyString description].
+ lldbutil.run_break_set_by_symbol(
+ self,
+ '-[MyString description]',
+ num_expected_locations=1,
+ sym_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The backtrace should show we stop at -[MyString description].
+ self.expect("thread backtrace", "Stop at -[MyString description]",
+ substrs=["a.out`-[MyString description]"])
+
+ # Use runtime information about NSString.
+
+ # The length property should be usable.
+ self.expect("expression str.length", VARIABLES_DISPLAYED_CORRECTLY,
+ patterns=[r"(\(unsigned long long\))|\(NSUInteger\)"])
+
+ # Static methods on NSString should work.
+ self.expect(
+ "expr [NSString stringWithCString:\"foo\" encoding:1]",
+ VALID_TYPE,
+ substrs=[
+ "(id)",
+ "$1"])
+
+ self.expect("po $1", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["foo"])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py
new file mode 100644
index 00000000000..abfc7621e2e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py
@@ -0,0 +1,68 @@
+"""
+Test symbol table access for main.m.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipUnlessDarwin
+class FoundationSymtabTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ symbols_list = ['-[MyString initWithNSString:]',
+ '-[MyString dealloc]',
+ '-[MyString description]',
+ '-[MyString descriptionPauses]', # synthesized property
+ # synthesized property
+ '-[MyString setDescriptionPauses:]',
+ 'Test_Selector',
+ 'Test_NSString',
+ 'Test_MyString',
+ 'Test_NSArray',
+ 'main'
+ ]
+
+ @add_test_categories(['pyapi'])
+ def test_with_python_api(self):
+ """Test symbol table access with Python APIs."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Launch the process, and do not stop at the entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ #
+ # Exercise Python APIs to access the symbol table entries.
+ #
+
+ # Create the filespec by which to locate our a.out module.
+ filespec = lldb.SBFileSpec(exe, False)
+
+ module = target.FindModule(filespec)
+ self.assertTrue(module, VALID_MODULE)
+
+ # Create the set of known symbols. As we iterate through the symbol
+ # table, remove the symbol from the set if it is a known symbol.
+ expected_symbols = set(self.symbols_list)
+ for symbol in module:
+ self.assertTrue(symbol, VALID_SYMBOL)
+ #print("symbol:", symbol)
+ name = symbol.GetName()
+ if name in expected_symbols:
+ #print("Removing %s from known_symbols %s" % (name, expected_symbols))
+ expected_symbols.remove(name)
+
+ # At this point, the known_symbols set should have become an empty set.
+ # If not, raise an error.
+ #print("symbols unaccounted for:", expected_symbols)
+ self.assertTrue(len(expected_symbols) == 0,
+ "All the known symbols are accounted for")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/const-strings.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/const-strings.m
new file mode 100644
index 00000000000..8a43abee7b8
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/const-strings.m
@@ -0,0 +1,24 @@
+#import <Foundation/Foundation.h>
+
+// Tests to run:
+
+// Breakpoint 1
+// --
+// (lldb) expr (int)[str compare:@"hello"]
+// (int) $0 = 0
+// (lldb) expr (int)[str compare:@"world"]
+// (int) $1 = -1
+// (lldb) expr (int)[@"" length]
+// (int) $2 = 0
+
+int main ()
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ NSString *str = [NSString stringWithCString:"hello" encoding:NSASCIIStringEncoding];
+
+ NSLog(@"String \"%@\" has length %lu", str, [str length]); // Set breakpoint here.
+
+ [pool drain];
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/main.m
new file mode 100644
index 00000000000..519bec5a3e6
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/main.m
@@ -0,0 +1,141 @@
+#import <Foundation/Foundation.h>
+#include <unistd.h>
+#import "my-base.h"
+
+@interface MyString : MyBase {
+ NSString *str;
+ NSDate *date;
+ BOOL _desc_pauses;
+}
+
+@property(retain) NSString * str_property;
+@property BOOL descriptionPauses;
+
+- (id)initWithNSString:(NSString *)string;
+@end
+
+@implementation MyString
+@synthesize descriptionPauses = _desc_pauses;
+@synthesize str_property = str;
+
+- (id)initWithNSString:(NSString *)string
+{
+ if (self = [super init])
+ {
+ str = [NSString stringWithString:string];
+ date = [NSDate date];
+ }
+ self.descriptionPauses = NO;
+ return self;
+}
+
+- (void)dealloc
+{
+ [date release];
+ [str release];
+ [super dealloc];
+}
+
+- (NSString *)description
+{
+ // Set a breakpoint on '-[MyString description]' and test expressions:
+ // expression (char *)sel_getName(_cmd)
+ if (self.descriptionPauses) // Break here for description test
+ {
+ printf ("\nAbout to sleep.\n");
+ usleep(100000);
+ }
+
+ return [str stringByAppendingFormat:@" with timestamp: %@", date];
+}
+@end
+
+int
+Test_Selector ()
+{
+ SEL sel = @selector(length);
+ printf("sel = %p\n", sel);
+ // Expressions to test here for selector:
+ // expression (char *)sel_getName(sel)
+ // The expression above should return "sel" as it should be just
+ // a uniqued C string pointer. We were seeing the result pointer being
+ // truncated with recent LLDBs.
+ return 0; // Break here for selector: tests
+}
+
+int
+Test_NSString (const char *program)
+{
+ NSString *str = [NSString stringWithFormat:@"Hello from '%s'", program];
+ NSLog(@"NSString instance: %@", str);
+ printf("str = '%s'\n", [str cStringUsingEncoding: [NSString defaultCStringEncoding]]);
+ printf("[str length] = %zu\n", (size_t)[str length]);
+ printf("[str description] = %s\n", [[str description] UTF8String]);
+ id str_id = str;
+ // Expressions to test here for NSString:
+ // expression (char *)sel_getName(sel)
+ // expression [str length]
+ // expression [str_id length]
+ // expression [str description]
+ // expression [str_id description]
+ // expression str.length
+ // expression str.description
+ // expression str = @"new"
+ // expression str = [NSString stringWithFormat: @"%cew", 'N']
+ return 0; // Break here for NSString tests
+}
+
+NSString *my_global_str = NULL;
+
+void
+Test_MyString (const char *program)
+{
+ my_global_str = @"This is a global string";
+ NSString *str = [NSString stringWithFormat:@"Hello from '%s'", program];
+ MyString *my = [[MyString alloc] initWithNSString:str];
+ NSLog(@"MyString instance: %@", [my description]);
+ my.descriptionPauses = YES; // Set break point at this line. Test 'expression -o -- my'.
+ NSLog(@"MyString instance: %@", [my description]);
+}
+
+int
+Test_NSArray ()
+{
+ NSMutableArray *nil_mutable_array = nil;
+ NSArray *array1 = [NSArray arrayWithObjects: @"array1 object1", @"array1 object2", @"array1 object3", nil];
+ NSArray *array2 = [NSArray arrayWithObjects: array1, @"array2 object2", @"array2 object3", nil];
+ // Expressions to test here for NSArray:
+ // expression [nil_mutable_array count]
+ // expression [array1 count]
+ // expression array1.count
+ // expression [array2 count]
+ // expression array2.count
+ id obj;
+ // After each object at index call, use expression and validate object
+ obj = [array1 objectAtIndex: 0]; // Break here for NSArray tests
+ obj = [array1 objectAtIndex: 1];
+ obj = [array1 objectAtIndex: 2];
+
+ obj = [array2 objectAtIndex: 0];
+ obj = [array2 objectAtIndex: 1];
+ obj = [array2 objectAtIndex: 2];
+ NSUInteger count = [nil_mutable_array count];
+ return 0;
+}
+
+
+int main (int argc, char const *argv[])
+{
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ Test_Selector();
+ Test_NSArray ();
+ Test_NSString (argv[0]);
+ Test_MyString (argv[0]);
+
+ printf("sizeof(id) = %zu\n", sizeof(id));
+ printf("sizeof(Class) = %zu\n", sizeof(Class));
+ printf("sizeof(SEL) = %zu\n", sizeof(SEL));
+
+ [pool release];
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/my-base.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/my-base.h
new file mode 100644
index 00000000000..53202aa0de3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/my-base.h
@@ -0,0 +1,8 @@
+@interface MyBase : NSObject
+{
+#if !__OBJC2__
+ int maybe_used; // The 1.0 runtime needs to have backed properties...
+#endif
+}
+@property int propertyMovesThings;
+@end
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/my-base.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/my-base.m
new file mode 100644
index 00000000000..0c316b244f2
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/my-base.m
@@ -0,0 +1,10 @@
+#import <Foundation/Foundation.h>
+#import "my-base.h"
+@implementation MyBase
+#if __OBJC2__
+@synthesize propertyMovesThings;
+#else
+@synthesize propertyMovesThings = maybe_used;
+#endif
+@end
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/global_ptrs/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/global_ptrs/Makefile
new file mode 100644
index 00000000000..afecbf96948
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/global_ptrs/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := main.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py
new file mode 100644
index 00000000000..5cc6f4e7ba9
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py
@@ -0,0 +1,57 @@
+"""Test that a global ObjC object found before the process is started updates correctly."""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestObjCGlobalVar(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ self.main_source = lldb.SBFileSpec("main.m")
+
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ def test_with_python_api(self):
+ """Test that a global ObjC object found before the process is started updates correctly."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ bkpt = target.BreakpointCreateBySourceRegex('NSLog', self.main_source)
+ self.assertTrue(bkpt, VALID_BREAKPOINT)
+
+ # Before we launch, make an SBValue for our global object pointer:
+ g_obj_ptr = target.FindFirstGlobalVariable("g_obj_ptr")
+ self.assertTrue(g_obj_ptr.GetError().Success(), "Made the g_obj_ptr")
+ self.assertTrue(
+ g_obj_ptr.GetValueAsUnsigned(10) == 0,
+ "g_obj_ptr is initially null")
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ threads = lldbutil.get_threads_stopped_at_breakpoint(process, bkpt)
+ if len(threads) != 1:
+ self.fail("Failed to stop at breakpoint 1.")
+
+ thread = threads[0]
+
+ dyn_value = g_obj_ptr.GetDynamicValue(lldb.eDynamicCanRunTarget)
+ self.assertTrue(
+ dyn_value.GetError().Success(),
+ "Dynamic value is valid")
+ self.assertTrue(dyn_value.GetObjectDescription() == "Some NSString")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/global_ptrs/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/global_ptrs/main.m
new file mode 100644
index 00000000000..977a984e06e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/global_ptrs/main.m
@@ -0,0 +1,11 @@
+#import <Foundation/Foundation.h>
+
+id g_obj_ptr = nil;
+
+int
+main()
+{
+ g_obj_ptr = @"Some NSString";
+ NSLog(@"My string was %@.", g_obj_ptr);
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/InternalDefiner.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/InternalDefiner.h
new file mode 100644
index 00000000000..59652d4b09c
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/InternalDefiner.h
@@ -0,0 +1,11 @@
+#import <Foundation/Foundation.h>
+#import <stdint.h>
+
+@interface InternalDefiner : NSObject {
+@public
+ uintptr_t foo;
+}
+
+-(id)initWithFoo:(uintptr_t)f andBar:(uintptr_t)b;
+
+@end
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/InternalDefiner.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/InternalDefiner.m
new file mode 100644
index 00000000000..1a10ce021ce
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/InternalDefiner.m
@@ -0,0 +1,31 @@
+#import "InternalDefiner.h"
+
+@interface InternalDefiner () {
+ uintptr_t bar;
+}
+
+@end
+
+@implementation InternalDefiner
+
+-(id)init
+{
+ if (self = [super init])
+ {
+ foo = 2;
+ bar = 3;
+ }
+ return self;
+}
+
+-(id)initWithFoo:(uintptr_t)f andBar:(uintptr_t)b
+{
+ if (self = [super init])
+ {
+ foo = f;
+ bar = b;
+ }
+ return self;
+}
+
+@end
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/Makefile
new file mode 100644
index 00000000000..0664769456e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/Makefile
@@ -0,0 +1,7 @@
+DYLIB_NAME := InternalDefiner
+DYLIB_OBJC_SOURCES := InternalDefiner.m
+OBJC_SOURCES := main.m
+
+LD_EXTRAS = -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/TestHiddenIvars.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/TestHiddenIvars.py
new file mode 100644
index 00000000000..03a325ac49c
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/TestHiddenIvars.py
@@ -0,0 +1,238 @@
+"""Test that hidden ivars in a shared library are visible from the main executable."""
+
+
+
+import unittest2
+import subprocess
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class HiddenIvarsTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.source = 'main.m'
+ self.line = line_number(self.source, '// breakpoint1')
+ # The makefile names of the shared libraries as they appear in DYLIB_NAME.
+ # The names should have no loading "lib" or extension as they will be
+ # localized
+ self.shlib_names = ["InternalDefiner"]
+
+ @skipUnlessDarwin
+ @skipIf(
+ debug_info=no_match("dsym"),
+ bugnumber="This test requires a stripped binary and a dSYM")
+ def test_expr_stripped(self):
+ if self.getArchitecture() == 'i386':
+ self.skipTest("requires modern objc runtime")
+ else:
+ self.build()
+ self.expr(True)
+
+ @skipUnlessDarwin
+ def test_expr(self):
+ if self.getArchitecture() == 'i386':
+ self.skipTest("requires modern objc runtime")
+ else:
+ self.build()
+ self.expr(False)
+
+ @skipUnlessDarwin
+ @skipIf(
+ debug_info=no_match("dsym"),
+ bugnumber="This test requires a stripped binary and a dSYM")
+ def test_frame_variable_stripped(self):
+ if self.getArchitecture() == 'i386':
+ self.skipTest("requires modern objc runtime")
+ else:
+ self.build()
+ self.frame_var(True)
+
+ @skipUnlessDarwin
+ def test_frame_variable(self):
+ if self.getArchitecture() == 'i386':
+ self.skipTest("requires modern objc runtime")
+ else:
+ self.build()
+ self.frame_var(False)
+
+ @unittest2.expectedFailure("rdar://18683637")
+ @skipUnlessDarwin
+ def test_frame_variable_across_modules(self):
+ if self.getArchitecture() == 'i386':
+ self.skipTest("requires modern objc runtime")
+ else:
+ self.build()
+ self.common_setup(False)
+ self.expect(
+ "frame variable k->bar",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["= 3"])
+
+ def common_setup(self, strip):
+
+ if strip:
+ self.assertTrue(subprocess.call(
+ ['/usr/bin/strip', '-Sx',
+ self.getBuildArtifact('libInternalDefiner.dylib')]) == 0,
+ 'stripping dylib succeeded')
+ self.assertTrue(subprocess.call(
+ ['/bin/rm', '-rf',
+ self.getBuildArtifact('libInternalDefiner.dylib.dSYM')]) == 0,
+ 'remove dylib dSYM file succeeded')
+ self.assertTrue(subprocess.call(['/usr/bin/strip', '-Sx',
+ self.getBuildArtifact("a.out")
+ ]) == 0,
+ 'stripping a.out succeeded')
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+ self.assertTrue(target, VALID_TARGET)
+
+ # Create the breakpoint inside function 'main'.
+ breakpoint = target.BreakpointCreateByLocation(self.source, self.line)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
+
+ # Register our shared libraries for remote targets so they get
+ # automatically uploaded
+ environment = self.registerSharedLibrariesWithTarget(
+ target, self.shlib_names)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, environment, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break inside the foo function which takes a bar_ptr argument.
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ 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, strip):
+ self.common_setup(strip)
+
+ # This should display correctly.
+ self.expect(
+ "expression (j->_definer->foo)",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["= 4"])
+
+ self.expect(
+ "expression (j->_definer->bar)",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["= 5"])
+
+ if strip:
+ self.expect(
+ "expression *(j->_definer)",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["foo = 4"])
+ else:
+ self.expect(
+ "expression *(j->_definer)",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "foo = 4",
+ "bar = 5"])
+
+ self.expect("expression (k->foo)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["= 2"])
+
+ self.expect("expression (k->bar)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["= 3"])
+
+ self.expect(
+ "expression k.filteredDataSource",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ ' = 0x',
+ '"2 elements"'])
+
+ if strip:
+ self.expect("expression *(k)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["foo = 2", ' = 0x', '"2 elements"'])
+ else:
+ self.expect(
+ "expression *(k)",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "foo = 2",
+ "bar = 3",
+ '_filteredDataSource = 0x',
+ '"2 elements"'])
+
+ def frame_var(self, strip):
+ self.common_setup(strip)
+
+ # This should display correctly.
+ self.expect(
+ "frame variable j->_definer->foo",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["= 4"])
+
+ if not strip:
+ self.expect(
+ "frame variable j->_definer->bar",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["= 5"])
+
+ if strip:
+ self.expect(
+ "frame variable *j->_definer",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["foo = 4"])
+ else:
+ self.expect(
+ "frame variable *j->_definer",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "foo = 4",
+ "bar = 5"])
+
+ self.expect("frame variable k->foo", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["= 2"])
+
+ self.expect(
+ "frame variable k->_filteredDataSource",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ ' = 0x',
+ '"2 elements"'])
+
+ if strip:
+ self.expect(
+ "frame variable *k",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "foo = 2",
+ '_filteredDataSource = 0x',
+ '"2 elements"'])
+ else:
+ self.expect(
+ "frame variable *k",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "foo = 2",
+ "bar = 3",
+ '_filteredDataSource = 0x',
+ '"2 elements"'])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/main.m
new file mode 100644
index 00000000000..1795d56e7d8
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/main.m
@@ -0,0 +1,54 @@
+#import <Foundation/Foundation.h>
+#import "InternalDefiner.h"
+
+@interface Container : NSObject {
+@public
+ InternalDefiner *_definer;
+}
+
+-(id)init;
+@end
+
+@implementation Container
+
+-(id)init
+{
+ if (self = [super init])
+ {
+ _definer = [[InternalDefiner alloc] initWithFoo:4 andBar:5];
+ }
+ return self;
+}
+
+@end
+
+@interface InheritContainer : InternalDefiner
+@property (nonatomic, strong) NSMutableArray *filteredDataSource;
+-(id)init;
+@end
+
+@implementation InheritContainer
+
+-(id)init
+{
+ if (self = [super initWithFoo:2 andBar:3])
+ {
+ self.filteredDataSource = [NSMutableArray arrayWithObjects:@"hello", @"world", nil];
+ }
+ return self;
+}
+
+@end
+
+int main(int argc, const char * argv[])
+{
+ @autoreleasepool {
+ Container *j = [[Container alloc] init];
+ InheritContainer *k = [[InheritContainer alloc] init];
+
+ printf("ivar value = %u\n", (unsigned)j->_definer->foo); // breakpoint1
+ printf("ivar value = %u\n", (unsigned)k->foo);
+ }
+ return 0;
+}
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/Makefile
new file mode 100644
index 00000000000..ba7e23acaba
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/Makefile
@@ -0,0 +1,13 @@
+CFLAGS := -g -O0
+CFLAGS_NO_DEBUG =
+
+all: aout
+
+aout:
+ $(CC) $(CFLAGS_NO_DEBUG) $(SRCDIR)/myclass.m -c -o myclass.o
+ $(CC) $(CFLAGS) myclass.o $(SRCDIR)/repro.m -framework Foundation
+
+clean::
+ rm -f myclass.o
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py
new file mode 100644
index 00000000000..3019bcfc5cf
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py
@@ -0,0 +1,48 @@
+"""
+Test that dynamically discovered ivars of type IMP do not crash LLDB
+"""
+
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ObjCiVarIMPTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ @skipIf(archs=['i386']) # objc file does not build for i386
+ @no_debug_info_test
+ def test_imp_ivar_type(self):
+ """Test that dynamically discovered ivars of type IMP do not crash LLDB"""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ # Create a target from the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Set up our breakpoint
+
+ bkpt = lldbutil.run_break_set_by_source_regexp(self, "break here")
+
+ # Now launch the process, and do not stop at the entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ self.assertTrue(process.GetState() == lldb.eStateStopped,
+ PROCESS_STOPPED)
+
+ self.expect(
+ 'frame variable --ptr-depth=1 --show-types -d run -- object',
+ substrs=[
+ '(MyClass *) object = 0x',
+ '(void *) myImp = 0x'])
+ self.expect(
+ 'disassemble --start-address `((MyClass*)object)->myImp`',
+ substrs=['-[MyClass init]'])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/myclass.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/myclass.h
new file mode 100644
index 00000000000..da28d1e0518
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/myclass.h
@@ -0,0 +1,6 @@
+#import <Foundation/Foundation.h>
+
+@interface MyClass : NSObject
+{}
+- (id)init;
+@end
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/myclass.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/myclass.m
new file mode 100644
index 00000000000..85b2fcfe9b3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/myclass.m
@@ -0,0 +1,16 @@
+#import <Foundation/Foundation.h>
+#import "myclass.h"
+
+@implementation MyClass
+{
+ IMP myImp;
+}
+- (id)init {
+ if (self = [super init])
+ {
+ SEL theSelector = @selector(init);
+ self->myImp = [self methodForSelector:theSelector];
+ }
+ return self;
+}
+@end
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/repro.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/repro.m
new file mode 100644
index 00000000000..14f911f07dd
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/repro.m
@@ -0,0 +1,7 @@
+#import <Foundation/Foundation.h>
+#import "myclass.h"
+
+int main() {
+ id object = [MyClass new];
+ return 0; // break here
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/Makefile
new file mode 100644
index 00000000000..0d8068b3085
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/Makefile
@@ -0,0 +1,5 @@
+CFLAGS_EXTRAS = -I$(BUILDDIR)
+USE_PRIVATE_MODULE_CACHE := YES
+OBJC_SOURCES := main.m foo.m
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/TestClangModulesAppUpdate.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/TestClangModulesAppUpdate.py
new file mode 100644
index 00000000000..4bd136b7285
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/TestClangModulesAppUpdate.py
@@ -0,0 +1,57 @@
+
+import unittest2
+import os
+import shutil
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestClangModuleAppUpdate(TestBase):
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ @skipIf(debug_info=no_match(["gmodules"]))
+ def test_rebuild_app_modules_untouched(self):
+ with open(self.getBuildArtifact("module.modulemap"), "w") as f:
+ f.write("""
+ module Foo { header "f.h" }
+ """)
+ with open(self.getBuildArtifact("f.h"), "w") as f:
+ f.write("""
+ @import Foundation;
+ @interface Foo : NSObject {
+ int i;
+ }
+ +(instancetype)init;
+ @end
+ """)
+
+ mod_cache = self.getBuildArtifact("private-module-cache")
+ import os
+ if os.path.isdir(mod_cache):
+ shutil.rmtree(mod_cache)
+ self.build()
+ self.assertTrue(os.path.isdir(mod_cache), "module cache exists")
+
+ target, process, _, bkpt = lldbutil.run_to_source_breakpoint(
+ self, "break here", lldb.SBFileSpec("main.m"))
+ bar = target.FindTypes('Bar').GetTypeAtIndex(0)
+ foo = bar.GetDirectBaseClassAtIndex(0).GetType()
+ self.assertEqual(foo.GetNumberOfFields(), 1)
+ self.assertEqual(foo.GetFieldAtIndex(0).GetName(), "i")
+
+ # Rebuild.
+ process.Kill()
+ os.remove(self.getBuildArtifact('main.o'))
+ os.remove(self.getBuildArtifact('a.out'))
+ self.build()
+
+ # Reattach.
+ target, process, _, _ = lldbutil.run_to_breakpoint_do_run(self, target, bkpt)
+ bar = target.FindTypes('Bar').GetTypeAtIndex(0)
+ foo = bar.GetDirectBaseClassAtIndex(0).GetType()
+ self.assertEqual(foo.GetNumberOfFields(), 1)
+ self.assertEqual(foo.GetFieldAtIndex(0).GetName(), "i")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/foo.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/foo.m
new file mode 100644
index 00000000000..83a5abc04e2
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/foo.m
@@ -0,0 +1,7 @@
+@import Foundation;
+@import Foo;
+@implementation Foo
++(instancetype)init {
+ return [super init];
+}
+@end
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/main.m
new file mode 100644
index 00000000000..37ec1f37b57
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/main.m
@@ -0,0 +1,17 @@
+@import Umbrella;
+
+@interface Bar : Foo
++(instancetype)init;
+@end
+
+@implementation Bar
++(instancetype)init {
+ return [super init];
+}
+@end
+
+int main(int argc, char **argv) {
+ id bar = [Bar new];
+ [bar i]; // break here
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/module.modulemap b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/module.modulemap
new file mode 100644
index 00000000000..c142410cd07
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/module.modulemap
@@ -0,0 +1,4 @@
+module Umbrella {
+ header "umbrella.h"
+ export *
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/umbrella.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/umbrella.h
new file mode 100644
index 00000000000..375d3ea2a04
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/umbrella.h
@@ -0,0 +1 @@
+@import Foo;
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/Makefile
new file mode 100644
index 00000000000..3b2bd504c89
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/Makefile
@@ -0,0 +1,5 @@
+OBJC_SOURCES := main.m
+
+CFLAGS_EXTRAS = $(MANDATORY_MODULE_BUILD_CFLAGS)
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py
new file mode 100644
index 00000000000..449e5b50d05
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py
@@ -0,0 +1,48 @@
+"""Test that importing modules in Objective-C works as expected."""
+
+
+
+import unittest2
+import lldb
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ObjCModulesAutoImportTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ 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.')
+
+ @skipUnlessDarwin
+ @skipIf(macos_version=["<", "10.12"])
+ def test_expr(self):
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break inside the foo function which takes a bar_ptr argument.
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ 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'])
+
+ self.runCmd("settings set target.auto-import-clang-modules true")
+
+ self.expect("p getpid()", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["pid_t"])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/main.m
new file mode 100644
index 00000000000..5452ffd9bd1
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/main.m
@@ -0,0 +1,7 @@
+@import Darwin;
+
+int main()
+{
+ size_t ret = printf("Stop here\n"); // Set breakpoint 0 here.
+ return ret;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/Makefile
new file mode 100644
index 00000000000..d0aadc1af9e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/Makefile
@@ -0,0 +1,2 @@
+OBJC_SOURCES := main.m
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/TestClangModulesCache.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/TestClangModulesCache.py
new file mode 100644
index 00000000000..3a12b23a79c
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/TestClangModulesCache.py
@@ -0,0 +1,35 @@
+"""Test that the clang modules cache directory can be controlled."""
+
+
+
+import unittest2
+import os
+import shutil
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ObjCModulesTestCase(TestBase):
+ NO_DEBUG_INFO_TESTCASE = True
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ def test_expr(self):
+ self.build()
+ self.main_source_file = lldb.SBFileSpec("main.m")
+ self.runCmd("settings set target.auto-import-clang-modules true")
+ mod_cache = self.getBuildArtifact("my-clang-modules-cache")
+ if os.path.isdir(mod_cache):
+ shutil.rmtree(mod_cache)
+ self.assertFalse(os.path.isdir(mod_cache),
+ "module cache should not exist")
+ self.runCmd('settings set symbols.clang-modules-cache-path "%s"' % mod_cache)
+ self.runCmd('settings set target.clang-module-search-paths "%s"'
+ % self.getSourceDir())
+ (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+ self, "Set breakpoint here", self.main_source_file)
+ self.runCmd("expr @import Foo")
+ self.assertTrue(os.path.isdir(mod_cache), "module cache exists")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/f.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/f.h
new file mode 100644
index 00000000000..56757a701bf
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/f.h
@@ -0,0 +1 @@
+void f() {}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/main.m
new file mode 100644
index 00000000000..6009d28d81b
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/main.m
@@ -0,0 +1,5 @@
+#include "f.h"
+int main() {
+ f(); // Set breakpoint here.
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/module.modulemap b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/module.modulemap
new file mode 100644
index 00000000000..f54534a1c07
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-cache/module.modulemap
@@ -0,0 +1,3 @@
+module Foo {
+ header "f.h"
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-hash-mismatch/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-hash-mismatch/Makefile
new file mode 100644
index 00000000000..59bf009f686
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-hash-mismatch/Makefile
@@ -0,0 +1,16 @@
+OBJC_SOURCES := main.m
+CFLAGS_EXTRAS = -I$(BUILDDIR)
+USE_PRIVATE_MODULE_CACHE = YES
+
+.PHONY: update-module
+
+all: $(EXE)
+ $(MAKE) -f $(SRCDIR)/Makefile update-module
+
+include Makefile.rules
+
+update-module:
+ echo "forcing an update of f.pcm"
+ echo "typedef int something_other;" > $(BUILDDIR)/f.h
+ $(CC) $(CFLAGS) $(MANDATORY_MODULE_BUILD_CFLAGS) \
+ -c $(SRCDIR)/other.m -o $(BUILDDIR)/other.o
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-hash-mismatch/TestClangModulesHashMismatch.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-hash-mismatch/TestClangModulesHashMismatch.py
new file mode 100644
index 00000000000..606bd300c24
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-hash-mismatch/TestClangModulesHashMismatch.py
@@ -0,0 +1,45 @@
+
+import unittest2
+import os
+import shutil
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestClangModuleHashMismatch(TestBase):
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ @skipIf(debug_info=no_match(["gmodules"]))
+ def test_expr(self):
+ with open(self.getBuildArtifact("module.modulemap"), "w") as f:
+ f.write("""
+ module Foo { header "f.h" }
+ """)
+ with open(self.getBuildArtifact("f.h"), "w") as f:
+ f.write("""
+ typedef int my_int;
+ void f() {}
+ """)
+
+ mod_cache = self.getBuildArtifact("private-module-cache")
+ if os.path.isdir(mod_cache):
+ shutil.rmtree(mod_cache)
+ self.build()
+ self.assertTrue(os.path.isdir(mod_cache), "module cache exists")
+
+ logfile = self.getBuildArtifact("host.log")
+ self.runCmd("log enable -v -f %s lldb host" % logfile)
+ target, _, _, _ = lldbutil.run_to_source_breakpoint(
+ self, "break here", lldb.SBFileSpec("main.m"))
+ target.GetModuleAtIndex(0).FindTypes('my_int')
+
+ found = False
+ with open(logfile, 'r') as f:
+ for line in f:
+ if "hash mismatch" in line and "Foo" in line:
+ found = True
+ self.assertTrue(found)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-hash-mismatch/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-hash-mismatch/main.m
new file mode 100644
index 00000000000..5065222731e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-hash-mismatch/main.m
@@ -0,0 +1,6 @@
+#include "f.h"
+int main(int argc, char **argv) {
+ my_int i = argc;
+ f(); // break here
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-hash-mismatch/other.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-hash-mismatch/other.m
new file mode 100644
index 00000000000..0afd3eb078d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-hash-mismatch/other.m
@@ -0,0 +1,4 @@
+#include "f.h"
+something_other f() {
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/Makefile
new file mode 100644
index 00000000000..abb36e281b2
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/Makefile
@@ -0,0 +1,5 @@
+OBJC_SOURCES := main.m myModule.m
+
+CFLAGS_EXTRAS = $(MANDATORY_MODULE_BUILD_CFLAGS)
+LD_EXTRAS := -framework Foundation
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/TestIncompleteModules.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/TestIncompleteModules.py
new file mode 100644
index 00000000000..8fed6133f7d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/TestIncompleteModules.py
@@ -0,0 +1,61 @@
+"""Test that DWARF types are trusted over module types"""
+
+
+
+import unittest2
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class IncompleteModulesTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ 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.')
+
+ @skipUnlessDarwin
+ @skipIf(debug_info=no_match(["gmodules"]))
+ def test_expr(self):
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ 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'])
+
+ self.runCmd(
+ "settings set target.clang-module-search-paths \"" +
+ self.getSourceDir() +
+ "\"")
+
+ self.expect("expr @import myModule; 3", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["int", "3"])
+
+ self.expect(
+ "expr private_func()",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "int",
+ "5"])
+
+ self.expect("expr MY_MIN(2,3)", "#defined macro was found",
+ substrs=["int", "2"])
+
+ self.expect("expr MY_MAX(2,3)", "#undefd macro was correctly not found",
+ error=True)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/main.m
new file mode 100644
index 00000000000..bfa0b06f1a1
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/main.m
@@ -0,0 +1,7 @@
+@import myModule;
+@import minmax;
+
+int main(int argc, char **argv) {
+ public_func(); // Set breakpoint 0 here.
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/minmax.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/minmax.h
new file mode 100644
index 00000000000..efad1201695
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/minmax.h
@@ -0,0 +1,2 @@
+#define MY_MIN(A, B) (((A) < (B)) ? (A) : (B))
+#define MY_MAX(A, B) (((A) < (B)) ? (B) : (A))
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/module.map b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/module.map
new file mode 100644
index 00000000000..0dd9fadb262
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/module.map
@@ -0,0 +1,9 @@
+module myModule {
+ header "myModule.h"
+ export *
+}
+
+module minmax {
+ header "minmax.h"
+ export *
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/myModule.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/myModule.h
new file mode 100644
index 00000000000..04ec3885c83
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/myModule.h
@@ -0,0 +1,5 @@
+@import minmax;
+
+#undef MY_MAX
+
+extern void public_func();
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/myModule.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/myModule.m
new file mode 100644
index 00000000000..372a3288932
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/myModule.m
@@ -0,0 +1,8 @@
+#include "myModule.h"
+
+void public_func() {}
+
+int private_func() {
+ return 5;
+}
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/Makefile
new file mode 100644
index 00000000000..b4afe2cb3e8
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/Makefile
@@ -0,0 +1,7 @@
+C_SOURCES := myModule.c
+
+OBJC_SOURCES := main.m
+
+CFLAGS_EXTRAS = $(MANDATORY_MODULE_BUILD_CFLAGS) -I$(BUILDDIR)
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py
new file mode 100644
index 00000000000..e2e335a1c43
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py
@@ -0,0 +1,38 @@
+"""Test that inline functions from modules are imported correctly"""
+
+
+
+
+import unittest2
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ModulesInlineFunctionsTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ @skipIf(macos_version=["<", "10.12"], debug_info=no_match(["gmodules"]))
+ def test_expr(self):
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break inside the foo function which takes a bar_ptr argument.
+ lldbutil.run_to_source_breakpoint(
+ self, '// Set breakpoint here.', lldb.SBFileSpec('main.m'))
+
+ self.runCmd(
+ "settings set target.clang-module-search-paths \"" +
+ self.getSourceDir() +
+ "\"")
+
+ self.expect("expr @import myModule; 3", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["int", "3"])
+
+ self.expect("expr isInline(2)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["4"])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/main.m
new file mode 100644
index 00000000000..13a5bf316ee
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/main.m
@@ -0,0 +1,9 @@
+@import Darwin;
+@import myModule;
+
+int main()
+{
+ int a = isInline(2);
+ int b = notInline();
+ printf("%d %d\n", a, b); // Set breakpoint here.
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/module.map b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/module.map
new file mode 100644
index 00000000000..2ef8064d15b
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/module.map
@@ -0,0 +1,4 @@
+module myModule {
+ header "myModule.h"
+ export *
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/myModule.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/myModule.c
new file mode 100644
index 00000000000..ad3c85d155e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/myModule.c
@@ -0,0 +1,7 @@
+#include "myModule.h"
+
+int notInline()
+{
+ return 3;
+}
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/myModule.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/myModule.h
new file mode 100644
index 00000000000..d50d0101f64
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/myModule.h
@@ -0,0 +1,7 @@
+int notInline();
+
+static __inline__ __attribute__ ((always_inline)) int isInline(int a)
+{
+ int b = a + a;
+ return b;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/Makefile
new file mode 100644
index 00000000000..5d0a2209ef7
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/Makefile
@@ -0,0 +1,3 @@
+CFLAGS_EXTRAS = -I$(BUILDDIR)
+USE_PRIVATE_MODULE_CACHE = YES
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/TestClangModulesUpdate.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/TestClangModulesUpdate.py
new file mode 100644
index 00000000000..e36a2278daa
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/TestClangModulesUpdate.py
@@ -0,0 +1,65 @@
+
+import unittest2
+import os
+import shutil
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestClangModuleUpdate(TestBase):
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ @skipIf(debug_info=no_match(["gmodules"]))
+ def test_expr(self):
+ with open(self.getBuildArtifact("module.modulemap"), "w") as f:
+ f.write("""
+ module Foo { header "f.h" }
+ """)
+ with open(self.getBuildArtifact("f.h"), "w") as f:
+ f.write("""
+ struct Q { int i; };
+ void f() {}
+ """)
+
+ mod_cache = self.getBuildArtifact("private-module-cache")
+ if os.path.isdir(mod_cache):
+ shutil.rmtree(mod_cache)
+ d = {'OBJC_SOURCES': 'first.m'}
+ self.build(dictionary=d)
+ self.assertTrue(os.path.isdir(mod_cache), "module cache exists")
+
+ logfile = self.getBuildArtifact("modules.log")
+ self.runCmd("log enable -f %s lldb module" % logfile)
+ target, process, _, bkpt = lldbutil.run_to_name_breakpoint(self, "main")
+ self.assertIn("int i", str(target.FindTypes('Q').GetTypeAtIndex(0)))
+ self.expect("image list -g", patterns=[r'first\.o', r'Foo.*\.pcm'])
+
+ # Update the module.
+ with open(self.getBuildArtifact("f.h"), "w") as f:
+ f.write("""
+ struct S { int i; };
+ struct S getS() { struct S r = {1}; return r; }
+ void f() {}
+ """)
+
+ # Rebuild.
+ d = {'OBJC_SOURCES': 'second.m'}
+ self.build(dictionary=d)
+
+ # Reattach.
+ process.Kill()
+ target, process, _, _ = lldbutil.run_to_breakpoint_do_run(self, target, bkpt)
+ self.assertIn("int i", str(target.FindTypes('S').GetTypeAtIndex(0)))
+ self.expect("image list -g", patterns=[r'second\.o', r'Foo.*\.pcm'])
+
+ # Check log file.
+ found = False
+ with open(logfile, 'r') as f:
+ for line in f:
+ if "module changed" in line and "Foo" in line:
+ found = True
+ self.assertTrue(found)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/first.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/first.m
new file mode 100644
index 00000000000..bcc458ffb8e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/first.m
@@ -0,0 +1,5 @@
+@import Umbrella;
+int main(int argc, char **argv) {
+ f(); // break here
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/module.modulemap b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/module.modulemap
new file mode 100644
index 00000000000..c142410cd07
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/module.modulemap
@@ -0,0 +1,4 @@
+module Umbrella {
+ header "umbrella.h"
+ export *
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/second.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/second.m
new file mode 100644
index 00000000000..bce925cb057
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/second.m
@@ -0,0 +1,5 @@
+@import Umbrella;
+int main() {
+ struct S s = getS(); // break here
+ return s.i;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/umbrella.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/umbrella.h
new file mode 100644
index 00000000000..375d3ea2a04
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules-update/umbrella.h
@@ -0,0 +1 @@
+@import Foo;
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules/Makefile
new file mode 100644
index 00000000000..37dd8f40a9d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules/Makefile
@@ -0,0 +1,6 @@
+OBJC_SOURCES := main.m
+
+
+
+LD_EXTRAS := -framework Foundation
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py
new file mode 100644
index 00000000000..695eac9ee85
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py
@@ -0,0 +1,79 @@
+"""Test that importing modules in Objective-C works as expected."""
+
+
+
+import unittest2
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ObjCModulesTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ 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.')
+
+ @skipUnlessDarwin
+ @skipIf(macos_version=["<", "10.12"])
+ def test_expr(self):
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break inside the foo function which takes a bar_ptr argument.
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ 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'])
+
+ self.expect("expr @import Darwin; 3", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["int", "3"])
+
+ self.expect("expr getpid()", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["pid_t"])
+
+ self.expect(
+ "expr @import Foundation; 4",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "int",
+ "4"])
+
+ # Type lookup should still work and print something reasonable
+ # for types from the module.
+ self.expect("type lookup NSObject", substrs=["instanceMethod"])
+
+ self.expect("expr string.length", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["NSUInteger", "5"])
+
+ self.expect("expr array.count", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["NSUInteger", "3"])
+
+ self.expect(
+ "p *[NSURL URLWithString:@\"http://lldb.llvm.org\"]",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "NSURL",
+ "isa",
+ "_urlString"])
+
+ self.expect(
+ "p [NSURL URLWithString:@\"http://lldb.llvm.org\"].scheme",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["http"])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules/main.m
new file mode 100644
index 00000000000..99b50f9620d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/modules/main.m
@@ -0,0 +1,12 @@
+#import <Foundation/Foundation.h>
+
+int main()
+{
+ @autoreleasepool
+ {
+ NSString *string = @"Hello";
+ NSArray *array = @[ @1, @2, @3 ];
+
+ NSLog(@"Stop here"); // Set breakpoint 0 here.
+ }
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc++/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc++/Makefile
new file mode 100644
index 00000000000..e8a4b0cc29c
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc++/Makefile
@@ -0,0 +1,4 @@
+OBJCXX_SOURCES := main.mm
+LD_EXTRAS = -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc++/TestObjCXX.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc++/TestObjCXX.py
new file mode 100644
index 00000000000..344af99f589
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc++/TestObjCXX.py
@@ -0,0 +1,33 @@
+"""
+Make sure that ivars of Objective-C++ classes are visible in LLDB.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ObjCXXTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ def test_break(self):
+ """Test ivars of Objective-C++ classes"""
+ if self.getArchitecture() == 'i386':
+ self.skipTest("requires Objective-C 2.0 runtime")
+
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_source_regexp(
+ self, 'breakpoint 1', num_expected_locations=1)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ self.expect("expr f->f", "Found ivar in class",
+ substrs=["= 3"])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc++/main.mm b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc++/main.mm
new file mode 100644
index 00000000000..50d2f0a8df3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc++/main.mm
@@ -0,0 +1,19 @@
+#include <Foundation/NSObject.h>
+
+@interface F : NSObject
+@end
+
+@implementation F
+{
+@public
+ int f;
+}
+
+@end
+
+int main(int argc, char* argv[])
+{
+ F* f = [F new];
+ f->f = 3;
+ return 0; // breakpoint 1
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/Makefile
new file mode 100644
index 00000000000..ad28ecfeb5d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := main.m
+LD_EXTRAS = -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py
new file mode 100644
index 00000000000..8f974f03838
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py
@@ -0,0 +1,64 @@
+"""
+Use lldb Python API to test base class resolution for ObjC classes
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ObjCDynamicValueTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ self.line = line_number('main.m', '// Set breakpoint here.')
+
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ def test_get_baseclass(self):
+ """Test fetching ObjC dynamic values."""
+ if self.getArchitecture() == 'i386':
+ # rdar://problem/9946499
+ self.skipTest("Dynamic types for ObjC V1 runtime not implemented")
+
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ # Create a target from the debugger.
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Set up our breakpoints:
+
+ target.BreakpointCreateByLocation('main.m', self.line)
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ self.assertTrue(process.GetState() == lldb.eStateStopped,
+ PROCESS_STOPPED)
+
+ var = self.frame().FindVariable("foo")
+ var_ptr_type = var.GetType()
+ var_pte_type = var_ptr_type.GetPointeeType()
+ self.assertTrue(
+ var_ptr_type.GetNumberOfDirectBaseClasses() == 1,
+ "Foo * has one base class")
+ self.assertTrue(
+ var_pte_type.GetNumberOfDirectBaseClasses() == 1,
+ "Foo has one base class")
+
+ self.assertTrue(var_ptr_type.GetDirectBaseClassAtIndex(
+ 0).IsValid(), "Foo * has a valid base class")
+ self.assertTrue(var_pte_type.GetDirectBaseClassAtIndex(
+ 0).IsValid(), "Foo * has a valid base class")
+
+ self.assertTrue(var_ptr_type.GetDirectBaseClassAtIndex(0).GetName() == var_pte_type.GetDirectBaseClassAtIndex(
+ 0).GetName(), "Foo and its pointer type don't agree on their base class")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/main.m
new file mode 100644
index 00000000000..3ec78fd0bd6
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/main.m
@@ -0,0 +1,22 @@
+#import <Foundation/Foundation.h>
+
+@interface Foo : NSObject {}
+
+-(id) init;
+
+@end
+
+@implementation Foo
+
+-(id) init
+{
+ return self = [super init];
+}
+@end
+int main ()
+{
+ Foo *foo = [Foo new];
+ NSLog(@"a"); // Set breakpoint here.
+ return 0;
+}
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/Makefile
new file mode 100644
index 00000000000..99998b20bcb
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py
new file mode 100644
index 00000000000..d07b827e771
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py
@@ -0,0 +1,61 @@
+"""Test that the expression parser doesn't get confused by 'id' and 'Class'"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestObjCBuiltinTypes(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers to break inside main().
+ self.main_source = "main.cpp"
+ self.break_line = line_number(
+ self.main_source, '// Set breakpoint here.')
+
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ #<rdar://problem/10591460> [regression] Can't print ivar value: error: reference to 'id' is ambiguous
+ def test_with_python_api(self):
+ """Test expression parser respect for ObjC built-in types."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ bpt = target.BreakpointCreateByLocation(
+ self.main_source, self.break_line)
+ self.assertTrue(bpt, VALID_BREAKPOINT)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt)
+
+ # Make sure we stopped at the first breakpoint.
+ self.assertTrue(
+ len(thread_list) != 0,
+ "No thread stopped at our breakpoint.")
+ self.assertTrue(len(thread_list) == 1,
+ "More than one thread stopped at our breakpoint.")
+
+ # Now make sure we can call a function in the class method we've
+ # stopped in.
+ frame = thread_list[0].GetFrameAtIndex(0)
+ self.assertTrue(frame, "Got a valid frame 0 frame.")
+
+ self.expect("expr (foo)", patterns=["\(ns::id\) \$.* = 0"])
+
+ self.expect("expr id my_id = 0; my_id", patterns=["\(id\) \$.* = nil"])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/main.cpp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/main.cpp
new file mode 100644
index 00000000000..6dd8cbc6e9f
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/main.cpp
@@ -0,0 +1,9 @@
+namespace ns {
+ typedef int id;
+};
+
+int main()
+{
+ ns::id foo = 0;
+ return foo; // Set breakpoint here.
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-checker/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-checker/Makefile
new file mode 100644
index 00000000000..afecbf96948
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-checker/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := main.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-checker/TestObjCCheckers.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-checker/TestObjCCheckers.py
new file mode 100644
index 00000000000..ac2dc2a3899
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-checker/TestObjCCheckers.py
@@ -0,0 +1,90 @@
+"""
+Use lldb Python API to make sure the dynamic checkers are doing their jobs.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ObjCCheckerTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ # Find the line number to break for main.c.
+ self.source_name = 'main.m'
+
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ def test_objc_checker(self):
+ """Test that checkers catch unrecognized selectors"""
+ if self.getArchitecture() == 'i386':
+ self.skipTest("requires Objective-C 2.0 runtime")
+
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ # Create a target from the debugger.
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Set up our breakpoints:
+
+ main_bkpt = target.BreakpointCreateBySourceRegex(
+ "Set a breakpoint here.", lldb.SBFileSpec(self.source_name))
+ self.assertTrue(main_bkpt and
+ main_bkpt.GetNumLocations() == 1,
+ VALID_BREAKPOINT)
+
+ # Now launch the process, and do not stop at the entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ self.assertTrue(process.GetState() == lldb.eStateStopped,
+ PROCESS_STOPPED)
+
+ threads = lldbutil.get_threads_stopped_at_breakpoint(
+ process, main_bkpt)
+ self.assertTrue(len(threads) == 1)
+ thread = threads[0]
+
+ #
+ # The class Simple doesn't have a count method. Make sure that we don't
+ # actually try to send count but catch it as an unrecognized selector.
+
+ frame = thread.GetFrameAtIndex(0)
+ expr_value = frame.EvaluateExpression("(int) [my_simple count]", False)
+ expr_error = expr_value.GetError()
+
+ self.assertTrue(expr_error.Fail())
+
+ # Make sure the call produced no NSLog stdout.
+ stdout = process.GetSTDOUT(100)
+ self.assertTrue(stdout is None or (len(stdout) == 0))
+
+ # Make sure the error is helpful:
+ err_string = expr_error.GetCString()
+ self.assertTrue("selector" in err_string)
+
+ #
+ # Check that we correctly insert the checker for an
+ # ObjC method with the struct return convention.
+ # Getting this wrong would cause us to call the checker
+ # with the wrong arguments, and the checker would crash
+ # So I'm just checking "expression runs successfully" here:
+ #
+ expr_value = frame.EvaluateExpression("[my_simple getBigStruct]", False)
+ expr_error = expr_value.GetError()
+
+ self.assertTrue(expr_error.Success())
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-checker/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-checker/main.m
new file mode 100644
index 00000000000..de73e688f25
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-checker/main.m
@@ -0,0 +1,47 @@
+#import <Foundation/Foundation.h>
+
+// This should be a big enough struct that it will force
+// the struct return convention:
+typedef struct BigStruct {
+ float a, b, c, d, e, f, g, h, i, j, k, l;
+} BigStruct;
+
+
+@interface Simple : NSObject
+{
+ int _value;
+}
+- (int) value;
+- (void) setValue: (int) newValue;
+- (BigStruct) getBigStruct;
+@end
+
+@implementation Simple
+- (int) value
+{
+ return _value;
+}
+
+- (void) setValue: (int) newValue
+{
+ _value = newValue;
+}
+
+- (BigStruct) getBigStruct
+{
+ BigStruct big_struct = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0,
+ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0};
+ return big_struct;
+}
+@end
+
+int main ()
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ Simple *my_simple = [[Simple alloc] init];
+ my_simple.value = 20;
+ // Set a breakpoint here.
+ NSLog (@"Object has value: %d.", my_simple.value);
+ [pool drain];
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-class-method/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-class-method/Makefile
new file mode 100644
index 00000000000..e6db3dee37b
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-class-method/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := class.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-class-method/TestObjCClassMethod.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-class-method/TestObjCClassMethod.py
new file mode 100644
index 00000000000..46cddd635c0
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-class-method/TestObjCClassMethod.py
@@ -0,0 +1,66 @@
+"""Test calling functions in class methods."""
+
+from __future__ import print_function
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestObjCClassMethod(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers to break inside main().
+ self.main_source = "class.m"
+ self.break_line = line_number(
+ self.main_source, '// Set breakpoint here.')
+
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ def test_with_python_api(self):
+ """Test calling functions in class methods."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ bpt = target.BreakpointCreateByLocation(
+ self.main_source, self.break_line)
+ self.assertTrue(bpt, VALID_BREAKPOINT)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt)
+
+ # Make sure we stopped at the first breakpoint.
+ self.assertTrue(
+ len(thread_list) != 0,
+ "No thread stopped at our breakpoint.")
+ self.assertTrue(len(thread_list) == 1,
+ "More than one thread stopped at our breakpoint.")
+
+ # Now make sure we can call a function in the class method we've
+ # stopped in.
+ frame = thread_list[0].GetFrameAtIndex(0)
+ self.assertTrue(frame, "Got a valid frame 0 frame.")
+
+ cmd_value = frame.EvaluateExpression(
+ "(int)[Foo doSomethingWithString:@\"Hello\"]")
+ if self.TraceOn():
+ if cmd_value.IsValid():
+ print("cmd_value is valid")
+ print("cmd_value has the value %d" % cmd_value.GetValueAsUnsigned())
+ self.assertTrue(cmd_value.IsValid())
+ self.assertTrue(cmd_value.GetValueAsUnsigned() == 5)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-class-method/class.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-class-method/class.m
new file mode 100644
index 00000000000..18a2c2729be
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-class-method/class.m
@@ -0,0 +1,24 @@
+#import <Foundation/Foundation.h>
+
+@interface Foo : NSObject
++(int) doSomethingWithString: (NSString *) string;
+-(int) doSomethingInstance: (NSString *) string;
+@end
+
+@implementation Foo
++(int) doSomethingWithString: (NSString *) string
+{
+ NSLog (@"String is: %@.", string);
+ return [string length];
+}
+
+-(int) doSomethingInstance: (NSString *)string
+{
+ return [Foo doSomethingWithString:string];
+}
+@end
+
+int main()
+{
+ return 0; // Set breakpoint here.
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/.categories b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/.categories
new file mode 100644
index 00000000000..9526bab96fb
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/.categories
@@ -0,0 +1 @@
+dyntype
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/Makefile
new file mode 100644
index 00000000000..9ff3ce6e4a5
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/Makefile
@@ -0,0 +1,5 @@
+OBJC_SOURCES := main.m
+
+include Makefile.rules
+
+LD_EXTRAS = -framework Foundation
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py
new file mode 100644
index 00000000000..1851bc33264
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py
@@ -0,0 +1,90 @@
+"""
+Test that we are able to properly report a usable dynamic type
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipUnlessDarwin
+class ObjCDynamicSBTypeTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ 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.')
+
+ @skipIf(archs="i[3-6]86")
+ def test_dyn(self):
+ """Test that we are able to properly report a usable dynamic type."""
+ d = {'EXE': self.exe_name}
+ self.build(dictionary=d)
+ self.setTearDownCleanup(dictionary=d)
+
+ exe = self.getBuildArtifact(self.exe_name)
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ self.main_source,
+ self.line,
+ num_expected_locations=1,
+ loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ 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")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/main.m
new file mode 100644
index 00000000000..f3587b52cd5
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/main.m
@@ -0,0 +1,53 @@
+#import <Foundation/Foundation.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];
+ NSObject* object = [[MyDerivedClass alloc] init];
+ MyBaseClass* base = [[MyDerivedClass alloc] init];
+ [pool release]; // Set breakpoint here.
+ return 0;
+}
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/Makefile
new file mode 100644
index 00000000000..a34977712c3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := dynamic-value.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
new file mode 100644
index 00000000000..5a6ec4ed39d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
@@ -0,0 +1,207 @@
+"""
+Use lldb Python API to test dynamic values in ObjC
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ObjCDynamicValueTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ # Find the line number to break for main.c.
+
+ self.source_name = 'dynamic-value.m'
+ self.set_property_line = line_number(
+ self.source_name,
+ '// This is the line in setProperty, make sure we step to here.')
+ self.handle_SourceBase = line_number(
+ self.source_name, '// Break here to check dynamic values.')
+ self.main_before_setProperty_line = line_number(
+ self.source_name, '// Break here to see if we can step into real method.')
+
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ @expectedFailureDarwin("llvm.org/pr20271 rdar://18684107")
+ def test_get_objc_dynamic_vals(self):
+ """Test fetching ObjC dynamic values."""
+ if self.getArchitecture() == 'i386':
+ # rdar://problem/9946499
+ self.skipTest("Dynamic types for ObjC V1 runtime not implemented")
+
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ # Create a target from the debugger.
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Set up our breakpoints:
+
+ handle_SourceBase_bkpt = target.BreakpointCreateByLocation(
+ self.source_name, self.handle_SourceBase)
+ self.assertTrue(handle_SourceBase_bkpt and
+ handle_SourceBase_bkpt.GetNumLocations() == 1,
+ VALID_BREAKPOINT)
+
+ main_before_setProperty_bkpt = target.BreakpointCreateByLocation(
+ self.source_name, self.main_before_setProperty_line)
+ self.assertTrue(main_before_setProperty_bkpt and
+ main_before_setProperty_bkpt.GetNumLocations() == 1,
+ VALID_BREAKPOINT)
+
+ # Now launch the process, and do not stop at the entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ self.assertTrue(process.GetState() == lldb.eStateStopped,
+ PROCESS_STOPPED)
+
+ threads = lldbutil.get_threads_stopped_at_breakpoint(
+ process, main_before_setProperty_bkpt)
+ self.assertTrue(len(threads) == 1)
+ thread = threads[0]
+
+ #
+ # At this point, myObserver has a Source pointer that is actually a KVO swizzled SourceDerived
+ # make sure we can get that properly:
+
+ frame = thread.GetFrameAtIndex(0)
+ myObserver = frame.FindVariable(
+ 'myObserver', lldb.eDynamicCanRunTarget)
+ self.assertTrue(myObserver)
+ myObserver_source = myObserver.GetChildMemberWithName(
+ '_source', lldb.eDynamicCanRunTarget)
+ self.examine_SourceDerived_ptr(myObserver_source)
+
+ #
+ # Make sure a static value can be correctly turned into a dynamic
+ # value.
+
+ frame = thread.GetFrameAtIndex(0)
+ myObserver_static = frame.FindVariable(
+ 'myObserver', lldb.eNoDynamicValues)
+ self.assertTrue(myObserver_static)
+ myObserver = myObserver_static.GetDynamicValue(
+ lldb.eDynamicCanRunTarget)
+ myObserver_source = myObserver.GetChildMemberWithName(
+ '_source', lldb.eDynamicCanRunTarget)
+ self.examine_SourceDerived_ptr(myObserver_source)
+
+ # The "frame var" code uses another path to get into children, so let's
+ # make sure that works as well:
+
+ result = lldb.SBCommandReturnObject()
+
+ self.expect(
+ 'frame var -d run-target myObserver->_source',
+ 'frame var finds its way into a child member',
+ patterns=['\(SourceDerived \*\)'])
+
+ # check that our ObjC GetISA() does a good job at hiding KVO swizzled
+ # classes
+
+ self.expect(
+ 'frame var -d run-target myObserver->_source -T',
+ 'the KVO-ed class is hidden',
+ substrs=['SourceDerived'])
+
+ self.expect(
+ 'frame var -d run-target myObserver->_source -T',
+ 'the KVO-ed class is hidden',
+ matching=False,
+ substrs=['NSKVONotify'])
+
+ # This test is not entirely related to the main thrust of this test case, but since we're here,
+ # try stepping into setProperty, and make sure we get into the version
+ # in Source:
+
+ thread.StepInto()
+
+ threads = lldbutil.get_stopped_threads(
+ process, lldb.eStopReasonPlanComplete)
+ self.assertTrue(len(threads) == 1)
+ line_entry = threads[0].GetFrameAtIndex(0).GetLineEntry()
+
+ self.assertEqual(line_entry.GetLine(), self.set_property_line)
+ self.assertEqual(
+ line_entry.GetFileSpec().GetFilename(),
+ self.source_name)
+
+ # Okay, back to the main business. Continue to the handle_SourceBase
+ # and make sure we get the correct dynamic value.
+
+ threads = lldbutil.continue_to_breakpoint(
+ process, handle_SourceBase_bkpt)
+ self.assertTrue(len(threads) == 1)
+ thread = threads[0]
+
+ frame = thread.GetFrameAtIndex(0)
+
+ # Get "object" using FindVariable:
+
+ noDynamic = lldb.eNoDynamicValues
+ useDynamic = lldb.eDynamicCanRunTarget
+
+ object_static = frame.FindVariable('object', noDynamic)
+ object_dynamic = frame.FindVariable('object', useDynamic)
+
+ # Delete this object to make sure that this doesn't cause havoc with
+ # the dynamic object that depends on it.
+ del (object_static)
+
+ self.examine_SourceDerived_ptr(object_dynamic)
+
+ # Get "this" using FindValue, make sure that works too:
+ object_static = frame.FindValue(
+ 'object', lldb.eValueTypeVariableArgument, noDynamic)
+ object_dynamic = frame.FindValue(
+ 'object', lldb.eValueTypeVariableArgument, useDynamic)
+ del (object_static)
+ self.examine_SourceDerived_ptr(object_dynamic)
+
+ # Get "this" using the EvaluateExpression:
+ object_static = frame.EvaluateExpression('object', noDynamic)
+ object_dynamic = frame.EvaluateExpression('object', useDynamic)
+ del (object_static)
+ self.examine_SourceDerived_ptr(object_dynamic)
+
+ # Continue again to the handle_SourceBase and make sure we get the correct dynamic value.
+ # This one looks exactly the same, but in fact this is an "un-KVO'ed" version of SourceBase, so
+ # its isa pointer points to SourceBase not NSKVOSourceBase or
+ # whatever...
+
+ threads = lldbutil.continue_to_breakpoint(
+ process, handle_SourceBase_bkpt)
+ self.assertTrue(len(threads) == 1)
+ thread = threads[0]
+
+ frame = thread.GetFrameAtIndex(0)
+
+ # Get "object" using FindVariable:
+
+ object_static = frame.FindVariable('object', noDynamic)
+ object_dynamic = frame.FindVariable('object', useDynamic)
+
+ # Delete this object to make sure that this doesn't cause havoc with
+ # the dynamic object that depends on it.
+ del (object_static)
+
+ self.examine_SourceDerived_ptr(object_dynamic)
+
+ def examine_SourceDerived_ptr(self, object):
+ self.assertTrue(object)
+ self.assertTrue(object.GetTypeName().find('SourceDerived') != -1)
+ derivedValue = object.GetChildMemberWithName('_derivedValue')
+ self.assertTrue(derivedValue)
+ self.assertTrue(int(derivedValue.GetValue(), 0) == 30)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/dynamic-value.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/dynamic-value.m
new file mode 100644
index 00000000000..2bcb76b1d9d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/dynamic-value.m
@@ -0,0 +1,147 @@
+#import <Foundation/Foundation.h>
+
+// SourceBase will be the base class of Source. We'll pass a Source object into a
+// function as a SourceBase, and then see if the dynamic typing can get us through the KVO
+// goo and all the way back to Source.
+
+@interface SourceBase: NSObject
+{
+ uint32_t _value;
+}
+- (SourceBase *) init;
+- (uint32_t) getValue;
+@end
+
+@implementation SourceBase
+- (SourceBase *) init
+{
+ [super init];
+ _value = 10;
+ return self;
+}
+- (uint32_t) getValue
+{
+ return _value;
+}
+@end
+
+// Source is a class that will be observed by the Observer class below.
+// When Observer sets itself up to observe this property (in initWithASource)
+// the KVO system will overwrite the "isa" pointer of the object with the "kvo'ed"
+// one.
+
+@interface Source : SourceBase
+{
+ int _property;
+}
+- (Source *) init;
+- (void) setProperty: (int) newValue;
+@end
+
+@implementation Source
+- (Source *) init
+{
+ [super init];
+ _property = 20;
+ return self;
+}
+- (void) setProperty: (int) newValue
+{
+ _property = newValue; // This is the line in setProperty, make sure we step to here.
+}
+@end
+
+@interface SourceDerived : Source
+{
+ int _derivedValue;
+}
+- (SourceDerived *) init;
+- (uint32_t) getValue;
+@end
+
+@implementation SourceDerived
+- (SourceDerived *) init
+{
+ [super init];
+ _derivedValue = 30;
+ return self;
+}
+- (uint32_t) getValue
+{
+ return _derivedValue;
+}
+@end
+
+// Observer is the object that will watch Source and cause KVO to swizzle it...
+
+@interface Observer : NSObject
+{
+ Source *_source;
+}
++ (Observer *) observerWithSource: (Source *) source;
+- (Observer *) initWithASource: (Source *) source;
+- (void) observeValueForKeyPath: (NSString *) path
+ ofObject: (id) object
+ change: (NSDictionary *) change
+ context: (void *) context;
+@end
+
+@implementation Observer
+
++ (Observer *) observerWithSource: (Source *) inSource;
+{
+ Observer *retval;
+
+ retval = [[Observer alloc] initWithASource: inSource];
+ return retval;
+}
+
+- (Observer *) initWithASource: (Source *) source
+{
+ [super init];
+ _source = source;
+ [_source addObserver: self
+ forKeyPath: @"property"
+ options: (NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld)
+ context: NULL];
+ return self;
+}
+
+- (void) observeValueForKeyPath: (NSString *) path
+ ofObject: (id) object
+ change: (NSDictionary *) change
+ context: (void *) context
+{
+ printf ("Observer function called.\n");
+ return;
+}
+@end
+
+uint32_t
+handle_SourceBase (SourceBase *object)
+{
+ return [object getValue]; // Break here to check dynamic values.
+}
+
+int main ()
+{
+ Source *mySource;
+ Observer *myObserver;
+
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+ mySource = [[SourceDerived alloc] init];
+ myObserver = [Observer observerWithSource: mySource];
+
+ [mySource setProperty: 5]; // Break here to see if we can step into real method.
+
+ uint32_t return_value = handle_SourceBase (mySource);
+
+ SourceDerived *unwatchedSource = [[SourceDerived alloc] init];
+
+ return_value = handle_SourceBase (unwatchedSource);
+
+ [pool release];
+ return 0;
+
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-foundation-dictionary-empty/TestNSDictionary0.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-foundation-dictionary-empty/TestNSDictionary0.py
new file mode 100644
index 00000000000..562d9ae01e2
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-foundation-dictionary-empty/TestNSDictionary0.py
@@ -0,0 +1,7 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(
+ __file__, globals(), [
+ decorators.skipIfFreeBSD, decorators.skipIfLinux,
+ decorators.skipIfWindows, decorators.skipIfNetBSD])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-foundation-dictionary-empty/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-foundation-dictionary-empty/main.m
new file mode 100644
index 00000000000..14a792b3776
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-foundation-dictionary-empty/main.m
@@ -0,0 +1,7 @@
+#import <Foundation/Foundation.h>
+
+int main(void)
+{
+ NSDictionary *emptyDictionary = [[NSDictionary alloc] init];
+ return 0; //% self.expect("frame var emptyDictionary", substrs = ["0 key/value pairs"]);
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/Makefile
new file mode 100644
index 00000000000..5408f4199f2
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := objc-ivar-offsets.m main.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py
new file mode 100644
index 00000000000..749c7137dc9
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py
@@ -0,0 +1,83 @@
+"""Test printing ObjC objects that use unbacked properties - so that the static ivar offsets are incorrect."""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestObjCIvarOffsets(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers to break inside main().
+ self.main_source = "main.m"
+ self.stop_line = line_number(
+ self.main_source, '// Set breakpoint here.')
+
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ def test_with_python_api(self):
+ """Test printing ObjC objects that use unbacked properties"""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ breakpoint = target.BreakpointCreateByLocation(
+ self.main_source, self.stop_line)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
+
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertTrue(process, "Created a process.")
+ self.assertTrue(
+ process.GetState() == lldb.eStateStopped,
+ "Stopped it too.")
+
+ thread_list = lldbutil.get_threads_stopped_at_breakpoint(
+ process, breakpoint)
+ self.assertTrue(len(thread_list) == 1)
+ thread = thread_list[0]
+
+ frame = thread.GetFrameAtIndex(0)
+ self.assertTrue(frame, "frame 0 is valid")
+
+ mine = thread.GetFrameAtIndex(0).FindVariable("mine")
+ self.assertTrue(mine, "Found local variable mine.")
+
+ # Test the value object value for BaseClass->_backed_int
+
+ error = lldb.SBError()
+
+ mine_backed_int = mine.GetChildMemberWithName("_backed_int")
+ self.assertTrue(
+ mine_backed_int,
+ "Found mine->backed_int local variable.")
+ backed_value = mine_backed_int.GetValueAsSigned(error)
+ self.assertTrue(error.Success())
+ self.assertTrue(backed_value == 1111)
+
+ # Test the value object value for DerivedClass->_derived_backed_int
+
+ mine_derived_backed_int = mine.GetChildMemberWithName(
+ "_derived_backed_int")
+ self.assertTrue(mine_derived_backed_int,
+ "Found mine->derived_backed_int local variable.")
+ derived_backed_value = mine_derived_backed_int.GetValueAsSigned(error)
+ self.assertTrue(error.Success())
+ self.assertTrue(derived_backed_value == 3333)
+
+ # Make sure we also get bit-field offsets correct:
+
+ mine_flag2 = mine.GetChildMemberWithName("flag2")
+ self.assertTrue(mine_flag2, "Found mine->flag2 local variable.")
+ flag2_value = mine_flag2.GetValueAsUnsigned(error)
+ self.assertTrue(error.Success())
+ self.assertTrue(flag2_value == 7)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/main.m
new file mode 100644
index 00000000000..41943f48aef
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/main.m
@@ -0,0 +1,15 @@
+#include "objc-ivar-offsets.h"
+
+int
+main ()
+{
+ DerivedClass *mine = [[DerivedClass alloc] init];
+ mine.backed_int = 1111;
+ mine.unbacked_int = 2222;
+ mine.derived_backed_int = 3333;
+ mine.derived_unbacked_int = 4444;
+ mine->flag1 = 1;
+ mine->flag2 = 7;
+
+ return 0; // Set breakpoint here.
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.h
new file mode 100644
index 00000000000..99bbd427b06
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.h
@@ -0,0 +1,27 @@
+#import <Foundation/Foundation.h>
+
+@interface BaseClass : NSObject
+{
+ int _backed_int;
+#if !__OBJC2__
+ int _unbacked_int;
+#endif
+}
+@property int backed_int;
+@property int unbacked_int;
+@end
+
+@interface DerivedClass : BaseClass
+{
+ int _derived_backed_int;
+#if !__OBJC2__
+ int _derived_unbacked_int;
+#endif
+ @public
+ uint32_t flag1 : 1;
+ uint32_t flag2 : 3;
+}
+
+@property int derived_backed_int;
+@property int derived_unbacked_int;
+@end
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.m
new file mode 100644
index 00000000000..db87adea3d1
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.m
@@ -0,0 +1,19 @@
+#import "objc-ivar-offsets.h"
+
+@implementation BaseClass
+@synthesize backed_int = _backed_int;
+#if __OBJC2__
+@synthesize unbacked_int;
+#else
+@synthesize unbacked_int = _unbacked_int;
+#endif
+@end
+
+@implementation DerivedClass
+@synthesize derived_backed_int = _derived_backed_int;
+#if __OBJC2__
+@synthesize derived_unbacked_int;
+#else
+@synthesize derived_unbacked_int = _derived_unbacked_int;
+#endif
+@end
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-protocols/TestIvarProtocols.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-protocols/TestIvarProtocols.py
new file mode 100644
index 00000000000..562d9ae01e2
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-protocols/TestIvarProtocols.py
@@ -0,0 +1,7 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(
+ __file__, globals(), [
+ decorators.skipIfFreeBSD, decorators.skipIfLinux,
+ decorators.skipIfWindows, decorators.skipIfNetBSD])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-protocols/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-protocols/main.m
new file mode 100644
index 00000000000..aa6c4715c33
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-protocols/main.m
@@ -0,0 +1,33 @@
+#import <Foundation/Foundation.h>
+
+@protocol MyProtocol
+-(void)aMethod;
+@end
+
+@interface MyClass : NSObject {
+ id <MyProtocol> myId;
+ NSObject <MyProtocol> *myObject;
+};
+
+-(void)doSomething;
+
+@end
+
+@implementation MyClass
+
+-(void)doSomething
+{
+ NSLog(@"Hello"); //% self.expect("expression -- myId", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["id"]);
+ //% self.expect("expression -- myObject", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["NSObject"]);
+}
+
+@end
+
+int main ()
+{
+ @autoreleasepool
+ {
+ MyClass *c = [MyClass alloc];
+ [c doSomething];
+ }
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/Makefile
new file mode 100644
index 00000000000..a218ce37e61
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/Makefile
@@ -0,0 +1,13 @@
+OBJC_SOURCES := main.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+all: a.out.stripped
+
+a.out.stripped: a.out.dSYM
+ strip -o a.out.stripped a.out
+
+clean::
+ rm -f a.out.stripped
+ rm -rf a.out.stripped.dSYM
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py
new file mode 100644
index 00000000000..12a22f6b903
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py
@@ -0,0 +1,67 @@
+"""Test printing ObjC objects that use unbacked properties - so that the static ivar offsets are incorrect."""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestObjCIvarStripped(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers to break inside main().
+ self.main_source = "main.m"
+ self.stop_line = line_number(
+ self.main_source, '// Set breakpoint here.')
+
+ @skipUnlessDarwin
+ @skipIf(
+ debug_info=no_match("dsym"),
+ bugnumber="This test requires a stripped binary and a dSYM")
+ @add_test_categories(['pyapi'])
+ def test_with_python_api(self):
+ """Test that we can find stripped Objective-C ivars in the runtime"""
+ self.build()
+ exe = self.getBuildArtifact("a.out.stripped")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ self.dbg.HandleCommand("add-dsym "+self.getBuildArtifact("a.out.dSYM"))
+
+ breakpoint = target.BreakpointCreateByLocation(
+ self.main_source, self.stop_line)
+ self.assertTrue(
+ breakpoint.IsValid() and breakpoint.GetNumLocations() > 0,
+ VALID_BREAKPOINT)
+
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertTrue(process, "Created a process.")
+ self.assertTrue(
+ process.GetState() == lldb.eStateStopped,
+ "Stopped it too.")
+
+ thread_list = lldbutil.get_threads_stopped_at_breakpoint(
+ process, breakpoint)
+ self.assertTrue(len(thread_list) == 1)
+ thread = thread_list[0]
+
+ frame = thread.GetFrameAtIndex(0)
+ self.assertTrue(frame, "frame 0 is valid")
+
+ # Test the expression for mc->_foo
+
+ error = lldb.SBError()
+
+ ivar = frame.EvaluateExpression("(mc->_foo)")
+ self.assertTrue(ivar, "Got result for mc->_foo")
+ ivar_value = ivar.GetValueAsSigned(error)
+ self.assertTrue(error.Success())
+ self.assertTrue(ivar_value == 3)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/main.m
new file mode 100644
index 00000000000..ed9c1d9ec42
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/main.m
@@ -0,0 +1,33 @@
+#import <Foundation/Foundation.h>
+
+@interface MyClass : NSObject {
+@public
+ int _foo;
+};
+
+-(id)init;
+@end
+
+@implementation MyClass
+
+-(id)init
+{
+ if ([super init])
+ {
+ _foo = 3;
+ }
+
+ return self;
+}
+
+@end
+
+int main ()
+{
+ @autoreleasepool
+ {
+ MyClass *mc = [[MyClass alloc] init];
+
+ NSLog(@"%d", mc->_foo); // Set breakpoint here.
+ }
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/Makefile
new file mode 100644
index 00000000000..37dd8f40a9d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/Makefile
@@ -0,0 +1,6 @@
+OBJC_SOURCES := main.m
+
+
+
+LD_EXTRAS := -framework Foundation
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/ObjCNewSyntaxTest.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/ObjCNewSyntaxTest.py
new file mode 100644
index 00000000000..5fa9336b731
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/ObjCNewSyntaxTest.py
@@ -0,0 +1,29 @@
+"""Test that the Objective-C syntax for dictionary/array literals and indexing works"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ObjCNewSyntaxTest(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def runToBreakpoint(self):
+ self.build()
+ self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+ self, '// Set breakpoint 0 here.', lldb.SBFileSpec(
+ 'main.m', False))
+
+ # 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'])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntaxArray.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntaxArray.py
new file mode 100644
index 00000000000..cf638c7a108
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntaxArray.py
@@ -0,0 +1,58 @@
+"""Test that the Objective-C syntax for dictionary/array literals and indexing works"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+from ObjCNewSyntaxTest import ObjCNewSyntaxTest
+
+
+class ObjCNewSyntaxTestCaseArray(ObjCNewSyntaxTest):
+
+ @skipUnlessDarwin
+ @skipIf(macos_version=["<", "10.12"])
+ @expectedFailureAll(archs=["i[3-6]86"])
+ def test_read_array(self):
+ self.runToBreakpoint()
+
+ self.expect(
+ "expr --object-description -- immutable_array[0]",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["foo"])
+
+ self.expect(
+ "expr --object-description -- mutable_array[0]",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["foo"])
+
+ @skipUnlessDarwin
+ @skipIf(macos_version=["<", "10.12"])
+ @expectedFailureAll(archs=["i[3-6]86"])
+ def test_update_array(self):
+ self.runToBreakpoint()
+
+ self.expect(
+ "expr --object-description -- mutable_array[0] = @\"bar\"",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["bar"])
+
+ self.expect(
+ "expr --object-description -- mutable_array[0]",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["bar"])
+
+ @skipUnlessDarwin
+ @skipIf(macos_version=["<", "10.12"])
+ @expectedFailureAll(archs=["i[3-6]86"])
+ def test_array_literal(self):
+ self.runToBreakpoint()
+
+ self.expect(
+ "expr --object-description -- @[ @\"foo\", @\"bar\" ]",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "NSArray",
+ "foo",
+ "bar"])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntaxDictionary.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntaxDictionary.py
new file mode 100644
index 00000000000..5291b46da2f
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntaxDictionary.py
@@ -0,0 +1,57 @@
+"""Test that the Objective-C syntax for dictionary/array literals and indexing works"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+from ObjCNewSyntaxTest import ObjCNewSyntaxTest
+
+
+class ObjCNewSyntaxTestCaseDictionary(ObjCNewSyntaxTest):
+
+ @skipUnlessDarwin
+ @skipIf(macos_version=["<", "10.12"])
+ @expectedFailureAll(archs=["i[3-6]86"])
+ def test_read_dictionary(self):
+ self.runToBreakpoint()
+
+ self.expect(
+ "expr --object-description -- immutable_dictionary[@\"key\"]",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["value"])
+
+ self.expect(
+ "expr --object-description -- mutable_dictionary[@\"key\"]",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["value"])
+
+ @skipUnlessDarwin
+ @skipIf(macos_version=["<", "10.12"])
+ @expectedFailureAll(archs=["i[3-6]86"])
+ def test_update_dictionary(self):
+ self.runToBreakpoint()
+
+ self.expect(
+ "expr --object-description -- mutable_dictionary[@\"key\"] = @\"object\"",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["object"])
+
+ self.expect(
+ "expr --object-description -- mutable_dictionary[@\"key\"]",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["object"])
+
+ @skipUnlessDarwin
+ @skipIf(macos_version=["<", "10.12"])
+ @expectedFailureAll(archs=["i[3-6]86"])
+ def test_dictionary_literal(self):
+ self.runToBreakpoint()
+
+ self.expect(
+ "expr --object-description -- @{ @\"key\" : @\"object\" }",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "key",
+ "object"])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntaxLiteral.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntaxLiteral.py
new file mode 100644
index 00000000000..e17343bed72
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntaxLiteral.py
@@ -0,0 +1,78 @@
+"""Test that the Objective-C syntax for dictionary/array literals and indexing works"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+from ObjCNewSyntaxTest import ObjCNewSyntaxTest
+
+
+class ObjCNewSyntaxTestCaseLiteral(ObjCNewSyntaxTest):
+
+ @skipUnlessDarwin
+ @skipIf(macos_version=["<", "10.12"])
+ @expectedFailureAll(archs=["i[3-6]86"])
+ def test_char_literal(self):
+ self.runToBreakpoint()
+
+ self.expect("expr --object-description -- @'a'",
+ VARIABLES_DISPLAYED_CORRECTLY, substrs=[str(ord('a'))])
+
+ @skipUnlessDarwin
+ @skipIf(macos_version=["<", "10.12"])
+ @expectedFailureAll(archs=["i[3-6]86"])
+ def test_integer_literals(self):
+ self.runToBreakpoint()
+
+ self.expect(
+ "expr --object-description -- @1",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["1"])
+
+ self.expect(
+ "expr --object-description -- @1l",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["1"])
+
+ self.expect(
+ "expr --object-description -- @1ul",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["1"])
+
+ self.expect(
+ "expr --object-description -- @1ll",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["1"])
+
+ self.expect(
+ "expr --object-description -- @1ull",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["1"])
+
+ @skipUnlessDarwin
+ @skipIf(macos_version=["<", "10.12"])
+ @expectedFailureAll(archs=["i[3-6]86"])
+ def test_float_literal(self):
+ self.runToBreakpoint()
+
+ self.expect("expr -- @123.45", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["NSNumber", "123.45"])
+
+ @skipUnlessDarwin
+ @skipIf(macos_version=["<", "10.12"])
+ @expectedFailureAll(archs=["i[3-6]86"])
+ def test_expressions_in_literals(self):
+ self.runToBreakpoint()
+
+ self.expect(
+ "expr --object-description -- @( 1 + 3 )",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["4"])
+ self.expect(
+ "expr -- @((char*)\"Hello world\" + 6)",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "NSString",
+ "world"])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/main.m
new file mode 100644
index 00000000000..d77ba5b10de
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/main.m
@@ -0,0 +1,21 @@
+#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];
+
+ NSNumber *one = @1;
+
+ NSLog(@"Stop here"); // Set breakpoint 0 here.
+ }
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-optimized/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-optimized/Makefile
new file mode 100644
index 00000000000..5fb128dcc7e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-optimized/Makefile
@@ -0,0 +1,6 @@
+OBJC_SOURCES := main.m
+
+CFLAGS ?= -arch $(ARCH) -g -O2
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py
new file mode 100644
index 00000000000..6209f14e7e4
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py
@@ -0,0 +1,72 @@
+"""
+Test that objective-c expression parser continues to work for optimized build.
+
+Fixed a bug in the expression parser where the 'this'
+or 'self' variable was not properly read if the compiler
+optimized it into a register.
+"""
+
+
+
+import lldb
+import re
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+# rdar://problem/9087739
+# test failure: objc_optimized does not work for "-C clang -A i386"
+
+
+@skipUnlessDarwin
+class ObjcOptimizedTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ myclass = "MyClass"
+ mymethod = "description"
+ method_spec = "-[%s %s]" % (myclass, mymethod)
+
+ def test_break(self):
+ """Test 'expr member' continues to work for optimized build."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_symbol(
+ self,
+ self.method_spec,
+ num_expected_locations=1,
+ sym_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+ self.expect(
+ "thread backtrace",
+ STOPPED_DUE_TO_BREAKPOINT,
+ substrs=["stop reason = breakpoint"],
+ patterns=[
+ "frame.*0:.*%s %s" %
+ (self.myclass,
+ self.mymethod)])
+
+ self.expect('expression member',
+ startstr="(int) $0 = 5")
+
+ # <rdar://problem/12693963>
+ interp = self.dbg.GetCommandInterpreter()
+ result = lldb.SBCommandReturnObject()
+ interp.HandleCommand('frame variable self', result)
+ output = result.GetOutput()
+
+ desired_pointer = "0x0"
+
+ mo = re.search("0x[0-9a-f]+", output)
+
+ if mo:
+ desired_pointer = mo.group(0)
+
+ self.expect('expression (self)',
+ substrs=[("(%s *) $1 = " % self.myclass), desired_pointer])
+
+ self.expect('expression self->non_member', error=True,
+ substrs=["does not have a member named 'non_member'"])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-optimized/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-optimized/main.m
new file mode 100644
index 00000000000..df88eea0f86
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-optimized/main.m
@@ -0,0 +1,44 @@
+#import <Foundation/Foundation.h>
+
+@interface MyClass : NSObject {
+ int member;
+}
+
+- (id)initWithMember:(int)_member;
+- (NSString*)description;
+@end
+
+@implementation MyClass
+
+- (id)initWithMember:(int)_member
+{
+ if (self = [super init])
+ {
+ member = _member;
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ [super dealloc];
+}
+
+// Set a breakpoint on '-[MyClass description]' and test expressions: expr member
+- (NSString *)description
+{
+ return [NSString stringWithFormat:@"%d", member];
+}
+@end
+
+int main (int argc, char const *argv[])
+{
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+ MyClass *my_object = [[MyClass alloc] initWithMember:5];
+
+ NSLog(@"MyObject %@", [my_object description]);
+
+ [pool release];
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/Makefile
new file mode 100644
index 00000000000..afecbf96948
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := main.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py
new file mode 100644
index 00000000000..3092c3f086a
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py
@@ -0,0 +1,135 @@
+"""
+Use lldb Python API to verify that expression evaluation for property references uses the correct getters and setters
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ObjCPropertyTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ # Find the line number to break for main.c.
+ self.source_name = 'main.m'
+
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ def test_objc_properties(self):
+ """Test that expr uses the correct property getters and setters"""
+ if self.getArchitecture() == 'i386':
+ self.skipTest("requires modern objc runtime")
+
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ # Create a target from the debugger.
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Set up our breakpoints:
+
+ main_bkpt = target.BreakpointCreateBySourceRegex(
+ "Set a breakpoint here.", lldb.SBFileSpec(self.source_name))
+ self.assertTrue(main_bkpt and
+ main_bkpt.GetNumLocations() == 1,
+ VALID_BREAKPOINT)
+
+ # Now launch the process, and do not stop at the entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ self.assertTrue(process.GetState() == lldb.eStateStopped,
+ PROCESS_STOPPED)
+
+ threads = lldbutil.get_threads_stopped_at_breakpoint(
+ process, main_bkpt)
+ self.assertTrue(len(threads) == 1)
+ thread = threads[0]
+ frame = thread.GetFrameAtIndex(0)
+
+ mine = frame.FindVariable("mine")
+ self.assertTrue(mine.IsValid())
+ access_count = mine.GetChildMemberWithName("_access_count")
+ self.assertTrue(access_count.IsValid())
+ start_access_count = access_count.GetValueAsUnsigned(123456)
+ self.assertTrue(start_access_count != 123456)
+
+ #
+ # The first set of tests test calling the getter & setter of
+ # a property that actually only has a getter & setter and no
+ # @property.
+ #
+ nonexistant_value = frame.EvaluateExpression(
+ "mine.nonexistantInt", False)
+ nonexistant_error = nonexistant_value.GetError()
+ self.assertTrue(nonexistant_error.Success())
+ nonexistant_int = nonexistant_value.GetValueAsUnsigned(123456)
+ self.assertTrue(nonexistant_int == 6)
+
+ # Calling the getter function would up the access count, so make sure
+ # that happened.
+
+ new_access_count = access_count.GetValueAsUnsigned(123456)
+ self.assertTrue(new_access_count - start_access_count == 1)
+ start_access_count = new_access_count
+
+ #
+ # Now call the setter, then make sure that
+ nonexistant_change = frame.EvaluateExpression(
+ "mine.nonexistantInt = 10", False)
+ nonexistant_error = nonexistant_change.GetError()
+ self.assertTrue(nonexistant_error.Success())
+
+ # Calling the setter function would up the access count, so make sure
+ # that happened.
+
+ new_access_count = access_count.GetValueAsUnsigned(123456)
+ self.assertTrue(new_access_count - start_access_count == 1)
+ start_access_count = new_access_count
+
+ #
+ # Now we call the getter of a property that is backed by an ivar,
+ # make sure it works and that we actually update the backing ivar.
+ #
+
+ backed_value = frame.EvaluateExpression("mine.backedInt", False)
+ backed_error = backed_value.GetError()
+ self.assertTrue(backed_error.Success())
+ backing_value = mine.GetChildMemberWithName("_backedInt")
+ self.assertTrue(backing_value.IsValid())
+ self.assertTrue(backed_value.GetValueAsUnsigned(12345)
+ == backing_value.GetValueAsUnsigned(23456))
+
+ unbacked_value = frame.EvaluateExpression("mine.unbackedInt", False)
+ unbacked_error = unbacked_value.GetError()
+ self.assertTrue(unbacked_error.Success())
+
+ idWithProtocol_value = frame.EvaluateExpression(
+ "mine.idWithProtocol", False)
+ idWithProtocol_error = idWithProtocol_value.GetError()
+ self.assertTrue(idWithProtocol_error.Success())
+ self.assertTrue(idWithProtocol_value.GetTypeName() == "id")
+
+ # Make sure that class property getter works as expected
+ value = frame.EvaluateExpression("BaseClass.classInt", False)
+ self.assertTrue(value.GetError().Success())
+ self.assertTrue(value.GetValueAsUnsigned(11111) == 123)
+
+ # Make sure that class property setter works as expected
+ value = frame.EvaluateExpression("BaseClass.classInt = 234", False)
+ self.assertTrue(value.GetError().Success())
+
+ # Verify that setter above actually worked
+ value = frame.EvaluateExpression("BaseClass.classInt", False)
+ self.assertTrue(value.GetError().Success())
+ self.assertTrue(value.GetValueAsUnsigned(11111) == 234)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m
new file mode 100644
index 00000000000..8d14759fb38
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m
@@ -0,0 +1,113 @@
+#import <Foundation/Foundation.h>
+
+@protocol MyProtocol
+
+-(const char *)hello;
+
+@end
+
+static int _class_int = 123;
+
+@interface BaseClass : NSObject
+{
+ int _backedInt;
+ int _access_count;
+}
+
+- (int) nonexistantInt;
+- (void) setNonexistantInt: (int) in_int;
+
+- (int) myGetUnbackedInt;
+- (void) mySetUnbackedInt: (int) in_int;
+
+- (int) getAccessCount;
+
++(BaseClass *) baseClassWithBackedInt: (int) inInt andUnbackedInt: (int) inOtherInt;
+
+@property(getter=myGetUnbackedInt,setter=mySetUnbackedInt:) int unbackedInt;
+@property int backedInt;
+@property (nonatomic, assign) id <MyProtocol> idWithProtocol;
+@property(class) int classInt;
+@end
+
+@implementation BaseClass
+@synthesize unbackedInt;
+@synthesize backedInt = _backedInt;
+
++ (BaseClass *) baseClassWithBackedInt: (int) inInt andUnbackedInt: (int) inOtherInt
+{
+ BaseClass *new = [[BaseClass alloc] init];
+
+ new->_backedInt = inInt;
+ new->unbackedInt = inOtherInt;
+
+ return new;
+}
+
+- (int) myGetUnbackedInt
+{
+ // NSLog (@"Getting BaseClass::unbackedInt - %d.\n", unbackedInt);
+ _access_count++;
+ return unbackedInt;
+}
+
+- (void) mySetUnbackedInt: (int) in_int
+{
+ // NSLog (@"Setting BaseClass::unbackedInt from %d to %d.", unbackedInt, in_int);
+ _access_count++;
+ unbackedInt = in_int;
+}
+
+- (int) nonexistantInt
+{
+ // NSLog (@"Getting BaseClass::nonexistantInt - %d.\n", 5);
+ _access_count++;
+ return 6;
+}
+
+- (void) setNonexistantInt: (int) in_int
+{
+ // NSLog (@"Setting BaseClass::nonexistantInt from 7 to %d.", in_int);
+ _access_count++;
+}
+
++ (int) classInt
+{
+ return _class_int;
+}
+
++ (void) setClassInt:(int) n
+{
+ _class_int = n;
+}
+
+- (int) getAccessCount
+{
+ return _access_count;
+}
+@end
+
+int
+main ()
+{
+ BaseClass *mine = [BaseClass baseClassWithBackedInt: 10 andUnbackedInt: 20];
+
+ // Set a breakpoint here.
+ int nonexistant = mine.nonexistantInt;
+
+ int backedInt = mine.backedInt;
+
+ int unbackedInt = mine.unbackedInt;
+
+ id idWithProtocol = mine.idWithProtocol;
+
+ NSLog (@"Results for %p: nonexistant: %d backed: %d unbacked: %d accessCount: %d.",
+ mine,
+ nonexistant,
+ backedInt,
+ unbackedInt,
+ [mine getAccessCount]);
+ return 0;
+
+}
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/Makefile
new file mode 100644
index 00000000000..afecbf96948
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := main.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/TestRuntimeIvars.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/TestRuntimeIvars.py
new file mode 100644
index 00000000000..f1b36943ece
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/TestRuntimeIvars.py
@@ -0,0 +1,8 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(
+ __file__, globals(), [
+ decorators.skipIfFreeBSD, decorators.skipIfLinux,
+ decorators.skipIfWindows, decorators.skipIfNetBSD,
+ decorators.skipIf(archs=["i386", "i686"])])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/main.m
new file mode 100644
index 00000000000..1f5a9b077e2
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/main.m
@@ -0,0 +1,10 @@
+#import <Foundation/Foundation.h>
+
+int main ()
+{
+ @autoreleasepool
+ {
+ NSLog(@"Hello"); //% self.expect("expression -- *((NSConcretePointerArray*)[NSPointerArray strongObjectsPointerArray])", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["count", "capacity", "options", "mutations"]);
+ //% self.expect("expression -- ((NSConcretePointerArray*)[NSPointerArray strongObjectsPointerArray])->count", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["unsigned"]);
+ }
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/Makefile
new file mode 100644
index 00000000000..0ad7e356316
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/Makefile
@@ -0,0 +1,14 @@
+OBJC_SOURCES := static.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+default: a.out.stripped
+
+a.out.stripped: a.out.dSYM
+ strip -o a.out.stripped a.out
+ ln -sf a.out.dSYM a.out.stripped.dSYM
+
+clean::
+ rm -f a.out.stripped
+ rm -rf $(wildcard *.dSYM)
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py
new file mode 100644
index 00000000000..8ee73eda3f7
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py
@@ -0,0 +1,77 @@
+"""Test calling functions in static methods with a stripped binary."""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestObjCStaticMethodStripped(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers to break inside main().
+ self.main_source = "static.m"
+ self.break_line = line_number(
+ self.main_source, '// Set breakpoint here.')
+
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ @skipIf(
+ debug_info=no_match("dsym"),
+ bugnumber="This test requires a stripped binary and a dSYM")
+ #<rdar://problem/12042992>
+ def test_with_python_api(self):
+ """Test calling functions in static methods with a stripped binary."""
+ if self.getArchitecture() == 'i386':
+ self.skipTest("requires modern objc runtime")
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ bpt = target.BreakpointCreateByLocation(
+ self.main_source, self.break_line)
+ self.assertTrue(bpt, VALID_BREAKPOINT)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt)
+
+ # Make sure we stopped at the first breakpoint.
+ self.assertTrue(
+ len(thread_list) != 0,
+ "No thread stopped at our breakpoint.")
+ self.assertTrue(len(thread_list) == 1,
+ "More than one thread stopped at our breakpoint.")
+
+ # Now make sure we can call a function in the static method we've
+ # stopped in.
+ frame = thread_list[0].GetFrameAtIndex(0)
+ self.assertTrue(frame, "Got a valid frame 0 frame.")
+
+ cmd_value = frame.EvaluateExpression("(char *) sel_getName (_cmd)")
+ self.assertTrue(cmd_value.IsValid())
+ sel_name = cmd_value.GetSummary()
+ self.assertTrue(
+ sel_name == "\"doSomethingWithString:\"",
+ "Got the right value for the selector as string.")
+
+ cmd_value = frame.EvaluateExpression(
+ "[Foo doSomethingElseWithString:string]")
+ self.assertTrue(cmd_value.IsValid())
+ string_length = cmd_value.GetValueAsUnsigned()
+ self.assertTrue(
+ string_length == 27,
+ "Got the right value from another class method on the same class.")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/static.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/static.m
new file mode 100644
index 00000000000..ec7b2ef6719
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/static.m
@@ -0,0 +1,29 @@
+#import <Foundation/Foundation.h>
+
+@interface Foo : NSObject
++(void) doSomethingWithString: (NSString *) string;
+-(void) doSomethingWithNothing;
+@end
+
+@implementation Foo
++(void) doSomethingWithString: (NSString *) string
+{
+ NSLog (@"String is: %@.", string); // Set breakpoint here.
+}
+
++(int) doSomethingElseWithString: (NSString *) string
+{
+ NSLog (@"String is still: %@.", string);
+ return [string length];
+}
+
+-(void) doSomethingWithNothing
+{
+}
+@end
+
+int main()
+{
+ [Foo doSomethingWithString: @"Some string I have in mind."];
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method/Makefile
new file mode 100644
index 00000000000..954dea47b32
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := static.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method/TestObjCStaticMethod.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method/TestObjCStaticMethod.py
new file mode 100644
index 00000000000..ce18a07394b
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method/TestObjCStaticMethod.py
@@ -0,0 +1,72 @@
+"""Test calling functions in static methods."""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestObjCStaticMethod(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers to break inside main().
+ self.main_source = "static.m"
+ self.break_line = line_number(
+ self.main_source, '// Set breakpoint here.')
+
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ #<rdar://problem/9745789> "expression" can't call functions in class methods
+ def test_with_python_api(self):
+ """Test calling functions in static methods."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ bpt = target.BreakpointCreateByLocation(
+ self.main_source, self.break_line)
+ self.assertTrue(bpt, VALID_BREAKPOINT)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt)
+
+ # Make sure we stopped at the first breakpoint.
+ self.assertTrue(
+ len(thread_list) != 0,
+ "No thread stopped at our breakpoint.")
+ self.assertTrue(len(thread_list) == 1,
+ "More than one thread stopped at our breakpoint.")
+
+ # Now make sure we can call a function in the static method we've
+ # stopped in.
+ frame = thread_list[0].GetFrameAtIndex(0)
+ self.assertTrue(frame, "Got a valid frame 0 frame.")
+
+ cmd_value = frame.EvaluateExpression("(char *) sel_getName (_cmd)")
+ self.assertTrue(cmd_value.IsValid())
+ sel_name = cmd_value.GetSummary()
+ self.assertTrue(
+ sel_name == "\"doSomethingWithString:\"",
+ "Got the right value for the selector as string.")
+
+ cmd_value = frame.EvaluateExpression(
+ "[self doSomethingElseWithString:string]")
+ self.assertTrue(cmd_value.IsValid())
+ string_length = cmd_value.GetValueAsUnsigned()
+ self.assertTrue(
+ string_length == 27,
+ "Got the right value from another class method on the same class.")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method/static.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method/static.m
new file mode 100644
index 00000000000..ec7b2ef6719
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method/static.m
@@ -0,0 +1,29 @@
+#import <Foundation/Foundation.h>
+
+@interface Foo : NSObject
++(void) doSomethingWithString: (NSString *) string;
+-(void) doSomethingWithNothing;
+@end
+
+@implementation Foo
++(void) doSomethingWithString: (NSString *) string
+{
+ NSLog (@"String is: %@.", string); // Set breakpoint here.
+}
+
++(int) doSomethingElseWithString: (NSString *) string
+{
+ NSLog (@"String is still: %@.", string);
+ return [string length];
+}
+
+-(void) doSomethingWithNothing
+{
+}
+@end
+
+int main()
+{
+ [Foo doSomethingWithString: @"Some string I have in mind."];
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/Makefile
new file mode 100644
index 00000000000..9906470d530
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := stepping-tests.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py
new file mode 100644
index 00000000000..bf80995b109
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py
@@ -0,0 +1,220 @@
+"""Test stepping through ObjC method dispatch in various forms."""
+
+from __future__ import print_function
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestObjCStepping(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers that we will step to in main:
+ self.main_source = "stepping-tests.m"
+ self.source_randomMethod_line = line_number(
+ self.main_source, '// Source randomMethod start line.')
+ self.sourceBase_randomMethod_line = line_number(
+ self.main_source, '// SourceBase randomMethod start line.')
+ self.source_returnsStruct_start_line = line_number(
+ self.main_source, '// Source returnsStruct start line.')
+ self.sourceBase_returnsStruct_start_line = line_number(
+ self.main_source, '// SourceBase returnsStruct start line.')
+ self.stepped_past_nil_line = line_number(
+ self.main_source, '// Step over nil should stop here.')
+
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi', 'basic_process'])
+ def test_with_python_api(self):
+ """Test stepping through ObjC method dispatch in various forms."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ self.main_source_spec = lldb.SBFileSpec(self.main_source)
+
+ breakpoints_to_disable = []
+
+ break1 = target.BreakpointCreateBySourceRegex(
+ "// Set first breakpoint here.", self.main_source_spec)
+ self.assertTrue(break1, VALID_BREAKPOINT)
+ breakpoints_to_disable.append(break1)
+
+ break2 = target.BreakpointCreateBySourceRegex(
+ "// Set second breakpoint here.", self.main_source_spec)
+ self.assertTrue(break2, VALID_BREAKPOINT)
+ breakpoints_to_disable.append(break2)
+
+ break3 = target.BreakpointCreateBySourceRegex(
+ '// Set third breakpoint here.', self.main_source_spec)
+ self.assertTrue(break3, VALID_BREAKPOINT)
+ breakpoints_to_disable.append(break3)
+
+ break4 = target.BreakpointCreateBySourceRegex(
+ '// Set fourth breakpoint here.', self.main_source_spec)
+ self.assertTrue(break4, VALID_BREAKPOINT)
+ breakpoints_to_disable.append(break4)
+
+ break5 = target.BreakpointCreateBySourceRegex(
+ '// Set fifth breakpoint here.', self.main_source_spec)
+ self.assertTrue(break5, VALID_BREAKPOINT)
+ breakpoints_to_disable.append(break5)
+
+ break_returnStruct_call_super = target.BreakpointCreateBySourceRegex(
+ '// Source returnsStruct call line.', self.main_source_spec)
+ self.assertTrue(break_returnStruct_call_super, VALID_BREAKPOINT)
+ breakpoints_to_disable.append(break_returnStruct_call_super)
+
+ break_step_nil = target.BreakpointCreateBySourceRegex(
+ '// Set nil step breakpoint here.', self.main_source_spec)
+ self.assertTrue(break_step_nil, VALID_BREAKPOINT)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ threads = lldbutil.get_threads_stopped_at_breakpoint(process, break1)
+ if len(threads) != 1:
+ self.fail("Failed to stop at breakpoint 1.")
+
+ thread = threads[0]
+
+ mySource = thread.GetFrameAtIndex(0).FindVariable("mySource")
+ self.assertTrue(mySource, "Found mySource local variable.")
+ mySource_isa = mySource.GetChildMemberWithName("isa")
+ self.assertTrue(mySource_isa, "Found mySource->isa local variable.")
+ className = mySource_isa.GetSummary()
+
+ if self.TraceOn():
+ print(mySource_isa)
+
+ # Lets delete mySource so we can check that after stepping a child variable
+ # with no parent persists and is useful.
+ del (mySource)
+
+ # Now step in, that should leave us in the Source randomMethod:
+ thread.StepInto()
+ line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
+ self.assertTrue(
+ line_number == self.source_randomMethod_line,
+ "Stepped into Source randomMethod.")
+
+ # Now step in again, through the super call, and that should leave us
+ # in the SourceBase randomMethod:
+ thread.StepInto()
+ line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
+ self.assertTrue(
+ line_number == self.sourceBase_randomMethod_line,
+ "Stepped through super into SourceBase randomMethod.")
+
+ threads = lldbutil.continue_to_breakpoint(process, break2)
+ self.assertTrue(
+ len(threads) == 1,
+ "Continued to second breakpoint in main.")
+
+ # Again, step in twice gets us to a stret method and a stret super
+ # call:
+ thread = threads[0]
+ thread.StepInto()
+ line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
+ self.assertTrue(
+ line_number == self.source_returnsStruct_start_line,
+ "Stepped into Source returnsStruct.")
+
+ threads = lldbutil.continue_to_breakpoint(
+ process, break_returnStruct_call_super)
+ self.assertTrue(
+ len(threads) == 1,
+ "Stepped to the call super line in Source returnsStruct.")
+ thread = threads[0]
+
+ thread.StepInto()
+ line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
+ self.assertTrue(
+ line_number == self.sourceBase_returnsStruct_start_line,
+ "Stepped through super into SourceBase returnsStruct.")
+
+ # Cool now continue to get past the call that initializes the Observer, and then do our steps in again to see that
+ # we can find our way when we're stepping through a KVO swizzled
+ # object.
+
+ threads = lldbutil.continue_to_breakpoint(process, break3)
+ self.assertTrue(
+ len(threads) == 1,
+ "Continued to third breakpoint in main, our object should now be swizzled.")
+
+ newClassName = mySource_isa.GetSummary()
+
+ if self.TraceOn():
+ print("className is %s, newClassName is %s" % (className, newClassName))
+ print(mySource_isa)
+
+ self.assertTrue(
+ newClassName != className,
+ "The isa did indeed change, swizzled!")
+
+ # Now step in, that should leave us in the Source randomMethod:
+ thread = threads[0]
+ thread.StepInto()
+ line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
+ self.assertTrue(
+ line_number == self.source_randomMethod_line,
+ "Stepped into Source randomMethod in swizzled object.")
+
+ # Now step in again, through the super call, and that should leave us
+ # in the SourceBase randomMethod:
+ thread.StepInto()
+ line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
+ self.assertTrue(
+ line_number == self.sourceBase_randomMethod_line,
+ "Stepped through super into SourceBase randomMethod in swizzled object.")
+
+ threads = lldbutil.continue_to_breakpoint(process, break4)
+ self.assertTrue(
+ len(threads) == 1,
+ "Continued to fourth breakpoint in main.")
+ thread = threads[0]
+
+ # Again, step in twice gets us to a stret method and a stret super
+ # call:
+ thread.StepInto()
+ line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
+ self.assertTrue(
+ line_number == self.source_returnsStruct_start_line,
+ "Stepped into Source returnsStruct in swizzled object.")
+
+ threads = lldbutil.continue_to_breakpoint(
+ process, break_returnStruct_call_super)
+ self.assertTrue(
+ len(threads) == 1,
+ "Stepped to the call super line in Source returnsStruct - second time.")
+ thread = threads[0]
+
+ thread.StepInto()
+ line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
+ self.assertTrue(
+ line_number == self.sourceBase_returnsStruct_start_line,
+ "Stepped through super into SourceBase returnsStruct in swizzled object.")
+
+ for bkpt in breakpoints_to_disable:
+ bkpt.SetEnabled(False)
+
+ threads = lldbutil.continue_to_breakpoint(process, break_step_nil)
+ self.assertTrue(len(threads) == 1, "Continued to step nil breakpoint.")
+
+ thread.StepInto()
+ line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
+ self.assertTrue(
+ line_number == self.stepped_past_nil_line,
+ "Step in over dispatch to nil stepped over.")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/stepping-tests.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/stepping-tests.m
new file mode 100644
index 00000000000..63db536dee4
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/stepping-tests.m
@@ -0,0 +1,138 @@
+#import <Foundation/Foundation.h>
+#include <stdio.h>
+
+struct return_me
+{
+ int first;
+ int second;
+};
+
+@interface SourceBase: NSObject
+{
+ struct return_me my_return;
+}
+- (SourceBase *) initWithFirst: (int) first andSecond: (int) second;
+- (void) randomMethod;
+- (struct return_me) returnsStruct;
+@end
+
+@implementation SourceBase
+- (void) randomMethod
+{
+ printf ("Called in SourceBase version of randomMethod.\n"); // SourceBase randomMethod start line.
+}
+
+- (struct return_me) returnsStruct
+{
+ return my_return; // SourceBase returnsStruct start line.
+}
+
+- (SourceBase *) initWithFirst: (int) first andSecond: (int) second
+{
+ my_return.first = first;
+ my_return.second = second;
+
+ return self;
+}
+@end
+
+@interface Source : SourceBase
+{
+ int _property;
+}
+- (void) setProperty: (int) newValue;
+- (void) randomMethod;
+- (struct return_me) returnsStruct;
+@end
+
+@implementation Source
+- (void) setProperty: (int) newValue
+{
+ _property = newValue;
+}
+
+- (void) randomMethod
+{
+ [super randomMethod]; // Source randomMethod start line.
+ printf ("Called in Source version of random method.");
+}
+
+- (struct return_me) returnsStruct
+{
+ printf ("Called in Source version of returnsStruct.\n"); // Source returnsStruct start line.
+ return [super returnsStruct]; // Source returnsStruct call line.
+}
+
+@end
+
+@interface Observer : NSObject
+{
+ Source *_source;
+}
++ (Observer *) observerWithSource: (Source *) source;
+- (Observer *) initWithASource: (Source *) source;
+- (void) observeValueForKeyPath: (NSString *) path
+ ofObject: (id) object
+ change: (NSDictionary *) change
+ context: (void *) context;
+@end
+
+@implementation Observer
+
++ (Observer *) observerWithSource: (Source *) inSource;
+{
+ Observer *retval;
+
+ retval = [[Observer alloc] initWithASource: inSource];
+ return retval;
+}
+
+- (Observer *) initWithASource: (Source *) source
+{
+ [super init];
+ _source = source;
+ [_source addObserver: self
+ forKeyPath: @"property"
+ options: (NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld)
+ context: NULL];
+ return self;
+}
+
+- (void) observeValueForKeyPath: (NSString *) path
+ ofObject: (id) object
+ change: (NSDictionary *) change
+ context: (void *) context
+{
+ printf ("Observer function called.\n");
+ return;
+}
+@end
+
+int main ()
+{
+ Source *mySource;
+ Observer *myObserver;
+ struct return_me ret_val;
+
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+ mySource = [[Source alloc] init];
+
+ [mySource randomMethod]; // Set first breakpoint here.
+ ret_val = [mySource returnsStruct]; // Set second breakpoint here.
+
+ myObserver = [Observer observerWithSource: mySource];
+
+ [mySource randomMethod]; // Set third breakpoint here.
+ ret_val = [mySource returnsStruct]; // Set fourth breakpoint here.
+ [mySource setProperty: 5]; // Set fifth breakpoint here.
+
+ // We also had a bug where stepping into a method dispatch to nil turned
+ // into continue. So make sure that works here:
+
+ mySource = nil;
+ [mySource randomMethod]; // Set nil step breakpoint here.
+ [pool release]; // Step over nil should stop here.
+ return 0;
+
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/Makefile
new file mode 100644
index 00000000000..d059a5c1c29
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := test.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py
new file mode 100644
index 00000000000..28188afc142
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py
@@ -0,0 +1,66 @@
+"""Test passing structs to Objective-C methods."""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestObjCStructArgument(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers to break inside main().
+ self.main_source = "test.m"
+ self.break_line = line_number(
+ self.main_source, '// Set breakpoint here.')
+
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ @skipIf(debug_info=no_match(["gmodules"]), oslist=['ios', 'watchos', 'tvos', 'bridgeos'], archs=['armv7', 'arm64']) # this test program only builds for ios with -gmodules
+ def test_with_python_api(self):
+ """Test passing structs to Objective-C methods."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ bpt = target.BreakpointCreateByLocation(
+ self.main_source, self.break_line)
+ self.assertTrue(bpt, VALID_BREAKPOINT)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt)
+
+ # Make sure we stopped at the first breakpoint.
+ self.assertTrue(
+ len(thread_list) != 0,
+ "No thread stopped at our breakpoint.")
+ self.assertTrue(len(thread_list) == 1,
+ "More than one thread stopped at our breakpoint.")
+
+ frame = thread_list[0].GetFrameAtIndex(0)
+ self.assertTrue(frame, "Got a valid frame 0 frame.")
+
+ self.expect("p [summer sumThings:tts]", substrs=['9'])
+
+ self.expect(
+ "po [NSValue valueWithRect:rect]",
+ substrs=['NSRect: {{0, 0}, {10, 20}}'])
+
+ # Now make sure we can call a method that returns a struct without
+ # crashing.
+ cmd_value = frame.EvaluateExpression("[provider getRange]")
+ self.assertTrue(cmd_value.IsValid())
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/test.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/test.m
new file mode 100644
index 00000000000..6b13a3a3d59
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/test.m
@@ -0,0 +1,40 @@
+#import <Foundation/Foundation.h>
+#include <TargetConditionals.h>
+
+#if TARGET_OS_IPHONE
+@import CoreGraphics;
+typedef CGRect NSRect;
+#endif
+
+struct things_to_sum {
+ int a;
+ int b;
+ int c;
+};
+
+@interface ThingSummer : NSObject {
+};
+-(int)sumThings:(struct things_to_sum)tts;
+@end
+
+@implementation ThingSummer
+-(int)sumThings:(struct things_to_sum)tts
+{
+ return tts.a + tts.b + tts.c;
+}
+@end
+
+int main()
+{
+ @autoreleasepool
+ {
+ ThingSummer *summer = [ThingSummer alloc];
+ struct things_to_sum tts = { 2, 3, 4 };
+ int ret = [summer sumThings:tts];
+ NSRect rect = {{0, 0}, {10, 20}};
+ // The Objective-C V1 runtime won't read types from metadata so we need
+ // NSValue in our debug info to use it in our test.
+ NSValue *v = [NSValue valueWithRect:rect];
+ return rect.origin.x; // Set breakpoint here.
+ }
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/Makefile
new file mode 100644
index 00000000000..d059a5c1c29
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := test.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/TestObjCStructReturn.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/TestObjCStructReturn.py
new file mode 100644
index 00000000000..c8c54848a99
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/TestObjCStructReturn.py
@@ -0,0 +1,59 @@
+"""Test calling functions in class methods."""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestObjCClassMethod(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers to break inside main().
+ self.main_source = "test.m"
+ self.break_line = line_number(
+ self.main_source, '// Set breakpoint here.')
+
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ def test_with_python_api(self):
+ """Test calling functions in class methods."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ bpt = target.BreakpointCreateByLocation(
+ self.main_source, self.break_line)
+ self.assertTrue(bpt, VALID_BREAKPOINT)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt)
+
+ # Make sure we stopped at the first breakpoint.
+ self.assertTrue(
+ len(thread_list) != 0,
+ "No thread stopped at our breakpoint.")
+ self.assertTrue(len(thread_list) == 1,
+ "More than one thread stopped at our breakpoint.")
+
+ frame = thread_list[0].GetFrameAtIndex(0)
+ self.assertTrue(frame, "Got a valid frame 0 frame.")
+
+ # Now make sure we can call a method that returns a struct without
+ # crashing.
+ cmd_value = frame.EvaluateExpression("[provider getRange]")
+ self.assertTrue(cmd_value.IsValid())
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/test.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/test.m
new file mode 100644
index 00000000000..aafe231ea81
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/test.m
@@ -0,0 +1,23 @@
+#import <Foundation/Foundation.h>
+
+@interface RangeProvider : NSObject {
+};
+-(NSRange)getRange;
+@end
+
+@implementation RangeProvider
+-(NSRange)getRange
+{
+ return NSMakeRange(0, 3);
+}
+@end
+
+int main()
+{
+ @autoreleasepool
+ {
+ RangeProvider *provider = [RangeProvider alloc];
+ NSRange range = [provider getRange]; // Set breakpoint here.
+ return 0;
+ }
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-super/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-super/Makefile
new file mode 100644
index 00000000000..e6db3dee37b
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-super/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := class.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-super/TestObjCSuper.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-super/TestObjCSuper.py
new file mode 100644
index 00000000000..5cb46e007d8
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-super/TestObjCSuper.py
@@ -0,0 +1,64 @@
+"""Test calling methods on super."""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestObjCSuperMethod(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers to break inside main().
+ self.main_source = "class.m"
+ self.break_line = line_number(
+ self.main_source, '// Set breakpoint here.')
+
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ def test_with_python_api(self):
+ """Test calling methods on super."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ bpt = target.BreakpointCreateByLocation(
+ self.main_source, self.break_line)
+ self.assertTrue(bpt, VALID_BREAKPOINT)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt)
+
+ # Make sure we stopped at the first breakpoint.
+ self.assertTrue(
+ len(thread_list) != 0,
+ "No thread stopped at our breakpoint.")
+ self.assertTrue(len(thread_list) == 1,
+ "More than one thread stopped at our breakpoint.")
+
+ # Now make sure we can call a function in the class method we've
+ # stopped in.
+ frame = thread_list[0].GetFrameAtIndex(0)
+ self.assertTrue(frame, "Got a valid frame 0 frame.")
+
+ cmd_value = frame.EvaluateExpression("[self get]")
+ self.assertTrue(cmd_value.IsValid())
+ self.assertTrue(cmd_value.GetValueAsUnsigned() == 2)
+
+ cmd_value = frame.EvaluateExpression("[super get]")
+ self.assertTrue(cmd_value.IsValid())
+ self.assertTrue(cmd_value.GetValueAsUnsigned() == 1)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-super/class.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-super/class.m
new file mode 100644
index 00000000000..b55b649aaae
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc-super/class.m
@@ -0,0 +1,39 @@
+#import <Foundation/Foundation.h>
+
+@interface Foo : NSObject {
+}
+-(int)get;
+@end
+
+@implementation Foo
+-(int)get
+{
+ return 1;
+}
+@end
+
+@interface Bar : Foo {
+}
+-(int)get;
+@end
+
+@implementation Bar
+-(int)get
+{
+ return 2;
+}
+
+-(int)callme
+{
+ return [self get]; // Set breakpoint here.
+}
+@end
+
+int main()
+{
+ @autoreleasepool
+ {
+ Bar *bar = [Bar alloc];
+ return [bar callme];
+ }
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/Makefile
new file mode 100644
index 00000000000..afecbf96948
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := main.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/TestObjCDirectMethods.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/TestObjCDirectMethods.py
new file mode 100644
index 00000000000..f0152de1ac3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/TestObjCDirectMethods.py
@@ -0,0 +1,5 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(
+ __file__, globals(), [decorators.skipUnlessDarwin])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/main.m
new file mode 100644
index 00000000000..6799f22500c
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/main.m
@@ -0,0 +1,92 @@
+#import <Foundation/Foundation.h>
+
+int side_effect = 0;
+
+NSString *str = @"some string";
+
+const char *directCallConflictingName() {
+ return "wrong function";
+}
+
+@interface Foo : NSObject {
+ int instance_var;
+}
+-(int) entryPoint;
+@end
+
+@implementation Foo
+-(int) entryPoint
+{
+ // Try calling directly with self. Same as in the main method otherwise.
+ return 0; //%self.expect("expr [self directCallNoArgs]", substrs=["called directCallNoArgs"])
+ //%self.expect("expr [self directCallArgs: 1111]", substrs=["= 2345"])
+ //%self.expect("expr side_effect = 0; [self directCallVoidReturn]; side_effect", substrs=["= 4321"])
+ //%self.expect("expr [self directCallNSStringArg: str]", substrs=['@"some string"'])
+ //%self.expect("expr [self directCallIdArg: (id)str]", substrs=['@"some string appendix"'])
+ //%self.expect("expr [self directCallConflictingName]", substrs=["correct function"])
+ //%self.expect("expr [self directCallWithCategory]", substrs=["called function with category"])
+}
+
+// Declare several objc_direct functions we can test.
+-(const char *) directCallNoArgs __attribute__((objc_direct))
+{
+ return "called directCallNoArgs";
+}
+
+-(void) directCallVoidReturn __attribute__((objc_direct))
+{
+ side_effect = 4321;
+}
+
+-(int) directCallArgs:(int)i __attribute__((objc_direct))
+{
+ // Use the arg in some way to make sure that gets passed correctly.
+ return i + 1234;
+}
+
+-(NSString *) directCallNSStringArg:(NSString *)str __attribute__((objc_direct))
+{
+ return str;
+}
+
+-(NSString *) directCallIdArg:(id)param __attribute__((objc_direct))
+{
+ return [param stringByAppendingString:@" appendix"];
+}
+
+// We have another function with the same name above. Make sure this doesn't influence
+// what we call.
+-(const char *) directCallConflictingName __attribute__((objc_direct))
+{
+ return "correct function";
+}
+@end
+
+
+@interface Foo (Cat)
+@end
+
+@implementation Foo (Cat)
+-(const char *) directCallWithCategory __attribute__((objc_direct))
+{
+ return "called function with category";
+}
+@end
+
+int main()
+{
+ Foo *foo = [[Foo alloc] init];
+ [foo directCallNoArgs];
+ [foo directCallArgs: 1];
+ [foo directCallVoidReturn];
+ [foo directCallNSStringArg: str];
+ [foo directCallIdArg: (id)str];
+ [foo entryPoint]; //%self.expect("expr [foo directCallNoArgs]", substrs=["called directCallNoArgs"])
+ //%self.expect("expr [foo directCallArgs: 1111]", substrs=["= 2345"])
+ //%self.expect("expr side_effect = 0; [foo directCallVoidReturn]; side_effect", substrs=["= 4321"])
+ //%self.expect("expr [foo directCallNSStringArg: str]", substrs=['@"some string"'])
+ //%self.expect("expr [foo directCallIdArg: (id)str]", substrs=['@"some string appendix"'])
+ //%self.expect("expr [foo directCallConflictingName]", substrs=["correct function"])
+ //%self.expect("expr [foo directCallWithCategory]", substrs=["called function with category"])
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/orderedset/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/orderedset/Makefile
new file mode 100644
index 00000000000..afecbf96948
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/orderedset/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := main.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/orderedset/TestOrderedSet.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/orderedset/TestOrderedSet.py
new file mode 100644
index 00000000000..90c6bc32f77
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/orderedset/TestOrderedSet.py
@@ -0,0 +1,18 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestOrderedSet(TestBase):
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ def test_ordered_set(self):
+ self.build()
+ src_file = "main.m"
+ src_file_spec = lldb.SBFileSpec(src_file)
+ (target, process, thread, main_breakpoint) = lldbutil.run_to_source_breakpoint(self,
+ "break here", src_file_spec, exe_name = "a.out")
+ frame = thread.GetSelectedFrame()
+ self.expect("expr -d run -- orderedSet", substrs=["3 elements"])
+ self.expect("expr -d run -- *orderedSet", substrs=["(int)1", "(int)2", "(int)3"])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/orderedset/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/orderedset/main.m
new file mode 100644
index 00000000000..e3f01622693
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/orderedset/main.m
@@ -0,0 +1,8 @@
+#import <Foundation/Foundation.h>
+
+int main() {
+ NSOrderedSet *orderedSet =
+ [NSOrderedSet orderedSetWithArray:@[@1,@2,@3,@1]];
+ NSLog(@"%@",orderedSet);
+ return 0; // break here
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/print-obj/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/print-obj/Makefile
new file mode 100644
index 00000000000..2eab56265f5
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/print-obj/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := blocked.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/print-obj/TestPrintObj.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/print-obj/TestPrintObj.py
new file mode 100644
index 00000000000..9b3ec33db4e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/print-obj/TestPrintObj.py
@@ -0,0 +1,91 @@
+"""
+Test "print object" where another thread blocks the print object from making progress.
+"""
+
+from __future__ import print_function
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipUnlessDarwin
+class PrintObjTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # My source program.
+ self.source = "blocked.m"
+ # Find the line numbers to break at.
+ self.line = line_number(self.source, '// Set a breakpoint here.')
+
+ def test_print_obj(self):
+ """
+ Test "print object" where another thread blocks the print object from making progress.
+
+ Set a breakpoint on the line in my_pthread_routine. Then switch threads
+ to the main thread, and do print the lock_me object. Since that will
+ try to get the lock already gotten by my_pthread_routime thread, it will
+ have to switch to running all threads, and that should then succeed.
+ """
+ d = {'EXE': 'b.out'}
+ self.build(dictionary=d)
+ self.setTearDownCleanup(dictionary=d)
+ exe = self.getBuildArtifact('b.out')
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ breakpoint = target.BreakpointCreateByLocation(self.source, self.line)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
+ self.runCmd("breakpoint list")
+
+ # Launch the process, and do not stop at the entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ self.runCmd("thread backtrace all")
+
+ # Let's get the current stopped thread. We'd like to switch to the
+ # other thread to issue our 'po lock_me' command.
+ import lldbsuite.test.lldbutil as lldbutil
+ this_thread = lldbutil.get_stopped_thread(
+ process, lldb.eStopReasonBreakpoint)
+ self.assertTrue(this_thread)
+
+ # Find the other thread. The iteration protocol of SBProcess and the
+ # rich comparison methods (__eq__/__ne__) of SBThread come in handy.
+ other_thread = None
+ for t in process:
+ if t != this_thread:
+ other_thread = t
+ break
+
+ # Set the other thread as the selected thread to issue our 'po'
+ # command.other
+ self.assertTrue(other_thread)
+ process.SetSelectedThread(other_thread)
+ if self.TraceOn():
+ print("selected thread:" + lldbutil.get_description(other_thread))
+ self.runCmd("thread backtrace")
+
+ # We want to traverse the frame to the one corresponding to blocked.m to
+ # issue our 'po lock_me' command.
+
+ depth = other_thread.GetNumFrames()
+ for i in range(depth):
+ frame = other_thread.GetFrameAtIndex(i)
+ name = frame.GetFunctionName()
+ if name == 'main':
+ other_thread.SetSelectedFrame(i)
+ if self.TraceOn():
+ print("selected frame:" + lldbutil.get_description(frame))
+ break
+
+ self.expect("po lock_me", OBJECT_PRINTED_CORRECTLY,
+ substrs=['I am pretty special.'])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/print-obj/blocked.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/print-obj/blocked.m
new file mode 100644
index 00000000000..58771264062
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/print-obj/blocked.m
@@ -0,0 +1,72 @@
+//===-- blocked.m --------------------------------------------------*- ObjC -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// This file is for testing running "print object" in a case where another thread
+// blocks the print object from making progress. Set a breakpoint on the line in
+// my_pthread_routine as indicated. Then switch threads to the main thread, and
+// do print the lock_me object. Since that will try to get the lock already gotten
+// by my_pthread_routime thread, it will have to switch to running all threads, and
+// that should then succeed.
+//
+
+#include <Foundation/Foundation.h>
+#include <pthread.h>
+
+static pthread_mutex_t test_mutex;
+
+static void Mutex_Init (void)
+{
+ pthread_mutexattr_t tmp_mutex_attr;
+ pthread_mutexattr_init(&tmp_mutex_attr);
+ pthread_mutex_init(&test_mutex, &tmp_mutex_attr);
+}
+
+@interface LockMe :NSObject
+{
+
+}
+- (NSString *) description;
+@end
+
+@implementation LockMe
+- (NSString *) description
+{
+ printf ("LockMe trying to get the lock.\n");
+ pthread_mutex_lock(&test_mutex);
+ printf ("LockMe got the lock.\n");
+ pthread_mutex_unlock(&test_mutex);
+ return @"I am pretty special.\n";
+}
+@end
+
+void *
+my_pthread_routine (void *data)
+{
+ printf ("my_pthread_routine about to enter.\n");
+ pthread_mutex_lock(&test_mutex);
+ printf ("Releasing Lock.\n"); // Set a breakpoint here.
+ pthread_mutex_unlock(&test_mutex);
+ return NULL;
+}
+
+int
+main ()
+{
+ pthread_attr_t tmp_attr;
+ pthread_attr_init (&tmp_attr);
+ pthread_t my_pthread;
+
+ Mutex_Init ();
+
+ LockMe *lock_me = [[LockMe alloc] init];
+ pthread_create (&my_pthread, &tmp_attr, my_pthread_routine, NULL);
+
+ pthread_join (my_pthread, NULL);
+
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ptr_refs/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ptr_refs/Makefile
new file mode 100644
index 00000000000..845553d5e3f
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ptr_refs/Makefile
@@ -0,0 +1,3 @@
+OBJC_SOURCES := main.m
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ptr_refs/TestPtrRefsObjC.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ptr_refs/TestPtrRefsObjC.py
new file mode 100644
index 00000000000..aade40c06b6
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ptr_refs/TestPtrRefsObjC.py
@@ -0,0 +1,47 @@
+"""
+Test the ptr_refs tool on Darwin with Objective-C
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestPtrRefsObjC(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ def test_ptr_refs(self):
+ """Test the ptr_refs tool on Darwin with Objective-C"""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ main_file_spec = lldb.SBFileSpec('main.m')
+ breakpoint = target.BreakpointCreateBySourceRegex(
+ 'break', main_file_spec)
+ self.assertTrue(breakpoint and
+ breakpoint.GetNumLocations() == 1,
+ VALID_BREAKPOINT)
+
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # Frame #0 should be on self.line1 and the break condition should hold.
+ thread = lldbutil.get_stopped_thread(
+ process, lldb.eStopReasonBreakpoint)
+ self.assertTrue(
+ thread.IsValid(),
+ "There should be a thread stopped due to breakpoint condition")
+
+ frame = thread.GetFrameAtIndex(0)
+
+ self.dbg.HandleCommand("script import lldb.macosx.heap")
+ self.expect("ptr_refs self", substrs=["malloc", "stack"])
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ptr_refs/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ptr_refs/main.m
new file mode 100644
index 00000000000..94bf0fb9fc5
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/ptr_refs/main.m
@@ -0,0 +1,38 @@
+//===-- main.c --------------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#import <Foundation/Foundation.h>
+
+@interface MyClass : NSObject {
+};
+-(void)test;
+@end
+
+@implementation MyClass
+-(void)test {
+ printf("%p\n", self); // break here
+}
+@end
+
+@interface MyOwner : NSObject {
+ @public id ownedThing; // should be id, to test <rdar://problem/31363513>
+};
+@end
+
+@implementation MyOwner
+@end
+
+int main (int argc, char const *argv[]) {
+ @autoreleasepool {
+ MyOwner *owner = [[MyOwner alloc] init];
+ owner->ownedThing = [[MyClass alloc] init];
+ [(MyClass*)owner->ownedThing test];
+ }
+ return 0;
+}
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/radar-9691614/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/radar-9691614/Makefile
new file mode 100644
index 00000000000..37dd8f40a9d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/radar-9691614/Makefile
@@ -0,0 +1,6 @@
+OBJC_SOURCES := main.m
+
+
+
+LD_EXTRAS := -framework Foundation
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py
new file mode 100644
index 00000000000..632ef7bfe73
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py
@@ -0,0 +1,45 @@
+"""
+Test that objective-c method returning BOOL works correctly.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipUnlessDarwin
+class MethodReturningBOOLTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ 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 test_method_ret_BOOL(self):
+ """Test that objective-c method returning BOOL works correctly."""
+ d = {'EXE': self.exe_name}
+ self.build(dictionary=d)
+ self.setTearDownCleanup(dictionary=d)
+
+ exe = self.getBuildArtifact(self.exe_name)
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+ self.expect("process status", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=[" at %s:%d" % (self.main_source, self.line),
+ "stop reason = breakpoint"])
+
+ # rdar://problem/9691614
+ self.runCmd('p (int)[my isValid]')
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/radar-9691614/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/radar-9691614/main.m
new file mode 100644
index 00000000000..bb87d673452
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/radar-9691614/main.m
@@ -0,0 +1,67 @@
+#import <Foundation/Foundation.h>
+#include <stdio.h>
+
+@interface MyString : NSObject {
+ NSString *str;
+ NSDate *date;
+ BOOL _is_valid;
+}
+
+- (id)initWithNSString:(NSString *)string;
+- (BOOL)isValid;
+@end
+
+@implementation MyString
+- (id)initWithNSString:(NSString *)string
+{
+ if (self = [super init])
+ {
+ str = [NSString stringWithString:string];
+ date = [NSDate date];
+ }
+ _is_valid = YES;
+ return self;
+}
+
+- (BOOL)isValid
+{
+ return _is_valid;
+}
+
+- (void)dealloc
+{
+ [date release];
+ [str release];
+ [super dealloc];
+}
+
+- (NSString *)description
+{
+ return [str stringByAppendingFormat:@" with timestamp: %@", date];
+}
+@end
+
+void
+Test_MyString (const char *program)
+{
+ NSString *str = [NSString stringWithFormat:@"Hello from '%s'", program];
+ MyString *my = [[MyString alloc] initWithNSString:str];
+ if ([my isValid])
+ printf("my is valid!\n");
+
+ NSLog(@"NSString instance: %@", [str description]); // Set breakpoint here.
+ // Test 'p (int)[my isValid]'.
+ // The expression parser should not crash -- rdar://problem/9691614.
+
+ NSLog(@"MyString instance: %@", [my description]);
+}
+
+int main (int argc, char const *argv[])
+{
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+ Test_MyString (argv[0]);
+
+ [pool release];
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/Makefile
new file mode 100644
index 00000000000..37dd8f40a9d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/Makefile
@@ -0,0 +1,6 @@
+OBJC_SOURCES := main.m
+
+
+
+LD_EXTRAS := -framework Foundation
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/TestRdar10967107.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/TestRdar10967107.py
new file mode 100644
index 00000000000..c6633b7fe52
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/TestRdar10967107.py
@@ -0,0 +1,70 @@
+"""
+Test that CoreFoundation classes CFGregorianDate and CFRange are not improperly uniqued
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipUnlessDarwin
+class Rdar10967107TestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ 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 test_cfrange_diff_cfgregoriandate(self):
+ """Test that CoreFoundation classes CFGregorianDate and CFRange are not improperly uniqued."""
+ d = {'EXE': self.exe_name}
+ self.build(dictionary=d)
+ self.setTearDownCleanup(dictionary=d)
+
+ exe = self.getBuildArtifact(self.exe_name)
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ self.main_source,
+ self.line,
+ num_expected_locations=1,
+ loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+ # check that each type is correctly bound to its list of children
+ self.expect(
+ "frame variable cf_greg_date --raw",
+ substrs=[
+ 'year',
+ 'month',
+ 'day',
+ 'hour',
+ 'minute',
+ 'second'])
+ self.expect(
+ "frame variable cf_range --raw",
+ substrs=[
+ 'location',
+ 'length'])
+ # check that printing both does not somehow confuse LLDB
+ self.expect(
+ "frame variable --raw",
+ substrs=[
+ 'year',
+ 'month',
+ 'day',
+ 'hour',
+ 'minute',
+ 'second',
+ 'location',
+ 'length'])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/main.m
new file mode 100644
index 00000000000..386a458950b
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/main.m
@@ -0,0 +1,13 @@
+#import <Foundation/Foundation.h>
+
+int main (int argc, char const *argv[])
+{
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+ NSDate *date1 = [NSDate date];
+ CFGregorianDate cf_greg_date = CFAbsoluteTimeGetGregorianDate(CFDateGetAbsoluteTime((CFDateRef)date1), NULL);
+ CFRange cf_range = {4,4};
+
+ [pool release]; // Set breakpoint here.
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/Makefile
new file mode 100644
index 00000000000..37dd8f40a9d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/Makefile
@@ -0,0 +1,6 @@
+OBJC_SOURCES := main.m
+
+
+
+LD_EXTRAS := -framework Foundation
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/TestRdar11355592.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/TestRdar11355592.py
new file mode 100644
index 00000000000..f9e825ada43
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/TestRdar11355592.py
@@ -0,0 +1,79 @@
+"""
+Test that we do not attempt to make a dynamic type for a 'const char*'
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipUnlessDarwin
+class Rdar10967107TestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ 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 test_charstar_dyntype(self):
+ """Test that we do not attempt to make a dynamic type for a 'const char*'"""
+ d = {'EXE': self.exe_name}
+ self.build(dictionary=d)
+ self.setTearDownCleanup(dictionary=d)
+
+ exe = self.getBuildArtifact(self.exe_name)
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ self.main_source,
+ self.line,
+ num_expected_locations=1,
+ loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+ # check that we correctly see the const char*, even with dynamic types
+ # on
+ self.expect("frame variable -raw-output my_string", substrs=['const char *'])
+ self.expect(
+ "frame variable my_string --raw-output --dynamic-type run-target",
+ substrs=['const char *'])
+ # check that expr also gets it right
+ self.expect("e -R -- my_string", substrs=['const char *'])
+ self.expect("expr -R -d run -- 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 --dynamic-type run-target",
+ substrs=['FoolMeOnce *'])
+ # check that expr also gets it right
+ self.expect("expr my_foolie", substrs=['FoolMeOnce *'])
+ self.expect("expr -d run -- 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 --dynamic-type run-target",
+ substrs=['const char *'])
+ # check that expr also gets it right
+ self.expect("expr my_string", substrs=['const char *'])
+ self.expect("expr -d run -- 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 --dynamic-type run-target",
+ substrs=['FoolMeOnce *'])
+ # check that expr also gets it right
+ self.expect("expr my_foolie", substrs=['FoolMeOnce *'])
+ self.expect("expr -d run -- my_foolie", substrs=['FoolMeOnce *'])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/main.m
new file mode 100644
index 00000000000..09b3b18a787
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/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;
+
+ my_string = "Now this is a REAL string..."; // Set breakpoint here.
+
+ [pool release];
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/Makefile
new file mode 100644
index 00000000000..919000e6402
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/Makefile
@@ -0,0 +1,9 @@
+OBJC_SOURCES := main.m
+
+include Makefile.rules
+
+ifneq (,$(findstring arm,$(ARCH)))
+ LD_EXTRAS = -framework Foundation -framework UIKit
+else
+ LD_EXTRAS = -framework Foundation -framework Cocoa
+endif
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py
new file mode 100644
index 00000000000..8f262a3413d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py
@@ -0,0 +1,69 @@
+"""
+Test that we are able to find out how many children NSWindow has
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+# TODO: The Jenkins testers on OS X fail running this test because they don't
+# have access to WindowServer so NSWindow doesn't work. We should disable this
+# test if WindowServer isn't available.
+# Note: Simply applying the @skipIf decorator here confuses the test harness
+# and gives a spurious failure.
+@skipUnlessDarwin
+class Rdar12408181TestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ 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 test_nswindow_count(self):
+ """Test that we are able to find out how many children NSWindow has."""
+
+ self.skipTest("Skipping this test due to timeout flakiness")
+
+ d = {'EXE': self.exe_name}
+ self.build(dictionary=d)
+ self.setTearDownCleanup(dictionary=d)
+
+ exe = self.getBuildArtifact(self.exe_name)
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ self.main_source,
+ self.line,
+ num_expected_locations=1,
+ loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+ if self.frame().EvaluateExpression(
+ '(void*)_CGSDefaultConnection()').GetValueAsUnsigned() != 0:
+ window = self.frame().FindVariable("window")
+ window_dynamic = window.GetDynamicValue(lldb.eDynamicCanRunTarget)
+ self.assertTrue(
+ window.GetNumChildren() > 1,
+ "NSWindow (static) only has 1 child!")
+ self.assertTrue(
+ window_dynamic.GetNumChildren() > 1,
+ "NSWindow (dynamic) only has 1 child!")
+ self.assertTrue(
+ window.GetChildAtIndex(0).IsValid(),
+ "NSWindow (static) has an invalid child")
+ self.assertTrue(
+ window_dynamic.GetChildAtIndex(0).IsValid(),
+ "NSWindow (dynamic) has an invalid child")
+ else:
+ self.skipTest('no WindowServer connection')
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/main.m
new file mode 100644
index 00000000000..858ba2a4a22
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/main.m
@@ -0,0 +1,24 @@
+#import <Foundation/Foundation.h>
+#if defined (__i386__) || defined (__x86_64__)
+#import <Cocoa/Cocoa.h>
+#else
+#import <UIKit/UIKit.h>
+#endif
+
+int main (int argc, char const *argv[])
+{
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+#if defined (__i386__) || defined (__x86_64__)
+
+ [NSApplication sharedApplication];
+ NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,100,100) styleMask:NSBorderlessWindowMask backing:NSBackingStoreRetained defer:NO];
+ [window setCanHide:YES];
+#else
+ [UIApplication sharedApplication];
+ CGRect rect = { 0, 0, 100, 100};
+ UIWindow* window = [[UIWindow alloc] initWithFrame:rect];
+#endif
+ [pool release]; // Set breakpoint here.
+ return 0;
+}
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Bar.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Bar.h
new file mode 100644
index 00000000000..5ee6acb2425
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Bar.h
@@ -0,0 +1,12 @@
+#import <Foundation/Foundation.h>
+
+@class InternalClass;
+
+@interface Bar : NSObject {
+ @private
+ InternalClass *storage;
+}
+
+- (NSString *)description;
+
+@end
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Bar.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Bar.m
new file mode 100644
index 00000000000..21c39066f8e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Bar.m
@@ -0,0 +1,43 @@
+#import "Bar.h"
+
+@interface InternalClass : NSObject {
+ @public
+ NSString *foo;
+ NSString *bar;
+}
+@end
+
+@implementation InternalClass
+@end
+
+@interface Bar ()
+{
+ NSString *_hidden_ivar;
+}
+
+@end
+
+@implementation Bar
+
+- (id)init
+{
+ self = [super init];
+ if (self) {
+ _hidden_ivar = [NSString stringWithFormat:@"%p: @Bar", self];
+ }
+ return self; // Set breakpoint where Bar is an implementation
+}
+
+- (void)dealloc
+{
+ [_hidden_ivar release];
+ [super dealloc];
+}
+
+- (NSString *)description
+{
+ return [_hidden_ivar copyWithZone:NULL];
+}
+
+@end
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Foo.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Foo.h
new file mode 100644
index 00000000000..d58da600765
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Foo.h
@@ -0,0 +1,11 @@
+#import <Foundation/Foundation.h>
+
+#import "Bar.h"
+
+@interface Foo : NSObject {
+ Bar *_bar;
+}
+
+- (NSString *)description;
+
+@end
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Foo.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Foo.m
new file mode 100644
index 00000000000..bcdeaeffc29
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Foo.m
@@ -0,0 +1,25 @@
+#import "Foo.h"
+
+@implementation Foo
+
+- (id)init
+{
+ self = [super init];
+ if (self) {
+ _bar = [[Bar alloc] init];
+ }
+ return self; // Set breakpoint where Bar is an interface
+}
+
+- (void)dealloc
+{
+ [_bar release];
+ [super dealloc];
+}
+
+- (NSString *)description
+{
+ return [NSString stringWithFormat:@"%p: @Foo { _bar = %@ }", self, _bar];
+}
+
+@end
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Makefile
new file mode 100644
index 00000000000..f1498efac1d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := Bar.m Foo.m main.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/TestRealDefinition.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/TestRealDefinition.py
new file mode 100644
index 00000000000..002bc6cbf82
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/TestRealDefinition.py
@@ -0,0 +1,98 @@
+"""Test that types defined in shared libraries work correctly."""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestRealDefinition(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ def test_frame_var_after_stop_at_interface(self):
+ """Test that we can find the implementation for an objective C type"""
+ if self.getArchitecture() == 'i386':
+ self.skipTest("requires modern objc runtime")
+ self.build()
+ self.common_setup()
+
+ line = line_number(
+ 'Foo.m', '// Set breakpoint where Bar is an interface')
+ lldbutil.run_break_set_by_file_and_line(
+ self, 'Foo.m', line, num_expected_locations=1, loc_exact=True)
+
+ 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'])
+
+ # Run and stop at Foo
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ self.runCmd("continue", RUN_SUCCEEDED)
+
+ # Run at stop at main
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ # This should display correctly.
+ self.expect(
+ "frame variable foo->_bar->_hidden_ivar",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "(NSString *)",
+ "foo->_bar->_hidden_ivar = 0x"])
+
+ @skipUnlessDarwin
+ def test_frame_var_after_stop_at_implementation(self):
+ """Test that we can find the implementation for an objective C type"""
+ if self.getArchitecture() == 'i386':
+ self.skipTest("requires modern objc runtime")
+ self.build()
+ self.common_setup()
+
+ line = line_number(
+ 'Bar.m', '// Set breakpoint where Bar is an implementation')
+ lldbutil.run_break_set_by_file_and_line(
+ self, 'Bar.m', line, num_expected_locations=1, loc_exact=True)
+
+ 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'])
+
+ # Run and stop at Foo
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ self.runCmd("continue", RUN_SUCCEEDED)
+
+ # Run at stop at main
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ # This should display correctly.
+ self.expect(
+ "frame variable foo->_bar->_hidden_ivar",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "(NSString *)",
+ "foo->_bar->_hidden_ivar = 0x"])
+
+ def common_setup(self):
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break inside the foo function which takes a bar_ptr argument.
+ line = line_number('main.m', '// Set breakpoint in main')
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.m", line, num_expected_locations=1, loc_exact=True)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/main.m
new file mode 100644
index 00000000000..8c31dc9abb3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/main.m
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <stdint.h>
+#import <Foundation/Foundation.h>
+#import "Foo.h"
+
+int main (int argc, char const *argv[])
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ Foo *foo = [[Foo alloc] init];
+ NSLog (@"foo is %@", foo); // Set breakpoint in main
+ [pool release];
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/sample/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/sample/Makefile
new file mode 100644
index 00000000000..afecbf96948
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/sample/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := main.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/sample/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/sample/main.m
new file mode 100644
index 00000000000..9dffc71aaac
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/sample/main.m
@@ -0,0 +1,70 @@
+#import <Foundation/Foundation.h>
+
+
+@interface MyString : NSObject {
+ NSString *_string;
+ NSDate *_date;
+}
+- (id)initWithNSString:(NSString *)string;
+
+@property (copy) NSString *string;
+@property (readonly,getter=getTheDate) NSDate *date;
+
+- (NSDate *) getTheDate;
+@end
+
+@implementation MyString
+
+@synthesize string = _string;
+@synthesize date = _date;
+
+- (id)initWithNSString:(NSString *)string
+{
+ if (self = [super init])
+ {
+ _string = [NSString stringWithString:string];
+ _date = [NSDate date];
+ }
+ return self;
+}
+
+- (void) dealloc
+{
+ [_date release];
+ [_string release];
+ [super dealloc];
+}
+
+- (NSDate *) getTheDate
+{
+ return _date;
+}
+
+- (NSString *)description
+{
+ return [_string stringByAppendingFormat:@" with timestamp: %@", _date];
+}
+@end
+
+int main (int argc, char const *argv[])
+{
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ static NSString *g_global_nsstr = @"Howdy";
+
+ MyString *myStr = [[MyString alloc] initWithNSString: [NSString stringWithFormat:@"string %i", 1]];
+ NSString *str1 = myStr.string;
+ NSString *str2 = [NSString stringWithFormat:@"string %i", 2];
+ NSString *str3 = [NSString stringWithFormat:@"string %i", 3];
+ NSArray *array = [NSArray arrayWithObjects: str1, str2, str3, nil];
+ NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
+ str1, @"1",
+ str2, @"2",
+ str3, @"3",
+ myStr.date, @"date",
+ nil];
+
+ id str_id = str1;
+ SEL sel = @selector(length);
+ [pool release];
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/Makefile
new file mode 100644
index 00000000000..644046c69ea
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := main.m
+LD_EXTRAS ?= -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py
new file mode 100644
index 00000000000..81d6b79ad53
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py
@@ -0,0 +1,39 @@
+"""
+Tests that ObjC member variables are available where they should be.
+"""
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ObjCSelfTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ def test_with_run_command(self):
+ """Test that the appropriate member variables are available when stopped in Objective-C class and instance methods"""
+ self.build()
+ self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
+
+ self.set_breakpoint(line_number('main.m', '// breakpoint 1'))
+ self.set_breakpoint(line_number('main.m', '// breakpoint 2'))
+
+ self.runCmd("process launch", RUN_SUCCEEDED)
+
+ self.expect("expression -- m_a = 2",
+ startstr="(int) $0 = 2")
+
+ self.runCmd("process continue")
+
+ # This would be disallowed if we enforced const. But we don't.
+ self.expect("expression -- m_a = 2",
+ error=True)
+
+ self.expect("expression -- s_a",
+ startstr="(int) $1 = 5")
+
+ def set_breakpoint(self, line):
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.m", line, num_expected_locations=1, loc_exact=True)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/main.m
new file mode 100644
index 00000000000..8f4e61202a3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/main.m
@@ -0,0 +1,53 @@
+//===-- main.m ------------------------------------------*- Objective-C -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#import <Foundation/Foundation.h>
+
+@interface A : NSObject
+{
+ int m_a;
+}
+-(id)init;
+-(void)accessMember:(int)a;
++(void)accessStaticMember:(int)a;
+@end
+
+static int s_a = 5;
+
+@implementation A
+-(id)init
+{
+ self = [super init];
+
+ if (self)
+ m_a = 2;
+
+ return self;
+}
+
+-(void)accessMember:(int)a
+{
+ m_a = a; // breakpoint 1
+}
+
++(void)accessStaticMember:(int)a
+{
+ s_a = a; // breakpoint 2
+}
+@end
+
+int main()
+{
+ NSAutoreleasePool *pool = [NSAutoreleasePool alloc];
+ A *my_a = [[A alloc] init];
+
+ [my_a accessMember:3];
+ [A accessStaticMember:5];
+
+ [pool release];
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/Makefile
new file mode 100644
index 00000000000..37dd8f40a9d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/Makefile
@@ -0,0 +1,6 @@
+OBJC_SOURCES := main.m
+
+
+
+LD_EXTRAS := -framework Foundation
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py
new file mode 100644
index 00000000000..85ad6286716
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py
@@ -0,0 +1,74 @@
+"""Test that we properly vend children for a single entry NSDictionary"""
+
+
+
+import unittest2
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ObjCSingleEntryDictionaryTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.line = line_number('main.m', '// break here')
+
+ @skipUnlessDarwin
+ @expectedFailureAll(oslist=['watchos'], bugnumber="rdar://problem/34642736") # bug in NSDictionary formatting on watchos
+ def test_single_entry_dict(self):
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break inside the foo function which takes a bar_ptr argument.
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ 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'])
+
+ d1 = self.frame().FindVariable("d1")
+ d1.SetPreferSyntheticValue(True)
+ d1.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
+
+ self.assertTrue(
+ d1.GetNumChildren() == 1,
+ "dictionary has != 1 child elements")
+ pair = d1.GetChildAtIndex(0)
+ pair.SetPreferSyntheticValue(True)
+ pair.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
+
+ self.assertTrue(
+ pair.GetNumChildren() == 2,
+ "pair has != 2 child elements")
+
+ key = pair.GetChildMemberWithName("key")
+ value = pair.GetChildMemberWithName("value")
+
+ key.SetPreferSyntheticValue(True)
+ key.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
+ value.SetPreferSyntheticValue(True)
+ value.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
+
+ self.assertTrue(
+ key.GetSummary() == '@"key"',
+ "key doesn't contain key")
+ self.assertTrue(
+ value.GetSummary() == '@"value"',
+ "value doesn't contain value")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/main.m
new file mode 100644
index 00000000000..be472fd43c3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/main.m
@@ -0,0 +1,7 @@
+#import <Foundation/Foundation.h>
+
+int main() {
+ NSDictionary *d1 = @{@"key" : @"value"};
+ NSLog(@"%@\n", d1); // break here
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
new file mode 100644
index 00000000000..c9986aafd7d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
@@ -0,0 +1,6 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(
+ __file__, globals(), [
+ decorators.skipUnlessDarwin])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m
new file mode 100644
index 00000000000..e55eb1ede9b
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m
@@ -0,0 +1,5 @@
+#import <Foundation/Foundation.h>
+
+int main() {
+ NSLog(@"凸"); //% self.expect("po @\"凹\"", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["凹"])
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/variadic_methods/TestVariadicMethods.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/variadic_methods/TestVariadicMethods.py
new file mode 100644
index 00000000000..562d9ae01e2
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/variadic_methods/TestVariadicMethods.py
@@ -0,0 +1,7 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(
+ __file__, globals(), [
+ decorators.skipIfFreeBSD, decorators.skipIfLinux,
+ decorators.skipIfWindows, decorators.skipIfNetBSD])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/variadic_methods/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/variadic_methods/main.m
new file mode 100644
index 00000000000..609d783dd59
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/variadic_methods/main.m
@@ -0,0 +1,30 @@
+//===-- main.m -------------------------------------------*- Objective-C-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#import <Foundation/Foundation.h>
+
+@interface VarClass : NSObject
+- (id) lottaArgs: (id) first, ...;
+@end
+
+@implementation VarClass
+- (id) lottaArgs: (id) first, ...
+{
+ return first;
+}
+@end
+
+int
+main()
+{
+ VarClass *my_var = [[VarClass alloc] init];
+ id something = [my_var lottaArgs: @"111", @"222", nil];
+ NSLog (@"%@ - %@", my_var, something); //% self.expect("expression -O -- [my_var lottaArgs:@\"111\", @\"222\", nil]", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["111"])
+ return 0;
+}
+