Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@ -0,0 +1 @@
objc

View File

@ -0,0 +1,12 @@
from lldbsuite.test import lldbinline
from lldbsuite.test import decorators
lldbinline.MakeInlineTest(
__file__,
globals(),
[
decorators.skipIfFreeBSD,
decorators.skipIfLinux,
decorators.skipIfWindows,
decorators.expectedFailureAll(
bugnumber="rdar://problem/17990991")])

View File

@ -0,0 +1,52 @@
//===-- main.m -------------------------------------------*- Objective-C-*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#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;
}

View File

@ -0,0 +1,6 @@
LEVEL = ../../../make
OBJC_SOURCES := ivars-in-blocks.m main.m
LDFLAGS = $(CFLAGS) -lobjc -framework Foundation
include $(LEVEL)/Makefile.rules

View File

@ -0,0 +1,135 @@
"""Test printing ivars and ObjC objects captured in blocks that are made in methods of an ObjC class."""
from __future__ import print_function
import os
import time
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'])
@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 = os.path.join(os.getcwd(), "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.")

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -0,0 +1,38 @@
LEVEL = ../../../make
CC ?= clang
ifeq "$(ARCH)" ""
ARCH = x86_64
endif
ifeq "$(OS)" ""
OS = $(shell uname -s)
endif
CFLAGS ?= -g -O0
ifeq "$(OS)" "Darwin"
CFLAGS += -arch $(ARCH)
endif
LDFLAGS = $(CFLAGS) -lobjc -framework Foundation
all: a.out libTest.dylib libTestExt.dylib
libTest.dylib: Test/Test.m
$(CC) $(CFLAGS) -I. -c -o Test.o Test/Test.m
$(CC) $(LDFLAGS) -shared -o libTest.dylib Test.o
dsymutil libTest.dylib
libTestExt.dylib: TestExt/TestExt.m
$(CC) $(CFLAGS) -I. -c -o TestExt.o TestExt/TestExt.m
$(CC) $(LDFLAGS) -L. -lTest -shared -o libTestExt.dylib TestExt.o
dsymutil libTestExt.dylib
a.out: main.m libTest.dylib libTestExt.dylib
$(CC) $(LDFLAGS) -I. -L. -lTest -lTestExt -o a.out main.m
.PHONY: clean
clean:
rm -rf libTest.dylib libTestExt.dylib a.out Test.o TestExt.o libTest.dylib.dSYM libTest.dylib.dSYM

View File

@ -0,0 +1,9 @@
#ifndef __Foo_h__
#define __Foo_h__
typedef struct {
float start;
float duration;
} CMTimeRange;
#endif

View File

@ -0,0 +1,10 @@
#import <Foundation/Foundation.h>
#import <Test/Foo.h>
@interface Test : NSObject {
@public
CMTimeRange _range;
}
- (void) doTest;
@end

View File

@ -0,0 +1,8 @@
#import "Test.h"
@implementation Test
- (void) doTest {
NSLog(@"-[Test doTest]");
}
@end

View File

@ -0,0 +1,53 @@
"""Test that types defined in shared libraries work correctly."""
from __future__ import print_function
import os
import time
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 = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.registerSharedLibrariesWithTarget(target, self.shlib_names)
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)

View File

@ -0,0 +1,9 @@
#ifndef __Foo_h__
#define __Foo_h__
typedef struct {
float s;
float d;
} CMTimeRange;
#endif

View File

@ -0,0 +1,7 @@
#import <TestExt/Foo.h>
#import <Test/Test.h>
struct CMTimeRange;
@interface Test (Stuff)
- (void)doSomethingElse: (CMTimeRange *)range_ptr;
@end

View File

@ -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

View File

@ -0,0 +1,10 @@
#import <Test/Test.h>
#import <TestExt/TestExt.h>
int main() {
@autoreleasepool {
Test *test = [[Test alloc] init];
[test doSomethingElse:&test->_range];
}
}

View File

@ -0,0 +1,13 @@
#import <Foundation/Foundation.h>
@class ForwardDeclaredClass;
@interface Container : NSObject {
@public
ForwardDeclaredClass *member;
}
-(id)init;
-(ForwardDeclaredClass*)getMember;
@end

View File

@ -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

View File

@ -0,0 +1,9 @@
LEVEL = ../../../make
DYLIB_NAME := Container
DYLIB_OBJC_SOURCES := Container.m
OBJC_SOURCES := main.m
include $(LEVEL)/Makefile.rules
LDFLAGS += -framework Foundation

Some files were not shown because too many files have changed in this diff Show More