62925c6f94fd7c7e2d99513dbd3856baada9d5f3
[openbsd] /
1 """
2 Test that LLDB can emit JIT objects when the appropriate setting is enabled
3 """
4
5
6 import os
7 import lldb
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
11
12 class SaveJITObjectsTestCase(TestBase):
13     mydir = TestBase.compute_mydir(__file__)
14
15     def enumerateJITFiles(self):
16         return [f for f in os.listdir(self.getBuildDir()) if f.startswith("jit")]
17
18     def countJITFiles(self):
19         return len(self.enumerateJITFiles())
20
21     def cleanJITFiles(self):
22         for j in self.enumerateJITFiles():
23             os.remove(j)
24         return
25
26     @expectedFailureAll(oslist=["windows"])
27     @expectedFailureNetBSD
28     def test_save_jit_objects(self):
29         self.build()
30         os.chdir(self.getBuildDir())
31         src_file = "main.c"
32         src_file_spec = lldb.SBFileSpec(src_file)
33
34         (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
35             self, "break", src_file_spec)
36
37         frame = thread.frames[0]
38
39         self.cleanJITFiles()
40         frame.EvaluateExpression("(void*)malloc(0x1)")
41         self.assertTrue(self.countJITFiles() == 0,
42                         "No files emitted with save-jit-objects=false")
43
44         self.runCmd("settings set target.save-jit-objects true")
45         frame.EvaluateExpression("(void*)malloc(0x1)")
46         jit_files_count = self.countJITFiles()
47         self.cleanJITFiles()
48         self.assertTrue(jit_files_count != 0,
49                         "At least one file emitted with save-jit-objects=true")
50
51         process.Kill()
52         os.chdir(self.getSourceDir())