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

View File

@ -0,0 +1,5 @@
LEVEL = ../../make
CXX_SOURCES := main.cpp
include $(LEVEL)/Makefile.rules

View File

@ -0,0 +1,45 @@
"""
Test calling user defined functions using expression evaluation.
This test checks that typesystem lookup works correctly for typedefs of
untagged structures.
Ticket: https://llvm.org/bugs/show_bug.cgi?id=26790
"""
from __future__ import print_function
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class TestExprLookupAnonStructTypedef(TestBase):
mydir = TestBase.compute_mydir(__file__)
def setUp(self):
TestBase.setUp(self)
# Find the breakpoint
self.line = line_number('main.cpp', '// lldb testsuite break')
@expectedFailureAll(oslist=["windows"])
@expectedFailureAll(
oslist=['linux'],
archs=['arm'],
bugnumber="llvm.org/pr27868")
def test(self):
"""Test typedeffed untagged struct arguments for function call expressions"""
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
lldbutil.run_break_set_by_file_and_line(
self,
"main.cpp",
self.line,
num_expected_locations=-1,
loc_exact=True
)
self.runCmd("run", RUN_SUCCEEDED)
self.expect("expr multiply(&s)", substrs=['$0 = 1'])

View File

@ -0,0 +1,26 @@
#include <tgmath.h>
typedef struct {
float f;
int i;
} my_untagged_struct;
double multiply(my_untagged_struct *s)
{
return s->f * s->i;
}
double multiply(my_untagged_struct *s, int x)
{
return multiply(s) * x;
}
int main(int argc, char **argv)
{
my_untagged_struct s = {
.f = (float)argc,
.i = argc,
};
// lldb testsuite break
return !(multiply(&s, argc) == pow(argc, 3));
}

View File

@ -0,0 +1,27 @@
"""
Test calling an expression without a target.
"""
from __future__ import print_function
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class TestCalculatorMode(TestBase):
mydir = TestBase.compute_mydir(__file__)
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
def test__calculator_mode(self):
"""Test calling expressions in the dummy target."""
self.expect("expression 11 + 22", "11 + 22 didn't get the expected result", substrs=["33"])
# Now try it with a specific language:
self.expect("expression -l c -- 11 + 22", "11 + 22 didn't get the expected result", substrs=["33"])

View File

@ -0,0 +1,8 @@
LEVEL = ../../make
CXX_SOURCES := main.cpp
include $(LEVEL)/Makefile.rules
clean::
rm -rf $(wildcard *.o *.d *.dSYM)

View File

@ -0,0 +1,56 @@
"""
Test calling std::String member functions.
"""
from __future__ import print_function
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class ExprCommandCallFunctionTestCase(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.line = line_number(
'main.cpp',
'// Please test these expressions while stopped at this line:')
@expectedFailureAll(
compiler="icc",
bugnumber="llvm.org/pr14437, fails with ICC 13.1")
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
def test_with(self):
"""Test calling std::String member function."""
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
# Some versions of GCC encode two locations for the 'return' statement
# in main.cpp
lldbutil.run_break_set_by_file_and_line(
self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True)
self.runCmd("run", RUN_SUCCEEDED)
self.expect("print str",
substrs=['Hello world'])
# Calling this function now succeeds, but we follow the typedef return type through to
# const char *, and thus don't invoke the Summary formatter.
# clang's libstdc++ on ios arm64 inlines std::string::c_str() always;
# skip this part of the test.
triple = self.dbg.GetSelectedPlatform().GetTriple()
do_cstr_test = True
if triple == "arm64-apple-ios" or triple == "arm64-apple-tvos" or triple == "armv7k-apple-watchos" or triple == "arm64-apple-bridgeos":
do_cstr_test = False
if do_cstr_test:
self.expect("print str.c_str()",
substrs=['Hello world'])

View File

@ -0,0 +1,58 @@
"""
Test calling a function, stopping in the call, continue and gather the result on stop.
"""
from __future__ import print_function
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class ExprCommandCallStopContinueTestCase(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.line = line_number(
'main.cpp',
'// Please test these expressions while stopped at this line:')
self.func_line = line_number('main.cpp', '{5, "five"}')
@expectedFlakeyDarwin("llvm.org/pr20274")
@expectedFailureAll(
oslist=["windows"],
bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
def test(self):
"""Test gathering result from interrupted function call."""
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
# Some versions of GCC encode two locations for the 'return' statement
# in main.cpp
lldbutil.run_break_set_by_file_and_line(
self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True)
self.runCmd("run", RUN_SUCCEEDED)
lldbutil.run_break_set_by_file_and_line(
self,
"main.cpp",
self.func_line,
num_expected_locations=-1,
loc_exact=True)
self.expect("expr -i false -- returnsFive()", error=True,
substrs=['Execution was interrupted, reason: breakpoint'])
self.runCmd("continue", "Continue completed")
self.expect(
"thread list",
substrs=[
'stop reason = User Expression thread plan',
r'Completed expression: (Five) $0 = (number = 5, name = "five")'])

View File

@ -0,0 +1,62 @@
"""
Test calling user defined functions using expression evaluation.
Note:
LLDBs current first choice of evaluating functions is using the IR interpreter,
which is only supported on Hexagon. Otherwise JIT is used for the evaluation.
"""
from __future__ import print_function
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class ExprCommandCallUserDefinedFunction(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.line = line_number(
'main.cpp',
'// Please test these expressions while stopped at this line:')
@expectedFlakeyDsym("llvm.org/pr20274")
@expectedFailureAll(
oslist=["windows"],
bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
def test(self):
"""Test return values of user defined function calls."""
self.build()
# Set breakpoint in main and run exe
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
lldbutil.run_break_set_by_file_and_line(
self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True)
self.runCmd("run", RUN_SUCCEEDED)
# Test recursive function call.
self.expect("expr fib(5)", substrs=['$0 = 5'])
# Test function with more than one paramter
self.expect("expr add(4,8)", substrs=['$1 = 12'])
# Test nesting function calls in function paramters
self.expect("expr add(add(5,2),add(3,4))", substrs=['$2 = 14'])
self.expect("expr add(add(5,2),fib(5))", substrs=['$3 = 12'])
# Test function with pointer paramter
self.expect(
"exp stringCompare((const char*) \"Hello world\")",
substrs=['$4 = true'])
self.expect(
"exp stringCompare((const char*) \"Hellworld\")",
substrs=['$5 = false'])

View File

@ -0,0 +1,53 @@
#include <iostream>
#include <string>
#include <cstring>
struct Five
{
int number;
const char *name;
};
Five
returnsFive()
{
Five my_five = {5, "five"};
return my_five;
}
unsigned int
fib(unsigned int n)
{
if (n < 2)
return n;
else
return fib(n - 1) + fib(n - 2);
}
int
add(int a, int b)
{
return a + b;
}
bool
stringCompare(const char *str)
{
if (strcmp( str, "Hello world" ) == 0)
return true;
else
return false;
}
int main (int argc, char const *argv[])
{
std::string str = "Hello world";
std::cout << str << std::endl;
std::cout << str.c_str() << std::endl;
Five main_five = returnsFive();
#if 0
print str
print str.c_str()
#endif
return 0; // Please test these expressions while stopped at this line:
}

View File

@ -0,0 +1,5 @@
LEVEL = ../../make
C_SOURCES := lotta-signals.c
include $(LEVEL)/Makefile.rules

View File

@ -0,0 +1,166 @@
"""
Test calling a function that hits a signal set to auto-restart, make sure the call completes.
"""
from __future__ import print_function
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class ExprCommandThatRestartsTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
NO_DEBUG_INFO_TESTCASE = True
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
self.main_source = "lotta-signals.c"
self.main_source_spec = lldb.SBFileSpec(self.main_source)
@skipIfFreeBSD # llvm.org/pr19246: intermittent failure
@skipIfDarwin # llvm.org/pr19246: intermittent failure
@skipIfWindows # Test relies on signals, unsupported on Windows
@expectedFlakeyAndroid(bugnumber="llvm.org/pr19246")
def test(self):
"""Test calling function that hits a signal and restarts."""
self.build()
self.call_function()
def check_after_call(self, num_sigchld):
after_call = self.sigchld_no.GetValueAsSigned(-1)
self.assertTrue(
after_call -
self.start_sigchld_no == num_sigchld,
"Really got %d SIGCHLD signals through the call." %
(num_sigchld))
self.start_sigchld_no = after_call
# Check that we are back where we were before:
frame = self.thread.GetFrameAtIndex(0)
self.assertTrue(
self.orig_frame_pc == frame.GetPC(),
"Restored the zeroth frame correctly")
def call_function(self):
(target, process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
'Stop here in main.', self.main_source_spec)
# Make sure the SIGCHLD behavior is pass/no-stop/no-notify:
return_obj = lldb.SBCommandReturnObject()
self.dbg.GetCommandInterpreter().HandleCommand(
"process handle SIGCHLD -s 0 -p 1 -n 0", return_obj)
self.assertTrue(return_obj.Succeeded(), "Set SIGCHLD to pass, no-stop")
# The sigchld_no variable should be 0 at this point.
self.sigchld_no = target.FindFirstGlobalVariable("sigchld_no")
self.assertTrue(
self.sigchld_no.IsValid(),
"Got a value for sigchld_no")
self.start_sigchld_no = self.sigchld_no.GetValueAsSigned(-1)
self.assertTrue(
self.start_sigchld_no != -1,
"Got an actual value for sigchld_no")
options = lldb.SBExpressionOptions()
# processing 30 signals takes a while, increase the expression timeout
# a bit
options.SetTimeoutInMicroSeconds(3000000) # 3s
options.SetUnwindOnError(True)
frame = self.thread.GetFrameAtIndex(0)
# Store away the PC to check that the functions unwind to the right
# place after calls
self.orig_frame_pc = frame.GetPC()
num_sigchld = 30
value = frame.EvaluateExpression(
"call_me (%d)" %
(num_sigchld), options)
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success())
self.assertTrue(value.GetValueAsSigned(-1) == num_sigchld)
self.check_after_call(num_sigchld)
# Okay, now try with a breakpoint in the called code in the case where
# we are ignoring breakpoint hits.
handler_bkpt = target.BreakpointCreateBySourceRegex(
"Got sigchld %d.", self.main_source_spec)
self.assertTrue(handler_bkpt.GetNumLocations() > 0)
options.SetIgnoreBreakpoints(True)
options.SetUnwindOnError(True)
value = frame.EvaluateExpression(
"call_me (%d)" %
(num_sigchld), options)
self.assertTrue(value.IsValid() and value.GetError().Success())
self.assertTrue(value.GetValueAsSigned(-1) == num_sigchld)
self.check_after_call(num_sigchld)
# Now set the signal to print but not stop and make sure that calling
# still works:
self.dbg.GetCommandInterpreter().HandleCommand(
"process handle SIGCHLD -s 0 -p 1 -n 1", return_obj)
self.assertTrue(
return_obj.Succeeded(),
"Set SIGCHLD to pass, no-stop, notify")
value = frame.EvaluateExpression(
"call_me (%d)" %
(num_sigchld), options)
self.assertTrue(value.IsValid() and value.GetError().Success())
self.assertTrue(value.GetValueAsSigned(-1) == num_sigchld)
self.check_after_call(num_sigchld)
# Now set this unwind on error to false, and make sure that we still
# complete the call:
options.SetUnwindOnError(False)
value = frame.EvaluateExpression(
"call_me (%d)" %
(num_sigchld), options)
self.assertTrue(value.IsValid() and value.GetError().Success())
self.assertTrue(value.GetValueAsSigned(-1) == num_sigchld)
self.check_after_call(num_sigchld)
# Okay, now set UnwindOnError to true, and then make the signal behavior to stop
# and see that now we do stop at the signal point:
self.dbg.GetCommandInterpreter().HandleCommand(
"process handle SIGCHLD -s 1 -p 1 -n 1", return_obj)
self.assertTrue(
return_obj.Succeeded(),
"Set SIGCHLD to pass, stop, notify")
value = frame.EvaluateExpression(
"call_me (%d)" %
(num_sigchld), options)
self.assertTrue(
value.IsValid() and value.GetError().Success() == False)
# Set signal handling back to no-stop, and continue and we should end
# up back in out starting frame:
self.dbg.GetCommandInterpreter().HandleCommand(
"process handle SIGCHLD -s 0 -p 1 -n 1", return_obj)
self.assertTrue(
return_obj.Succeeded(),
"Set SIGCHLD to pass, no-stop, notify")
error = process.Continue()
self.assertTrue(
error.Success(),
"Continuing after stopping for signal succeeds.")
frame = self.thread.GetFrameAtIndex(0)
self.assertTrue(
frame.GetPC() == self.orig_frame_pc,
"Continuing returned to the place we started.")

View File

@ -0,0 +1,61 @@
#include <unistd.h>
#include <stdio.h>
#include <signal.h>
static int sigchld_no;
static int nosig_no;
static int weird_value;
void
sigchld_handler (int signo)
{
sigchld_no++;
printf ("Got sigchld %d.\n", sigchld_no);
}
int
call_me (int some_value)
{
int ret_val = 0;
int i;
for (i = 0; i < some_value; i++)
{
int result = 0;
if (i%2 == 0)
result = kill (getpid(), SIGCHLD);
else
sigchld_no++;
usleep(1000);
if (result == 0)
ret_val++;
}
usleep (10000);
return ret_val;
}
int
call_me_nosig (int some_value)
{
int ret_val = 0;
int i;
for (i = 0; i < some_value; i++)
weird_value += i % 4;
nosig_no += some_value;
return some_value;
}
int
main ()
{
int ret_val;
signal (SIGCHLD, sigchld_handler);
ret_val = call_me (2); // Stop here in main.
ret_val = call_me_nosig (10);
return 0;
}

View File

@ -0,0 +1,6 @@
LEVEL = ../../make
OBJC_SOURCES := call-throws.m
include $(LEVEL)/Makefile.rules
LDFLAGS += -framework Foundation

View File

@ -0,0 +1,104 @@
"""
Test calling a function that throws an ObjC exception, make sure that it doesn't propagate the exception.
"""
from __future__ import print_function
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class ExprCommandWithThrowTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
self.main_source = "call-throws.m"
self.main_source_spec = lldb.SBFileSpec(self.main_source)
@skipUnlessDarwin
def test(self):
"""Test calling a function that throws and ObjC exception."""
self.build()
self.call_function()
def check_after_call(self):
# Check that we are back where we were before:
frame = self.thread.GetFrameAtIndex(0)
self.assertTrue(
self.orig_frame_pc == frame.GetPC(),
"Restored the zeroth frame correctly")
def call_function(self):
"""Test calling function that throws."""
(target, process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
'I am about to throw.', self.main_source_spec)
options = lldb.SBExpressionOptions()
options.SetUnwindOnError(True)
frame = self.thread.GetFrameAtIndex(0)
# Store away the PC to check that the functions unwind to the right
# place after calls
self.orig_frame_pc = frame.GetPC()
value = frame.EvaluateExpression("[my_class callMeIThrow]", options)
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success() == False)
self.check_after_call()
# Okay, now try with a breakpoint in the called code in the case where
# we are ignoring breakpoint hits.
handler_bkpt = target.BreakpointCreateBySourceRegex(
"I felt like it", self.main_source_spec)
self.assertTrue(handler_bkpt.GetNumLocations() > 0)
options.SetIgnoreBreakpoints(True)
options.SetUnwindOnError(True)
value = frame.EvaluateExpression("[my_class callMeIThrow]", options)
self.assertTrue(
value.IsValid() and value.GetError().Success() == False)
self.check_after_call()
# Now set the ObjC language breakpoint and make sure that doesn't
# interfere with the call:
exception_bkpt = target.BreakpointCreateForException(
lldb.eLanguageTypeObjC, False, True)
self.assertTrue(exception_bkpt.GetNumLocations() > 0)
options.SetIgnoreBreakpoints(True)
options.SetUnwindOnError(True)
value = frame.EvaluateExpression("[my_class callMeIThrow]", options)
self.assertTrue(
value.IsValid() and value.GetError().Success() == False)
self.check_after_call()
# Now turn off exception trapping, and call a function that catches the exceptions,
# and make sure the function actually completes, and we get the right
# value:
options.SetTrapExceptions(False)
value = frame.EvaluateExpression("[my_class iCatchMyself]", options)
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success())
self.assertTrue(value.GetValueAsUnsigned() == 57)
self.check_after_call()
options.SetTrapExceptions(True)
# Now set this unwind on error to false, and make sure that we stop
# where the exception was thrown
options.SetUnwindOnError(False)
value = frame.EvaluateExpression("[my_class callMeIThrow]", options)
self.assertTrue(
value.IsValid() and value.GetError().Success() == False)
self.check_after_call()

View File

@ -0,0 +1,47 @@
#import <Foundation/Foundation.h>
@interface MyClass : NSObject
{
}
- (int) callMeIThrow;
- (int) iCatchMyself;
@end
@implementation MyClass
- (int) callMeIThrow
{
NSException *e = [NSException
exceptionWithName:@"JustForTheHeckOfItException"
reason:@"I felt like it"
userInfo:nil];
@throw e;
return 56;
}
- (int) iCatchMyself
{
int return_value = 55;
@try
{
return_value = [self callMeIThrow];
}
@catch (NSException *e)
{
return_value = 57;
}
return return_value;
}
@end
int
main ()
{
int return_value;
MyClass *my_class = [[MyClass alloc] init];
NSLog (@"I am about to throw.");
return_value = [my_class iCatchMyself];
return return_value;
}

View File

@ -0,0 +1,5 @@
LEVEL = ../../make
CXX_SOURCES := main.cpp
include $(LEVEL)/Makefile.rules

View File

@ -0,0 +1,69 @@
from __future__ import print_function
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class ExprCharTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
self.main_source = "main.cpp"
self.main_source_spec = lldb.SBFileSpec(self.main_source)
def do_test(self, dictionary=None):
"""These basic expression commands should work as expected."""
self.build(dictionary=dictionary)
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
'// Break here', self.main_source_spec)
frame = thread.GetFrameAtIndex(0)
value = frame.EvaluateExpression("foo(c)")
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success())
self.assertEqual(value.GetValueAsSigned(0), 1)
value = frame.EvaluateExpression("foo(sc)")
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success())
self.assertEqual(value.GetValueAsSigned(0), 2)
value = frame.EvaluateExpression("foo(uc)")
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success())
self.assertEqual(value.GetValueAsSigned(0), 3)
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
def test_default_char(self):
self.do_test()
@expectedFailureAll(
archs=[
"arm",
"aarch64",
"s390x"],
bugnumber="llvm.org/pr23069")
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
def test_signed_char(self):
self.do_test(dictionary={'CFLAGS_EXTRAS': '-fsigned-char'})
@expectedFailureAll(
archs=[
"i[3-6]86",
"x86_64",
"arm64",
'armv7',
'armv7k'],
bugnumber="llvm.org/pr23069, <rdar://problem/28721938>")
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
@expectedFailureAll(triple='mips*', bugnumber="llvm.org/pr23069")
def test_unsigned_char(self):
self.do_test(dictionary={'CFLAGS_EXTRAS': '-funsigned-char'})

View File

@ -0,0 +1,10 @@
int foo(char c) { return 1; }
int foo(signed char c) { return 2; }
int foo(unsigned char c) { return 3; }
int main() {
char c = 0;
signed char sc = 0;
unsigned char uc = 0;
return 0; // Break here
}

View File

@ -0,0 +1,5 @@
LEVEL = ../../make
CXX_SOURCES := main.cpp
include $(LEVEL)/Makefile.rules

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