From c63f340d90800895f007de64b7d2d14624263331 Mon Sep 17 00:00:00 2001 From: nthnluu Date: Sun, 28 Jan 2024 21:20:27 -0500 Subject: Created student weenix repository --- kernel/util/list.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 kernel/util/list.py (limited to 'kernel/util/list.py') diff --git a/kernel/util/list.py b/kernel/util/list.py new file mode 100644 index 0000000..4eeed03 --- /dev/null +++ b/kernel/util/list.py @@ -0,0 +1,32 @@ +import gdb + +import weenix +import weenix.list + + +class ListCommand(weenix.Command): + """usage: list [ ] + the list_t to be printed + the type of the values stored on the list + type's list link member used to make the list + Prints all items on a list_t, if and are not given + then the addresses of the list links are printed, otherwise the items + are printed assuming that they have the given type.""" + + def __init__(self): + weenix.Command.__init__(self, "list", gdb.COMMAND_DATA, gdb.COMPLETE_SYMBOL) + + def invoke(self, arg, tty): + args = gdb.string_to_argv(arg) + if len(args) == 1: + for i, item in enumerate(weenix.list.load(args[0])): + gdb.write("{0:>3}: {1:8}\n".format(i, item.link_addr())) + elif len(args) == 3: + for i, item in enumerate(weenix.list.load(args[0], args[1], args[2])): + gdb.write("{0:>3}: {1}\n".format(i, item.item())) + else: + gdb.write("{0}\n".format(self.__doc__)) + raise gdb.GdbError("invalid arguments") + + +ListCommand() -- cgit v1.2.3-70-g09d2