]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/python_api/lldbutil/frame/TestFrameUtils.py
Vendor import of lldb release_39 branch r276489:
[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.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
14
15 class FrameUtilsTestCase(TestBase):
16
17     mydir = TestBase.compute_mydir(__file__)
18
19     def setUp(self):
20         # Call super's setUp().
21         TestBase.setUp(self)
22         # Find the line number to break inside main().
23         self.line = line_number('main.c',
24                                 "// Find the line number here.")
25
26     @add_test_categories(['pyapi'])
27     def test_frame_utils(self):
28         """Test utility functions for the frame object."""
29         self.build()
30         exe = os.path.join(os.getcwd(), "a.out")
31
32         target = self.dbg.CreateTarget(exe)
33         self.assertTrue(target, VALID_TARGET)
34
35         breakpoint = target.BreakpointCreateByLocation("main.c", self.line)
36         self.assertTrue(breakpoint, VALID_BREAKPOINT)
37
38         # Now launch the process, and do not stop at entry point.
39         process = target.LaunchSimple (None, None, self.get_process_working_directory())
40
41         if not process:
42             self.fail("SBTarget.LaunchProcess() failed")
43         self.assertTrue(process.GetState() == lldb.eStateStopped,
44                         PROCESS_STOPPED)
45
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)
58         if self.TraceOn():
59             lldbutil.print_stacktrace(thread)
60             print("Current frame: %s" % frame0_args)
61             print("Parent frame: %s" % parent_args)