diff options
| author | Michał Górny <mgorny@moritz.systems> | 2021-04-26 13:47:02 +0200 |
|---|---|---|
| committer | Michał Górny <mgorny@moritz.systems> | 2021-09-06 12:16:14 +0200 |
| commit | 37cbd817d3e2b8c673862e2eb262cad6dd3dd244 (patch) | |
| tree | 57262d6e7bbc9c8d89a3a88be8887c0b64fee23d /lldb/test/API/tools/lldb-server/TestGdbRemoteSaveCore.py | |
| parent | fae0dfa6421ea6c02f86ba7292fa782e1e2b69d1 (diff) | |
[lldb] [llgs server] Support creating core dumps on NetBSD
Add a new SaveCore() process method that can be used to request a core
dump. This is currently implemented on NetBSD via the PT_DUMPCORE
ptrace(2) request, and enabled via 'savecore' extension.
Protocol-wise, a new qSaveCore packet is introduced. It accepts zero
or more semicolon-separated key:value options, invokes the core dump
and returns a key:value response. Currently the only option supported
is "path-hint", and the return value contains the "path" actually used.
The support for the feature is exposed via qSaveCore qSupported feature.
Differential Revision: https://reviews.llvm.org/D101285
Diffstat (limited to 'lldb/test/API/tools/lldb-server/TestGdbRemoteSaveCore.py')
| -rw-r--r-- | lldb/test/API/tools/lldb-server/TestGdbRemoteSaveCore.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteSaveCore.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteSaveCore.py new file mode 100644 index 000000000000..405a73bcdba8 --- /dev/null +++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteSaveCore.py @@ -0,0 +1,52 @@ +import gdbremote_testcase +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +import binascii +import os + +class TestGdbSaveCore(gdbremote_testcase.GdbRemoteTestCaseBase): + mydir = TestBase.compute_mydir(__file__) + + def coredump_test(self, core_path=None, expect_path=None): + self.build() + self.set_inferior_startup_attach() + procs = self.prep_debug_monitor_and_inferior() + self.add_qSupported_packets() + ret = self.expect_gdbremote_sequence() + self.assertIn("qSaveCore+", ret["qSupported_response"]) + self.reset_test_sequence() + + packet = "$qSaveCore" + if core_path is not None: + packet += ";path-hint:{}".format( + binascii.b2a_hex(core_path.encode()).decode()) + + self.test_sequence.add_log_lines([ + "read packet: {}#00".format(packet), + {"direction": "send", "regex": "[$]core-path:([0-9a-f]+)#.*", + "capture": {1: "path"}}, + ], True) + ret = self.expect_gdbremote_sequence() + out_path = binascii.a2b_hex(ret["path"].encode()).decode() + if expect_path is not None: + self.assertEqual(out_path, expect_path) + + target = self.dbg.CreateTarget(None) + process = target.LoadCore(out_path) + self.assertTrue(process, PROCESS_IS_VALID) + self.assertEqual(process.GetProcessID(), procs["inferior"].pid) + + @skipUnlessPlatform(oslist=["netbsd"]) + def test_netbsd_path(self): + core = lldbutil.append_to_process_working_directory(self, "core") + self.coredump_test(core, core) + + @skipUnlessPlatform(oslist=["netbsd"]) + def test_netbsd_no_path(self): + self.coredump_test() + + @skipUnlessPlatform(oslist=["netbsd"]) + def test_netbsd_bad_path(self): + self.coredump_test("/dev/null/cantwritehere") |
