|
| 1 | +import binascii |
| 2 | +import itertools |
| 3 | +import struct |
| 4 | + |
| 5 | +import gdbremote_testcase |
| 6 | +import lldbgdbserverutils |
| 7 | +from lldbsuite.support import seven |
| 8 | +from lldbsuite.test.decorators import * |
| 9 | +from lldbsuite.test.lldbtest import * |
| 10 | +from lldbsuite.test.lldbdwarf import * |
| 11 | +from lldbsuite.test import lldbutil, lldbplatformutil |
| 12 | + |
| 13 | + |
| 14 | +class TestGdbRemote_qSupported( |
| 15 | + gdbremote_testcase.GdbRemoteTestCaseBase |
| 16 | +): |
| 17 | + def get_qSupported_dict(self, features=[]): |
| 18 | + self.build() |
| 19 | + self.set_inferior_startup_launch() |
| 20 | + |
| 21 | + # Start up the stub and start/prep the inferior. |
| 22 | + procs = self.prep_debug_monitor_and_inferior() |
| 23 | + self.add_qSupported_packets(features) |
| 24 | + |
| 25 | + # Run the packet stream. |
| 26 | + context = self.expect_gdbremote_sequence() |
| 27 | + self.assertIsNotNone(context) |
| 28 | + |
| 29 | + # Retrieve the qSupported features. |
| 30 | + return self.parse_qSupported_response(context) |
| 31 | + |
| 32 | + def test_qSupported_returns_known_stub_features(self): |
| 33 | + supported_dict = self.get_qSupported_dict() |
| 34 | + self.assertIsNotNone(supported_dict) |
| 35 | + self.assertGreater(len(supported_dict), 0) |
| 36 | + |
| 37 | + def test_qSupported_auvx(self): |
| 38 | + expected = ( |
| 39 | + "+" |
| 40 | + if lldbplatformutil.getPlatform() in ["freebsd", "linux", "netbsd"] |
| 41 | + else "-" |
| 42 | + ) |
| 43 | + supported_dict = self.get_qSupported_dict() |
| 44 | + self.assertEqual(supported_dict.get("qXfer:auxv:read", "-"), expected) |
| 45 | + |
| 46 | + def test_qSupported_libraries_svr4(self): |
| 47 | + expected = ( |
| 48 | + "+" |
| 49 | + if lldbplatformutil.getPlatform() in ["freebsd", "linux", "netbsd"] |
| 50 | + else "-" |
| 51 | + ) |
| 52 | + supported_dict = self.get_qSupported_dict() |
| 53 | + self.assertEqual(supported_dict.get("qXfer:libraries-svr4:read", "-"), expected) |
| 54 | + |
| 55 | + def test_qSupported_siginfo_read(self): |
| 56 | + expected = ( |
| 57 | + "+" if lldbplatformutil.getPlatform() in ["freebsd", "linux"] else "-" |
| 58 | + ) |
| 59 | + supported_dict = self.get_qSupported_dict() |
| 60 | + self.assertEqual(supported_dict.get("qXfer:siginfo:read", "-"), expected) |
| 61 | + |
| 62 | + def test_qSupported_QPassSignals(self): |
| 63 | + expected = ( |
| 64 | + "+" |
| 65 | + if lldbplatformutil.getPlatform() in ["freebsd", "linux", "netbsd"] |
| 66 | + else "-" |
| 67 | + ) |
| 68 | + supported_dict = self.get_qSupported_dict() |
| 69 | + self.assertEqual(supported_dict.get("QPassSignals", "-"), expected) |
| 70 | + |
| 71 | + @add_test_categories(["fork"]) |
| 72 | + def test_qSupported_fork_events(self): |
| 73 | + supported_dict = self.get_qSupported_dict(["multiprocess+", "fork-events+"]) |
| 74 | + self.assertEqual(supported_dict.get("multiprocess", "-"), "+") |
| 75 | + self.assertEqual(supported_dict.get("fork-events", "-"), "+") |
| 76 | + self.assertEqual(supported_dict.get("vfork-events", "-"), "-") |
| 77 | + |
| 78 | + @add_test_categories(["fork"]) |
| 79 | + def test_qSupported_fork_events_without_multiprocess(self): |
| 80 | + supported_dict = self.get_qSupported_dict(["fork-events+"]) |
| 81 | + self.assertEqual(supported_dict.get("multiprocess", "-"), "-") |
| 82 | + self.assertEqual(supported_dict.get("fork-events", "-"), "-") |
| 83 | + self.assertEqual(supported_dict.get("vfork-events", "-"), "-") |
| 84 | + |
| 85 | + @add_test_categories(["fork"]) |
| 86 | + def test_qSupported_vfork_events(self): |
| 87 | + supported_dict = self.get_qSupported_dict(["multiprocess+", "vfork-events+"]) |
| 88 | + self.assertEqual(supported_dict.get("multiprocess", "-"), "+") |
| 89 | + self.assertEqual(supported_dict.get("fork-events", "-"), "-") |
| 90 | + self.assertEqual(supported_dict.get("vfork-events", "-"), "+") |
| 91 | + |
| 92 | + @add_test_categories(["fork"]) |
| 93 | + def test_qSupported_vfork_events_without_multiprocess(self): |
| 94 | + supported_dict = self.get_qSupported_dict(["vfork-events+"]) |
| 95 | + self.assertEqual(supported_dict.get("multiprocess", "-"), "-") |
| 96 | + self.assertEqual(supported_dict.get("fork-events", "-"), "-") |
| 97 | + self.assertEqual(supported_dict.get("vfork-events", "-"), "-") |
| 98 | + |
| 99 | + # We need to be able to self.runCmd to get cpuinfo, |
| 100 | + # which is not possible when using a remote platform. |
| 101 | + @skipIfRemote |
| 102 | + def test_qSupported_memory_tagging(self): |
| 103 | + supported_dict = self.get_qSupported_dict() |
| 104 | + self.assertEqual( |
| 105 | + supported_dict.get("memory-tagging", "-"), |
| 106 | + "+" if self.isAArch64MTE() else "-", |
| 107 | + ) |
0 commit comments