From: Dmitry Selyutin Date: Sat, 3 Jun 2023 16:58:02 +0000 (+0300) Subject: insndb/db: support pcode command X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=612cdb6383fc9b7ed2d473edacac19885fdbadd3;p=openpower-isa.git insndb/db: support pcode command --- 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")