From: Marc R. <re...@gm...> - 2022-06-07 11:42:27
|
I've submitted branch interactive-trace, an *experimental* *experiment* to mimic Classic Rexx interactive trace capabilities. The new 'TRACE INT' instruction will intercept and pause execution during interpretation and present a '*->' prompt to the user. Pressing [Enter] will interpret next clause Typing '=' will reinterpret current clause Typing '?' will show usage Typing 'TRACE OFF' will stop interactive trace and will continue normally with next clause Typing anything else is currently 'not supported'. TRACE INT is only active when interpreting NetRexx code, otherwise a warning 'TRACE INT ignored when compiling' is shown. An example: << $ cat trace.nrx class trace method main(args=String[]) static say 'interactively tracing..' trace int i=0 say 'i='i do say 'Hello world'||'!'.copies(i) end trace off loop while i < 5 trace int i=i+1 say 'i='i say 'Hello world'||'!'.copies(i) end >> Sample run: << $ nrc -exec trace NetRexx portable processor 4.04-alpha build 1,400-20220530-2046 Copyright (c) RexxLA, 2011,2022. All rights reserved. Parts Copyright (c) IBM Corporation, 1995,2008. Program trace.nrx === class trace === function main(String[]) ===== Exec: trace ===== interactively tracing.. *-> --- trace.nrx 6 *=* i=0 >v> i "0" *-> 7 *=* say 'i='i >>> "i=0" i=0 *-> trace off Hello world *-> 14 *=* i=i+1 >v> i "1" *-> trace off i=1 Hello world! *-> 14 *=* i=i+1 >v> i "2" *-> = *=* i=i+1 >v> i "3" *-> 15 *=* say 'i='i >>> "i=3" i=3 *-> 16 *=* say 'Hello world'||'!'.copies(i) >>> "3" >>> "Hello world!!!" Hello world!!! *-> 12 *=* loop while i < 5 >>> "1" *-> trace off *-> 14 *=* i=i+1 >v> i "4" *-> trace off i=4 Hello world!!!! *-> trace off i=5 Hello world!!!!! Processing of 'trace.nrx' complete >> Do not reinterprete a clause that changes 'level' depth: << $ nrc -exec trace NetRexx portable processor 4.04-alpha build 1,400-20220530-2046 Copyright (c) RexxLA, 2011,2022. All rights reserved. Parts Copyright (c) IBM Corporation, 1995,2008. Program trace.nrx === class trace === function main(String[]) ===== Exec: trace ===== interactively tracing.. *-> --- trace.nrx 6 *=* i=0 >v> i "0" *-> 7 *=* say 'i='i >>> "i=0" i=0 *-> 8 *=* do *-> 9 *=* say 'Hello world'||'!'.copies(i) >>> "0" >>> "Hello world" Hello world *-> 10 *=* end *-> = *=* end *-> = *=* end Exception in thread "main" java.lang.NullPointerException: Cannot read field "prev" because "<parameter1>.curlevel" is null at org.netrexx.process.RxInterpreter.poplevel(RxInterpreter.java:1590) at org.netrexx.process.NrEnd.interpret(NrEnd.java:174) at org.netrexx.process.RxInterpreter.runfree(RxInterpreter.java:1314) at org.netrexx.process.RxInterpreter.callMethod(RxInterpreter.java:1180) at org.netrexx.process.RxInterpreter.callMethod(RxInterpreter.java:835) at org.netrexx.process.RxTranslator.exec(RxTranslator.java:791) at org.netrexx.process.NetRexxC.process(NetRexxC.java:536) at org.netrexx.process.NetRexxC.main2(NetRexxC.java:345) at org.netrexx.process.NetRexxC.main2(NetRexxC.java:324) at org.netrexx.process.NetRexxC.main2(NetRexxC.java:320) at org.netrexx.process.NetRexxC.main(NetRexxC.java:174) >> As such, the code is to be considered experimental.. Pressing [Enter] without interfering with execution should not have other impact than 'pausing' execution. Obviously, 'not supported' should be replaced by interpreting the provided 'trace' clause in the context of the current program with access to the current varpool. Unfortunately, this is not trivial, at least with my understanding of Mike's code. Marc |