From 35adf8493b41f8f2f7c133e292d809b584e932da Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sat, 3 Jun 2023 19:58:02 +0300 Subject: [PATCH] insndb/db: support pcode command --- src/openpower/insndb/core.py | 4 ++++ src/openpower/insndb/db.py | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/openpower/insndb/core.py b/src/openpower/insndb/core.py index 4911ae54..68c8ba0a 100644 --- a/src/openpower/insndb/core.py +++ b/src/openpower/insndb/core.py @@ -826,6 +826,10 @@ class Record: with visitor.record(record=self) as record: pass + @property + def pcode(self): + return self.mdwn.pcode + def __lt__(self, other): if not isinstance(other, Record): return NotImplemented diff --git a/src/openpower/insndb/db.py b/src/openpower/insndb/db.py index ed9063da..ce83c2f7 100644 --- a/src/openpower/insndb/db.py +++ b/src/openpower/insndb/db.py @@ -53,11 +53,18 @@ class OperandsVisitor(ConcreteInstructionVisitor): print(operand.name, operand.value, sep="=") +class PCodeVisitor(ConcreteInstructionVisitor): + def handler(self, record): + for line in record.pcode: + print(line) + + def main(): visitors = { "list": ListVisitor, "opcodes": OpcodesVisitor, "operands": OperandsVisitor, + "pcode": PCodeVisitor, } main_parser = argparse.ArgumentParser() @@ -72,6 +79,7 @@ def main(): for (command, help) in { "opcodes": "print instruction opcodes", "operands": "print instruction operands", + "pcode": "print instruction pseudocode", }.items(): parser = main_subparser.add_parser(command, help=help) parser.add_argument("insn", metavar="INSN", help="instruction") -- 2.30.2