summaryrefslogtreecommitdiff
path: root/utilities
diff options
context:
space:
mode:
authorEelco Chaudron <echaudro@redhat.com>2018-11-22 16:18:14 +0100
committerBen Pfaff <blp@ovn.org>2018-12-12 08:40:55 -0800
commitcd5b89a5a99c3ead973b168326eaef47d4e4c077 (patch)
treea9f49c4144e35107273b0edf491dd17060affb26 /utilities
parentb1331295eaada5bc0e3bcd7e3b964003af3273d6 (diff)
downloadopenvswitch-cd5b89a5a99c3ead973b168326eaef47d4e4c077.tar.gz
utilities: Add smap related command and iterator to the GDB script
Adds "ovs_dump_smap <struct smap *>" command Example output: Breakpoint 1, trtcm_policer_qos_construct (details=0x135bad0, conf=0x7ffd31f5da28) at lib/netdev-dpdk.c:4154 (gdb) ovs_dump_smap 0x135bad0 cbs: 2048 cir: 151800 eir: 151800 pbs: 2048 Signed-off-by: Eelco Chaudron <echaudro@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'utilities')
-rw-r--r--utilities/gdb/ovs_gdb.py56
1 files changed, 53 insertions, 3 deletions
diff --git a/utilities/gdb/ovs_gdb.py b/utilities/gdb/ovs_gdb.py
index 006fbb60a..cb9778c69 100644
--- a/utilities/gdb/ovs_gdb.py
+++ b/utilities/gdb/ovs_gdb.py
@@ -30,6 +30,7 @@
# - ovs_dump_netdev_provider
# - ovs_dump_ovs_list <struct ovs_list *> {[<structure>] [<member>] {dump}]}
# - ovs_dump_simap <struct simap *>
+# - ovs_dump_smap <struct smap *>
# - ovs_dump_udpif_keys {<udpif_name>|<udpif_address>} {short}
# - ovs_show_fdb {[<bridge_name>] {dbg} {hash}}
# - ovs_show_upcall {dbg}
@@ -320,6 +321,19 @@ class ForEachSIMAP(ForEachHMAP):
#
+# Class that will provide an iterator over an OVS smap.
+#
+class ForEachSMAP(ForEachHMAP):
+ def __init__(self, shash):
+ super(ForEachSMAP, self).__init__(shash['map'],
+ "struct smap_node", "node")
+
+ def next(self):
+ node = super(ForEachSMAP, self).next()
+ return node['key'], node['value']
+
+
+#
# Class that will provide an iterator over an OVS list.
#
class ForEachLIST():
@@ -734,8 +748,8 @@ class CmdDumpOvsList(gdb.Command):
# Implements the GDB "ovs_dump_simap" command
#
class CmdDumpSimap(gdb.Command):
- """Dump all nodes of an ovs_list give
- Usage: ovs_dump_ovs_list <struct simap *>
+ """Dump all key, value entries of a simap
+ Usage: ovs_dump_simap <struct simap *>
"""
def __init__(self):
@@ -766,7 +780,42 @@ class CmdDumpSimap(gdb.Command):
#
-# Implements the GDB "ovs_dump_simap" command
+# Implements the GDB "ovs_dump_smap" command
+#
+class CmdDumpSmap(gdb.Command):
+ """Dump all key, value pairs of a smap
+ Usage: ovs_dump_smap <struct smap *>
+ """
+
+ def __init__(self):
+ super(CmdDumpSmap, self).__init__("ovs_dump_smap",
+ gdb.COMMAND_DATA)
+
+ def invoke(self, arg, from_tty):
+ arg_list = gdb.string_to_argv(arg)
+
+ if len(arg_list) != 1:
+ print("ERROR: Missing argument!\n")
+ print(self.__doc__)
+ return
+
+ smap = gdb.parse_and_eval(arg_list[0]).cast(
+ gdb.lookup_type('struct smap').pointer())
+
+ values = dict()
+ max_key_len = 0
+ for key, value in ForEachSMAP(smap.dereference()):
+ values[key.string()] = value.string()
+ if len(key.string()) > max_key_len:
+ max_key_len = len(key.string())
+
+ for key in sorted(values.iterkeys()):
+ print("{}: {}".format(key.ljust(max_key_len),
+ values[key]))
+
+
+#
+# Implements the GDB "ovs_dump_udpif_keys" command
#
class CmdDumpUdpifKeys(gdb.Command):
"""Dump all nodes of an ovs_list give
@@ -1124,6 +1173,7 @@ CmdDumpNetdev()
CmdDumpNetdevProvider()
CmdDumpOvsList()
CmdDumpSimap()
+CmdDumpSmap()
CmdDumpUdpifKeys()
CmdShowFDB()
CmdShowUpcall()