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 <[email protected]> --- utilities/gdb/ovs_gdb.py | 56 +++++++++++++++++++++++++++++++++++++--- 1 file 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} @@ -319,6 +320,19 @@ class ForEachSIMAP(ForEachHMAP): return node['name'], node['data'] +# +# 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. # @@ -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() -- 2.19.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
