]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/python_api/lldbutil/frame/TestFrameUtils.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / python_api / lldbutil / frame / TestFrameUtils.py
1 """
2 Test utility functions for the frame object.
3 """
4
5 from __future__ import print_function
6
7
8
9 import os
10 import lldb
11 from lldbsuite.test.lldbtest import *
12
13 class FrameUtilsTestCase(TestBase):
14
15     mydir = TestBase.compute_mydir(__file__)
16
17     def setUp(self):
18         # Call super's setUp().
19         TestBase.setUp(self)
20         # Find the line number to break inside main().
21         self.line = line_number('main.c',
22                                 "// Find the line number here.")
23
24     @add_test_categories(['pyapi'])
25     def test_frame_utils(self):
26         """Test utility functions for the frame object."""
27         self.build()
28         exe = os.path.join(os.getcwd(), "a.out")
29
30         target = self.dbg.CreateTarget(exe)
31         self.assertTrue(target, VALID_TARGET)
32
33         breakpoint = target.BreakpointCreateByLocation("main.c", self.line)
34         self.assertTrue(breakpoint, VALID_BREAKPOINT)
35
36         # Now launch the process, and do not stop at entry point.
37         process = target.LaunchSimple (None, None, self.get_process_working_directory())
38
39         if not process:
40             self.fail("SBTarget.LaunchProcess() failed")
41         self.assertTrue(process.GetState() == lldb.eStateStopped,
42                         PROCESS_STOPPED)
43
44         import lldbsuite.test.lldbutil as lldbutil
45         thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
46         self.assertTrue (thread)
47         frame0 = thread.GetFrameAtIndex(0)
48         self.assertTrue (frame0)
49         frame1 = thread.GetFrameAtIndex(1)
50         self.assertTrue (frame1)
51         parent = lldbutil.get_parent_frame(frame0)
52         self.assertTrue(parent and parent.GetFrameID() == frame1.GetFrameID())
53         frame0_args = lldbutil.get_args_as_string(frame0)
54         parent_args = lldbutil.get_args_as_string(parent)
55         self.assertTrue(frame0_args and parent_args and "(int)val=1" in frame0_args)
56         if self.TraceOn():
57             lldbutil.print_stacktrace(thread)
58             print("Current frame: %s" % frame0_args)
59             print("Parent frame: %s" % parent_args)