1 import gdbremote_testcase
2 from lldbsuite
.test
.decorators
import *
3 from lldbsuite
.test
.lldbtest
import *
4 from lldbsuite
.test
import lldbutil
10 class TestGdbSaveCore(gdbremote_testcase
.GdbRemoteTestCaseBase
):
11 def coredump_test(self
, core_path
=None, expect_path
=None):
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()
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
),
32 "regex": "[$]core-path:([0-9a-f]+)#.*",
33 "capture": {1: "path"},
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
):
57 @skipUnlessPlatform(oslist
=["freebsd", "netbsd"])
58 def test_netbsd_bad_path(self
):
59 self
.coredump_test("/dev/null/cantwritehere")