Thread: [Objectscript-users] command line debugger
Brought to you by:
rob_d_clark
From: Lysander D. <sa...@sb...> - 2005-10-17 22:08:48
|
Hi, Is there a commandline debugger for objectscript ? Thanks, Lysander |
From: Lysander D. <sa...@sb...> - 2005-11-27 06:54:52
Attachments:
dbg.os
debugger.pat
|
Hi Rob, I have made some modifications to the previous dbg.os you previously posted. Here is the help for it: objectsript command line debugger help continue - continue execution ( synonym "c" ) step - single step ( synonym "s" ) next - Next, steps over subs ( synonym "n" ) where - stack trace ( synonym "T" ) up - change context to higher stack frame ( synonym "u" ) down - change context to lower stack frame ( synonym "d" ) list [file][:[line][:length]] - list the [file] at [line] with [length] number of lines b [[file][:line]] - set a breakpoint. If [file] is not specified, a breakpoint is set at the curent debug stack frame b list - list breakpoints d index - delete breakpoint at specified breakpoint index help - this message ( synonym "h" ) exit - exit debugging session ( synonym "x", "quit", "q") Aside from the os file, some changes in Debugger.java were necessary in order to get the "next" command to work ( see included patch "debugger.pat" ). I realize that a lot of it is kind of hacky but hopfully you can indicate what changes should be made so that it can eventually be included as a part of the objectscritpt distribution. ( Two things I can think of offhand are 1. add a command line flag to add a step breakpoint so that it will not be necessary to modify os code to get the first breakpoint 2. add a return command to continue until the current function returns. ) By the way, is an emacs mode for javascript available ? Thanks, Lysander |
From: Rob C. <ro...@ti...> - 2005-11-28 02:57:20
|
I haven't tried this, but it might work: http://www.brigadoon.de/peter/javascript-mode.el On Nov 26, 2005, at 10:54 PM, Lysander David wrote: > By the way, is an emacs mode for javascript available ____________________ CONTACT INFORMATION: email: ro...@ti... IM: rob@sandjabber desk: 1 858 552 2946 cell: 1 619 300 9661 |
From: Rob C. <ro...@ti...> - 2005-10-17 23:10:40
|
not really... you might be able to use the debugger API to setup a read-eval-print shell to run at certain file and line numbers... for example: // dbg.os: function setBreakpoint( filename, line ) { var file = pkg.fs.resolve(filename); Debugger.setBreakpoint( file, line, new function() extends Debugger.Breakpoint() { public function handle( scope, file, line ) { var status = null; mixin java.io; writeln("hit breakpoint at " + file + ":" + line); var shell = new function() extends oscript.Shell( new BufferedReader( new InputStreamReader(System.in) ), new PrintWriter(System.out), new PrintWriter(System.err) ) { // overload to evaluate in the scope of the breakpoint public function evalStr(str) { // note: default implementation of read() automagically appends ";" if( (str == "exit;") || (str == "c;") ) status = "exit"; else if( str == "step;" || (str == "s;") ) status = "step"; if( status != null ) return status; return oscript.OscriptInterpreter.__eval( str, scope ); } private var _super_read = read; public function read() { if( status != null ) return "exit"; return _super_read(); } }(); shell.run(); if( status == "step" ) return this; // keep stepping return null; // stop stepping } }() ); } --------------------------- // test.os import "dbg.os"; var globalvar = 2; function test() { var a = 1; // <--- line 8 var b = 2; writeln("a=" + a + ", b=" + b + ", globalvar=" + globalvar); } setBreakpoint("test.os",8); test(); --------------------------- this is not very clean, but just meant to be an example.. maybe someday someone will have some time to package this up into a nice command-line debugger program. On Oct 17, 2005, at 3:08 PM, Lysander David wrote: > Hi, > > Is there a commandline debugger for objectscript ? > > Thanks, > Lysander |
From: Lysander D. <sa...@sb...> - 2005-10-18 05:56:36
|
That appears to work. However after hitting the breakpoint entering this: writeln ( "a" ) results in nothing being written to standard out. Does that successfully write anything to standarad out for you ? If not, do you know what needs to be changed in order to allow that command to successfully output text ? Thanks, Lysander --- Rob Clark <ro...@ti...> wrote: > not really... you might be able to use the debugger > API to setup a > read-eval-print shell to run at certain file and > line numbers... for > example: > > > // dbg.os: > > function setBreakpoint( filename, line ) > { > var file = pkg.fs.resolve(filename); > Debugger.setBreakpoint( > file, line, > new function() extends Debugger.Breakpoint() { > > public function handle( scope, file, line ) > { > var status = null; > > > mixin java.io; > writeln("hit breakpoint at " + file + ":" + > line); > var shell = new function() extends > oscript.Shell( > new BufferedReader( new > InputStreamReader(System.in) ), > new PrintWriter(System.out), > new PrintWriter(System.err) > ) { > > // overload to evaluate in the scope of > the breakpoint > public function evalStr(str) > { > // note: default implementation of > read() automagically > appends ";" > if( (str == "exit;") || (str == "c;") ) > status = "exit"; > else if( str == "step;" || (str == > "s;") ) status = "step"; > > if( status != null ) > return status; > > return > oscript.OscriptInterpreter.__eval( str, scope ); > } > > private var _super_read = read; > > public function read() > { > if( status != null ) > return "exit"; > return _super_read(); > } > > }(); > > shell.run(); > > if( status == "step" ) > return this; // keep stepping > > return null; // stop stepping > } > > }() > ); > } > > > --------------------------- > > // test.os > > import "dbg.os"; > > var globalvar = 2; > > function test() > { > var a = 1; // <--- line 8 > var b = 2; > writeln("a=" + a + ", b=" + b + ", globalvar=" + > globalvar); > } > > > setBreakpoint("test.os",8); > > test(); > > > --------------------------- > > this is not very clean, but just meant to be an > example.. maybe > someday someone will have some time to package this > up into a nice > command-line debugger program. > > > > On Oct 17, 2005, at 3:08 PM, Lysander David wrote: > > > Hi, > > > > Is there a commandline debugger for objectscript ? > > > > Thanks, > > Lysander > > |
From: Rob C. <ro...@ti...> - 2005-10-18 06:22:34
|
you need to "s" (step) for at least one line, because on the line it halts on, "a" has not been declared yet. It should probably result in a NoSuchMemberException which isn't getting printed out for some reason On Oct 17, 2005, at 10:56 PM, Lysander David wrote: > That appears to work. However after hitting the > breakpoint entering this: > > writeln ( "a" ) > > results in nothing being written to standard out. > > Does that successfully write anything to standarad out > for you ? > > If not, do you know what needs to be changed in > order to allow that command to successfully output > text ? > > Thanks, > Lysander > > > --- Rob Clark <ro...@ti...> wrote: > > >> not really... you might be able to use the debugger >> API to setup a >> read-eval-print shell to run at certain file and >> line numbers... for >> example: >> >> >> // dbg.os: >> >> function setBreakpoint( filename, line ) >> { >> var file = pkg.fs.resolve(filename); >> Debugger.setBreakpoint( >> file, line, >> new function() extends Debugger.Breakpoint() { >> >> public function handle( scope, file, line ) >> { >> var status = null; >> >> >> mixin java.io; >> writeln("hit breakpoint at " + file + ":" + >> line); >> var shell = new function() extends >> oscript.Shell( >> new BufferedReader( new >> InputStreamReader(System.in) ), >> new PrintWriter(System.out), >> new PrintWriter(System.err) >> ) { >> >> // overload to evaluate in the scope of >> the breakpoint >> public function evalStr(str) >> { >> // note: default implementation of >> read() automagically >> appends ";" >> if( (str == "exit;") || (str == "c;") ) >> status = "exit"; >> else if( str == "step;" || (str == >> "s;") ) status = "step"; >> >> if( status != null ) >> return status; >> >> return >> oscript.OscriptInterpreter.__eval( str, scope ); >> } >> >> private var _super_read = read; >> >> public function read() >> { >> if( status != null ) >> return "exit"; >> return _super_read(); >> } >> >> }(); >> >> shell.run(); >> >> if( status == "step" ) >> return this; // keep stepping >> >> return null; // stop stepping >> } >> >> }() >> ); >> } >> >> >> --------------------------- >> >> // test.os >> >> import "dbg.os"; >> >> var globalvar = 2; >> >> function test() >> { >> var a = 1; // <--- line 8 >> var b = 2; >> writeln("a=" + a + ", b=" + b + ", globalvar=" + >> globalvar); >> } >> >> >> setBreakpoint("test.os",8); >> >> test(); >> >> >> --------------------------- >> >> this is not very clean, but just meant to be an >> example.. maybe >> someday someone will have some time to package this >> up into a nice >> command-line debugger program. >> >> >> >> On Oct 17, 2005, at 3:08 PM, Lysander David wrote: >> >> >>> Hi, >>> >>> Is there a commandline debugger for objectscript ? >>> >>> Thanks, >>> Lysander >>> >> >> >> > > ____________________ CONTACT INFORMATION: email: ro...@ti... IM: rob@sandjabber desk: 1 858 552 2946 cell: 1 619 300 9661 |
From: Lysander D. <sa...@sb...> - 2005-10-18 16:37:19
|
Unfortunately, even after stepping ( 's' ) for one line nothing is written to stdout. Additionally, attempting to write a simple string to stdout like this: writeln ( "a nice string" ); doesn't result in any output. Additionally, after modifying oscript.OscriptInterpreter.__eval(String str, Scope scope) to print the string to be evaluated with this System.out.println ( "eval: \"" + str + "\""); nothing is printed out. It almost appears that __eval is not being called. How would it be possible to ensure that __eval is getting called ? Thanks, Lysander --- Rob Clark <ro...@ti...> wrote: > you need to "s" (step) for at least one line, > because on the line it > halts on, "a" has not been declared yet. It should > probably result > in a NoSuchMemberException which isn't getting > printed out for some > reason > > > On Oct 17, 2005, at 10:56 PM, Lysander David wrote: > > > That appears to work. However after hitting the > > breakpoint entering this: > > > > writeln ( "a" ) > > > > results in nothing being written to standard out. > > > > Does that successfully write anything to standarad > out > > for you ? > > > > If not, do you know what needs to be changed in > > order to allow that command to successfully output > > text ? > > > > Thanks, > > Lysander > > > > > > --- Rob Clark <ro...@ti...> wrote: > > > > > >> not really... you might be able to use the > debugger > >> API to setup a > >> read-eval-print shell to run at certain file and > >> line numbers... for > >> example: > >> > >> > >> // dbg.os: > >> > >> function setBreakpoint( filename, line ) > >> { > >> var file = pkg.fs.resolve(filename); > >> Debugger.setBreakpoint( > >> file, line, > >> new function() extends Debugger.Breakpoint() > { > >> > >> public function handle( scope, file, line > ) > >> { > >> var status = null; > >> > >> > >> mixin java.io; > >> writeln("hit breakpoint at " + file + > ":" + > >> line); > >> var shell = new function() extends > >> oscript.Shell( > >> new BufferedReader( new > >> InputStreamReader(System.in) ), > >> new PrintWriter(System.out), > >> new PrintWriter(System.err) > >> ) { > >> > >> // overload to evaluate in the scope > of > >> the breakpoint > >> public function evalStr(str) > >> { > >> // note: default implementation of > >> read() automagically > >> appends ";" > >> if( (str == "exit;") || (str == > "c;") ) > >> status = "exit"; > >> else if( str == "step;" || (str == > >> "s;") ) status = "step"; > >> > >> if( status != null ) > >> return status; > >> > >> return > >> oscript.OscriptInterpreter.__eval( str, scope ); > >> } > >> > >> private var _super_read = read; > >> > >> public function read() > >> { > >> if( status != null ) > >> return "exit"; > >> return _super_read(); > >> } > >> > >> }(); > >> > >> shell.run(); > >> > >> if( status == "step" ) > >> return this; // keep stepping > >> > >> return null; // stop stepping > >> } > >> > >> }() > >> ); > >> } > >> > >> > >> --------------------------- > >> > >> // test.os > >> > >> import "dbg.os"; > >> > >> var globalvar = 2; > >> > >> function test() > >> { > >> var a = 1; // <--- line 8 > >> var b = 2; > >> writeln("a=" + a + ", b=" + b + ", globalvar=" > + > >> globalvar); > >> } > >> > >> > >> setBreakpoint("test.os",8); > >> > >> test(); > >> > >> > >> --------------------------- > >> > >> this is not very clean, but just meant to be an > >> example.. maybe > >> someday someone will have some time to package > this > >> up into a nice > >> command-line debugger program. > >> > >> > >> > >> On Oct 17, 2005, at 3:08 PM, Lysander David > wrote: > >> > >> > >>> Hi, > >>> > >>> Is there a commandline debugger for objectscript > ? > >>> > >>> Thanks, > >>> Lysander > >>> > >> > >> > >> > > > > > > > ____________________ > CONTACT INFORMATION: > email: ro...@ti... > IM: rob@sandjabber > desk: 1 858 552 2946 > cell: 1 619 300 9661 > > > > |
From: Rob C. <ro...@ti...> - 2005-10-21 00:42:38
|
hmm... try putting a try/catch around the call to __eval()... it could be throwing an exception for some reason. Which ObjectScript version are you using? Send me your version of setBreakpoint() (if you've made any changes), and I'll try to reproduce it when I get a few mins over the weekend. btw, sorry for the delayed response, I've been in the midst of a major debugging session for the last few days. (Debugging object code on a small embedded platform is fun.) On Oct 18, 2005, at 9:36 AM, Lysander David wrote: > Unfortunately, even after stepping ( 's' ) for one > line > nothing is written to stdout. Additionally, > attempting to write a simple string to stdout like > this: > > writeln ( "a nice string" ); > > doesn't result in any output. > > Additionally, after modifying > oscript.OscriptInterpreter.__eval(String str, Scope > scope) > > to print the string to be evaluated with this > > System.out.println ( "eval: \"" + str + "\""); > > nothing is printed out. It almost appears that > __eval is not being called. > > How would it be possible to ensure that __eval > is getting called ? > > Thanks, > Lysander > > > --- Rob Clark <ro...@ti...> wrote: > > >> you need to "s" (step) for at least one line, >> because on the line it >> halts on, "a" has not been declared yet. It should >> probably result >> in a NoSuchMemberException which isn't getting >> printed out for some >> reason >> >> >> On Oct 17, 2005, at 10:56 PM, Lysander David wrote: >> >> >>> That appears to work. However after hitting the >>> breakpoint entering this: >>> >>> writeln ( "a" ) >>> >>> results in nothing being written to standard out. >>> >>> Does that successfully write anything to standarad >>> >> out >> >>> for you ? >>> >>> If not, do you know what needs to be changed in >>> order to allow that command to successfully output >>> text ? >>> >>> Thanks, >>> Lysander >>> >>> >>> --- Rob Clark <ro...@ti...> wrote: >>> >>> >>> >>>> not really... you might be able to use the >>>> >> debugger >> >>>> API to setup a >>>> read-eval-print shell to run at certain file and >>>> line numbers... for >>>> example: >>>> >>>> >>>> // dbg.os: >>>> >>>> function setBreakpoint( filename, line ) >>>> { >>>> var file = pkg.fs.resolve(filename); >>>> Debugger.setBreakpoint( >>>> file, line, >>>> new function() extends Debugger.Breakpoint() >>>> >> { >> >>>> >>>> public function handle( scope, file, line >>>> >> ) >> >>>> { >>>> var status = null; >>>> >>>> >>>> mixin java.io; >>>> writeln("hit breakpoint at " + file + >>>> >> ":" + >> >>>> line); >>>> var shell = new function() extends >>>> oscript.Shell( >>>> new BufferedReader( new >>>> InputStreamReader(System.in) ), >>>> new PrintWriter(System.out), >>>> new PrintWriter(System.err) >>>> ) { >>>> >>>> // overload to evaluate in the scope >>>> >> of >> >>>> the breakpoint >>>> public function evalStr(str) >>>> { >>>> // note: default implementation of >>>> read() automagically >>>> appends ";" >>>> if( (str == "exit;") || (str == >>>> >> "c;") ) >> >>>> status = "exit"; >>>> else if( str == "step;" || (str == >>>> "s;") ) status = "step"; >>>> >>>> if( status != null ) >>>> return status; >>>> >>>> return >>>> oscript.OscriptInterpreter.__eval( str, scope ); >>>> } >>>> >>>> private var _super_read = read; >>>> >>>> public function read() >>>> { >>>> if( status != null ) >>>> return "exit"; >>>> return _super_read(); >>>> } >>>> >>>> }(); >>>> >>>> shell.run(); >>>> >>>> if( status == "step" ) >>>> return this; // keep stepping >>>> >>>> return null; // stop stepping >>>> } >>>> >>>> }() >>>> ); >>>> } >>>> >>>> >>>> --------------------------- >>>> >>>> // test.os >>>> >>>> import "dbg.os"; >>>> >>>> var globalvar = 2; >>>> >>>> function test() >>>> { >>>> var a = 1; // <--- line 8 >>>> var b = 2; >>>> writeln("a=" + a + ", b=" + b + ", globalvar=" >>>> >> + >> >>>> globalvar); >>>> } >>>> >>>> >>>> setBreakpoint("test.os",8); >>>> >>>> test(); >>>> >>>> >>>> --------------------------- >>>> >>>> this is not very clean, but just meant to be an >>>> example.. maybe >>>> someday someone will have some time to package >>>> >> this >> >>>> up into a nice >>>> command-line debugger program. >>>> >>>> >>>> >>>> On Oct 17, 2005, at 3:08 PM, Lysander David >>>> >> wrote: >> >>>> >>>> >>>> >>>>> Hi, >>>>> >>>>> Is there a commandline debugger for objectscript >>>>> >> ? >> >>>>> >>>>> Thanks, >>>>> Lysander >>>>> >>>>> >>>> >>>> >>>> >>>> >>> >>> >>> >> >> >> ____________________ >> CONTACT INFORMATION: >> email: ro...@ti... >> IM: rob@sandjabber >> desk: 1 858 552 2946 >> cell: 1 619 300 9661 >> >> >> >> >> > > -- Rob ____________________ CONTACT INFORMATION: email: ro...@ti... IM: rob@sandjabber desk: 1 858 552 2946 cell: 1 619 300 9661 |
From: Lysander D. <sa...@sb...> - 2005-10-21 18:40:21
|
Arrgh!!! I put too many underscores in front of eval. __eval() works but ___eval() doesn't. The try block really did the trick. BTW I was wondering if you had a chance to set up a login for me in trac so that I could check out the classloader changes in subversion ? As always, thanks for all the help, Lysander --- Rob Clark <ro...@ti...> wrote: > hmm... try putting a try/catch around the call to > __eval()... it > could be throwing an exception for some reason. > Which ObjectScript > version are you using? Send me your version of > setBreakpoint() (if > you've made any changes), and I'll try to reproduce > it when I get a > few mins over the weekend. > > > btw, sorry for the delayed response, I've been in > the midst of a > major debugging session for the last few days. > (Debugging object > code on a small embedded platform is fun.) > > > On Oct 18, 2005, at 9:36 AM, Lysander David wrote: > > > Unfortunately, even after stepping ( 's' ) for > one > > line > > nothing is written to stdout. Additionally, > > attempting to write a simple string to stdout like > > this: > > > > writeln ( "a nice string" ); > > > > doesn't result in any output. > > > > Additionally, after modifying > > oscript.OscriptInterpreter.__eval(String str, > Scope > > scope) > > > > to print the string to be evaluated with this > > > > System.out.println ( "eval: \"" + str + "\""); > > > > nothing is printed out. It almost appears that > > __eval is not being called. > > > > How would it be possible to ensure that __eval > > is getting called ? > > > > Thanks, > > Lysander > > > > > > --- Rob Clark <ro...@ti...> wrote: > > > > > >> you need to "s" (step) for at least one line, > >> because on the line it > >> halts on, "a" has not been declared yet. It > should > >> probably result > >> in a NoSuchMemberException which isn't getting > >> printed out for some > >> reason > >> > >> > >> On Oct 17, 2005, at 10:56 PM, Lysander David > wrote: > >> > >> > >>> That appears to work. However after hitting the > >>> breakpoint entering this: > >>> > >>> writeln ( "a" ) > >>> > >>> results in nothing being written to standard > out. > >>> > >>> Does that successfully write anything to > standarad > >>> > >> out > >> > >>> for you ? > >>> > >>> If not, do you know what needs to be changed in > >>> order to allow that command to successfully > output > >>> text ? > >>> > >>> Thanks, > >>> Lysander > >>> > >>> > >>> --- Rob Clark <ro...@ti...> wrote: > >>> > >>> > >>> > >>>> not really... you might be able to use the > >>>> > >> debugger > >> > >>>> API to setup a > >>>> read-eval-print shell to run at certain file > and > >>>> line numbers... for > >>>> example: > >>>> > >>>> > >>>> // dbg.os: > >>>> > >>>> function setBreakpoint( filename, line ) > >>>> { > >>>> var file = pkg.fs.resolve(filename); > >>>> Debugger.setBreakpoint( > >>>> file, line, > >>>> new function() extends > Debugger.Breakpoint() > >>>> > >> { > >> > >>>> > >>>> public function handle( scope, file, > line > >>>> > >> ) > >> > >>>> { > >>>> var status = null; > >>>> > >>>> > >>>> mixin java.io; > >>>> writeln("hit breakpoint at " + file + > >>>> > >> ":" + > >> > >>>> line); > >>>> var shell = new function() extends > >>>> oscript.Shell( > >>>> new BufferedReader( new > >>>> InputStreamReader(System.in) ), > >>>> new PrintWriter(System.out), > >>>> new PrintWriter(System.err) > >>>> ) { > >>>> > >>>> // overload to evaluate in the scope > >>>> > >> of > >> > >>>> the breakpoint > >>>> public function evalStr(str) > >>>> { > >>>> // note: default implementation of > >>>> read() automagically > >>>> appends ";" > >>>> if( (str == "exit;") || (str == > >>>> > >> "c;") ) > >> > >>>> status = "exit"; > >>>> else if( str == "step;" || (str == > >>>> "s;") ) status = "step"; > >>>> > >>>> if( status != null ) > >>>> return status; > >>>> > >>>> return > >>>> oscript.OscriptInterpreter.__eval( str, scope > ); > >>>> } > >>>> > >>>> private var _super_read = read; > >>>> > >>>> public function read() > >>>> { > >>>> if( status != null ) > >>>> return "exit"; > >>>> return _super_read(); > >>>> } > >>>> > >>>> }(); > >>>> > >>>> shell.run(); > >>>> > >>>> if( status == "step" ) > >>>> return this; // keep stepping > >>>> > >>>> return null; // stop stepping > >>>> } > >>>> > >>>> }() > >>>> ); > >>>> } > >>>> > >>>> > >>>> --------------------------- > >>>> > >>>> // test.os > >>>> > >>>> import "dbg.os"; > >>>> > >>>> var globalvar = 2; > >>>> > >>>> function test() > === message truncated === |