insndb/db: support pcode command
authorDmitry Selyutin <ghostmansd@gmail.com>
Sat, 3 Jun 2023 16:58:02 +0000 (19:58 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Sat, 3 Jun 2023 16:58:02 +0000 (19:58 +0300)
src/openpower/insndb/core.py
src/openpower/insndb/db.py

index 4911ae54620fb99b8da05ef2b28c99810ec801f9..68c8ba0a0c0e85ef9503ff1e9523288326b34764 100644 (file)
@@ -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
index ed9063daff93bc0095b963e117acf4fca68552c0..ce83c2f76f09abd1dc775f8aa50ca02ff72f3fe7 100644 (file)
@@ -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")