• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2
3import gdbremote_testcase
4import textwrap
5from lldbsuite.test.decorators import *
6from lldbsuite.test.lldbtest import *
7from lldbsuite.test import lldbutil
8import re
9import xml.etree.ElementTree as ET
10
11class TestGdbRemoteTargetXmlPacket(gdbremote_testcase.GdbRemoteTestCaseBase):
12
13    mydir = TestBase.compute_mydir(__file__)
14
15    @expectedFailureNetBSD
16    @llgs_test
17    def test_g_target_xml_returns_correct_data(self):
18        self.init_llgs_test()
19        self.build()
20        self.set_inferior_startup_launch()
21
22        procs = self.prep_debug_monitor_and_inferior()
23
24        OFFSET = 0
25        LENGTH = 0x1ffff0
26        self.test_sequence.add_log_lines([
27            "read packet: $qXfer:features:read:target.xml:{:x},{:x}#00".format(
28                    OFFSET,
29                    LENGTH),
30            {
31                "direction": "send",
32                "regex": re.compile("^\$l(.+)#[0-9a-fA-F]{2}$"),
33                "capture": {1: "target_xml"}
34            }],
35            True)
36        context = self.expect_gdbremote_sequence()
37
38        target_xml = context.get("target_xml")
39
40        root = ET.fromstring(target_xml)
41        self.assertIsNotNone(root)
42        self.assertEqual(root.tag, "target")
43
44        architecture = root.find("architecture")
45        self.assertIsNotNone(architecture)
46        self.assertIn(self.getArchitecture(), architecture.text)
47
48        feature = root.find("feature")
49        self.assertIsNotNone(feature)
50
51        target_xml_registers = feature.findall("reg")
52        self.assertTrue(len(target_xml_registers) > 0)
53
54        # registers info collected by qRegisterInfo
55        self.add_register_info_collection_packets()
56        context = self.expect_gdbremote_sequence()
57        self.assertIsNotNone(context)
58        q_info_registers = self.parse_register_info_packets(context)
59
60        self.assertTrue(len(target_xml_registers) == len(q_info_registers))
61        for register in zip(target_xml_registers, q_info_registers):
62            xml_info_reg = register[0]
63            q_info_reg = register[1]
64            self.assertEqual(q_info_reg["name"], xml_info_reg.get("name"))
65            self.assertEqual(q_info_reg["set"], xml_info_reg.get("group"))
66            self.assertEqual(q_info_reg["format"], xml_info_reg.get("format"))
67            self.assertEqual(q_info_reg["bitsize"], xml_info_reg.get("bitsize"))
68
69            if not self.getArchitecture() == 'aarch64':
70                self.assertEqual(q_info_reg["offset"], xml_info_reg.get("offset"))
71
72            self.assertEqual(q_info_reg["encoding"], xml_info_reg.get("encoding"))
73