diff options
author | Eelco Chaudron <echaudro@redhat.com> | 2022-12-07 17:26:39 +0100 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2022-12-20 13:02:53 +0100 |
commit | 79e7756a5d9e10c18343096187744f95a793ccf8 (patch) | |
tree | af4e23afa45d60ea3d8b764de7c31f4e6b155ee0 /utilities | |
parent | bf8fa1fe414e92f8386ca2b7745822ced63385ee (diff) | |
download | openvswitch-79e7756a5d9e10c18343096187744f95a793ccf8.tar.gz |
utilities: Add a GDB macro to dump hmap structures.
Add a new GDB macro called ovs_dump_hmap, which can be used to dump any
cmap structure. For example
(gdb) ovs_dump_hmap "&'all_bridges.lto_priv.0'" "struct bridge" "node"
(struct bridge *) 0x55ec43069c70
(struct bridge *) 0x55ec430428a0
(struct bridge *) 0x55ec430a55f0
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'utilities')
-rw-r--r-- | utilities/gdb/ovs_gdb.py | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/utilities/gdb/ovs_gdb.py b/utilities/gdb/ovs_gdb.py index 7f63dd0d5..982395dd1 100644 --- a/utilities/gdb/ovs_gdb.py +++ b/utilities/gdb/ovs_gdb.py @@ -30,6 +30,8 @@ # - ovs_dump_netdev_provider # - ovs_dump_ovs_list <struct ovs_list *> {[<structure>] [<member>] {dump}]} # - ovs_dump_packets <struct dp_packet_batch|dp_packet> [tcpdump options] +# - ovs_dump_cmap <struct cmap *> {[<structure>] [<member>] {dump}]} +# - ovs_dump_hmap <struct hmap *> <structure> <member> {dump} # - ovs_dump_simap <struct simap *> # - ovs_dump_smap <struct smap *> # - ovs_dump_udpif_keys {<udpif_name>|<udpif_address>} {short} @@ -876,7 +878,7 @@ class CmdDumpCmap(gdb.Command): """ def __init__(self): super(CmdDumpCmap, self).__init__("ovs_dump_cmap", - gdb.COMMAND_DATA) + gdb.COMMAND_DATA) def invoke(self, arg, from_tty): arg_list = gdb.string_to_argv(arg) @@ -915,6 +917,54 @@ class CmdDumpCmap(gdb.Command): # +# Implements the GDB "ovs_dump_hmap" command +# +class CmdDumpHmap(gdb.Command): + """Dump all nodes of a given hmap + Usage: + ovs_dump_hmap <struct hmap *> <structure> <member> {dump} + + For example dump all the bridges when the all_bridges variable is + optimized out due to LTO: + + (gdb) ovs_dump_hmap "&'all_bridges.lto_priv.0'" "struct bridge" "node" + (struct bridge *) 0x55ec43069c70 + (struct bridge *) 0x55ec430428a0 + (struct bridge *) 0x55ec430a55f0 + + The 'dump' option will also include the full structure content in the + output. + """ + def __init__(self): + super(CmdDumpHmap, self).__init__("ovs_dump_hmap", + gdb.COMMAND_DATA) + + def invoke(self, arg, from_tty): + arg_list = gdb.string_to_argv(arg) + typeobj = None + member = None + dump = False + + if len(arg_list) != 3 and len(arg_list) != 4: + print("usage: ovs_dump_hmap <struct hmap *> " + "<structure> <member> {dump}") + return + + hmap = gdb.parse_and_eval(arg_list[0]).cast( + gdb.lookup_type('struct hmap').pointer()) + + typeobj = arg_list[1] + member = arg_list[2] + if len(arg_list) == 4 and arg_list[3] == "dump": + dump = True + + for node in ForEachHMAP(hmap.dereference(), typeobj, member): + print("({} *) {} {}".format(typeobj, node, "=" if dump else "")) + if dump: + print(" {}\n".format(node.dereference())) + + +# # Implements the GDB "ovs_dump_simap" command # class CmdDumpSimap(gdb.Command): @@ -1515,6 +1565,7 @@ CmdDumpOfpacts() CmdDumpOvsList() CmdDumpPackets() CmdDumpCmap() +CmdDumpHmap() CmdDumpSimap() CmdDumpSmap() CmdDumpUdpifKeys() |