Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / tools / lldb-server / TestGdbRemoteSaveCore.py
bloba7ce8890685da02bae0c9d67b24f064e5c74be85
1 import gdbremote_testcase
2 from lldbsuite.test.decorators import *
3 from lldbsuite.test.lldbtest import *
4 from lldbsuite.test import lldbutil
6 import binascii
7 import os
10 class TestGdbSaveCore(gdbremote_testcase.GdbRemoteTestCaseBase):
11 def coredump_test(self, core_path=None, expect_path=None):
12 self.build()
13 self.set_inferior_startup_attach()
14 procs = self.prep_debug_monitor_and_inferior()
15 self.add_qSupported_packets()
16 ret = self.expect_gdbremote_sequence()
17 if "qSaveCore+" not in ret["qSupported_response"]:
18 self.skipTest("qSaveCore not supported by lldb-server")
19 self.reset_test_sequence()
21 packet = "$qSaveCore"
22 if core_path is not None:
23 packet += ";path-hint:{}".format(
24 binascii.b2a_hex(core_path.encode()).decode()
27 self.test_sequence.add_log_lines(
29 "read packet: {}#00".format(packet),
31 "direction": "send",
32 "regex": "[$]core-path:([0-9a-f]+)#.*",
33 "capture": {1: "path"},
36 True,
38 ret = self.expect_gdbremote_sequence()
39 out_path = binascii.a2b_hex(ret["path"].encode()).decode()
40 if expect_path is not None:
41 self.assertEqual(out_path, expect_path)
43 target = self.dbg.CreateTarget(None)
44 process = target.LoadCore(out_path)
45 self.assertTrue(process, PROCESS_IS_VALID)
46 self.assertEqual(process.GetProcessID(), procs["inferior"].pid)
48 @skipUnlessPlatform(oslist=["freebsd", "netbsd"])
49 def test_netbsd_path(self):
50 core = lldbutil.append_to_process_working_directory(self, "core")
51 self.coredump_test(core, core)
53 @skipUnlessPlatform(oslist=["freebsd", "netbsd"])
54 def test_netbsd_no_path(self):
55 self.coredump_test()
57 @skipUnlessPlatform(oslist=["freebsd", "netbsd"])
58 def test_netbsd_bad_path(self):
59 self.coredump_test("/dev/null/cantwritehere")