2 Test utility functions for the frame object.
5 from __future__ import print_function
10 from lldbsuite.test.decorators import *
11 from lldbsuite.test.lldbtest import *
12 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 = self.getBuildArtifact("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(
40 None, None, self.get_process_working_directory())
43 self.fail("SBTarget.LaunchProcess() failed")
44 self.assertTrue(process.GetState() == lldb.eStateStopped,
47 import lldbsuite.test.lldbutil as lldbutil
48 thread = lldbutil.get_stopped_thread(
49 process, lldb.eStopReasonBreakpoint)
50 self.assertTrue(thread)
51 frame0 = thread.GetFrameAtIndex(0)
52 self.assertTrue(frame0)
53 frame1 = thread.GetFrameAtIndex(1)
54 self.assertTrue(frame1)
55 parent = lldbutil.get_parent_frame(frame0)
56 self.assertTrue(parent and parent.GetFrameID() == frame1.GetFrameID())
57 frame0_args = lldbutil.get_args_as_string(frame0)
58 parent_args = lldbutil.get_args_as_string(parent)
60 frame0_args and parent_args and "(int)val=1" in frame0_args)
62 lldbutil.print_stacktrace(thread)
63 print("Current frame: %s" % frame0_args)
64 print("Parent frame: %s" % parent_args)