brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · a7ce889 Raw
60 lines · python
1import gdbremote_testcase2from lldbsuite.test.decorators import *3from lldbsuite.test.lldbtest import *4from lldbsuite.test import lldbutil5 6import binascii7import os8 9 10class 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()20 21        packet = "$qSaveCore"22        if core_path is not None:23            packet += ";path-hint:{}".format(24                binascii.b2a_hex(core_path.encode()).decode()25            )26 27        self.test_sequence.add_log_lines(28            [29                "read packet: {}#00".format(packet),30                {31                    "direction": "send",32                    "regex": "[$]core-path:([0-9a-f]+)#.*",33                    "capture": {1: "path"},34                },35            ],36            True,37        )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)42 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)47 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)52 53    @skipUnlessPlatform(oslist=["freebsd", "netbsd"])54    def test_netbsd_no_path(self):55        self.coredump_test()56 57    @skipUnlessPlatform(oslist=["freebsd", "netbsd"])58    def test_netbsd_bad_path(self):59        self.coredump_test("/dev/null/cantwritehere")60