From 0f821339dad1bf45dd71a1cac32b6352ba251ecb Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 3 Aug 2022 11:42:12 -0700 Subject: [PATCH] [lldb] Add assertStopReason helper function Add a function to make it easier to debug a test failure caused by an unexpected stop reason. This is similar to the assertState helper that was added in ce825e46743b. Before: self.assertEqual(stop_reason, lldb.eStopReasonInstrumentation) AssertionError: 5 != 10 After: self.assertStopReason(stop_reason, lldb.eStopReasonInstrumentation) AssertionError: signal (5) != instrumentation (10) Differential revision: https://reviews.llvm.org/D131083 --- lldb/docs/resources/test.rst | 10 ++++++---- lldb/packages/Python/lldbsuite/test/lldbtest.py | 8 ++++++++ lldb/packages/Python/lldbsuite/test/lldbutil.py | 4 ++++ .../commands/process/continue_to_bkpt/TestContinueToBkpts.py | 2 +- .../API/commands/watchpoints/multiple_hits/TestMultipleHits.py | 2 +- .../watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py | 6 +++--- .../watchpoints/watchpoint_count/TestWatchpointCount.py | 4 ++-- .../watchpoints/watchpoint_disable/TestWatchpointDisable.py | 4 ++-- .../breakpoint_on_lambda_capture/TestBreakOnLambdaCapture.py | 4 ++-- .../breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py | 6 +++--- .../breakpoint/two_hits_one_actual/TestTwoHitsOneActual.py | 4 ++-- .../gdb_remote_client/TestRecognizeBreakpoint.py | 2 +- lldb/test/API/functionalities/mtc/simple/TestMTCSimple.py | 2 +- .../API/functionalities/postmortem/elf-core/gcore/TestGCore.py | 2 +- .../postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py | 2 +- .../functionalities/postmortem/minidump-new/TestMiniDumpNew.py | 10 +++++----- .../API/functionalities/postmortem/minidump/TestMiniDump.py | 2 +- .../functionalities/postmortem/netbsd-core/TestNetBSDCore.py | 10 +++++----- .../postmortem/wow64_minidump/TestWow64MiniDump.py | 2 +- .../functionalities/process_group/TestChangeProcessGroup.py | 2 +- lldb/test/API/functionalities/return-value/TestReturnValue.py | 8 ++++---- .../functionalities/scripted_process/TestScriptedProcess.py | 2 +- .../TestStopOnSharedlibraryEvents.py | 4 ++-- .../thread/create_during_step/TestCreateDuringStep.py | 2 +- .../API/functionalities/thread/num_threads/TestNumThreads.py | 2 +- lldb/test/API/functionalities/thread/state/TestThreadStates.py | 8 ++++---- .../thread/state_after_expression/TestStateAfterExpression.py | 2 +- lldb/test/API/functionalities/ubsan/basic/TestUbsanBasic.py | 2 +- lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py | 4 ++-- .../test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py | 2 +- lldb/test/API/python_api/thread/TestThreadAPI.py | 2 +- 31 files changed, 70 insertions(+), 56 deletions(-) diff --git a/lldb/docs/resources/test.rst b/lldb/docs/resources/test.rst index 001803d..d0e94fb 100644 --- a/lldb/docs/resources/test.rst +++ b/lldb/docs/resources/test.rst @@ -323,13 +323,15 @@ A better way to write the test above would be using LLDB's testing function asserts are available. LLDB also has a few custom asserts that are tailored to our own data types. -+-----------------------------------------------+---------------------------------------------------------------+ ++-----------------------------------------------+-----------------------------------------------------------------+ | **Assert** | **Description** | -+-----------------------------------------------+---------------------------------------------------------------+ ++-----------------------------------------------+-----------------------------------------------------------------+ | ``assertSuccess`` | Assert that an ``lldb.SBError`` is in the "success" state. | -+-----------------------------------------------+---------------------------------------------------------------+ ++-----------------------------------------------+-----------------------------------------------------------------+ | ``assertState`` | Assert that two states (``lldb.eState*``) are equal. | -+-----------------------------------------------+---------------------------------------------------------------+ ++-----------------------------------------------+-----------------------------------------------------------------+ +| ``assertStopReason`` | Assert that two stop reasons (``lldb.eStopReason*``) are equal. | ++-----------------------------------------------+-----------------------------------------------------------------+ If you can't find a specific assert that fits your needs and you fall back to a generic assert, make sure you put useful information into the assert's diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index d46e54f..d28e0d2 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -2474,6 +2474,14 @@ FileCheck output: lldbutil.state_type_to_str(second), second) self.fail(self._formatMessage(msg, error)) + """Assert two stop reasons are equal""" + def assertStopReason(self, first, second, msg=None): + if first != second: + error = "{} ({}) != {} ({})".format( + lldbutil.stop_reason_to_str(first), first, + lldbutil.stop_reason_to_str(second), second) + self.fail(self._formatMessage(msg, error)) + def createTestTarget(self, file_path=None, msg=None, load_dependent_modules=True): """ diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py index 7863e64..f21f492 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbutil.py +++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py @@ -266,6 +266,10 @@ def stop_reason_to_str(enum): return "plancomplete" elif enum == lldb.eStopReasonThreadExiting: return "threadexiting" + elif enum == lldb.eStopReasonInstrumentation: + return "instrumentation" + elif enum == lldb.eStopReasonProcessorTrace: + return "processortrace" else: raise Exception("Unknown StopReason enum") diff --git a/lldb/test/API/commands/process/continue_to_bkpt/TestContinueToBkpts.py b/lldb/test/API/commands/process/continue_to_bkpt/TestContinueToBkpts.py index c8f6764..eef1a6d 100644 --- a/lldb/test/API/commands/process/continue_to_bkpt/TestContinueToBkpts.py +++ b/lldb/test/API/commands/process/continue_to_bkpt/TestContinueToBkpts.py @@ -32,7 +32,7 @@ class TestContinueToBkpts(TestBase): for elem in stop_list: command += " -b {0}".format(elem) self.expect(command) - self.assertEqual(self.thread.stop_reason, lldb.eStopReasonBreakpoint, "Hit a breakpoint") + self.assertStopReason(self.thread.stop_reason, lldb.eStopReasonBreakpoint, "Hit a breakpoint") self.assertEqual(self.thread.GetStopReasonDataAtIndex(0), bkpt_to_hit, "Hit the right breakpoint") if loc_to_hit != 0: self.assertEqual(self.thread.GetStopReasonDataAtIndex(1), loc_to_hit, "Hit the right location") diff --git a/lldb/test/API/commands/watchpoints/multiple_hits/TestMultipleHits.py b/lldb/test/API/commands/watchpoints/multiple_hits/TestMultipleHits.py index 9267637..2a37831 100644 --- a/lldb/test/API/commands/watchpoints/multiple_hits/TestMultipleHits.py +++ b/lldb/test/API/commands/watchpoints/multiple_hits/TestMultipleHits.py @@ -45,5 +45,5 @@ class MultipleHitsTestCase(TestBase): process.Continue(); self.assertState(process.GetState(), lldb.eStateStopped) - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonWatchpoint) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonWatchpoint) diff --git a/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py b/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py index 775d80d..7d54156a 100644 --- a/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py +++ b/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py @@ -56,7 +56,7 @@ class TestStepOverWatchpoint(TestBase): self.assertTrue(read_watchpoint, "Failed to set read watchpoint.") thread.StepOver() - self.assertEquals(thread.GetStopReason(), lldb.eStopReasonWatchpoint, + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonWatchpoint, STOPPED_DUE_TO_WATCHPOINT) self.assertEquals(thread.GetStopDescription(20), 'watchpoint 1') @@ -83,7 +83,7 @@ class TestStepOverWatchpoint(TestBase): self.assertSuccess(error, "Error while setting watchpoint") thread.StepOver() - self.assertEquals(thread.GetStopReason(), lldb.eStopReasonWatchpoint, + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonWatchpoint, STOPPED_DUE_TO_WATCHPOINT) self.assertEquals(thread.GetStopDescription(20), 'watchpoint 2') @@ -108,6 +108,6 @@ class TestStepOverWatchpoint(TestBase): "Watchpoint ID didn't match.") watchpoint_hit = True else: - self.assertEquals(stop_reason, lldb.eStopReasonPlanComplete, + self.assertStopReason(stop_reason, lldb.eStopReasonPlanComplete, STOPPED_DUE_TO_STEP_IN) self.assertTrue(watchpoint_hit, "Watchpoint never hit.") diff --git a/lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py b/lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py index a940e00..9b34a2e 100644 --- a/lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py +++ b/lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py @@ -33,12 +33,12 @@ class TestWatchpointCount(TestBase): process.Continue() stop_reason = thread.GetStopReason() - self.assertEqual(stop_reason, lldb.eStopReasonWatchpoint, "watchpoint for x1 not hit") + self.assertStopReason(stop_reason, lldb.eStopReasonWatchpoint, "watchpoint for x1 not hit") stop_reason_descr = thread.GetStopDescription(256) self.assertEqual(stop_reason_descr, "watchpoint 1") process.Continue() stop_reason = thread.GetStopReason() - self.assertEqual(stop_reason, lldb.eStopReasonWatchpoint, "watchpoint for x2 not hit") + self.assertStopReason(stop_reason, lldb.eStopReasonWatchpoint, "watchpoint for x2 not hit") stop_reason_descr = thread.GetStopDescription(256) self.assertEqual(stop_reason_descr, "watchpoint 2") diff --git a/lldb/test/API/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py b/lldb/test/API/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py index e582d54..d1a8075 100644 --- a/lldb/test/API/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py +++ b/lldb/test/API/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py @@ -56,12 +56,12 @@ class TestWatchpointSetEnable(TestBase): stop_reason = thread.GetStopReason() - self.assertEqual(stop_reason, lldb.eStopReasonBreakpoint, "We didn't stop at our breakpoint.") + self.assertStopReason(stop_reason, lldb.eStopReasonBreakpoint, "We didn't stop at our breakpoint.") if test_enable: wp.SetEnabled(True) self.assertTrue(wp.IsEnabled(), "The watchpoint thinks it is still disabled.") process.Continue() stop_reason = thread.GetStopReason() - self.assertEqual(stop_reason, lldb.eStopReasonWatchpoint, "We didn't stop at our watchpoint") + self.assertStopReason(stop_reason, lldb.eStopReasonWatchpoint, "We didn't stop at our watchpoint") diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_on_lambda_capture/TestBreakOnLambdaCapture.py b/lldb/test/API/functionalities/breakpoint/breakpoint_on_lambda_capture/TestBreakOnLambdaCapture.py index da6af1e..a75d872 100644 --- a/lldb/test/API/functionalities/breakpoint/breakpoint_on_lambda_capture/TestBreakOnLambdaCapture.py +++ b/lldb/test/API/functionalities/breakpoint/breakpoint_on_lambda_capture/TestBreakOnLambdaCapture.py @@ -49,6 +49,6 @@ class TestBreakOnLambdaCapture(TestBase): process.Continue() for thread in process.threads: if thread.id == main_thread.id: - self.assertEqual(thread.stop_reason, lldb.eStopReasonBreakpoint) + self.assertStopReason(thread.stop_reason, lldb.eStopReasonBreakpoint) else: - self.assertEqual(thread.stop_reason, lldb.eStopReasonNone) + self.assertStopReason(thread.stop_reason, lldb.eStopReasonNone) diff --git a/lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py b/lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py index 0953f0b..921a24d 100644 --- a/lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py +++ b/lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py @@ -89,17 +89,17 @@ class StepOverBreakpointsTestCase(TestBase): self.thread.StepOver() # We should be stopped at the breakpoint_2 line with stop plan complete reason self.assertState(self.process.GetState(), lldb.eStateStopped) - self.assertEquals(self.thread.GetStopReason(), lldb.eStopReasonPlanComplete) + self.assertStopReason(self.thread.GetStopReason(), lldb.eStopReasonPlanComplete) self.thread.StepOver() # We should be stopped at the breakpoint_3 line with stop plan complete reason self.assertState(self.process.GetState(), lldb.eStateStopped) - self.assertEquals(self.thread.GetStopReason(), lldb.eStopReasonPlanComplete) + self.assertStopReason(self.thread.GetStopReason(), lldb.eStopReasonPlanComplete) self.thread.StepOver() # We should be stopped at the breakpoint_4 self.assertState(self.process.GetState(), lldb.eStateStopped) - self.assertEquals(self.thread.GetStopReason(), lldb.eStopReasonBreakpoint) + self.assertStopReason(self.thread.GetStopReason(), lldb.eStopReasonBreakpoint) thread1 = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoint4) self.assertEquals(self.thread, thread1, "Didn't stop at breakpoint 4.") diff --git a/lldb/test/API/functionalities/breakpoint/two_hits_one_actual/TestTwoHitsOneActual.py b/lldb/test/API/functionalities/breakpoint/two_hits_one_actual/TestTwoHitsOneActual.py index 6e5c721..65fdf31 100644 --- a/lldb/test/API/functionalities/breakpoint/two_hits_one_actual/TestTwoHitsOneActual.py +++ b/lldb/test/API/functionalities/breakpoint/two_hits_one_actual/TestTwoHitsOneActual.py @@ -57,8 +57,8 @@ class TestTwoHitsOneActual(TestBase): process.Continue() for thread in process.threads: if thread.id == main_thread.id: - self.assertEqual(thread.stop_reason, lldb.eStopReasonBreakpoint) + self.assertStopReason(thread.stop_reason, lldb.eStopReasonBreakpoint) else: - self.assertEqual(thread.stop_reason, lldb.eStopReasonNone) + self.assertStopReason(thread.stop_reason, lldb.eStopReasonNone) diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py b/lldb/test/API/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py index 783240b..7e047bb 100644 --- a/lldb/test/API/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py +++ b/lldb/test/API/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py @@ -137,5 +137,5 @@ class TestRecognizeBreakpoint(GDBRemoteTestBase): self.assertEqual(thread_1.GetName(), "three", "Thread_0 is called three") self.assertTrue(thread_1.IsValid(), "Thread_1 is valid") - self.assertEqual(thread_1.GetStopReason(), lldb.eStopReasonBreakpoint, "Stopped at breakpoint") + self.assertStopReason(thread_1.GetStopReason(), lldb.eStopReasonBreakpoint, "Stopped at breakpoint") diff --git a/lldb/test/API/functionalities/mtc/simple/TestMTCSimple.py b/lldb/test/API/functionalities/mtc/simple/TestMTCSimple.py index 863afe1..9ecacba 100644 --- a/lldb/test/API/functionalities/mtc/simple/TestMTCSimple.py +++ b/lldb/test/API/functionalities/mtc/simple/TestMTCSimple.py @@ -53,7 +53,7 @@ class MTCSimpleTestCase(TestBase): "instrumentation_class", "selector" ]) - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonInstrumentation) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonInstrumentation) output_lines = self.res.GetOutput().split('\n') json_line = '\n'.join(output_lines[2:]) data = json.loads(json_line) diff --git a/lldb/test/API/functionalities/postmortem/elf-core/gcore/TestGCore.py b/lldb/test/API/functionalities/postmortem/elf-core/gcore/TestGCore.py index 0f3f484..4aafd40 100644 --- a/lldb/test/API/functionalities/postmortem/elf-core/gcore/TestGCore.py +++ b/lldb/test/API/functionalities/postmortem/elf-core/gcore/TestGCore.py @@ -37,7 +37,7 @@ class GCoreTestCase(TestBase): for thread in process: reason = thread.GetStopReason() - self.assertEqual(reason, lldb.eStopReasonSignal) + self.assertStopReason(reason, lldb.eStopReasonSignal) signal = thread.GetStopReasonDataAtIndex(1) # Check we got signal 19 (SIGSTOP) self.assertEqual(signal, 19) diff --git a/lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py b/lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py index 398af86..3eb1eb8 100644 --- a/lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py +++ b/lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py @@ -53,7 +53,7 @@ class LinuxCoreThreadsTestCase(TestBase): self.assertEqual(bytes_read, None) reason = thread.GetStopReason() if( thread.GetThreadID() == tid ): - self.assertEqual(reason, lldb.eStopReasonSignal) + self.assertStopReason(reason, lldb.eStopReasonSignal) signal = thread.GetStopReasonDataAtIndex(1) # Check we got signal 4 (SIGILL) self.assertEqual(signal, 4) diff --git a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py index 286ff07..7c36675 100644 --- a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py +++ b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py @@ -117,7 +117,7 @@ class MiniDumpNewTestCase(TestBase): # one and only thread. self.assertEqual(self.process.GetNumThreads(), 1) thread = self.process.GetThreadAtIndex(0) - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonSignal) stop_description = thread.GetStopDescription(256) self.assertIn("SIGSEGV", stop_description) @@ -153,7 +153,7 @@ class MiniDumpNewTestCase(TestBase): self.check_state() self.assertEqual(self.process.GetNumThreads(), 1) thread = self.process.GetThreadAtIndex(0) - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonNone) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonNone) stop_description = thread.GetStopDescription(256) self.assertEqual(stop_description, "") @@ -164,7 +164,7 @@ class MiniDumpNewTestCase(TestBase): self.check_state() self.assertEqual(self.process.GetNumThreads(), 1) thread = self.process.GetThreadAtIndex(0) - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonNone) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonNone) stop_description = thread.GetStopDescription(256) self.assertEqual(stop_description, "") @@ -191,7 +191,7 @@ class MiniDumpNewTestCase(TestBase): self.check_state() self.assertEqual(self.process.GetNumThreads(), 1) thread = self.process.GetThreadAtIndex(0) - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonNone) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonNone) stop_description = thread.GetStopDescription(256) self.assertEqual(stop_description, "") registers = thread.GetFrameAtIndex(0).GetRegisters() @@ -258,7 +258,7 @@ class MiniDumpNewTestCase(TestBase): self.check_state() self.assertEqual(self.process.GetNumThreads(), 1) thread = self.process.GetThreadAtIndex(0) - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonNone) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonNone) stop_description = thread.GetStopDescription(256) self.assertEqual(stop_description, "") registers = thread.GetFrameAtIndex(0).GetRegisters() diff --git a/lldb/test/API/functionalities/postmortem/minidump/TestMiniDump.py b/lldb/test/API/functionalities/postmortem/minidump/TestMiniDump.py index 4d08efc..e0c5600 100644 --- a/lldb/test/API/functionalities/postmortem/minidump/TestMiniDump.py +++ b/lldb/test/API/functionalities/postmortem/minidump/TestMiniDump.py @@ -34,7 +34,7 @@ class MiniDumpTestCase(TestBase): # one and only thread. self.assertEqual(self.process.GetNumThreads(), 1) thread = self.process.GetThreadAtIndex(0) - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonException) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonException) stop_description = thread.GetStopDescription(256) self.assertIn("0xc0000005", stop_description) diff --git a/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py b/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py index fb02016..c22ef58 100644 --- a/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py +++ b/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py @@ -150,7 +150,7 @@ class NetBSD1LWPCoreTestCase(NetBSDCoreCommonTestCase): thread = process.GetSelectedThread() self.assertTrue(thread) self.assertEqual(thread.GetThreadID(), 1) - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonSignal) self.assertEqual(thread.GetStopReasonDataCount(), 1) self.assertEqual(thread.GetStopReasonDataAtIndex(0), signal.SIGSEGV) backtrace = ["bar", "foo", "main"] @@ -174,7 +174,7 @@ class NetBSD2LWPT2CoreTestCase(NetBSDCoreCommonTestCase): thread = process.GetSelectedThread() self.assertTrue(thread) self.assertEqual(thread.GetThreadID(), 2) - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonSignal) self.assertEqual(thread.GetStopReasonDataCount(), 1) self.assertEqual(thread.GetStopReasonDataAtIndex(0), signal.SIGSEGV) backtrace = ["bar", "foo", "lwp_main"] @@ -182,7 +182,7 @@ class NetBSD2LWPT2CoreTestCase(NetBSDCoreCommonTestCase): # thread 1 should have no signal thread = process.GetThreadByID(1) - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonSignal) self.assertEqual(thread.GetStopReasonDataCount(), 1) self.assertEqual(thread.GetStopReasonDataAtIndex(0), 0) @@ -204,7 +204,7 @@ class NetBSD2LWPProcessSigCoreTestCase(NetBSDCoreCommonTestCase): thread = process.GetSelectedThread() self.assertTrue(thread) self.assertEqual(thread.GetThreadID(), 2) - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonSignal) self.assertEqual(thread.GetStopReasonDataCount(), 1) self.assertEqual(thread.GetStopReasonDataAtIndex(0), signal.SIGSEGV) backtrace = ["bar", "foo", "lwp_main"] @@ -212,7 +212,7 @@ class NetBSD2LWPProcessSigCoreTestCase(NetBSDCoreCommonTestCase): # thread 1 should have the same signal thread = process.GetThreadByID(1) - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonSignal) self.assertEqual(thread.GetStopReasonDataCount(), 1) self.assertEqual(thread.GetStopReasonDataAtIndex(0), signal.SIGSEGV) diff --git a/lldb/test/API/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py b/lldb/test/API/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py index d057856..ef4cf6e 100644 --- a/lldb/test/API/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py +++ b/lldb/test/API/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py @@ -42,7 +42,7 @@ class Wow64MiniDumpTestCase(TestBase): # In the dump, none of the threads are stopped, so we cannot use # lldbutil.get_stopped_thread. thread = process.GetThreadAtIndex(0) - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonNone) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonNone) def test_stack_info_in_wow64_mini_dump(self): """Test that we can see a trivial stack in a VS-generate mini dump.""" diff --git a/lldb/test/API/functionalities/process_group/TestChangeProcessGroup.py b/lldb/test/API/functionalities/process_group/TestChangeProcessGroup.py index 98f3552..6263c14 100644 --- a/lldb/test/API/functionalities/process_group/TestChangeProcessGroup.py +++ b/lldb/test/API/functionalities/process_group/TestChangeProcessGroup.py @@ -77,7 +77,7 @@ class ChangeProcessGroupTestCase(TestBase): # step over the setpgid() call thread.StepOver() - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonPlanComplete) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonPlanComplete) # verify that the process group has been set correctly # this also checks that we are still in full control of the child diff --git a/lldb/test/API/functionalities/return-value/TestReturnValue.py b/lldb/test/API/functionalities/return-value/TestReturnValue.py index 67a268a..41e0b97 100644 --- a/lldb/test/API/functionalities/return-value/TestReturnValue.py +++ b/lldb/test/API/functionalities/return-value/TestReturnValue.py @@ -61,7 +61,7 @@ class ReturnValueTestCase(TestBase): thread.StepOut() self.assertState(self.process.GetState(), lldb.eStateStopped) - self.assertEquals(thread.GetStopReason(), lldb.eStopReasonPlanComplete) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonPlanComplete) frame = thread.GetFrameAtIndex(0) fun_name = frame.GetFunctionName() @@ -93,7 +93,7 @@ class ReturnValueTestCase(TestBase): thread.StepOutOfFrame(frame) self.assertState(self.process.GetState(), lldb.eStateStopped) - self.assertEquals(thread.GetStopReason(), lldb.eStopReasonPlanComplete) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonPlanComplete) frame = thread.GetFrameAtIndex(0) fun_name = frame.GetFunctionName() self.assertEquals(fun_name, "main") @@ -122,7 +122,7 @@ class ReturnValueTestCase(TestBase): thread.StepOut() self.assertState(self.process.GetState(), lldb.eStateStopped) - self.assertEquals(thread.GetStopReason(), lldb.eStopReasonPlanComplete) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonPlanComplete) frame = thread.GetFrameAtIndex(0) fun_name = frame.GetFunctionName() @@ -262,7 +262,7 @@ class ReturnValueTestCase(TestBase): thread.StepOut() self.assertState(self.process.GetState(), lldb.eStateStopped) - self.assertEquals(thread.GetStopReason(), lldb.eStopReasonPlanComplete) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonPlanComplete) # Assuming all these functions step out to main. Could figure out the caller dynamically # if that would add something to the test. diff --git a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py index d1e75cd..7c6ce83 100644 --- a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py +++ b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py @@ -122,7 +122,7 @@ class ScriptedProcesTestCase(TestBase): self.assertTrue(thread, "Invalid thread.") self.assertEqual(thread.GetThreadID(), 0x19) self.assertEqual(thread.GetName(), "DummyScriptedThread.thread-1") - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonSignal) self.assertGreater(thread.GetNumFrames(), 0) diff --git a/lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py b/lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py index b6af635..f12d6fc 100644 --- a/lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py +++ b/lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py @@ -82,14 +82,14 @@ class TestStopOnSharedlibraryEvents(TestBase): process.Continue() self.assertState(process.GetState(), lldb.eStateStopped, "We didn't stop for the load") self.assertEqual(backstop_bkpt_2.GetHitCount(), 0, "Hit our backstop breakpoint") - self.assertEqual(thread.stop_reason, lldb.eStopReasonBreakpoint, "We attributed the stop to the breakpoint") + self.assertStopReason(thread.stop_reason, lldb.eStopReasonBreakpoint, "We attributed the stop to the breakpoint") self.assertEqual(load_bkpt.GetHitCount(), 1, "We hit our breakpoint at the load address") else: bkpt_modifier(load_bkpt) process.Continue() self.assertState(process.GetState(), lldb.eStateStopped, "We didn't stop") self.assertTrue(thread.IsValid(), "Our thread was no longer valid.") - self.assertEqual(thread.stop_reason, lldb.eStopReasonBreakpoint, "We didn't hit some breakpoint") + self.assertStopReason(thread.stop_reason, lldb.eStopReasonBreakpoint, "We didn't hit some breakpoint") self.assertEqual(backstop_bkpt_2.GetHitCount(), 1, "We continued to the right breakpoint") diff --git a/lldb/test/API/functionalities/thread/create_during_step/TestCreateDuringStep.py b/lldb/test/API/functionalities/thread/create_during_step/TestCreateDuringStep.py index 372ac13..6abeccb 100644 --- a/lldb/test/API/functionalities/thread/create_during_step/TestCreateDuringStep.py +++ b/lldb/test/API/functionalities/thread/create_during_step/TestCreateDuringStep.py @@ -141,7 +141,7 @@ class CreateDuringStepTestCase(TestBase): 'Number of expected threads and actual threads do not match after thread exit.') stop_reason = stepping_thread.GetStopReason() - self.assertEqual(stop_reason, lldb.eStopReasonPlanComplete, "Stopped for plan completion") + self.assertStopReason(stop_reason, lldb.eStopReasonPlanComplete, "Stopped for plan completion") # Run to completion self.runCmd("process continue") diff --git a/lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py b/lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py index 7ddf6f2..8cc1100 100644 --- a/lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py +++ b/lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py @@ -107,7 +107,7 @@ class NumberOfThreadsTestCase(TestBase): # If we aren't stopped out the thread breakpoint try to resume. if thread.GetStopReason() != lldb.eStopReasonBreakpoint: self.runCmd("thread continue %d"%(i+1)) - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonBreakpoint) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonBreakpoint) expect_threads += " #%d"%(i+1) diff --git a/lldb/test/API/functionalities/thread/state/TestThreadStates.py b/lldb/test/API/functionalities/thread/state/TestThreadStates.py index 9d6863f..c9d1938 100644 --- a/lldb/test/API/functionalities/thread/state/TestThreadStates.py +++ b/lldb/test/API/functionalities/thread/state/TestThreadStates.py @@ -226,7 +226,7 @@ class ThreadStateTestCase(TestBase): # Stop the process self.runCmd("process interrupt") - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonSignal) # Get the inferior out of its loop self.runCmd("expression g_test = 1") @@ -282,7 +282,7 @@ class ThreadStateTestCase(TestBase): # Stop the process self.runCmd("process interrupt") - self.assertEqual(thread.GetState(), lldb.eStopReasonSignal) + self.assertStopReason(thread.GetState(), lldb.eStopReasonSignal) # Check the thread state self.assertTrue( @@ -302,12 +302,12 @@ class ThreadStateTestCase(TestBase): thread.IsSuspended(), "Thread state is \'suspended\' after expression evaluation.") - self.assertEqual(thread.GetState(), lldb.eStopReasonSignal) + self.assertStopReason(thread.GetState(), lldb.eStopReasonSignal) # Run to breakpoint 2 self.runCmd("continue") - self.assertEqual(thread.GetState(), lldb.eStopReasonBreakpoint) + self.assertStopReason(thread.GetState(), lldb.eStopReasonBreakpoint) # Make sure both threads are stopped self.assertTrue( diff --git a/lldb/test/API/functionalities/thread/state_after_expression/TestStateAfterExpression.py b/lldb/test/API/functionalities/thread/state_after_expression/TestStateAfterExpression.py index e26e066..90fc9a2 100644 --- a/lldb/test/API/functionalities/thread/state_after_expression/TestStateAfterExpression.py +++ b/lldb/test/API/functionalities/thread/state_after_expression/TestStateAfterExpression.py @@ -45,7 +45,7 @@ class TestStopReasonAfterExpression(TestBase): stop_reason = other_thread.GetStopReason() - self.assertEqual(stop_reason, lldb.eStopReasonBreakpoint, + self.assertStopReason(stop_reason, lldb.eStopReasonBreakpoint, "Still records stopped at breakpoint: %s" %(lldbutil.stop_reason_to_str(stop_reason))) self.assertEqual(other_thread.GetStopReasonDataAtIndex(0), 1, diff --git a/lldb/test/API/functionalities/ubsan/basic/TestUbsanBasic.py b/lldb/test/API/functionalities/ubsan/basic/TestUbsanBasic.py index 4220a59..2af9709 100644 --- a/lldb/test/API/functionalities/ubsan/basic/TestUbsanBasic.py +++ b/lldb/test/API/functionalities/ubsan/basic/TestUbsanBasic.py @@ -41,7 +41,7 @@ class UbsanBasicTestCase(TestBase): substrs=['stopped', 'stop reason =']) stop_reason = thread.GetStopReason() - self.assertEqual(stop_reason, lldb.eStopReasonInstrumentation) + self.assertStopReason(stop_reason, lldb.eStopReasonInstrumentation) # test that the UBSan dylib is present self.expect( diff --git a/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py b/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py index 62cce71..1834771 100644 --- a/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py +++ b/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py @@ -165,13 +165,13 @@ class TestCStepping(TestBase): process.Continue() self.assertEqual(thread.GetFrameAtIndex(0).GetFunctionName(), "a") - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonPlanComplete) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonPlanComplete) # And one more time should get us back to main: process.Continue() self.assertEqual(thread.GetFrameAtIndex(0).GetFunctionName(), "main") - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonPlanComplete) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonPlanComplete) # Now make sure we can call a function, break in the called function, # then have "continue" get us back out again: diff --git a/lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py b/lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py index f8112b68..4117e5e 100644 --- a/lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py +++ b/lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py @@ -46,7 +46,7 @@ class TestDarwinSignalHandlers(TestBase): name = thread.frame[0].name self.fail("Hit breakpoint {0} in '{1}' rather than getting a SIGBUS".format(id, name)) - self.assertEqual(thread.stop_reason, lldb.eStopReasonSignal) + self.assertStopReason(thread.stop_reason, lldb.eStopReasonSignal) self.assertEqual(thread.GetStopReasonDataAtIndex(0), 10, "Got a SIGBUS") # Now when we continue, we'll find our way into the signal handler: diff --git a/lldb/test/API/python_api/thread/TestThreadAPI.py b/lldb/test/API/python_api/thread/TestThreadAPI.py index 612c47e..50dd73c4 100644 --- a/lldb/test/API/python_api/thread/TestThreadAPI.py +++ b/lldb/test/API/python_api/thread/TestThreadAPI.py @@ -214,7 +214,7 @@ class ThreadAPITestCase(TestBase): # main2.cpp. frame0 = thread.GetFrameAtIndex(0) lineEntry = frame0.GetLineEntry() - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonPlanComplete) + self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonPlanComplete) # Expected failure with clang as the compiler. # rdar://problem/9223880 # -- 2.7.4