This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 5ec2c9742460af9ac4ba051739bc83c683b3c010
Author: Zhe Weng <weng...@xiaomi.com>
AuthorDate: Fri Aug 23 14:20:28 2024 +0800

    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 <weng...@xiaomi.com>
---
 tools/gdb/net.py | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/tools/gdb/net.py b/tools/gdb/net.py
index a80a311b70..c07190a1ef 100644
--- a/tools/gdb/net.py
+++ b/tools/gdb/net.py
@@ -103,7 +103,14 @@ def tcp_ofoseg_bufsize(conn):
 
 
 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):
         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)
 
     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()
             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()
             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()
             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()
             gdb.write("\n")
 

Reply via email to