On Fri, Apr 17, 2020 at 02:51:34PM +0200, Eelco Chaudron wrote: > This adds the ovs_dump_ifpacts command: > > (gdb) help ovs_dump_ofpacts > Dump all actions in an ofpacts set > Usage: ovs_dump_ofpacts <struct ofpact *> <ofpacts_len> > > <struct ofpact *> : Pointer to set of ofpact structures. > <ofpacts_len> : Total length of the set. > > Example dumping all actions when in the clone_xlate_actions() function: > > (gdb) ovs_dump_ofpacts actions actions_len > (struct ofpact *) 0x561c7be487c8: {type = OFPACT_SET_FIELD, raw = 255 '', > len = 24} > (struct ofpact *) 0x561c7be487e0: {type = OFPACT_SET_FIELD, raw = 255 '', > len = 24} > (struct ofpact *) 0x561c7be487f8: {type = OFPACT_SET_FIELD, raw = 255 '', > len = 24} > (struct ofpact *) 0x561c7be48810: {type = OFPACT_SET_FIELD, raw = 255 '', > len = 32} > (struct ofpact *) 0x561c7be48830: {type = OFPACT_SET_FIELD, raw = 255 '', > len = 24} > (struct ofpact *) 0x561c7be48848: {type = OFPACT_RESUBMIT, raw = 38 '&', > len = 16} > > Signed-off-by: Eelco Chaudron <echau...@redhat.com> > --- Hi Eelco,
I'm trying to test this patch. But I hit another problem. Can you help me with the issue? Sorry this is not related to your patch. root@osboxes:~/ovs# gdb $(which ovs-vswitchd) $(pidof ovs-vswitchd) GNU gdb (GDB) 8.0.50.20170501-git Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-pc-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from /usr/local/sbin/ovs-vswitchd...done. Attaching to program: /usr/local/sbin/ovs-vswitchd, process 58469 [New LWP 58473] [New LWP 58474] [New LWP 58475] [New LWP 58484] [New LWP 58485] [New LWP 58486] [New LWP 58487] [New LWP 58578] [New LWP 58579] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". 0x00007fe63d33774d in poll () from /lib/x86_64-linux-gnu/libc.so.6 (gdb) source ./utilities/gdb/ovs_gdb.py File "./utilities/gdb/ovs_gdb.py", line 164 print(self.message, end='') Is this due to python2/3? My python version: boxes:~/ovs# python Python 3.5.2 (default, Oct 8 2019, 13:06:37) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. Thanks! William > utilities/gdb/ovs_gdb.py | 74 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 74 insertions(+) > > diff --git a/utilities/gdb/ovs_gdb.py b/utilities/gdb/ovs_gdb.py > index befc2b4a4..0b2ecb81b 100644 > --- a/utilities/gdb/ovs_gdb.py > +++ b/utilities/gdb/ovs_gdb.py > @@ -413,6 +413,39 @@ class ForEachLIST(): > return self.__next__() > > > +# > +# Class that will provide an iterator over an OFPACTS. > +# > +class ForEachOFPACTS(): > + def __init__(self, ofpacts, ofpacts_len): > + self.ofpact = ofpacts.cast(gdb.lookup_type('struct > ofpact').pointer()) > + self.length = int(ofpacts_len) > + > + def __round_up(self, val, round_to): > + return int(val) + (round_to - int(val)) % round_to > + > + def __iter__(self): > + return self > + > + def __next__(self): > + if self.ofpact is None or self.length <= 0: > + raise StopIteration > + > + ofpact = self.ofpact > + length = self.__round_up(ofpact['len'], 8) > + > + self.length -= length > + self.ofpact = self.ofpact.cast( > + gdb.lookup_type('void').pointer()) + length > + self.ofpact = self.ofpact.cast( > + gdb.lookup_type('struct ofpact').pointer()) > + > + return ofpact > + > + def next(self): > + return self.__next__() > + > + > # > # Implements the GDB "ovs_dump_bridges" command > # > @@ -1233,6 +1266,46 @@ class CmdShowUpcall(gdb.Command): > self.display_udpif_upcall(udpif, 0, "dbg" in arg_list) > > > +# > +# Implements the GDB "ovs_dump_ofpacts" command > +# > +class CmdDumpOfpacts(gdb.Command): > + """Dump all actions in an ofpacts set > + Usage: ovs_dump_ofpacts <struct ofpact *> <ofpacts_len> > + > + <struct ofpact *> : Pointer to set of ofpact structures. > + <ofpacts_len> : Total length of the set. > + > + Example dumping all actions when in the clone_xlate_actions() function: > + > + (gdb) ovs_dump_ofpacts actions actions_len > + (struct ofpact *) 0x561c7be487c8: {type = OFPACT_SET_FIELD, raw = 255 > '', len = 24} > + (struct ofpact *) 0x561c7be487e0: {type = OFPACT_SET_FIELD, raw = 255 > '', len = 24} > + (struct ofpact *) 0x561c7be487f8: {type = OFPACT_SET_FIELD, raw = 255 > '', len = 24} > + (struct ofpact *) 0x561c7be48810: {type = OFPACT_SET_FIELD, raw = 255 > '', len = 32} > + (struct ofpact *) 0x561c7be48830: {type = OFPACT_SET_FIELD, raw = 255 > '', len = 24} > + (struct ofpact *) 0x561c7be48848: {type = OFPACT_RESUBMIT, raw = 38 '&', > len = 16} > + """ > + def __init__(self): > + super(CmdDumpOfpacts, self).__init__("ovs_dump_ofpacts", > + gdb.COMMAND_DATA) > + > + def invoke(self, arg, from_tty): > + arg_list = gdb.string_to_argv(arg) > + > + if len(arg_list) != 2: > + print("usage: ovs_dump_ofpacts <struct ofpact *> <ofpacts_len>") > + return > + > + ofpacts = gdb.parse_and_eval(arg_list[0]).cast( > + gdb.lookup_type('struct ofpact').pointer()) > + > + length = gdb.parse_and_eval(arg_list[1]) > + > + for node in ForEachOFPACTS(ofpacts, length): > + print("(struct ofpact *) {}: {}".format(node, > node.dereference())) > + > + > # > # Initialize all GDB commands > # > @@ -1244,6 +1317,7 @@ CmdDumpDpNetdevPorts() > CmdDumpDpProvider() > CmdDumpNetdev() > CmdDumpNetdevProvider() > +CmdDumpOfpacts() > CmdDumpOvsList() > CmdDumpSimap() > CmdDumpSmap() > -- > 2.24.0 > > _______________________________________________ > dev mailing list > d...@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev