[ORC] Fail materialization in tasks that are destroyed before running.
[llvm-project.git] / lldb / test / API / functionalities / jitloader_gdb / TestJITLoaderGDB.py
blob98c0b149003df63c13bb3eade14d385b3202cad8
1 """Test for the JITLoaderGDB interface"""
4 import unittest
5 import os
6 import lldb
7 from lldbsuite.test import lldbutil
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
12 class JITLoaderGDBTestCase(TestBase):
13 @skipTestIfFn(
14 lambda: "Skipped because the test crashes the test runner",
15 bugnumber="llvm.org/pr24702",
17 @unittest.expectedFailure # llvm.org/pr24702
18 def test_bogus_values(self):
19 """Test that we handle inferior misusing the GDB JIT interface"""
20 self.build()
21 exe = self.getBuildArtifact("a.out")
23 # Create a target by the debugger.
24 target = self.dbg.CreateTarget(exe)
25 self.assertTrue(target, VALID_TARGET)
27 # Launch the process, do not stop at entry point.
28 process = target.LaunchSimple(None, None, self.get_process_working_directory())
29 self.assertTrue(process, PROCESS_IS_VALID)
31 # The inferior will now pass bogus values over the interface. Make sure
32 # we don't crash.
33 self.assertState(process.GetState(), lldb.eStateExited)
34 self.assertEqual(process.GetExitStatus(), 0)
36 def gen_log_file(self):
37 logfile = self.getBuildArtifact(
38 "jitintgdb-{}.txt".format(self.getArchitecture())
41 def cleanup():
42 if os.path.exists(logfile):
43 os.unlink(logfile)
45 self.addTearDownHook(cleanup)
46 return logfile
48 def test_jit_int_default(self):
49 self.expect(
50 "settings show plugin.jit-loader.gdb.enable",
51 substrs=["plugin.jit-loader.gdb.enable (enum) = default"],
54 @skipIfWindows # This test fails on Windows during C code build
55 def test_jit_int_on(self):
56 """Tests interface with 'enable' settings 'on'"""
57 self.build()
58 exe = self.getBuildArtifact("simple")
60 logfile = self.gen_log_file()
61 self.runCmd("log enable -f %s lldb jit" % (logfile))
62 self.runCmd("settings set plugin.jit-loader.gdb.enable on")
64 def cleanup():
65 self.runCmd("log disable lldb")
66 self.runCmd("settings set plugin.jit-loader.gdb.enable default")
68 self.addTearDownHook(cleanup)
70 # Launch the process.
71 target = self.dbg.CreateTarget(exe)
72 self.assertTrue(target, VALID_TARGET)
73 process = target.LaunchSimple(None, None, self.get_process_working_directory())
74 self.assertTrue(process, PROCESS_IS_VALID)
76 self.assertState(process.GetState(), lldb.eStateExited)
77 self.assertEqual(process.GetExitStatus(), 0)
79 self.assertTrue(os.path.exists(logfile))
80 logcontent = open(logfile).read()
81 self.assertIn("SetJITBreakpoint setting JIT breakpoint", logcontent)
83 @skipIfWindows # This test fails on Windows during C code build
84 def test_jit_int_off(self):
85 """Tests interface with 'enable' settings 'off'"""
86 self.build()
87 exe = self.getBuildArtifact("simple")
89 logfile = self.gen_log_file()
90 self.runCmd("log enable -f %s lldb jit" % (logfile))
91 self.runCmd("settings set plugin.jit-loader.gdb.enable off")
93 def cleanup():
94 self.runCmd("log disable lldb")
95 self.runCmd("settings set plugin.jit-loader.gdb.enable default")
97 self.addTearDownHook(cleanup)
99 # Launch the process.
100 target = self.dbg.CreateTarget(exe)
101 self.assertTrue(target, VALID_TARGET)
102 process = target.LaunchSimple(None, None, self.get_process_working_directory())
103 self.assertTrue(process, PROCESS_IS_VALID)
105 self.assertState(process.GetState(), lldb.eStateExited)
106 self.assertEqual(process.GetExitStatus(), 0)
108 self.assertTrue(os.path.exists(logfile))
109 logcontent = open(logfile).read()
110 self.assertNotIn("SetJITBreakpoint setting JIT breakpoint", logcontent)