forked from nuttx/nuttx-update
tools/gdb: Supports args and help for netstats
(gdb) help netstats Network statistics Usage: netstats [iob|pkt|tcp|udp|all] Examples: netstats - Show all stats netstats all - Show all stats netstats iob - Show IOB stats netstats tcp udp - Show both TCP and UDP stats (gdb) netstats iob pkt IOB: size ntotal nfree nwait nthrottle 1518 72 72 0 40 Packets: IPv4 IPv6 TCP UDP ICMP ICMPv6 Received 12 20 2 10 0 0 Dropped 0 20 0 0 0 0 VHL 0 0 - - - - Frag 0 0 - - - - Chksum 0 - 0 0 - - Type - - - - 0 0 Proto 0 0 - - - - Sent 4 0 4 0 0 0 Rexmit - - 2 - - - Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
parent
d0884828ed
commit
5ec2c97424
1 changed files with 17 additions and 5 deletions
|
@ -103,7 +103,14 @@ def tcp_ofoseg_bufsize(conn):
|
||||||
|
|
||||||
|
|
||||||
class NetStats(gdb.Command):
|
class NetStats(gdb.Command):
|
||||||
"""Network statistics"""
|
"""Network statistics
|
||||||
|
Usage: netstats [iob|pkt|tcp|udp|all]
|
||||||
|
|
||||||
|
Examples: netstats - Show all stats
|
||||||
|
netstats all - Show all stats
|
||||||
|
netstats iob - Show IOB stats
|
||||||
|
netstats tcp udp - Show both TCP and UDP stats
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(NetStats, self).__init__("netstats", gdb.COMMAND_USER)
|
super(NetStats, self).__init__("netstats", gdb.COMMAND_USER)
|
||||||
|
@ -223,16 +230,21 @@ class NetStats(gdb.Command):
|
||||||
gdb.write("Failed to get UDP stats: %s\n" % e)
|
gdb.write("Failed to get UDP stats: %s\n" % e)
|
||||||
|
|
||||||
def invoke(self, args, from_tty):
|
def invoke(self, args, from_tty):
|
||||||
if utils.get_symbol_value("CONFIG_MM_IOB"):
|
# Parse the arguments in a simple way
|
||||||
|
if not args or "all" in args:
|
||||||
|
args = "iob pkt tcp udp"
|
||||||
|
|
||||||
|
# Call the corresponding function
|
||||||
|
if utils.get_symbol_value("CONFIG_MM_IOB") and "iob" in args:
|
||||||
self.iob_stats()
|
self.iob_stats()
|
||||||
gdb.write("\n")
|
gdb.write("\n")
|
||||||
if utils.get_symbol_value("CONFIG_NET_STATISTICS"):
|
if utils.get_symbol_value("CONFIG_NET_STATISTICS") and "pkt" in args:
|
||||||
self.pkt_stats()
|
self.pkt_stats()
|
||||||
gdb.write("\n")
|
gdb.write("\n")
|
||||||
if utils.get_symbol_value("CONFIG_NET_TCP"):
|
if utils.get_symbol_value("CONFIG_NET_TCP") and "tcp" in args:
|
||||||
self.tcp_stats()
|
self.tcp_stats()
|
||||||
gdb.write("\n")
|
gdb.write("\n")
|
||||||
if utils.get_symbol_value("CONFIG_NET_UDP"):
|
if utils.get_symbol_value("CONFIG_NET_UDP") and "udp" in args:
|
||||||
self.udp_stats()
|
self.udp_stats()
|
||||||
gdb.write("\n")
|
gdb.write("\n")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue