diff options
-rw-r--r-- | lldb/include/lldb/API/SBFrame.h | 3 | ||||
-rw-r--r-- | lldb/scripts/Python/interface/SBFrame.i | 3 | ||||
-rw-r--r-- | lldb/source/API/SBFrame.cpp | 12 | ||||
-rw-r--r-- | lldb/test/python_api/frame/TestFrames.py | 62 |
4 files changed, 78 insertions, 2 deletions
diff --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h index 4501f774e97..e1b93ddc3e6 100644 --- a/lldb/include/lldb/API/SBFrame.h +++ b/lldb/include/lldb/API/SBFrame.h @@ -30,6 +30,9 @@ public: ~SBFrame(); bool + IsEqual (const lldb::SBFrame &that) const; + + bool IsValid() const; uint32_t diff --git a/lldb/scripts/Python/interface/SBFrame.i b/lldb/scripts/Python/interface/SBFrame.i index c718073506c..4bedbff8cce 100644 --- a/lldb/scripts/Python/interface/SBFrame.i +++ b/lldb/scripts/Python/interface/SBFrame.i @@ -55,6 +55,9 @@ public: ~SBFrame(); bool + IsEqual (const lldb::SBFrame &rhs) const; + + bool IsValid() const; uint32_t diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index 8931e70581c..9f4709fac9e 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -718,15 +718,23 @@ SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueTy } bool +SBFrame::IsEqual (const SBFrame &that) const +{ + lldb::StackFrameSP this_sp = GetFrameSP(); + lldb::StackFrameSP that_sp = that.GetFrameSP(); + return (this_sp && that_sp && this_sp->GetStackID() == that_sp->GetStackID()); +} + +bool SBFrame::operator == (const SBFrame &rhs) const { - return GetFrameSP().get() == rhs.GetFrameSP().get(); + return IsEqual(rhs); } bool SBFrame::operator != (const SBFrame &rhs) const { - return GetFrameSP().get() != rhs.GetFrameSP().get(); + return !IsEqual(rhs); } SBThread diff --git a/lldb/test/python_api/frame/TestFrames.py b/lldb/test/python_api/frame/TestFrames.py index dbb3119802c..554755ff18e 100644 --- a/lldb/test/python_api/frame/TestFrames.py +++ b/lldb/test/python_api/frame/TestFrames.py @@ -1,5 +1,6 @@ """ Use lldb Python SBFrame API to get the argument values of the call stacks. +And other SBFrame API tests. """ import os, time @@ -31,6 +32,12 @@ class FrameAPITestCase(TestBase): self.buildDefault() self.frame_api_boundary_condition() + @python_api_test + def test_frame_api_IsEqual(self): + """Exercise SBFrame API IsEqual.""" + self.buildDefault() + self.frame_api_IsEqual() + def do_get_arg_vals(self): """Get argument vals for the call stack when stopped on a breakpoint.""" exe = os.path.join(os.getcwd(), "a.out") @@ -152,6 +159,61 @@ class FrameAPITestCase(TestBase): frame.EvaluateExpression(None) + def frame_api_IsEqual(self): + """Exercise SBFrame API IsEqual.""" + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Now create a breakpoint on main.c by name 'c'. + breakpoint = target.BreakpointCreateByName('c', 'a.out') + #print "breakpoint:", breakpoint + self.assertTrue(breakpoint and + breakpoint.GetNumLocations() == 1, + VALID_BREAKPOINT) + + # Now launch the process, and do not stop at the entry point. + process = target.LaunchSimple(None, None, os.getcwd()) + + process = target.GetProcess() + self.assertTrue(process.GetState() == lldb.eStateStopped, + PROCESS_STOPPED) + + thread = process.GetThreadAtIndex(0) + self.assertTrue(thread) + + frameEntered = thread.GetFrameAtIndex(0) + if self.TraceOn(): + print frameEntered + lldbutil.print_stacktrace(thread) + self.assertTrue(frameEntered) + + # Doing two step overs while still inside c(). + thread.StepOver() + thread.StepOver() + self.assertTrue(thread) + frameNow = thread.GetFrameAtIndex(0) + if self.TraceOn(): + print frameNow + lldbutil.print_stacktrace(thread) + self.assertTrue(frameNow) + + # The latest two frames are considered equal. + self.assertTrue(frameEntered.IsEqual(frameNow)) + + # Now let's step out of frame c(). + thread.StepOutOfFrame(frameNow) + frameOutOfC = thread.GetFrameAtIndex(0) + if self.TraceOn(): + print frameOutOfC + lldbutil.print_stacktrace(thread) + self.assertTrue(frameOutOfC) + + # The latest two frames should not be equal. + self.assertFalse(frameEntered.IsEqual(frameNow)) + if __name__ == '__main__': import atexit |