]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / expression_command / save_jit_objects / TestSaveJITObjects.py
1 """
2 Test that LLDB can emit JIT objects when the appropriate setting is enabled
3 """
4
5 from __future__ import print_function
6
7 import os
8 import time
9 import lldb
10 from lldbsuite.test.decorators import *
11 from lldbsuite.test.lldbtest import *
12 from lldbsuite.test import lldbutil
13
14 def enumerateJITFiles():
15     return [f for f in os.listdir(os.getcwd()) if f.startswith("jit")]
16     
17 def countJITFiles():
18     return len(enumerateJITFiles())
19
20 def cleanJITFiles():
21     for j in enumerateJITFiles():
22         os.remove(j)
23     return
24
25 class SaveJITObjectsTestCase(TestBase):
26     mydir = TestBase.compute_mydir(__file__)
27
28     @expectedFailureAll(oslist=["windows"])
29     def test_save_jit_objects(self):
30         self.build()
31         src_file = "main.c"
32         src_file_spec = lldb.SBFileSpec(src_file)
33   
34         exe_path = os.path.join(os.getcwd(), "a.out")
35         target = self.dbg.CreateTarget(exe_path)
36
37         breakpoint = target.BreakpointCreateBySourceRegex(
38             "break", src_file_spec)
39
40         process = target.LaunchSimple(None, None,
41                                       self.get_process_working_directory())
42
43         thread = process.GetSelectedThread()
44         frame = thread.GetSelectedFrame()
45
46         cleanJITFiles()
47         frame.EvaluateExpression("(void*)malloc(0x1)")
48         self.assertTrue(countJITFiles() == 0,
49                         "No files emitted with save-jit-objects=false")
50
51         self.runCmd("settings set target.save-jit-objects true")
52         frame.EvaluateExpression("(void*)malloc(0x1)")
53         jit_files_count = countJITFiles()
54         cleanJITFiles()
55         self.assertTrue(jit_files_count != 0,
56                         "At least one file emitted with save-jit-objects=true")
57
58         process.Kill()