From: Dmitry Selyutin Date: Fri, 23 Jun 2023 08:36:19 +0000 (+0300) Subject: insndb/db: update traversal algorithm X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=refs%2Fheads%2Fmdis;p=openpower-isa.git insndb/db: update traversal algorithm --- diff --git a/src/openpower/insndb/db.py b/src/openpower/insndb/db.py index 50fe9eba..71e3a630 100644 --- a/src/openpower/insndb/db.py +++ b/src/openpower/insndb/db.py @@ -182,14 +182,14 @@ class ExtrasVisitor(SVP64InstructionVisitor, SelectorsVisitor): @mdis.dispatcher.Hook(SVP64Record.ExtraMap) @contextlib.contextmanager def dispatch_extramap(self, node): - self.__index = -1 + self.__index = 0 yield node @mdis.dispatcher.Hook(SVP64Record.ExtraMap.Extra) @contextlib.contextmanager def dispatch_extramap_extra(self, node): - self.__index += 1 yield node + self.__index += 1 @mdis.dispatcher.Hook(SVP64Record.ExtraMap.Extra.Entry) @contextlib.contextmanager @@ -272,12 +272,14 @@ def main(): if not isinstance(visitor, InstructionVisitor): root = db else: - root = [db[args.pop("insn")]] + root = db[args.pop("insn")] + + def traverse(root, visitor, walker): + with visitor(root): + for (node, *_) in walker(root): + traverse(root=node, visitor=visitor, walker=walker) - walker = Walker() - for (node, *_) in walker(root): - with visitor(node): - pass + traverse(root=root, visitor=visitor, walker=Walker()) if __name__ == "__main__":