Debugging using the Phantom Command Line Interpreter

General discussion about the Phantom Automation Language and related tools.

Debugging using the Phantom Command Line Interpreter

Postby john on Thu Jan 20, 2011 2:23 pm

Hello All-

You can now debug scripts using the Phantom Command Line Interpreter using the '-d' option with a script:

Code: Select all
C:\Phantom>phantom.exe -?
Usage:
  phantom.exe [script] [-l count] [-o file] [-d] [script_args]

   [script]      - The Phantom script to run [optional]
   [-l count]    - Run the script 'count' times [optional]
   [-o file]     - Capture all output to 'file' [optional]
   [-d]          - Enter debug mode (enter 'help' in debug mode
                   for commands).  Requires [script]. [optional]
   [-?]          - Display this help message. [optional]
   [script_args] - Additional arguments to pass to the script [optional]

  Entering no arguments will start Phantom in console mode.


Type 'help' once in debug mode to get a list of debug commands:

Code: Select all
C:\Phantom>phantom.exe -d .\scripts\test.psc
FileName is: .\scripts\test.psc
    -----------------------------------------
    | Phantom v2.1                          |
    | ****://****.phantomtest.com            |
    | This DOS version is freeware          |
    | Type 'stop' to quit.                  |
    -----------------------------------------
DEBUG >>help
++++ Debug Commands ++++
<ENTER>    - Steps one line
v {var}    - Displays the value of variable {var}
g {#}      - Steps {#} lines
t {#}      - Runs to {#} line number
+b {#} {f} - Sets a breakpoint at line {#} in file {f}
-b {#} {f} - Removes a breakpoint at line {#} in file {f}
e {s}      - Evaluates statement {s}
j          - Jumps in to the current function
o          - Jumps out of the current function
q or stop  - Quits the script
verbose    - Toggles the verbose mode on and off
? or help  - Displays this help message
DEBUG >>g 1
DEBUG >>v i
10
DEBUG >>g 11
0
1
2
3
4
DEBUG >>v i
5
DEBUG >>e i = 10;
DEBUG >>v i
10
DEBUG >>g 10
10
Finished!


Below is an example of using the debugger on a simple script:

Code: Select all
C:\Phantom>phantom.exe -d .\scripts\test.psc
FileName is: .\scripts\test.psc
    -----------------------------------------
    | Phantom v2.1                          |
    | ****://****.phantomtest.com            |
    | This DOS version is freeware          |
    | Type 'stop' to quit.                  |
    -----------------------------------------
DEBUG >>g 1
DEBUG >>v i
10
DEBUG >>g 11
0
1
2
3
4
DEBUG >>v i
5
DEBUG >>e i = 10;
DEBUG >>v i
10
DEBUG >>g 10
10
Finished!


The test.psc script is:

Code: Select all
int i = 10;
for(i = 0; i < 10; i++){
    disp(i);
}
disp("Finished!");


Note that the PTD debugger can also still be used. This new feature is provided for script debugging when PTD is not installed or available.

We hope this helps! If you have any questions, please let me know.

-John
john
 
Posts: 27
Joined: Wed Apr 22, 2009 12:32 pm

Re: Debugging using the Phantom Command Line Interpreter

Postby CashCow on Fri Jul 20, 2012 10:35 am

It would be useful if this information was on the main "documentation" part of your site.

There does not appear any way to capture whether or not the process succeeded or failed, i.e. whether any errors occurred (within the script itself).

We don't use test suites because they are not text files, cannot be edited easily with a text editor and don't work well in source control.
We therefore want to run our scripts as a series of command line calls to .psc files. And we want to know if a test has failed so we can stop the run.

Capturing the output text and browsing for ** ERROR in it is not a great option.

The command line interpreter doesn't appear to "fail" when what it runs fail (i.e. exit with a value other than 0).
CashCow
 
Posts: 5
Joined: Wed Jul 04, 2012 9:07 am


Return to Phantom

Who is online

Users browsing this forum: No registered users and 4 guests

cron