summaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Python/lldbsuite')
-rw-r--r--packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py24
-rw-r--r--packages/Python/lldbsuite/test/expression_command/call-throws/TestCallThatThrows.py24
-rw-r--r--packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py21
-rw-r--r--packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py24
-rw-r--r--packages/Python/lldbsuite/test/expression_command/issue_11588/Test11588.py23
-rw-r--r--packages/Python/lldbsuite/test/expression_command/macros/TestMacros.py28
-rw-r--r--packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py21
-rw-r--r--packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py13
-rw-r--r--packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py28
-rw-r--r--packages/Python/lldbsuite/test/functionalities/mtc/simple/Makefile6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py57
-rw-r--r--packages/Python/lldbsuite/test/functionalities/mtc/simple/main.m15
-rw-r--r--packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/signal/raise/main.c7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/Makefile6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/TestUbsanUserExpression.py49
-rw-r--r--packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/main.c9
-rw-r--r--packages/Python/lldbsuite/test/lang/go/types/TestGoASTContext.py1
-rw-r--r--packages/Python/lldbsuite/test/lldbplatformutil.py14
-rw-r--r--packages/Python/lldbsuite/test/lldbutil.py41
-rw-r--r--packages/Python/lldbsuite/test/make/Android.rules4
-rw-r--r--packages/Python/lldbsuite/test/sample_test/TestSampleTest.py40
23 files changed, 241 insertions, 221 deletions
diff --git a/packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py b/packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py
index 0b9ad0ed63232..5eb7b309c94a0 100644
--- a/packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py
+++ b/packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py
@@ -48,28 +48,8 @@ class ExprCommandThatRestartsTestCase(TestBase):
"Restored the zeroth frame correctly")
def call_function(self):
- exe_name = "a.out"
- exe = os.path.join(os.getcwd(), exe_name)
-
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
- empty = lldb.SBFileSpec()
- breakpoint = target.BreakpointCreateBySourceRegex(
- 'Stop here in main.', self.main_source_spec)
- self.assertTrue(breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT)
-
- # Launch the process, and do not stop at the entry point.
- process = target.LaunchSimple(
- None, None, self.get_process_working_directory())
-
- self.assertTrue(process, PROCESS_IS_VALID)
-
- # Frame #0 should be at our breakpoint.
- threads = lldbutil.get_threads_stopped_at_breakpoint(
- process, breakpoint)
-
- self.assertTrue(len(threads) == 1)
- self.thread = threads[0]
+ (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()
diff --git a/packages/Python/lldbsuite/test/expression_command/call-throws/TestCallThatThrows.py b/packages/Python/lldbsuite/test/expression_command/call-throws/TestCallThatThrows.py
index e5162609dfa60..f2ec340ac8459 100644
--- a/packages/Python/lldbsuite/test/expression_command/call-throws/TestCallThatThrows.py
+++ b/packages/Python/lldbsuite/test/expression_command/call-throws/TestCallThatThrows.py
@@ -37,28 +37,8 @@ class ExprCommandWithThrowTestCase(TestBase):
def call_function(self):
"""Test calling function that throws."""
- exe_name = "a.out"
- exe = os.path.join(os.getcwd(), exe_name)
-
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
-
- breakpoint = target.BreakpointCreateBySourceRegex(
- 'I am about to throw.', self.main_source_spec)
- self.assertTrue(breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT)
-
- # Launch the process, and do not stop at the entry point.
- process = target.LaunchSimple(
- None, None, self.get_process_working_directory())
-
- self.assertTrue(process, PROCESS_IS_VALID)
-
- # Frame #0 should be at our breakpoint.
- threads = lldbutil.get_threads_stopped_at_breakpoint(
- process, breakpoint)
-
- self.assertTrue(len(threads) == 1)
- self.thread = threads[0]
+ (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)
diff --git a/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py b/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py
index a771e7004c945..74991999d926a 100644
--- a/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py
+++ b/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py
@@ -17,29 +17,14 @@ class ExprCharTestCase(TestBase):
self.main_source = "main.cpp"
self.main_source_spec = lldb.SBFileSpec(self.main_source)
- self.exe = os.path.join(os.getcwd(), "a.out")
def do_test(self, dictionary=None):
"""These basic expression commands should work as expected."""
self.build(dictionary=dictionary)
- target = self.dbg.CreateTarget(self.exe)
- self.assertTrue(target)
-
- breakpoint = target.BreakpointCreateBySourceRegex(
- '// Break here', self.main_source_spec)
- self.assertTrue(breakpoint)
-
- # Launch the process, and do not stop at the entry point.
- process = target.LaunchSimple(
- None, None, self.get_process_working_directory())
- self.assertTrue(process)
-
- threads = lldbutil.get_threads_stopped_at_breakpoint(
- process, breakpoint)
- self.assertEqual(len(threads), 1)
-
- frame = threads[0].GetFrameAtIndex(0)
+ (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())
diff --git a/packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py b/packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py
index 418c5325ad080..4b096149e7286 100644
--- a/packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py
+++ b/packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py
@@ -37,28 +37,8 @@ class ExprCommandWithFixits(TestBase):
def try_expressions(self):
"""Test calling expressions with errors that can be fixed by the FixIts."""
- exe_name = "a.out"
- exe = os.path.join(os.getcwd(), exe_name)
-
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
-
- breakpoint = target.BreakpointCreateBySourceRegex(
- 'Stop here to evaluate expressions', self.main_source_spec)
- self.assertTrue(breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT)
-
- # Launch the process, and do not stop at the entry point.
- process = target.LaunchSimple(
- None, None, self.get_process_working_directory())
-
- self.assertTrue(process, PROCESS_IS_VALID)
-
- # Frame #0 should be at our breakpoint.
- threads = lldbutil.get_threads_stopped_at_breakpoint(
- process, breakpoint)
-
- self.assertTrue(len(threads) == 1)
- self.thread = threads[0]
+ (target, process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
+ 'Stop here to evaluate expressions', self.main_source_spec)
options = lldb.SBExpressionOptions()
options.SetAutoApplyFixIts(True)
diff --git a/packages/Python/lldbsuite/test/expression_command/issue_11588/Test11588.py b/packages/Python/lldbsuite/test/expression_command/issue_11588/Test11588.py
index afb497e04b5bb..a2d68cffe5484 100644
--- a/packages/Python/lldbsuite/test/expression_command/issue_11588/Test11588.py
+++ b/packages/Python/lldbsuite/test/expression_command/issue_11588/Test11588.py
@@ -32,26 +32,9 @@ class Issue11581TestCase(TestBase):
"""valobj.AddressOf() should return correct values."""
self.build()
- exe = os.path.join(os.getcwd(), "a.out")
-
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
-
- breakpoint = target.BreakpointCreateBySourceRegex(
- 'Set breakpoint here.', lldb.SBFileSpec("main.cpp", False))
-
- 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]
-
+ (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
+ 'Set breakpoint here.',
+ lldb.SBFileSpec("main.cpp", False))
self.runCmd("command script import --allow-reload s11588.py")
self.runCmd(
"type synthetic add --python-class s11588.Issue11581SyntheticProvider StgClosure")
diff --git a/packages/Python/lldbsuite/test/expression_command/macros/TestMacros.py b/packages/Python/lldbsuite/test/expression_command/macros/TestMacros.py
index 70b862bf48678..817f6cb3944a6 100644
--- a/packages/Python/lldbsuite/test/expression_command/macros/TestMacros.py
+++ b/packages/Python/lldbsuite/test/expression_command/macros/TestMacros.py
@@ -30,32 +30,8 @@ class TestMacros(TestBase):
src_file_spec = lldb.SBFileSpec(src_file)
self.assertTrue(src_file_spec.IsValid(), "Main source file")
- # Get the path of the executable
- cwd = os.getcwd()
- exe_file = "a.out"
- exe_path = os.path.join(cwd, exe_file)
-
- # Load the executable
- target = self.dbg.CreateTarget(exe_path)
- self.assertTrue(target.IsValid(), VALID_TARGET)
-
- # Set breakpoints
- bp1 = target.BreakpointCreateBySourceRegex("Break here", src_file_spec)
- self.assertTrue(
- bp1.IsValid() and bp1.GetNumLocations() >= 1,
- VALID_BREAKPOINT)
-
- # Launch the process
- process = target.LaunchSimple(
- None, None, self.get_process_working_directory())
- self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
-
- # Get the thread of the process
- self.assertTrue(
- process.GetState() == lldb.eStateStopped,
- PROCESS_STOPPED)
- thread = lldbutil.get_stopped_thread(
- process, lldb.eStopReasonBreakpoint)
+ (target, process, thread, bp1) = lldbutil.run_to_source_breakpoint(
+ self, "Break here", src_file_spec)
# Get frame for current thread
frame = thread.GetSelectedFrame()
diff --git a/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py b/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py
index 0d1a17352a3f0..b4e9a8bfeab8b 100644
--- a/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py
+++ b/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py
@@ -37,25 +37,10 @@ class ExprOptionsTestCase(TestBase):
# Set debugger into synchronous mode
self.dbg.SetAsync(False)
- # Create a target by the debugger.
- target = self.dbg.CreateTarget(self.exe)
- self.assertTrue(target, VALID_TARGET)
+ (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+ self, '// breakpoint_in_main', self.main_source_spec)
- # Set breakpoints inside main.
- breakpoint = target.BreakpointCreateBySourceRegex(
- '// breakpoint_in_main', self.main_source_spec)
- self.assertTrue(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)
-
- threads = lldbutil.get_threads_stopped_at_breakpoint(
- process, breakpoint)
- self.assertEqual(len(threads), 1)
-
- frame = threads[0].GetFrameAtIndex(0)
+ frame = thread.GetFrameAtIndex(0)
options = lldb.SBExpressionOptions()
# test --language on C++ expression using the SB API's
diff --git a/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py b/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py
index 7f796971d0ed9..f6938b1ea98b0 100644
--- a/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py
+++ b/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py
@@ -31,17 +31,10 @@ class SaveJITObjectsTestCase(TestBase):
src_file = "main.c"
src_file_spec = lldb.SBFileSpec(src_file)
- exe_path = os.path.join(os.getcwd(), "a.out")
- target = self.dbg.CreateTarget(exe_path)
+ (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+ self, "break", src_file_spec)
- breakpoint = target.BreakpointCreateBySourceRegex(
- "break", src_file_spec)
-
- process = target.LaunchSimple(None, None,
- self.get_process_working_directory())
-
- thread = process.GetSelectedThread()
- frame = thread.GetSelectedFrame()
+ frame = thread.frames[0]
cleanJITFiles()
frame.EvaluateExpression("(void*)malloc(0x1)")
diff --git a/packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py b/packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py
index 29c03b1d7ef90..7862477001ead 100644
--- a/packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py
+++ b/packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py
@@ -25,36 +25,14 @@ class ExprCommandWithTimeoutsTestCase(TestBase):
@expectedFlakeyFreeBSD("llvm.org/pr19605")
@expectedFailureAll(
oslist=[
- "windows",
- "macosx"],
+ "windows"],
bugnumber="llvm.org/pr21765")
def test(self):
"""Test calling std::String member function."""
self.build()
- exe_name = "a.out"
- exe = os.path.join(os.getcwd(), exe_name)
-
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
-
- breakpoint = target.BreakpointCreateBySourceRegex(
- 'stop here in main.', self.main_source_spec)
- 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.assertTrue(process, PROCESS_IS_VALID)
-
- # Frame #0 should be on self.step_out_of_malloc.
- threads = lldbutil.get_threads_stopped_at_breakpoint(
- process, breakpoint)
-
- self.assertTrue(len(threads) == 1)
- thread = threads[0]
+ (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+ self, 'stop here in main.', self.main_source_spec)
# First set the timeout too short, and make sure we fail.
options = lldb.SBExpressionOptions()
diff --git a/packages/Python/lldbsuite/test/functionalities/mtc/simple/Makefile b/packages/Python/lldbsuite/test/functionalities/mtc/simple/Makefile
new file mode 100644
index 0000000000000..5665652329dc0
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/mtc/simple/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+OBJC_SOURCES := main.m
+LDFLAGS = $(CFLAGS) -lobjc -framework Foundation -framework AppKit
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py b/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py
new file mode 100644
index 0000000000000..6a779ecfac5b2
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py
@@ -0,0 +1,57 @@
+"""
+Tests basic Main Thread Checker support (detecting a main-thread-only violation).
+"""
+
+import os
+import time
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbplatformutil import *
+import json
+
+
+class MTCSimpleTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ def test(self):
+ self.mtc_dylib_path = findMainThreadCheckerDylib()
+ if self.mtc_dylib_path == "":
+ self.skipTest("This test requires libMainThreadChecker.dylib.")
+
+ self.build()
+ self.mtc_tests()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ def mtc_tests(self):
+ # Load the test
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.expect("file " + exe, patterns=["Current executable set to .*a.out"])
+
+ self.runCmd("env DYLD_INSERT_LIBRARIES=%s" % self.mtc_dylib_path)
+ self.runCmd("run")
+
+ process = self.dbg.GetSelectedTarget().process
+ thread = process.GetSelectedThread()
+ frame = thread.GetSelectedFrame()
+
+ self.expect("thread info", substrs=['stop reason = -[NSView superview] must be used from main thread only'])
+
+ self.expect(
+ "thread info -s",
+ substrs=["instrumentation_class", "api_name", "class_name", "selector", "description"])
+ self.assertEqual(thread.GetStopReason(), lldb.eStopReasonInstrumentation)
+ output_lines = self.res.GetOutput().split('\n')
+ json_line = '\n'.join(output_lines[2:])
+ data = json.loads(json_line)
+ self.assertEqual(data["instrumentation_class"], "MainThreadChecker")
+ self.assertEqual(data["api_name"], "-[NSView superview]")
+ self.assertEqual(data["class_name"], "NSView")
+ self.assertEqual(data["selector"], "superview")
+ self.assertEqual(data["description"], "-[NSView superview] must be used from main thread only")
diff --git a/packages/Python/lldbsuite/test/functionalities/mtc/simple/main.m b/packages/Python/lldbsuite/test/functionalities/mtc/simple/main.m
new file mode 100644
index 0000000000000..651347cf74eeb
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/mtc/simple/main.m
@@ -0,0 +1,15 @@
+#import <Foundation/Foundation.h>
+#import <AppKit/AppKit.h>
+
+int main() {
+ NSView *view = [[NSView alloc] init];
+ dispatch_group_t g = dispatch_group_create();
+ dispatch_group_enter(g);
+ [NSThread detachNewThreadWithBlock:^{
+ @autoreleasepool {
+ [view superview];
+ }
+ dispatch_group_leave(g);
+ }];
+ dispatch_group_wait(g, DISPATCH_TIME_FOREVER);
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py b/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py
index cf435a4aae911..1750bd31b3df6 100644
--- a/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py
+++ b/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py
@@ -31,8 +31,6 @@ class ReturnValueTestCase(TestBase):
"<=",
"3.6"],
archs=["i386"])
- @expectedFailureAll(compiler="clang", compiler_version=["<=", "5.0.300080"],
- triple='.*-android', archs=["i386"])
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
@add_test_categories(['pyapi'])
def test_with_python(self):
diff --git a/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py b/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py
index efadea51f6696..79175562fe7ab 100644
--- a/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py
+++ b/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py
@@ -16,6 +16,7 @@ from lldbsuite.test import lldbutil
class RaiseTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
def test_sigstop(self):
self.build()
@@ -29,6 +30,10 @@ class RaiseTestCase(TestBase):
self.build()
self.signal_test('SIGRTMIN', True)
+ def test_sigtrap(self):
+ self.build()
+ self.signal_test('SIGTRAP', True)
+
def launch(self, target, signal):
# launch the process, do not stop at entry point.
process = target.LaunchSimple(
diff --git a/packages/Python/lldbsuite/test/functionalities/signal/raise/main.c b/packages/Python/lldbsuite/test/functionalities/signal/raise/main.c
index 8827174e758e3..4203fe5d4c89e 100644
--- a/packages/Python/lldbsuite/test/functionalities/signal/raise/main.c
+++ b/packages/Python/lldbsuite/test/functionalities/signal/raise/main.c
@@ -10,6 +10,11 @@ void handler(int signo)
int main (int argc, char *argv[])
{
+ if (signal(SIGTRAP, handler) == SIG_ERR)
+ {
+ perror("signal(SIGTRAP)");
+ return 1;
+ }
#ifndef __APPLE__
// Real time signals not supported on apple platforms.
if (signal(SIGRTMIN, handler) == SIG_ERR)
@@ -27,6 +32,8 @@ int main (int argc, char *argv[])
if (strcmp(argv[1], "SIGSTOP") == 0)
raise(SIGSTOP);
+ else if (strcmp(argv[1], "SIGTRAP") == 0)
+ raise(SIGTRAP);
#ifndef __APPLE__
else if (strcmp(argv[1], "SIGRTMIN") == 0)
raise(SIGRTMIN);
diff --git a/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/Makefile b/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/Makefile
new file mode 100644
index 0000000000000..6e7d19b6f48c2
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+CFLAGS_EXTRAS := -fsanitize=undefined -g
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/TestUbsanUserExpression.py b/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/TestUbsanUserExpression.py
new file mode 100644
index 0000000000000..a5e5f572a9792
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/TestUbsanUserExpression.py
@@ -0,0 +1,49 @@
+"""
+Test that hitting a UBSan issue while running user expression doesn't break the evaluation.
+"""
+
+import os
+import time
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbutil as lldbutil
+import json
+
+
+class UbsanUserExpressionTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessUndefinedBehaviorSanitizer
+ def test(self):
+ self.build()
+ self.ubsan_tests()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ self.line_breakpoint = line_number('main.c', '// breakpoint line')
+
+ def ubsan_tests(self):
+ # Load the test
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.expect(
+ "file " + exe,
+ patterns=["Current executable set to .*a.out"])
+
+ self.runCmd("breakpoint set -f main.c -l %d" % self.line_breakpoint)
+
+ self.runCmd("run")
+
+ process = self.dbg.GetSelectedTarget().process
+ thread = process.GetSelectedThread()
+ frame = thread.GetSelectedFrame()
+
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped', 'stop reason = breakpoint'])
+
+ self.expect("p foo()", substrs=["(int) $0 = 42"])
+
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped', 'stop reason = breakpoint'])
diff --git a/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/main.c b/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/main.c
new file mode 100644
index 0000000000000..4786aaa89b27e
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/main.c
@@ -0,0 +1,9 @@
+int foo() {
+ int data[4];
+ int x = *(int *)(((char *)&data[0]) + 2);
+ return 42;
+}
+
+int main() {
+ return 0; // breakpoint line
+}
diff --git a/packages/Python/lldbsuite/test/lang/go/types/TestGoASTContext.py b/packages/Python/lldbsuite/test/lang/go/types/TestGoASTContext.py
index 8e158c3e82d49..9571e259629ff 100644
--- a/packages/Python/lldbsuite/test/lang/go/types/TestGoASTContext.py
+++ b/packages/Python/lldbsuite/test/lang/go/types/TestGoASTContext.py
@@ -20,6 +20,7 @@ class TestGoASTContext(TestBase):
@skipIfRemote # Not remote test suit ready
@no_debug_info_test
@skipUnlessGoInstalled
+ @expectedFailureAll(bugnumber="llvm.org/pr33643")
def test_with_dsym_and_python_api(self):
"""Test GoASTContext dwarf parsing."""
self.buildGo()
diff --git a/packages/Python/lldbsuite/test/lldbplatformutil.py b/packages/Python/lldbsuite/test/lldbplatformutil.py
index 89ce1d468bd01..4f45643241ed2 100644
--- a/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -8,6 +8,7 @@ import itertools
import re
import subprocess
import sys
+import os
# Third-party modules
import six
@@ -140,6 +141,19 @@ def platformIsDarwin():
return getPlatform() in getDarwinOSTriples()
+def findMainThreadCheckerDylib():
+ if not platformIsDarwin():
+ return ""
+
+ with os.popen('xcode-select -p') as output:
+ xcode_developer_path = output.read().strip()
+ mtc_dylib_path = '%s/usr/lib/libMainThreadChecker.dylib' % xcode_developer_path
+ if os.path.isfile(mtc_dylib_path):
+ return mtc_dylib_path
+
+ return ""
+
+
class _PlatformContext(object):
"""Value object class which contains platform-specific options."""
diff --git a/packages/Python/lldbsuite/test/lldbutil.py b/packages/Python/lldbsuite/test/lldbutil.py
index 7732dbe6dff3f..58a1ead1ea0bd 100644
--- a/packages/Python/lldbsuite/test/lldbutil.py
+++ b/packages/Python/lldbsuite/test/lldbutil.py
@@ -725,6 +725,47 @@ def get_crashed_threads(test, process):
threads.append(thread)
return threads
+def run_to_source_breakpoint(test, bkpt_pattern, source_spec, launch_info = None, exe_name = "a.out", in_cwd = True):
+ """Start up a target, using exe_name as the executable, and run it to
+ a breakpoint set by source regex bkpt_pattern.
+ If you want to pass in launch arguments or environment variables, you can optionally pass in
+ an SBLaunchInfo. If you do that, remember to set the working directory as well.
+ If your executable isn't called a.out, you can pass that in. And if your executable isn't
+ in the CWD, pass in the absolute path to the executable in exe_name, and set in_cwd to False.
+ If the target isn't valid, the breakpoint isn't found, or hit, the
+ function will cause a testsuite failure.
+ If successful it returns a tuple with the target process and thread that hit the breakpoint."""
+
+ if in_cwd:
+ exe = os.path.join(os.getcwd(), exe_name)
+
+ # Create the target
+ target = test.dbg.CreateTarget(exe)
+ test.assertTrue(target, "Target: %s is not valid."%(exe_name))
+
+ # Set the breakpoints
+ breakpoint = target.BreakpointCreateBySourceRegex(
+ bkpt_pattern, source_spec)
+ test.assertTrue(breakpoint.GetNumLocations() > 0,
+ 'No locations found for source breakpoint: "%s"'%(bkpt_pattern))
+
+ # Launch the process, and do not stop at the entry point.
+ if not launch_info:
+ launch_info = lldb.SBLaunchInfo(None)
+ launch_info.SetWorkingDirectory(test.get_process_working_directory())
+
+ error = lldb.SBError()
+ process = target.Launch(launch_info, error)
+
+ test.assertTrue(process, "Could not create a valid process for %s: %s"%(exe_name, error.GetCString()))
+
+ # Frame #0 should be at our breakpoint.
+ threads = get_threads_stopped_at_breakpoint(
+ process, breakpoint)
+
+ test.assertTrue(len(threads) == 1, "Expected 1 thread to stop at breakpoint, %d did."%(len(threads)))
+ thread = threads[0]
+ return (target, process, thread, breakpoint)
def continue_to_breakpoint(process, bkpt):
""" Continues the process, if it stops, returns the threads stopped at bkpt; otherwise, returns None"""
diff --git a/packages/Python/lldbsuite/test/make/Android.rules b/packages/Python/lldbsuite/test/make/Android.rules
index 0a725494d3542..058401f425ad7 100644
--- a/packages/Python/lldbsuite/test/make/Android.rules
+++ b/packages/Python/lldbsuite/test/make/Android.rules
@@ -90,7 +90,3 @@ else
ARCH_LDFLAGS += $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/libgnustl_static.a
endif
-
-ifeq "$(ARCH)" "i386"
- ARCH_CFLAGS += -mstackrealign
-endif
diff --git a/packages/Python/lldbsuite/test/sample_test/TestSampleTest.py b/packages/Python/lldbsuite/test/sample_test/TestSampleTest.py
index bb34727ff81b5..9a1748bbabb50 100644
--- a/packages/Python/lldbsuite/test/sample_test/TestSampleTest.py
+++ b/packages/Python/lldbsuite/test/sample_test/TestSampleTest.py
@@ -25,6 +25,7 @@ class RenameThisSampleTestTestCase(TestBase):
def test_sample_rename_this(self):
"""There can be many tests in a test case - describe this test here."""
self.build()
+ self.main_source_file = lldb.SBFileSpec("main.c")
self.sample_test()
def setUp(self):
@@ -33,40 +34,15 @@ class RenameThisSampleTestTestCase(TestBase):
def sample_test(self):
"""You might use the test implementation in several ways, say so here."""
- exe = os.path.join(os.getcwd(), "a.out")
- # Create a target by the debugger.
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
+ # This function starts a process, "a.out" by default, sets a source
+ # breakpoint, runs to it, and returns the thread, process & target.
+ # It optionally takes an SBLaunchOption argument if you want to pass
+ # arguments or environment variables.
+ (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
+ "Set a breakpoint here", self.main_source_file)
- # Now create a breakpoint in main.c at the source matching
- # "Set a breakpoint here"
- breakpoint = target.BreakpointCreateBySourceRegex(
- "Set a breakpoint here", lldb.SBFileSpec("main.c"))
- self.assertTrue(breakpoint and
- breakpoint.GetNumLocations() >= 1,
- VALID_BREAKPOINT)
-
- error = lldb.SBError()
- # This is the launch info. If you want to launch with arguments or
- # environment variables, add them using SetArguments or
- # SetEnvironmentEntries
-
- launch_info = lldb.SBLaunchInfo(None)
- process = target.Launch(launch_info, error)
- self.assertTrue(process, PROCESS_IS_VALID)
-
- # Did we hit our breakpoint?
- from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
- threads = get_threads_stopped_at_breakpoint(process, breakpoint)
- self.assertTrue(
- len(threads) == 1,
- "There should be a thread stopped at our breakpoint")
-
- # The hit count for the breakpoint should be 1.
- self.assertTrue(breakpoint.GetHitCount() == 1)
-
- frame = threads[0].GetFrameAtIndex(0)
+ frame = thread.GetFrameAtIndex(0)
test_var = frame.FindVariable("test_var")
self.assertTrue(test_var.GetError().Success(), "Failed to fetch test_var")
test_value = test_var.GetValueAsUnsigned()