@@ -23,6 +23,7 @@ class KRISCVOpts:
2323@dataclass
2424class RunOpts (KRISCVOpts ):
2525 input_file : Path
26+ depth : int | None
2627 end_symbol : str | None
2728 zero_init : bool | None
2829
@@ -55,6 +56,7 @@ def _parse_args(args: Sequence[str]) -> KRISCVOpts:
5556 return RunOpts (
5657 temp_dir = ns .temp_dir ,
5758 input_file = ns .input_file .resolve (strict = True ),
59+ depth = ns .depth if ns .depth is not None and ns .depth >= 0 else None ,
5860 end_symbol = ns .end_symbol ,
5961 zero_init = ns .zero_init ,
6062 )
@@ -71,7 +73,12 @@ def _parse_args(args: Sequence[str]) -> KRISCVOpts:
7173def _kriscv_run (opts : RunOpts ) -> None :
7274 tools = semantics (temp_dir = opts .temp_dir )
7375 regs = dict .fromkeys (range (32 ), 0 ) if opts .zero_init else {}
74- final_conf = tools .run_elf (opts .input_file , regs = regs , end_symbol = opts .end_symbol )
76+ final_conf = tools .run_elf (
77+ opts .input_file ,
78+ depth = opts .depth ,
79+ regs = regs ,
80+ end_symbol = opts .end_symbol ,
81+ )
7582 print (tools .kprint .pretty_print (final_conf , sort_collections = True ))
7683
7784
@@ -125,6 +132,7 @@ def _arg_parser() -> ArgumentParser:
125132
126133 run_parser = command_parser .add_parser ('run' , help = 'execute a RISC-V ELF file' , parents = [common_parser ])
127134 run_parser .add_argument ('input_file' , type = Path , metavar = 'FILE' , help = 'RISC-V ELF file to run' )
135+ run_parser .add_argument ('-d' , '--depth' , type = int , help = 'execution depth (set negative for unbounded execution)' )
128136 run_parser .add_argument ('--end-symbol' , type = str , help = 'symbol marking the address which terminates execution' )
129137 run_parser .add_argument ('-z' , '--zero-init' , action = 'store_true' , help = 'initialize registers to zero' )
130138
0 commit comments