1 """Test for the JITLoaderGDB interface"""
7 from lldbsuite
.test
import lldbutil
8 from lldbsuite
.test
.decorators
import *
9 from lldbsuite
.test
.lldbtest
import *
12 class JITLoaderGDBTestCase(TestBase
):
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"""
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
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())
42 if os
.path
.exists(logfile
):
45 self
.addTearDownHook(cleanup
)
48 def test_jit_int_default(self
):
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'"""
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")
65 self
.runCmd("log disable lldb")
66 self
.runCmd("settings set plugin.jit-loader.gdb.enable default")
68 self
.addTearDownHook(cleanup
)
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'"""
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")
94 self
.runCmd("log disable lldb")
95 self
.runCmd("settings set plugin.jit-loader.gdb.enable default")
97 self
.addTearDownHook(cleanup
)
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
)