diff options
Diffstat (limited to 'packages/Python/lldbsuite/test/python_api')
52 files changed, 489 insertions, 102 deletions
diff --git a/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py b/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py index 1f4fa20b8304..a3dd91fe8802 100644 --- a/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py +++ b/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py @@ -9,8 +9,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class BreakpointAPITestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/python_api/class_members/TestSBTypeClassMembers.py b/packages/Python/lldbsuite/test/python_api/class_members/TestSBTypeClassMembers.py index e1d5520bcc3d..3d9309e26cec 100644 --- a/packages/Python/lldbsuite/test/python_api/class_members/TestSBTypeClassMembers.py +++ b/packages/Python/lldbsuite/test/python_api/class_members/TestSBTypeClassMembers.py @@ -9,8 +9,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class SBTypeMemberFunctionsTest(TestBase): diff --git a/packages/Python/lldbsuite/test/python_api/debugger/TestDebuggerAPI.py b/packages/Python/lldbsuite/test/python_api/debugger/TestDebuggerAPI.py index 98feda859ae9..d8ac342f4754 100644 --- a/packages/Python/lldbsuite/test/python_api/debugger/TestDebuggerAPI.py +++ b/packages/Python/lldbsuite/test/python_api/debugger/TestDebuggerAPI.py @@ -4,7 +4,10 @@ Test Debugger APIs. import os import lldb + +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class DebuggerAPITestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py b/packages/Python/lldbsuite/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py index aa3a6141326a..3e2ff2ffa9dd 100644 --- a/packages/Python/lldbsuite/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py +++ b/packages/Python/lldbsuite/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py @@ -18,8 +18,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class APIDefaultConstructorTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py b/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py index 31ba44928794..311791cca014 100644 --- a/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py +++ b/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py @@ -9,8 +9,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class DisassembleRawDataTestCase(TestBase): @@ -18,6 +19,7 @@ class DisassembleRawDataTestCase(TestBase): @add_test_categories(['pyapi']) @no_debug_info_test + @skipIfRemote def test_disassemble_raw_data(self): """Test disassembling raw bytes with the API.""" # Create a target from the debugger. diff --git a/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py b/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py index e24b2ee5613a..f991ab329a89 100644 --- a/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py +++ b/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py @@ -9,14 +9,15 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class Disassemble_VST1_64(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIf(True) # llvm.org/pr24575: all tests get ERRORs in dotest.py after this + @skipTestIfFn(lambda : True, "llvm.org/pr24575: all tests get ERRORs in dotest.py after this") @add_test_categories(['pyapi']) @no_debug_info_test def test_disassemble_invalid_vst_1_64_raw_data(self): diff --git a/packages/Python/lldbsuite/test/python_api/event/TestEvents.py b/packages/Python/lldbsuite/test/python_api/event/TestEvents.py index 51c924b2aff1..1c23f50e9d4d 100644 --- a/packages/Python/lldbsuite/test/python_api/event/TestEvents.py +++ b/packages/Python/lldbsuite/test/python_api/event/TestEvents.py @@ -9,10 +9,10 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil -@skipIfDarwin # llvm.org/pr25924, sometimes generating SIGSEGV @skipIfLinux # llvm.org/pr25924, sometimes generating SIGSEGV class EventAPITestCase(TestBase): @@ -25,7 +25,7 @@ class EventAPITestCase(TestBase): self.line = line_number('main.c', '// Find the line number of function "c" here.') @add_test_categories(['pyapi']) - @expectedFailureLinux("llvm.org/pr23730") # Flaky, fails ~1/10 cases + @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr23730 Flaky, fails ~1/10 cases") def test_listen_for_and_print_event(self): """Exercise SBEvent API.""" self.build() @@ -85,6 +85,7 @@ class EventAPITestCase(TestBase): if traceOn: print("timeout occurred waiting for event...") count = count + 1 + listener.Clear() return # Let's start the listening thread to retrieve the events. @@ -102,8 +103,11 @@ class EventAPITestCase(TestBase): # Wait until the 'MyListeningThread' terminates. my_thread.join() + # Shouldn't we be testing against some kind of expectation here? + @add_test_categories(['pyapi']) @expectedFlakeyLinux("llvm.org/pr23730") # Flaky, fails ~1/100 cases + @expectedFlakeyOS(oslist=["windows"]) def test_wait_for_event(self): """Exercise SBListener.WaitForEvent() API.""" self.build() @@ -154,10 +158,11 @@ class EventAPITestCase(TestBase): #print("Got a valid event:", event) #print("Event data flavor:", event.GetDataFlavor()) #print("Event type:", lldbutil.state_type_to_str(event.GetType())) + listener.Clear() return count = count + 1 print("Timeout: listener.WaitForEvent") - + listener.Clear() return # Use Python API to kill the process. The listening thread should be @@ -176,8 +181,8 @@ class EventAPITestCase(TestBase): @skipIfFreeBSD # llvm.org/pr21325 @add_test_categories(['pyapi']) - @expectedFailureLinux("llvm.org/pr23617") # Flaky, fails ~1/10 cases - @expectedFailureWindows("llvm.org/pr24778") + @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr23617 Flaky, fails ~1/10 cases") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_add_listener_to_broadcaster(self): """Exercise some SBBroadcaster APIs.""" self.build() @@ -265,7 +270,7 @@ class EventAPITestCase(TestBase): count = count + 1 if count > 6: break - + listener.Clear() return # Use Python API to continue the process. The listening thread should be diff --git a/packages/Python/lldbsuite/test/python_api/exprpath_synthetic/TestExprPathSynthetic.py b/packages/Python/lldbsuite/test/python_api/exprpath_synthetic/TestExprPathSynthetic.py index 80305e303d03..49bc148dd579 100644 --- a/packages/Python/lldbsuite/test/python_api/exprpath_synthetic/TestExprPathSynthetic.py +++ b/packages/Python/lldbsuite/test/python_api/exprpath_synthetic/TestExprPathSynthetic.py @@ -1,4 +1,4 @@ -import lldbsuite.test.lldbinline as lldbinline -import lldbsuite.test.lldbtest as lldbtest +from lldbsuite.test import decorators +from lldbsuite.test import lldbinline -lldbinline.MakeInlineTest(__file__, globals(), [lldbtest.skipIfFreeBSD,lldbtest.skipIfLinux,lldbtest.skipIfWindows]) +lldbinline.MakeInlineTest(__file__, globals(), [decorators.skipIfFreeBSD,decorators.skipIfLinux,decorators.skipIfWindows]) diff --git a/packages/Python/lldbsuite/test/python_api/findvalue_duplist/TestSBFrameFindValue.py b/packages/Python/lldbsuite/test/python_api/findvalue_duplist/TestSBFrameFindValue.py index 96d4f51fd097..9c1fd1e7bef7 100644 --- a/packages/Python/lldbsuite/test/python_api/findvalue_duplist/TestSBFrameFindValue.py +++ b/packages/Python/lldbsuite/test/python_api/findvalue_duplist/TestSBFrameFindValue.py @@ -6,8 +6,9 @@ from __future__ import print_function import os, sys, time import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class SBFrameFindValueTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py b/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py index de7f15f76faf..babae237b8ce 100644 --- a/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py +++ b/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py @@ -6,8 +6,9 @@ from __future__ import print_function import os, sys, time import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class SBFormattersAPITestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py b/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py index 7cc976fc6aa3..0b1e12b08fcb 100644 --- a/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py +++ b/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py @@ -10,15 +10,16 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class FrameAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @add_test_categories(['pyapi']) - @expectedFailureWindows("llvm.org/pr24778") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_get_arg_vals_for_call_stack(self): """Exercise SBFrame.GetVariables() API to get argument vals.""" self.build() @@ -49,7 +50,8 @@ class FrameAPITestCase(TestBase): from six import StringIO as SixStringIO session = SixStringIO() while process.GetState() == lldb.eStateStopped: - thread = process.GetThreadAtIndex(0) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertIsNotNone(thread) # Inspect at most 3 frames. numFrames = min(3, thread.GetNumFrames()) for i in range(numFrames): @@ -134,7 +136,8 @@ class FrameAPITestCase(TestBase): self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) - thread = process.GetThreadAtIndex(0) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertIsNotNone(thread) frame = thread.GetFrameAtIndex(0) if self.TraceOn(): print("frame:", frame) @@ -173,8 +176,8 @@ class FrameAPITestCase(TestBase): self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) - thread = process.GetThreadAtIndex(0) - self.assertTrue(thread) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertIsNotNone(thread) frameEntered = thread.GetFrameAtIndex(0) if self.TraceOn(): diff --git a/packages/Python/lldbsuite/test/python_api/frame/get-variables/Makefile b/packages/Python/lldbsuite/test/python_api/frame/get-variables/Makefile new file mode 100644 index 000000000000..b09a579159d4 --- /dev/null +++ b/packages/Python/lldbsuite/test/python_api/frame/get-variables/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/python_api/frame/get-variables/TestGetVariables.py b/packages/Python/lldbsuite/test/python_api/frame/get-variables/TestGetVariables.py new file mode 100644 index 000000000000..914c3d25fd5d --- /dev/null +++ b/packages/Python/lldbsuite/test/python_api/frame/get-variables/TestGetVariables.py @@ -0,0 +1,190 @@ +""" +Test that SBFrame::GetVariables() calls work correctly. +""" + +from __future__ import print_function + + + +import os, time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbplatform +from lldbsuite.test import lldbutil + +def get_names_from_value_list(value_list): + names = list() + for value in value_list: + names.append(value.GetName()) + return names + +class TestGetVariables(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + self.source = 'main.c' + + def verify_variable_names(self, description, value_list, names): + copy_names = list(names) + actual_names = get_names_from_value_list(value_list) + for name in actual_names: + if name in copy_names: + copy_names.remove(name) + else: + self.assertTrue(False, "didn't find '%s' in %s" % (name, copy_names)) + self.assertEqual(len(copy_names), 0, "%s: we didn't find variables: %s in value list (%s)" % (description, copy_names, actual_names)) + + def test (self): + self.build () + + # Set debugger into synchronous mode + self.dbg.SetAsync(False) + + # Create a target by the debugger. + exe = os.path.join(os.getcwd(), "a.out") + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + line1 = line_number(self.source, '// breakpoint 1') + line2 = line_number(self.source, '// breakpoint 2') + line3 = line_number(self.source, '// breakpoint 3') + + breakpoint1 = target.BreakpointCreateByLocation (self.source, line1); + breakpoint2 = target.BreakpointCreateByLocation (self.source, line2); + breakpoint3 = target.BreakpointCreateByLocation (self.source, line3); + + self.assertTrue(breakpoint1.GetNumLocations() >= 1, PROCESS_IS_VALID) + self.assertTrue(breakpoint2.GetNumLocations() >= 1, PROCESS_IS_VALID) + self.assertTrue(breakpoint3.GetNumLocations() >= 1, PROCESS_IS_VALID) + + # Register our shared libraries for remote targets so they get automatically uploaded + arguments = None + environment = None + + # Now launch the process, and do not stop at entry point. + process = target.LaunchSimple (arguments, environment, self.get_process_working_directory()) + self.assertTrue(process, PROCESS_IS_VALID) + + threads = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint1) + self.assertEqual(len(threads), 1, "There should be a thread stopped at breakpoint 1") + + thread = threads[0] + self.assertTrue(thread.IsValid(), "Thread must be valid") + frame = thread.GetFrameAtIndex(0) + self.assertTrue(frame.IsValid(), "Frame must be valid") + + arg_names = ['argc', 'argv'] + local_names = ['i', 'j', 'k'] + static_names = ['static_var', 'g_global_var', 'g_static_var'] + breakpoint1_locals = ['i'] + breakpoint1_statics = ['static_var'] + num_args = len(arg_names) + num_locals = len(local_names) + num_statics = len(static_names) + args_yes = True + args_no = False + locals_yes = True + locals_no = False + statics_yes = True + statics_no = False + in_scopy_only = True + ignore_scope = False + + # Verify if we ask for only arguments that we got what we expect + vars = frame.GetVariables(args_yes, locals_no, statics_no, ignore_scope) + self.assertEqual(vars.GetSize(), num_args, "There should be %i arguments, but we are reporting %i" % (num_args, vars.GetSize())) + self.verify_variable_names("check names of arguments", vars, arg_names) + self.assertEqual(len(arg_names), num_args, "make sure verify_variable_names() didn't mutate list") + + # Verify if we ask for only locals that we got what we expect + vars = frame.GetVariables(args_no, locals_yes, statics_no, ignore_scope) + self.assertEqual(vars.GetSize(), num_locals, "There should be %i local variables, but we are reporting %i" % (num_locals, vars.GetSize())) + self.verify_variable_names("check names of locals", vars, local_names) + + # Verify if we ask for only statics that we got what we expect + vars = frame.GetVariables(args_no, locals_no, statics_yes, ignore_scope) + print('statics: ', str(vars)) + self.assertEqual(vars.GetSize(), num_statics, "There should be %i static variables, but we are reporting %i" % (num_statics, vars.GetSize())) + self.verify_variable_names("check names of statics", vars, static_names) + + # Verify if we ask for arguments and locals that we got what we expect + vars = frame.GetVariables(args_yes, locals_yes, statics_no, ignore_scope) + desc = 'arguments + locals' + names = arg_names + local_names + count = len(names) + self.assertEqual(vars.GetSize(), count, "There should be %i %s (%s) but we are reporting %i (%s)" % (count, desc, names, vars.GetSize(), get_names_from_value_list(vars))) + self.verify_variable_names("check names of %s" % (desc), vars, names) + + # Verify if we ask for arguments and statics that we got what we expect + vars = frame.GetVariables(args_yes, locals_no, statics_yes, ignore_scope) + desc = 'arguments + statics' + names = arg_names + static_names + count = len(names) + self.assertEqual(vars.GetSize(), count, "There should be %i %s (%s) but we are reporting %i (%s)" % (count, desc, names, vars.GetSize(), get_names_from_value_list(vars))) + self.verify_variable_names("check names of %s" % (desc), vars, names) + + # Verify if we ask for locals and statics that we got what we expect + vars = frame.GetVariables(args_no, locals_yes, statics_yes, ignore_scope) + desc = 'locals + statics' + names = local_names + static_names + count = len(names) + self.assertEqual(vars.GetSize(), count, "There should be %i %s (%s) but we are reporting %i (%s)" % (count, desc, names, vars.GetSize(), get_names_from_value_list(vars))) + self.verify_variable_names("check names of %s" % (desc), vars, names) + + # Verify if we ask for arguments, locals and statics that we got what we expect + vars = frame.GetVariables(args_yes, locals_yes, statics_yes, ignore_scope) + desc = 'arguments + locals + statics' + names = arg_names + local_names + static_names + count = len(names) + self.assertEqual(vars.GetSize(), count, "There should be %i %s (%s) but we are reporting %i (%s)" % (count, desc, names, vars.GetSize(), get_names_from_value_list(vars))) + self.verify_variable_names("check names of %s" % (desc), vars, names) + + # Verify if we ask for in scope locals that we got what we expect + vars = frame.GetVariables(args_no, locals_yes, statics_no, in_scopy_only) + desc = 'in scope locals at breakpoint 1' + names = ['i'] + count = len(names) + self.assertEqual(vars.GetSize(), count, "There should be %i %s (%s) but we are reporting %i (%s)" % (count, desc, names, vars.GetSize(), get_names_from_value_list(vars))) + self.verify_variable_names("check names of %s" % (desc), vars, names) + + # Continue to breakpoint 2 + process.Continue() + + threads = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint2) + self.assertEqual(len(threads), 1, "There should be a thread stopped at breakpoint 2") + + thread = threads[0] + self.assertTrue(thread.IsValid(), "Thread must be valid") + frame = thread.GetFrameAtIndex(0) + self.assertTrue(frame.IsValid(), "Frame must be valid") + + # Verify if we ask for in scope locals that we got what we expect + vars = frame.GetVariables(args_no, locals_yes, statics_no, in_scopy_only) + desc = 'in scope locals at breakpoint 2' + names = ['i', 'j'] + count = len(names) + self.assertEqual(vars.GetSize(), count, "There should be %i %s (%s) but we are reporting %i (%s)" % (count, desc, names, vars.GetSize(), get_names_from_value_list(vars))) + self.verify_variable_names("check names of %s" % (desc), vars, names) + + # Continue to breakpoint 3 + process.Continue() + + threads = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint3) + self.assertEqual(len(threads), 1, "There should be a thread stopped at breakpoint 3") + + thread = threads[0] + self.assertTrue(thread.IsValid(), "Thread must be valid") + frame = thread.GetFrameAtIndex(0) + self.assertTrue(frame.IsValid(), "Frame must be valid") + + # Verify if we ask for in scope locals that we got what we expect + vars = frame.GetVariables(args_no, locals_yes, statics_no, in_scopy_only) + desc = 'in scope locals at breakpoint 3' + names = ['i', 'j', 'k'] + count = len(names) + self.assertEqual(vars.GetSize(), count, "There should be %i %s (%s) but we are reporting %i (%s)" % (count, desc, names, vars.GetSize(), get_names_from_value_list(vars))) + self.verify_variable_names("check names of %s" % (desc), vars, names) diff --git a/packages/Python/lldbsuite/test/python_api/frame/get-variables/main.c b/packages/Python/lldbsuite/test/python_api/frame/get-variables/main.c new file mode 100644 index 000000000000..7fecfc0293c3 --- /dev/null +++ b/packages/Python/lldbsuite/test/python_api/frame/get-variables/main.c @@ -0,0 +1,29 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include <stdio.h> + +int g_global_var = 123; +static int g_static_var = 123; + +int main (int argc, char const *argv[]) +{ + static int static_var = 123; + g_static_var = 123; // clang bug. Need to touch this variable, otherwise it disappears. + int i = 0; // breakpoint 1 + for (i=0; i<1; ++i) + { + int j = i*2; + printf("i = %i, j = %i\n", i, j); // breakpoint 2 + { + int k = i*j*3; + printf("i = %i, j = %i\n", i, j); // breakpoint 3 + } + } + return 0; +} diff --git a/packages/Python/lldbsuite/test/python_api/frame/inlines/TestInlinedFrame.py b/packages/Python/lldbsuite/test/python_api/frame/inlines/TestInlinedFrame.py index d4cf8fe30ccd..ee6c33f54314 100644 --- a/packages/Python/lldbsuite/test/python_api/frame/inlines/TestInlinedFrame.py +++ b/packages/Python/lldbsuite/test/python_api/frame/inlines/TestInlinedFrame.py @@ -9,8 +9,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class InlinedFrameAPITestCase(TestBase): @@ -60,7 +61,10 @@ class InlinedFrameAPITestCase(TestBase): # # outer_inline (argc); # - frame0 = process.GetThreadAtIndex(0).GetFrameAtIndex(0) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertIsNotNone(thread) + + frame0 = thread.GetFrameAtIndex(0) if frame0.IsInlined(): filename = frame0.GetLineEntry().GetFileSpec().GetFilename() self.assertTrue(filename == self.source) diff --git a/packages/Python/lldbsuite/test/python_api/function_symbol/TestDisasmAPI.py b/packages/Python/lldbsuite/test/python_api/function_symbol/TestDisasmAPI.py index c9876a8c8954..9a763b89c27f 100644 --- a/packages/Python/lldbsuite/test/python_api/function_symbol/TestDisasmAPI.py +++ b/packages/Python/lldbsuite/test/python_api/function_symbol/TestDisasmAPI.py @@ -9,8 +9,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class DisasmAPITestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py b/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py index 187ba69def0e..35d73e494270 100644 --- a/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py +++ b/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py @@ -9,8 +9,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class SymbolAPITestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py b/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py index 47c3ba146cef..a8beaa903293 100644 --- a/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py +++ b/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py @@ -4,10 +4,14 @@ from __future__ import print_function -import os, sys, time -import lldb +import os +import sys import time + +import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class HelloWorldTestCase(TestBase): @@ -64,18 +68,14 @@ class HelloWorldTestCase(TestBase): process = target.GetProcess() self.assertTrue(process, PROCESS_IS_VALID) - 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())) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertIsNotNone(thread) # The breakpoint should have a hit count of 1. - self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) + self.assertEqual(breakpoint.GetHitCount(), 1, BREAKPOINT_HIT_ONCE) @add_test_categories(['pyapi']) - @expectedFailureWindows("llvm.org/pr24600") - @expectedFailurei386("llvm.org/pr25338") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24600") @skipIfiOSSimulator def test_with_attach_to_process_with_id_api(self): """Create target, spawn a process, and attach to it with process id.""" @@ -104,8 +104,7 @@ class HelloWorldTestCase(TestBase): '(int)argc=3']) @add_test_categories(['pyapi']) - @expectedFailureWindows("llvm.org/pr24600") - @expectedFailurei386("llvm.org/pr25338") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24600") @skipIfiOSSimulator def test_with_attach_to_process_with_name_api(self): """Create target, spawn a process, and attach to it with process name.""" diff --git a/packages/Python/lldbsuite/test/python_api/interpreter/TestCommandInterpreterAPI.py b/packages/Python/lldbsuite/test/python_api/interpreter/TestCommandInterpreterAPI.py index faff11818da7..d39984adb732 100644 --- a/packages/Python/lldbsuite/test/python_api/interpreter/TestCommandInterpreterAPI.py +++ b/packages/Python/lldbsuite/test/python_api/interpreter/TestCommandInterpreterAPI.py @@ -6,7 +6,9 @@ from __future__ import print_function import os import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class CommandInterpreterAPICase(TestBase): diff --git a/packages/Python/lldbsuite/test/python_api/lldbutil/frame/TestFrameUtils.py b/packages/Python/lldbsuite/test/python_api/lldbutil/frame/TestFrameUtils.py index 2cde05af0c39..09a5bc126571 100644 --- a/packages/Python/lldbsuite/test/python_api/lldbutil/frame/TestFrameUtils.py +++ b/packages/Python/lldbsuite/test/python_api/lldbutil/frame/TestFrameUtils.py @@ -8,7 +8,9 @@ from __future__ import print_function import os import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class FrameUtilsTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestLLDBIterator.py b/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestLLDBIterator.py index 07177c1fae4a..90f879d37610 100644 --- a/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestLLDBIterator.py +++ b/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestLLDBIterator.py @@ -9,7 +9,9 @@ from __future__ import print_function import os, time import re import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class LLDBIteratorTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestRegistersIterator.py b/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestRegistersIterator.py index 1645ae1f2a5d..84ef44d2dd73 100644 --- a/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestRegistersIterator.py +++ b/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestRegistersIterator.py @@ -9,7 +9,9 @@ from __future__ import print_function import os, time import re import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class RegistersIteratorTestCase(TestBase): @@ -22,7 +24,7 @@ class RegistersIteratorTestCase(TestBase): self.line1 = line_number('main.cpp', '// Set break point at this line.') @add_test_categories(['pyapi']) - @expectedFailureWindows # Test crashes + @expectedFailureAll(oslist=["windows"]) def test_iter_registers(self): """Test iterator works correctly for lldbutil.iter_registers().""" self.build() diff --git a/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py b/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py index 97bfa3956f6c..fafd05fd92c8 100644 --- a/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py +++ b/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py @@ -9,7 +9,9 @@ from __future__ import print_function import os, time import re import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class ThreadsStackTracesTestCase(TestBase): @@ -26,7 +28,9 @@ class ThreadsStackTracesTestCase(TestBase): #The __thread_start function in libc doesn't contain any epilogue and prologue instructions #hence unwinding fail when we are stopped in __thread_start @expectedFailureAll(triple = 'mips*') - @expectedFailureWindows("llvm.org/pr24778") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") + @expectedFlakeyAndroid("llvm.org/26492", archs=["arm"]) + @expectedFlakeyLinux("llvm.org/pr27687") @add_test_categories(['pyapi']) def test_stack_traces(self): """Test SBprocess and SBThread APIs with printing of the stack traces.""" diff --git a/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py b/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py index 2de026c54eef..859edd80ee83 100644 --- a/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py +++ b/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py @@ -9,7 +9,9 @@ from __future__ import print_function import os, time import re import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil from lldbsuite.test.lldbutil import symbol_type_to_str class ModuleAndSectionAPIsTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/python_api/objc_type/TestObjCType.py b/packages/Python/lldbsuite/test/python_api/objc_type/TestObjCType.py index e9b29b90e1a6..b81c422863cb 100644 --- a/packages/Python/lldbsuite/test/python_api/objc_type/TestObjCType.py +++ b/packages/Python/lldbsuite/test/python_api/objc_type/TestObjCType.py @@ -9,8 +9,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class ObjCSBTypeTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py b/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py index f312bc8a9247..d5f407155b29 100644 --- a/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py +++ b/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py @@ -8,8 +8,9 @@ from __future__ import print_function import os, time import lldb -from lldbsuite.test.lldbutil import get_stopped_thread, state_type_to_str +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test.lldbutil import get_stopped_thread, state_type_to_str class ProcessAPITestCase(TestBase): @@ -56,7 +57,7 @@ class ProcessAPITestCase(TestBase): self.expect(content, "Result from SBProcess.ReadMemory() matches our expected output: 'x'", exe=False, - startstr = 'x') + startstr = b'x') # Read (char *)my_char_ptr. val = frame.FindValue("my_char_ptr", lldb.eValueTypeVariableGlobal) @@ -154,7 +155,7 @@ class ProcessAPITestCase(TestBase): self.expect(content, "Result from SBProcess.ReadMemory() matches our expected output: 'a'", exe=False, - startstr = 'a') + startstr = b'a') @add_test_categories(['pyapi']) def test_access_my_int(self): @@ -206,9 +207,8 @@ class ProcessAPITestCase(TestBase): # But we want to use the WriteMemory() API to assign 256 to the variable. # Now use WriteMemory() API to write 256 into the global variable. - new_value = str(bytes) error = lldb.SBError() - result = process.WriteMemory(location, new_value, error) + result = process.WriteMemory(location, bytes, error) if not error.Success() or result != byteSize: self.fail("SBProcess.WriteMemory() failed") @@ -230,20 +230,18 @@ class ProcessAPITestCase(TestBase): if not error.Success(): self.fail("SBProcess.ReadMemory() failed") - # Use "ascii" as the encoding because each element of 'content' is in the range [0..255]. - new_bytes = bytearray(content, "ascii") - # The bytearray_to_int utility function expects a little endian bytearray. if byteOrder == lldb.eByteOrderBig: - new_bytes.reverse() + content = bytearray(content, 'ascii') + content.reverse() - new_value = bytearray_to_int(new_bytes, byteSize) + new_value = bytearray_to_int(content, byteSize) if new_value != 256: self.fail("Memory content read from 'my_int' does not match (int)256") # Dump the memory content.... if self.TraceOn(): - for i in new_bytes: + for i in content: print("byte:", i) @add_test_categories(['pyapi']) diff --git a/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py b/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py index 2944ee78acf1..1a194035f4de 100644 --- a/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py +++ b/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py @@ -6,8 +6,9 @@ from __future__ import print_function import os, sys, time import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class ProcessIOTestCase(TestBase): @@ -29,6 +30,7 @@ class ProcessIOTestCase(TestBase): @skipIfWindows # stdio manipulation unsupported on Windows @add_test_categories(['pyapi']) + @expectedFlakeyLinux(bugnumber="llvm.org/pr26437") def test_stdin_by_api(self): """Exercise SBProcess.PutSTDIN().""" self.build() @@ -39,6 +41,7 @@ class ProcessIOTestCase(TestBase): @skipIfWindows # stdio manipulation unsupported on Windows @add_test_categories(['pyapi']) + @expectedFlakeyLinux(bugnumber="llvm.org/pr26437") def test_stdin_redirection(self): """Exercise SBLaunchInfo::AddOpenFileAction() for STDIN without specifying STDOUT or STDERR.""" self.build() @@ -50,6 +53,7 @@ class ProcessIOTestCase(TestBase): @skipIfWindows # stdio manipulation unsupported on Windows @add_test_categories(['pyapi']) + @expectedFlakeyLinux(bugnumber="llvm.org/pr26437") def test_stdout_redirection(self): """Exercise SBLaunchInfo::AddOpenFileAction() for STDOUT without specifying STDIN or STDERR.""" self.build() @@ -62,6 +66,7 @@ class ProcessIOTestCase(TestBase): @skipIfWindows # stdio manipulation unsupported on Windows @add_test_categories(['pyapi']) + @expectedFlakeyLinux(bugnumber="llvm.org/pr26437") def test_stderr_redirection(self): """Exercise SBLaunchInfo::AddOpenFileAction() for STDERR without specifying STDIN or STDOUT.""" self.build() @@ -74,6 +79,7 @@ class ProcessIOTestCase(TestBase): @skipIfWindows # stdio manipulation unsupported on Windows @add_test_categories(['pyapi']) + @expectedFlakeyLinux(bugnumber="llvm.org/pr26437") def test_stdout_stderr_redirection(self): """Exercise SBLaunchInfo::AddOpenFileAction() for STDOUT and STDERR without redirecting STDIN.""" self.build() diff --git a/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py b/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py index 2ff516e10d8e..d8e9515973f7 100644 --- a/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py +++ b/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py @@ -4,11 +4,12 @@ from __future__ import print_function +from math import fabs import os import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -from math import fabs -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class SBDataAPICase(TestBase): @@ -38,8 +39,9 @@ class SBDataAPICase(TestBase): target = self.dbg.GetSelectedTarget() process = target.GetProcess() - - thread = process.GetThreadAtIndex(0) + + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertIsNotNone(thread) frame = thread.GetSelectedFrame() if self.TraceOn(): @@ -184,7 +186,10 @@ class SBDataAPICase(TestBase): self.assertTrue(new_object.GetValue() == "1", 'new_object == 1') - data.SetData(error, 'A\0\0\0', data.GetByteOrder(), data.GetAddressByteSize()) + if data.GetByteOrder() == lldb.eByteOrderBig: + data.SetData(error, '\0\0\0A', data.GetByteOrder(), data.GetAddressByteSize()) + else: + data.SetData(error, 'A\0\0\0', data.GetByteOrder(), data.GetAddressByteSize()) self.assertTrue(error.Success()) data2 = lldb.SBData() @@ -309,8 +314,8 @@ class SBDataAPICase(TestBase): self.assert_data(data2.GetSignedInt32, 4, -2) data2.SetDataFromSInt64Array([2, -2]) - self.assert_data(data2.GetSignedInt32, 0, 2) - self.assert_data(data2.GetSignedInt32, 8, -2) + self.assert_data(data2.GetSignedInt64, 0, 2) + self.assert_data(data2.GetSignedInt64, 8, -2) data2.SetDataFromUInt32Array([1,2,3,4,5]) self.assert_data(data2.GetUnsignedInt32, 0, 1) diff --git a/packages/Python/lldbsuite/test/python_api/sbtype_typeclass/TestSBTypeTypeClass.py b/packages/Python/lldbsuite/test/python_api/sbtype_typeclass/TestSBTypeTypeClass.py index 80305e303d03..49bc148dd579 100644 --- a/packages/Python/lldbsuite/test/python_api/sbtype_typeclass/TestSBTypeTypeClass.py +++ b/packages/Python/lldbsuite/test/python_api/sbtype_typeclass/TestSBTypeTypeClass.py @@ -1,4 +1,4 @@ -import lldbsuite.test.lldbinline as lldbinline -import lldbsuite.test.lldbtest as lldbtest +from lldbsuite.test import decorators +from lldbsuite.test import lldbinline -lldbinline.MakeInlineTest(__file__, globals(), [lldbtest.skipIfFreeBSD,lldbtest.skipIfLinux,lldbtest.skipIfWindows]) +lldbinline.MakeInlineTest(__file__, globals(), [decorators.skipIfFreeBSD,decorators.skipIfLinux,decorators.skipIfWindows]) diff --git a/packages/Python/lldbsuite/test/python_api/sbvalue_persist/TestSBValuePersist.py b/packages/Python/lldbsuite/test/python_api/sbvalue_persist/TestSBValuePersist.py index 6edbbda4c112..e726db7c2d08 100644 --- a/packages/Python/lldbsuite/test/python_api/sbvalue_persist/TestSBValuePersist.py +++ b/packages/Python/lldbsuite/test/python_api/sbvalue_persist/TestSBValuePersist.py @@ -6,15 +6,16 @@ from __future__ import print_function import os, sys, time import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class SBValuePersistTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @add_test_categories(['pyapi']) - @expectedFailureWindows("llvm.org/pr24772") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24772") def test(self): """Test SBValue::Persist""" self.build() diff --git a/packages/Python/lldbsuite/test/python_api/section/TestSectionAPI.py b/packages/Python/lldbsuite/test/python_api/section/TestSectionAPI.py index 587216468f06..29e089f6b84d 100644 --- a/packages/Python/lldbsuite/test/python_api/section/TestSectionAPI.py +++ b/packages/Python/lldbsuite/test/python_api/section/TestSectionAPI.py @@ -5,8 +5,9 @@ Test SBSection APIs. from __future__ import print_function - +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class SectionAPITestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/python_api/signals/TestSignalsAPI.py b/packages/Python/lldbsuite/test/python_api/signals/TestSignalsAPI.py index 9825c553cce9..733b0c9d6764 100644 --- a/packages/Python/lldbsuite/test/python_api/signals/TestSignalsAPI.py +++ b/packages/Python/lldbsuite/test/python_api/signals/TestSignalsAPI.py @@ -8,14 +8,15 @@ from __future__ import print_function import os, time import lldb -from lldbsuite.test.lldbutil import get_stopped_thread, state_type_to_str +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil +from lldbsuite.test.lldbutil import get_stopped_thread, state_type_to_str class SignalsAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @add_test_categories(['pyapi']) - @expectedFlakeyLinux # this test fails 1/100 dosep runs @skipIfWindows # Windows doesn't have signals def test_ignore_signal(self): """Test Python SBUnixSignals.Suppress/Stop/Notify() API.""" diff --git a/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py b/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py index 2fec8dba0365..5d0d01d7a2b6 100644 --- a/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py +++ b/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py @@ -6,11 +6,14 @@ from __future__ import print_function -import os, time +import os import re +import time + import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class SymbolContextAPITestCase(TestBase): @@ -23,7 +26,7 @@ class SymbolContextAPITestCase(TestBase): self.line = line_number('main.c', '// Find the line number of function "c" here.') @add_test_categories(['pyapi']) - @expectedFailureWindows("llvm.org/pr24778") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test(self): """Exercise SBSymbolContext API extensively.""" self.build() diff --git a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/Makefile b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/Makefile new file mode 100644 index 000000000000..650a8b261bea --- /dev/null +++ b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := file1.cpp file2.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py new file mode 100644 index 000000000000..1d8d70114573 --- /dev/null +++ b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py @@ -0,0 +1,36 @@ +""" +Test SBSymbolContext APIs. +""" + +from __future__ import print_function + +import os + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class SymbolContextTwoFilesTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @add_test_categories(['pyapi']) + @expectedFailureAll(oslist=["windows"]) + def test_lookup_by_address(self): + """Test lookup by address in a module with multiple compilation units""" + self.build() + exe = os.path.join(os.getcwd(), "a.out") + + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + module = target.GetModuleAtIndex(0) + self.assertTrue(module.IsValid()) + for symbol_name in ["struct1::f()", "struct2::f()"]: + sc_list = module.FindFunctions(symbol_name, lldb.eSymbolTypeCode) + self.assertTrue(1, sc_list.GetSize()) + symbol_address = sc_list.GetContextAtIndex(0).GetSymbol().GetStartAddress() + self.assertTrue(symbol_address.IsValid()) + sc_by_address = module.ResolveSymbolContextForAddress(symbol_address, lldb.eSymbolContextFunction) + self.assertEqual(symbol_name, sc_by_address.GetFunction().GetName()) diff --git a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/decls.h b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/decls.h new file mode 100644 index 000000000000..0cb685622cd0 --- /dev/null +++ b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/decls.h @@ -0,0 +1,11 @@ +struct struct1 +{ + static void + f(); +}; + +struct struct2 +{ + static void + f(); +}; diff --git a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/file1.cpp b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/file1.cpp new file mode 100644 index 000000000000..16c8ce7d9488 --- /dev/null +++ b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/file1.cpp @@ -0,0 +1,13 @@ +#include "decls.h" + +void +struct1::f() +{ +} + +int main() +{ + struct1::f(); + struct2::f(); + return 0; +} diff --git a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/file2.cpp b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/file2.cpp new file mode 100644 index 000000000000..3bd1aaf95a73 --- /dev/null +++ b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/file2.cpp @@ -0,0 +1,6 @@ +#include "decls.h" + +void +struct2::f() +{ +} diff --git a/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py b/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py index 0231d285ecf9..1278742675f3 100644 --- a/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py +++ b/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py @@ -10,8 +10,9 @@ import unittest2 import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class TargetAPITestCase(TestBase): @@ -41,7 +42,7 @@ class TargetAPITestCase(TestBase): self.find_global_variables('b.out') @add_test_categories(['pyapi']) - @expectedFailureWindows("llvm.org/pr24778") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_find_functions(self): """Exercise SBTarget.FindFunctions() API.""" d = {'EXE': 'b.out'} diff --git a/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py b/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py index dad829a48f2f..588aa66cf53e 100644 --- a/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py +++ b/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py @@ -8,8 +8,10 @@ from __future__ import print_function import os, time import lldb -from lldbsuite.test.lldbutil import get_stopped_thread, get_caller_symbol +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil +from lldbsuite.test.lldbutil import get_stopped_thread, get_caller_symbol class ThreadAPITestCase(TestBase): @@ -37,8 +39,8 @@ class ThreadAPITestCase(TestBase): self.run_to_address(self.exe_name) @add_test_categories(['pyapi']) - @expectedFailureFreeBSD # llvm.org/pr20476 - @expectedFailureWindows # Test crashes + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr20476') + @expectedFailureAll(oslist=["windows"]) def test_step_out_of_malloc_into_function_b(self): """Test Python SBThread.StepOut() API to step out of a malloc call where the call site is at function b().""" # We build a different executable than the default build() does. diff --git a/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py b/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py index d9e5719844e2..20e899beee45 100644 --- a/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py +++ b/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py @@ -6,11 +6,14 @@ from __future__ import print_function -import os, time +import os import re +import time + import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class TypeAndTypeListTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py b/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py index 77ff07ea6488..2a53177d28af 100644 --- a/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py +++ b/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py @@ -4,13 +4,14 @@ Test some SBValue APIs. from __future__ import print_function - - -import os, time +import os import re +import time + import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class ValueAPITestCase(TestBase): @@ -24,7 +25,7 @@ class ValueAPITestCase(TestBase): # Find the line number to of function 'c'. self.line = line_number('main.c', '// Break at this line') - @expectedFailureWindows("llvm.org/pr24772") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24772") @add_test_categories(['pyapi']) def test(self): """Exercise some SBValue APIs.""" @@ -133,3 +134,12 @@ class ValueAPITestCase(TestBase): val_a = target.EvaluateExpression('a') self.assertTrue(val_s.GetChildMemberWithName('a').AddressOf(), VALID_VARIABLE) self.assertTrue(val_a.Cast(val_i.GetType()).AddressOf(), VALID_VARIABLE) + + self.assertTrue(int(lldb.value(frame0.FindVariable('uinthex'))) == 3768803088, 'uinthex == 3768803088') + self.assertTrue(int(lldb.value(frame0.FindVariable('sinthex'))) == -526164208, 'sinthex == -526164208') + + self.assertTrue(frame0.FindVariable('uinthex').GetValueAsUnsigned() == 3768803088, 'unsigned uinthex == 3768803088') + self.assertTrue(frame0.FindVariable('sinthex').GetValueAsUnsigned() == 3768803088, 'unsigned sinthex == 3768803088') + + self.assertTrue(frame0.FindVariable('uinthex').GetValueAsSigned() == -526164208, 'signed uinthex == -526164208') + self.assertTrue(frame0.FindVariable('sinthex').GetValueAsSigned() == -526164208, 'signed sinthex == -526164208') diff --git a/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py b/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py index f8ad97277f05..52c91e0b2621 100644 --- a/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py +++ b/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py @@ -9,8 +9,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class ChangeValueAPITestCase(TestBase): @@ -26,9 +27,9 @@ class ChangeValueAPITestCase(TestBase): self.check_line = line_number('main.c', '// Stop here and check values') self.end_line = line_number ('main.c', '// Set a breakpoint here at the end') - @expectedFailureWindows("llvm.org/pr24772") @add_test_categories(['pyapi']) @expectedFlakeyLinux("llvm.org/pr25652") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24772") def test_change_value(self): """Exercise the SBValue::SetValueFromCString API.""" d = {'EXE': self.exe_name} diff --git a/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py b/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py index 8b60be97bdc2..879efd186d68 100644 --- a/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py +++ b/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py @@ -10,8 +10,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class ValueAsLinkedListTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/python_api/value/main.c b/packages/Python/lldbsuite/test/python_api/value/main.c index a00795750de0..2ebe3ad303cf 100644 --- a/packages/Python/lldbsuite/test/python_api/value/main.c +++ b/packages/Python/lldbsuite/test/python_api/value/main.c @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// #include <stdio.h> +#include <stdint.h> // This simple program is to test the lldb Python API SBValue.GetChildAtIndex(). @@ -38,6 +39,9 @@ struct MyStruct int main (int argc, char const *argv[]) { + uint32_t uinthex = 0xE0A35F10; + int32_t sinthex = 0xE0A35F10; + int i; MyInt a = 12345; struct MyStruct s = { 11, 22 }; diff --git a/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py b/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py index 251bbcf4b24d..8620117386f9 100644 --- a/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py +++ b/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py @@ -7,7 +7,9 @@ from __future__ import print_function import os, sys, time import lldb import time +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class HelloWorldTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py b/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py index 264e21240dd9..bedf286e199b 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py @@ -9,8 +9,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class SetWatchpointAPITestCase(TestBase): @@ -26,7 +27,8 @@ class SetWatchpointAPITestCase(TestBase): @add_test_categories(['pyapi']) @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ def test_watch_val(self): """Exercise SBValue.Watch() API to set a watchpoint.""" self.build() diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py b/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py index a15e73347030..d7b45a533e39 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py @@ -9,8 +9,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class WatchpointIgnoreCountTestCase(TestBase): @@ -26,7 +27,8 @@ class WatchpointIgnoreCountTestCase(TestBase): @add_test_categories(['pyapi']) @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ def test_set_watch_ignore_count(self): """Test SBWatchpoint.SetIgnoreCount() API.""" self.build() diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py b/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py index 315450280675..8bbb93af07e5 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py @@ -6,11 +6,14 @@ from __future__ import print_function -import os, time +import os import re +import time + import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class WatchpointIteratorTestCase(TestBase): @@ -26,7 +29,7 @@ class WatchpointIteratorTestCase(TestBase): @add_test_categories(['pyapi']) @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") def test_watch_iter(self): """Exercise SBTarget.watchpoint_iter() API to iterate on the available watchpoints.""" self.build() @@ -55,7 +58,7 @@ class WatchpointIteratorTestCase(TestBase): # Watch 'global' for read and write. value = frame0.FindValue('global', lldb.eValueTypeVariableGlobal) error = lldb.SBError(); - watchpoint = value.Watch(True, True, True, error) + watchpoint = value.Watch(True, False, True, error) self.assertTrue(value and watchpoint, "Successfully found the variable and set a watchpoint") self.DebugSBValue(value) diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py b/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py index f30bf856aa07..b368cc066615 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py @@ -8,8 +8,9 @@ from __future__ import print_function import os, time import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class WatchpointConditionAPITestCase(TestBase): @@ -29,6 +30,7 @@ class WatchpointConditionAPITestCase(TestBase): self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name} @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported + @expectedFailureAll(oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr27710") @skipIfWindows # Watchpoints not supported on Windows, and this test hangs def test_watchpoint_cond_api(self): """Test watchpoint condition API.""" diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py b/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py index 5a4a464657d6..d0a2c2fff128 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py @@ -6,11 +6,14 @@ from __future__ import print_function -import os, time +import os import re +import time + import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class SetWatchlocationAPITestCase(TestBase): @@ -28,7 +31,7 @@ class SetWatchlocationAPITestCase(TestBase): @add_test_categories(['pyapi']) @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") def test_watch_location(self): """Exercise SBValue.WatchPointee() API to set a watchpoint.""" self.build() diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py b/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py index 6facbaa8f2e9..468f3131f337 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py @@ -9,8 +9,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class TargetWatchAddressAPITestCase(TestBase): @@ -28,7 +29,7 @@ class TargetWatchAddressAPITestCase(TestBase): @add_test_categories(['pyapi']) @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureWindows("llvm.org/pr24446") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") def test_watch_address(self): """Exercise SBTarget.WatchAddress() API to set a watchpoint.""" self.build() @@ -92,6 +93,7 @@ class TargetWatchAddressAPITestCase(TestBase): @add_test_categories(['pyapi']) @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported @skipIf(archs=['mips', 'mipsel', 'mips64', 'mips64el']) # No size constraint on MIPS for watches + @skipIf(archs=['s390x']) # Likewise on SystemZ def test_watch_address_with_invalid_watch_size(self): """Exercise SBTarget.WatchAddress() API but pass an invalid watch_size.""" self.build() |