2 Test utility functions for the frame object.
5 from __future__ import print_function
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
15 class FrameUtilsTestCase(TestBase):
17 mydir = TestBase.compute_mydir(__file__)
20 # Call super's setUp().
22 # Find the line number to break inside main().
23 self.line = line_number('main.c',
24 "// Find the line number here.")
26 @add_test_categories(['pyapi'])
27 def test_frame_utils(self):
28 """Test utility functions for the frame object."""
30 exe = os.path.join(os.getcwd(), "a.out")
32 target = self.dbg.CreateTarget(exe)
33 self.assertTrue(target, VALID_TARGET)
35 breakpoint = target.BreakpointCreateByLocation("main.c", self.line)
36 self.assertTrue(breakpoint, VALID_BREAKPOINT)
38 # Now launch the process, and do not stop at entry point.
39 process = target.LaunchSimple (None, None, self.get_process_working_directory())
42 self.fail("SBTarget.LaunchProcess() failed")
43 self.assertTrue(process.GetState() == lldb.eStateStopped,
46 import lldbsuite.test.lldbutil as lldbutil
47 thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
48 self.assertTrue (thread)
49 frame0 = thread.GetFrameAtIndex(0)
50 self.assertTrue (frame0)
51 frame1 = thread.GetFrameAtIndex(1)
52 self.assertTrue (frame1)
53 parent = lldbutil.get_parent_frame(frame0)
54 self.assertTrue(parent and parent.GetFrameID() == frame1.GetFrameID())
55 frame0_args = lldbutil.get_args_as_string(frame0)
56 parent_args = lldbutil.get_args_as_string(parent)
57 self.assertTrue(frame0_args and parent_args and "(int)val=1" in frame0_args)
59 lldbutil.print_stacktrace(thread)
60 print("Current frame: %s" % frame0_args)
61 print("Parent frame: %s" % parent_args)