2 Test that LLDB can emit JIT objects when the appropriate setting is enabled
5 from __future__ import print_function
10 from lldbsuite.test.decorators import *
11 from lldbsuite.test.lldbtest import *
12 from lldbsuite.test import lldbutil
14 def enumerateJITFiles():
15 return [f for f in os.listdir(os.getcwd()) if f.startswith("jit")]
18 return len(enumerateJITFiles())
21 for j in enumerateJITFiles():
25 class SaveJITObjectsTestCase(TestBase):
26 mydir = TestBase.compute_mydir(__file__)
28 @expectedFailureAll(oslist=["windows"])
29 def test_save_jit_objects(self):
32 src_file_spec = lldb.SBFileSpec(src_file)
34 exe_path = os.path.join(os.getcwd(), "a.out")
35 target = self.dbg.CreateTarget(exe_path)
37 breakpoint = target.BreakpointCreateBySourceRegex(
38 "break", src_file_spec)
40 process = target.LaunchSimple(None, None,
41 self.get_process_working_directory())
43 thread = process.GetSelectedThread()
44 frame = thread.GetSelectedFrame()
47 frame.EvaluateExpression("(void*)malloc(0x1)")
48 self.assertTrue(countJITFiles() == 0,
49 "No files emitted with save-jit-objects=false")
51 self.runCmd("settings set target.save-jit-objects true")
52 frame.EvaluateExpression("(void*)malloc(0x1)")
53 jit_files_count = countJITFiles()
55 self.assertTrue(jit_files_count != 0,
56 "At least one file emitted with save-jit-objects=true")