From c5b06ebe827448a258fb81a235257d1a33a15637 Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Thu, 7 Oct 2010 16:51:56 +0000 Subject: [PATCH] Clean up the StateType and StopReason enums now that they reside in the lldb module. llvm-svn: 115922 --- lldb/test/array_types/TestArrayTypes.py | 2 +- lldb/test/bitfields/TestBitfields.py | 2 +- lldb/test/class_types/TestClassTypes.py | 7 +- lldb/test/hello_world/TestHelloWorld.py | 2 +- lldb/test/lldbtest.py | 90 ++++++------------------- 5 files changed, 25 insertions(+), 78 deletions(-) diff --git a/lldb/test/array_types/TestArrayTypes.py b/lldb/test/array_types/TestArrayTypes.py index 8a309d59efd7..3f3a448e685c 100644 --- a/lldb/test/array_types/TestArrayTypes.py +++ b/lldb/test/array_types/TestArrayTypes.py @@ -114,7 +114,7 @@ class ArrayTypesTestCase(TestBase): # The stop reason of the thread should be breakpoint. thread = self.process.GetThreadAtIndex(0) - self.assertTrue(thread.GetStopReason() == StopReasonEnum("Breakpoint"), + self.assertTrue(thread.GetStopReason() == lldb.eStopReasonBreakpoint, STOPPED_DUE_TO_BREAKPOINT) # Sanity check the print representation of thread. diff --git a/lldb/test/bitfields/TestBitfields.py b/lldb/test/bitfields/TestBitfields.py index f3c71ee87a2a..b5a2f92c5a07 100644 --- a/lldb/test/bitfields/TestBitfields.py +++ b/lldb/test/bitfields/TestBitfields.py @@ -93,7 +93,7 @@ class BitfieldsTestCase(TestBase): # The stop reason of the thread should be breakpoint. thread = target.GetProcess().GetThreadAtIndex(0) - self.assertTrue(thread.GetStopReason() == StopReasonEnum("Breakpoint"), + self.assertTrue(thread.GetStopReason() == lldb.eStopReasonBreakpoint, STOPPED_DUE_TO_BREAKPOINT) # The breakpoint should have a hit count of 1. diff --git a/lldb/test/class_types/TestClassTypes.py b/lldb/test/class_types/TestClassTypes.py index 53b82285aa6b..53242d59d903 100644 --- a/lldb/test/class_types/TestClassTypes.py +++ b/lldb/test/class_types/TestClassTypes.py @@ -112,7 +112,7 @@ class ClassTypesTestCase(TestBase): if not rc.Success() or not self.process.IsValid(): self.fail("SBTarget.LaunchProcess() failed") - if self.process.GetState() != StateTypeEnum("Stopped"): + if self.process.GetState() != lldb.eStateStopped: self.fail("Process should be in the 'Stopped' state, " "instead the actual state is: '%s'" % StateTypeString(self.process.GetState())) @@ -120,9 +120,8 @@ class ClassTypesTestCase(TestBase): # The stop reason of the thread should be breakpoint. thread = self.process.GetThreadAtIndex(0) - self.expect(StopReasonString(thread.GetStopReason()), - STOPPED_DUE_TO_BREAKPOINT, exe=False, - startstr = "Breakpoint") + self.assertTrue(thread.GetStopReason() == lldb.eStopReasonBreakpoint, + STOPPED_DUE_TO_BREAKPOINT) # The filename of frame #0 should be 'main.cpp' and the line number # should be 93. diff --git a/lldb/test/hello_world/TestHelloWorld.py b/lldb/test/hello_world/TestHelloWorld.py index 9f08e00de0f8..bc6dddf8b693 100644 --- a/lldb/test/hello_world/TestHelloWorld.py +++ b/lldb/test/hello_world/TestHelloWorld.py @@ -69,7 +69,7 @@ class HelloWorldTestCase(TestBase): self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) thread = self.process.GetThreadAtIndex(0) - self.assertTrue(thread.GetStopReason() == StopReasonEnum("Breakpoint"), + self.assertTrue(thread.GetStopReason() == lldb.eStopReasonBreakpoint, STOPPED_DUE_TO_BREAKPOINT) # The breakpoint should have a hit count of 1. diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index d361f47c78c7..a313be4b864e 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -164,106 +164,54 @@ def CMD_MSG(str, exe): else: return "'%s' compares successfully" % str -# -# Returns the enum from the input string. -# -def StateTypeEnum(string): - if string == "Invalid": - return 0 - elif string == "Unloaded": - return 1 - elif string == "Attaching": - return 2 - elif string == "Launching": - return 3 - elif string == "Stopped": - return 4 - elif string == "Running": - return 5 - elif string == "Stepping": - return 6 - elif string == "Crashed": - return 7 - elif string == "Detached": - return 8 - elif string == "Exited": - return 9 - elif string == "Suspended": - return 10 - else: - raise Exception("Unknown stateType string") - # # Returns the stateType string given an enum. # def StateTypeString(enum): - if enum == 0: + if enum == lldb.eStateInvalid: return "Invalid" - elif enum == 1: + elif enum == lldb.eStateUnloaded: return "Unloaded" - elif enum == 2: + elif enum == lldb.eStateAttaching: return "Attaching" - elif enum == 3: + elif enum == lldb.eStateLaunching: return "Launching" - elif enum == 4: + elif enum == lldb.eStateStopped: return "Stopped" - elif enum == 5: + elif enum == lldb.eStateRunning: return "Running" - elif enum == 6: + elif enum == lldb.eStateStepping: return "Stepping" - elif enum == 7: + elif enum == lldb.eStateCrashed: return "Crashed" - elif enum == 8: + elif enum == lldb.eStateDetached: return "Detached" - elif enum == 9: + elif enum == lldb.eStateExited: return "Exited" - elif enum == 10: + elif enum == lldb.eStateSuspended: return "Suspended" else: raise Exception("Unknown stopReason enum") -# -# Returns the enum from the input string. -# -def StopReasonEnum(string): - if string == "Invalid": - return 0 - elif string == "None": - return 1 - elif string == "Trace": - return 2 - elif string == "Breakpoint": - return 3 - elif string == "Watchpoint": - return 4 - elif string == "Signal": - return 5 - elif string == "Exception": - return 6 - elif string == "PlanComplete": - return 7 - else: - raise Exception("Unknown stopReason string") - # # Returns the stopReason string given an enum. # def StopReasonString(enum): - if enum == 0: + if enum == lldb.eStopReasonInvalid: return "Invalid" - elif enum == 1: + elif enum == lldb.eStopReasonNone: return "None" - elif enum == 2: + elif enum == lldb.eStopReasonTrace: return "Trace" - elif enum == 3: + elif enum == lldb.eStopReasonBreakpoint: return "Breakpoint" - elif enum == 4: + elif enum == lldb.eStopReasonWatchpoint: return "Watchpoint" - elif enum == 5: + elif enum == lldb.eStopReasonSignal: return "Signal" - elif enum == 6: + elif enum == lldb.eStopReasonException: return "Exception" - elif enum == 7: + elif enum == lldb.eStopReasonPlanComplete: return "PlanComplete" else: raise Exception("Unknown stopReason enum")