diff options
author | Eelco Chaudron <echaudro@redhat.com> | 2022-10-18 15:27:52 +0200 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2022-11-02 19:21:58 +0100 |
commit | 2158254fcbd97620151525a8aa91b0a040927690 (patch) | |
tree | 495b9c9ff1fa5ebd3895b0552625aab9fa273b36 /utilities | |
parent | 46ab9d80c2ab8f13dfe2ba2a9700887cd4f7fc36 (diff) | |
download | openvswitch-2158254fcbd97620151525a8aa91b0a040927690.tar.gz |
utilities: Add a GDB macro to dump any cmap structure.
Add a new GDB macro called ovs_dump_cmap, which can be used to dump any
cmap structure. Some examples:
(gdb) ovs_dump_cmap &subtable->rules
(struct cmap *) 0x3e02758
(gdb) ovs_dump_cmap &subtable->rules "struct dpcls_rule" cmap_node
(struct dpcls_rule *) 0x3e02758
(gdb) ovs_dump_cmap &subtable->rules "struct dpcls_rule" cmap_node dump
(struct dpcls_rule *) 0x3e02758 =
{cmap_node = {next = {p = 0x0}}, mask = 0x3dfe100, flow = {hash = ...
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 | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/utilities/gdb/ovs_gdb.py b/utilities/gdb/ovs_gdb.py index 763ece2a7..7f63dd0d5 100644 --- a/utilities/gdb/ovs_gdb.py +++ b/utilities/gdb/ovs_gdb.py @@ -850,6 +850,71 @@ class CmdDumpOvsList(gdb.Command): # +# Implements the GDB "ovs_dump_cmap" command +# +class CmdDumpCmap(gdb.Command): + """Dump all nodes of a given cmap + Usage: + ovs_dump_cmap <struct cmap *> {[<structure>] [<member>] {dump}]} + + For example dump all the rules in a dpcls_subtable: + + (gdb) ovs_dump_cmap &subtable->rules + (struct cmap *) 0x3e02758 + + This is not very useful, so please use this with the container_of mode: + + (gdb) ovs_dump_cmap &subtable->rules "struct dpcls_rule" cmap_node + (struct dpcls_rule *) 0x3e02758 + + Now you can manually use the print command to show the content, or use the + dump option to dump the structure for all nodes: + + (gdb) ovs_dump_cmap &subtable->rules "struct dpcls_rule" cmap_node dump + (struct dpcls_rule *) 0x3e02758 = + {cmap_node = {next = {p = 0x0}}, mask = 0x3dfe100, flow = {hash = ... + """ + def __init__(self): + super(CmdDumpCmap, self).__init__("ovs_dump_cmap", + 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) != 1 and len(arg_list) != 3 and len(arg_list) != 4: + print("usage: ovs_dump_cmap <struct cmap *> " + "{[<structure>] [<member>] {dump}]}") + return + + cmap = gdb.parse_and_eval(arg_list[0]).cast( + gdb.lookup_type('struct cmap').pointer()) + + if len(arg_list) >= 3: + typeobj = arg_list[1] + member = arg_list[2] + if len(arg_list) == 4 and arg_list[3] == "dump": + dump = True + + for node in ForEachCMAP(cmap.dereference()): + if typeobj is None or member is None: + print("(struct cmap *) {}".format(node)) + else: + print("({} *) {} {}".format( + typeobj, + container_of(node, + gdb.lookup_type(typeobj).pointer(), member), + "=" if dump else "")) + if dump: + print(" {}\n".format(container_of( + node, + gdb.lookup_type(typeobj).pointer(), + member).dereference())) + + +# # Implements the GDB "ovs_dump_simap" command # class CmdDumpSimap(gdb.Command): @@ -1449,6 +1514,7 @@ CmdDumpNetdevProvider() CmdDumpOfpacts() CmdDumpOvsList() CmdDumpPackets() +CmdDumpCmap() CmdDumpSimap() CmdDumpSmap() CmdDumpUdpifKeys() |