Getting Started: Command Line Interaction


 

Since gbeta is biased towards language design and semantics, the support for observation of program executions has a high priority. When running interactively, i.e. when giving the -i option:

gbeta -i ...

the execution stops at the first statement of the program, and you can investigate what is going on much like in a source level debugger. You can print the state of objects, execute ad-hoc statements, and retrieve static analysis information about program elements, e.g. the statically known type of a reference attribute. Moreover, you can control the program execution by single-stepping, setting breakpoints, and running the program.

Starting an interactive session

Try to execute the program hello2.gb interactively:

gbeta -i hello2

The program looks like this:

 
(* FILE hello2.gb *)
-- betaenv:descriptor --
(# s: @string;
   hello: (# exit 'Hello' #)
do 'world!'->s;
   hello+', '+s->stdio
#) 

When gbeta starts executing this program interactively, you will have the usual startup message, and then:

 
====================
(#`196
   s: @string;
   hello: (#`74
      exit 'Hello'
      #)
do 'world!'->s;
   hello+', '+s->stdio
#)
====================

executing~1> _ 

The source code surrounding the currently executing imperative (statement) is pretty-printed before the interactive prompt "executing~1> _". Depending on the capabilities of the terminal, the exact imperative to execute next is emphasized one way or another, in this case by an underlined and bold font. The -c option is used to select other color coding schemes; in particular, option -cc selects the most expressive one using ISO 6429 color escape sequences. This is also an ANSI standard, and it is often used e.g. under Linux to show color coded directory listings.

The interactive prompt

There are two different interactive prompts, namely "terminated> _" and prompts like "executing~1> _". The first one indicates that no threads are currently executing. In this situation many commands are disabled, but the program can e.g. be started with run or step.

The second kind of prompt, "executing~1> _", indicates that the program is currently being executed, and it specifies the identifying number for the thread which is the current run-time context. For programs without concurrency, the thread number is always one. For programs with concurrency it is nice to know just what thread was trapped at a given breakpoint..

After these preparations, the next section deals with the actual executing of the program.

 


Signed by: eernst@cs.auc.dk. Last Modified: 3-Jul-01