From 7d5b1f58351f0f1910a5258c3dafb63d06d16c25 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 6 Sep 2022 00:12:10 +0100 Subject: [PATCH] add a new log option to pysvp64dis and make it a command-line console script using setup.py entry_points --- setup.py | 3 ++- src/openpower/sv/trans/pysvp64dis.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index baad4cfc..58a7ec32 100644 --- a/setup.py +++ b/setup.py @@ -82,7 +82,8 @@ setup( 'pyfnwriter=openpower.decoder.pseudo.pyfnwriter:pyfnwriter', 'sv_analysis=openpower.sv.sv_analysis:main', 'pypowersim=openpower.decoder.isa.pypowersim:run_simulation', - 'pysvp64asm=openpower.sv.trans.svp64:asm_process' + 'pysvp64asm=openpower.sv.trans.svp64:asm_process', + 'pysvp64dis=openpower.sv.trans.pysvp64dis:main' ] } ) diff --git a/src/openpower/sv/trans/pysvp64dis.py b/src/openpower/sv/trans/pysvp64dis.py index ac653de9..ff276ed4 100644 --- a/src/openpower/sv/trans/pysvp64dis.py +++ b/src/openpower/sv/trans/pysvp64dis.py @@ -1,6 +1,7 @@ import argparse as _argparse import enum as _enum import sys as _sys +import os from openpower.decoder.power_enums import ( find_wiki_dir as _find_wiki_dir, @@ -55,6 +56,7 @@ def dump(insns, verbose, **_): yield from insn.disassemble(db=db, verbose=verbose) +# this is the entry-point for the console-script pysvp64dis def main(): parser = _argparse.ArgumentParser() parser.add_argument("ifile", nargs="?", @@ -65,12 +67,22 @@ def main(): type=ByteOrder, default=ByteOrder.LITTLE) parser.add_argument("-v", "--verbose", action="store_true", default=False) + parser.add_argument("-l", "--log", + action="store_true", default=False) args = dict(vars(parser.parse_args())) + + # if logging requested do not disable it. + if not args['log']: + os.environ['SILENCELOG'] = '1' + + # load instructions and dump them insns = load(**args) for line in dump(insns, **args): print(line, file=args["ofile"]) +# still here but use "python3 setup.py develop" then run the +# command "pysvp64dis" instead of "python3 src/openpower/sv/trans/pysvp64dis.py" if __name__ == "__main__": main() -- 2.30.2