Skip to content

Commit 4d9beed

Browse files
author
yangao1
committed
nuttxgdb/rpmsg.py:dump rpmsg_service message
(gdb)rpmsg_service g_rpmsg_cb: rpmsg_cb_s at ns_match ns_bind ------------- -------- ------- 0xf4e00ac0 0x44708225 <rpmsg_rtc_server_ns_match> 0x4470874c <rpmsg_rtc_server_ns_bind> 0xf4e27b20 0x440c8fd6 <syslog_rpmsg_ns_match> 0x440c966a <syslog_rpmsg_ns_bind> 0xf4e27af0 0x0 0x0 g_rpmsg: Endpoint at Name local Addr dest Addr cb ns_bound_cb ns_unbind_cb ----------- ---- ---------- --------- -- ----------- ------------ 0xf2302ac0 NS 53 53 0x44699520 <rpmsg_virtio_ns_callback> 0x0 0x0 0xf3c0f920 rpmsg-ttysensor 1025 1028 0x44704457 <uart_rpmsg_ept_cb> 0x0 0x0 0xf301d058 rpmsg-sensor 1026 1029 0x440c1680 <sensor_rpmsg_ept_cb> 0x440c1871 <sensor_rpmsg_device_ns_bound> 0x44693a18 <rpmsg_destroy_ept> 0xf2302a6c rpmsg-ping 1027 1036 0x440a10d2 <rpmsg_ping_ept_cb> 0x0 0x0 List update: rpmsg dump contains none initialized list, need to take care of it in NxList. Signed-off-by: yangao1 <[email protected]>
1 parent a2fcd98 commit 4d9beed

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

tools/gdb/nuttxgdb/rpmsg.py

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
############################################################################
2+
# tools/gdb/rpmsg.py
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership. The
7+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance with the
9+
# License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
############################################################################
20+
21+
import gdb
22+
23+
from . import utils
24+
from .lists import NxList
25+
26+
27+
class RPMsgDump(gdb.Command):
28+
"""Dump rpmsg service"""
29+
30+
CALLBACK_HEADER = ["rpmsg_cb_s at", "ns_match", "ns_bind"]
31+
ENDPOINT_HEADER = [
32+
"endpoint_addr",
33+
"name",
34+
"addr",
35+
"dest_addr",
36+
"cb",
37+
"ns_bound_cb",
38+
"ns_unbind_cb",
39+
]
40+
41+
CALLBACK_FORAMTTER = "{:<20} {:<40} {:<40}"
42+
ENDPOINT_FORMATTER = "{:<20} {:<20} {:<12} {:<12} {:<40} {:<40} {:<40}"
43+
44+
def __init__(self):
45+
if utils.get_symbol_value("CONFIG_RPMSG"):
46+
super(RPMsgDump, self).__init__("rpmsgdump", gdb.COMMAND_USER)
47+
48+
def print_headers(self, headers, formatter):
49+
gdb.write(formatter.format(*headers) + "\n")
50+
gdb.write(formatter.format(*["-" * len(header) for header in headers]) + "\n")
51+
52+
def dump_rdev_epts(self, endpoints_head):
53+
gdb.write(f"dump_rdev_epts:{endpoints_head}\n")
54+
self.print_headers(self.ENDPOINT_HEADER, self.ENDPOINT_FORMATTER)
55+
56+
output = []
57+
for endpoint in NxList(endpoints_head, "struct rpmsg_endpoint", "node"):
58+
output.append(
59+
self.ENDPOINT_FORMATTER.format(
60+
f"{endpoint}",
61+
f"{endpoint['name'].string()}",
62+
f"{endpoint['addr']}",
63+
f"{endpoint['dest_addr']}",
64+
f"{endpoint['cb']}",
65+
f"{endpoint['ns_bound_cb']}",
66+
f"{endpoint['ns_unbind_cb']}",
67+
)
68+
)
69+
70+
gdb.write("\n".join(output) + "\n")
71+
72+
def dump_rdev_bitmap(self, rdev):
73+
bitmap_values = [hex(bit) for bit in utils.ArrayIterator(rdev["bitmap"])]
74+
75+
gdb.write(
76+
f"bitmap:{' '.join(bitmap_values):<20} bitmaplast: {rdev['bitmap']}\n"
77+
)
78+
79+
def dump_rdev(self, rdev):
80+
gdb.write(f"device:{rdev}\n")
81+
82+
self.dump_rdev_bitmap(rdev)
83+
self.dump_rdev_epts(rdev["endpoints"])
84+
85+
def dump_rpmsg_cb(self):
86+
gdb.write("g_rpmsg_cb:\n")
87+
self.print_headers(self.CALLBACK_HEADER, self.CALLBACK_FORAMTTER)
88+
89+
output = []
90+
for cb in NxList(gdb.parse_and_eval("g_rpmsg_cb"), "struct rpmsg_cb_s", "node"):
91+
output.append(
92+
self.CALLBACK_FORAMTTER.format(
93+
str(cb), str(cb["ns_match"]), str(cb["ns_bind"])
94+
)
95+
)
96+
gdb.write("\n".join(output) + "\n")
97+
98+
def dump_rpmsg(self):
99+
gdb.write("g_rpmsg:\n")
100+
for rpmsg in NxList(gdb.parse_and_eval("g_rpmsg"), "struct rpmsg_s", "node"):
101+
self.dump_rdev(rpmsg["rdev"])
102+
103+
def invoke(self, args, from_tty):
104+
self.dump_rpmsg_cb()
105+
self.dump_rpmsg()

0 commit comments

Comments
 (0)