1
0

Painter can now be selected when using the --painter argument

This commit is contained in:
Jon Michael Aanes 2018-02-06 18:04:57 +01:00
parent 49ff6506e6
commit 43584807b1

21
main.py
View File

@ -10,10 +10,16 @@ from TikzPainter import TikzPainter
from AsciiPainter import AsciiPainter from AsciiPainter import AsciiPainter
import Junk import Junk
PAINTER_ID_TO_CLASS = {
'ascii': AsciiPainter,
'tikz': TikzPainter
}
def parse_args (): def parse_args ():
parser = argparse.ArgumentParser(description="For fun x86-64 emulator and stack visualizer.") parser = argparse.ArgumentParser(description="For fun x86-64 emulator and stack visualizer.")
parser.add_argument('-i', '--input-file', default='-', help = '.S file to use as input', dest = 'input-file') parser.add_argument('-i', '--input-file', default='-', help = 'File to use as input', dest = 'input-file')
parser.add_argument('-o', '--output-file', default='-', help = '.S file to use as output', dest = 'output-file') parser.add_argument('-o', '--output-file', default='-', help = 'File to use as output', dest = 'output-file')
parser.add_argument('-p', '--painter', default='ascii', help = 'Drawer to use', dest = 'painter-name', choices=PAINTER_ID_TO_CLASS.keys())
for register in REGISTERS: for register in REGISTERS:
parser.add_argument('--'+register[1:], nargs = 1, type = int, default = None, dest = register, help = 'the initial value of the register') parser.add_argument('--'+register[1:], nargs = 1, type = int, default = None, dest = register, help = 'the initial value of the register')
args = vars(parser.parse_args()) args = vars(parser.parse_args())
@ -46,13 +52,16 @@ def parse_args ():
else: else:
output_file = open(args['output-file'], 'w') output_file = open(args['output-file'], 'w')
##
return (program, registers_init, output_file) # Determine painter class
painter_class = PAINTER_ID_TO_CLASS[args['painter-name']]
## Return
return (program, registers_init, output_file, painter_class)
def main (): def main ():
(program, registers_init, output_file) = parse_args() (program, registers_init, output_file, painter_class) = parse_args()
# Determine registers to display # Determine registers to display
registers_to_draw = ["%rip","%rbp","%rsp", ""] registers_to_draw = ["%rip","%rbp","%rsp", ""]
@ -65,8 +74,6 @@ def main ():
emu.setRegs(**registers_init) emu.setRegs(**registers_init)
emu.setStack(Junk.Junk("junk..."), Junk.Junk("calling eip")) emu.setStack(Junk.Junk("junk..."), Junk.Junk("calling eip"))
painter_class = TikzPainter # AsciiPainter
painter = painter_class(registers_to_draw) painter = painter_class(registers_to_draw)
# Iteratively draw states. # Iteratively draw states.