From: Marc R. <re...@gm...> - 2022-06-17 14:38:24
|
Latest push fixes access to properties On 6/17/22 10:49, Marc Remes wrote: > > I've updated branch interactive-trace. > > You now have access to method variables and arguments, you can view or modify their values. Accessing properties still throws an exception. > > On the interactive trace *-> prompt you can now: > > press [Enter] to trace interactively > type '=' to reinterpret current clause > type '-[n]' to show previous n clause(s), shows current clause if n is absent > type '+[n]' to show next n clause(s), shows next clause if n is absent > type 'trace off' to stop tracing > any other clause entered must be either an assignment or a SAY instruction > > I've turned away of touching existing code as much as possible, so albeit experimental, impact on existing code is limited to nonexistent. > > A sample run : > << > $ 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 > x=traces(9) > say 'x:'x > xx=traced(9) > say 'xx.prop:'xx.prop > loop while i < 5 > trace int > i=i+1 > say 'i='i > say 'Hello world'||'!'.copies(i) > end > > method traces(arg=Rexx) static > trace int > say 'method traced called' > say 'traced:'arg > return arg > > class traced > properties public > prop = 9 > > method traced(arg=Rexx) > trace int > say 'prop:'prop > say 'class traced constructed' > say 'traced:'arg > $ nrc -exec trace > NetRexx portable processor 4.04-alpha build 1,558-20220616-1912 > Copyright (c) RexxLA, 2011,2022. All rights reserved. > Parts Copyright (c) IBM Corporation, 1995,2008. > Program trace.nrx > === class trace === > function main(String[]) > function traces(Rexx) > > === class traced === > constructor traced(Rexx) > ===== Exec: trace ===== > interactively tracing.. > *-> > --- trace.nrx > 6 *=* i=0 > >v> i "0" > *-> say i > 0 > *-> i=3 > *-> say i > 3 > *-> > 7 *=* say 'i='i > >>> "i=3" > i=3 > *-> > 8 *=* do > *-> > 9 *=* say 'Hello world'||'!'.copies(i) > >>> "3" > >>> "Hello world!!!" > Hello world!!! > *-> > 10 *=* end > *-> > 11 *=* trace off > *-> > 25 *=* say 'method traced called' > >>> "method traced called" > method traced called > *-> -3 > method traces(arg=Rexx) static > trace int > say "method traced called" > *-> say arg > 9 > *-> arg=8 > *-> > 26 *=* say 'traced:'arg > >>> "traced:8" > traced:8 > *-> > 27 *=* return arg > >>> "8" > *-> > x:8 > *-> > 35 *=* say 'prop:'prop > >>> "prop:9" > prop:9 > *-> > 36 *=* say 'class traced constructed' > >>> "class traced constructed" > class traced constructed > *-> -3 > trace int > say "prop:"prop > say "class traced constructed" > *-> -5 > prop=9 > method traced(arg=Rexx) > trace int > say "prop:"prop > say "class traced constructed" > *-> say arg > 9 > *-> arg=8 > *-> say arg > 8 > *-> > 37 *=* say 'traced:'arg > >>> "traced:8" > traced:8 > *-> > xx.prop:9 > *-> > 18 *=* i=i+1 > >v> i "4" > *-> > 19 *=* say 'i='i > >>> "i=4" > i=4 > *-> trace off > Hello world!!!! > *-> > 18 *=* i=i+1 > >v> i "5" > *-> > 19 *=* say 'i='i > >>> "i=5" > i=5 > *-> > 20 *=* say 'Hello world'||'!'.copies(i) > >>> "5" > >>> "Hello world!!!!!" > Hello world!!!!! > *-> > 16 *=* loop while i < 5 > >>> "0" > *-> > 21 *=* end > *-> > Processing of 'trace.nrx' complete [2 classes] >>> > > Please test; > > Marc > > On 6/7/22 13:42, Marc Remes wrote: >> 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 >> >> >> >> >> |