Next: The Concert Interpreter Up: The Concert Debugger Users Previous: Interrupting Program Execution

Examining Program State

A Concert program's state consists of two parts: the states of whatever objects exist and the states of the method invocations are active upon them. The Concert Debugger represents the method state as a context, which is the activation frame for that method. These contexts are organized as a forest (a collection of trees) where each context is the child of the method that invoked it. The Concert Debugger has a notion of the current context, which is analogous to the current stack frame in The GNU Debugger ; the current context is generalized to be either a method invocation or an object.

Viewing a Context

When the current context is a method invocation, typing ``concert current'' within The Concert Debugger prints the current context. This will display the context's address (which is used as its name), the method it is running and the object class with which the method is associated. It also displays the arguments that were passed in the message that invoked the context. The ``offset'' provided below is the current program counter of the method, as a character position in CA file. Emacs will automatically load the source file and show this position. Also, all currently bound local variables will be displayed. The output will look like the following:


(cadb) concert current
(dd558) handler counters add (val = <int:2>)
 at /home/chien/dolby/ca/programs/party.ca, offset = 1137
        local_var_a = 8
              var_b = 9
                buf = <object:0,16b40>

There is also a concert show backtrace command that prints the method call chain that resulted in the current method being invoked. It goes back to a ``root'' method that will be explained later.


(cadb) concert show backtrace
(dd558) handler counters add (val = <int:2>)
(1a44b) function rootclass add_fun (val = <int:2>)
(aa44c) method osystem initial_message ()

Viewing an Object

When the current context is an object, typing ``concert current'' will display that object; the object's name and class are printed and it is noted whether or not the object is an aggregate representative. Also, the current values of all of the object's instance variables is printed, along with their names. For example,


(cadb) concert current 
(4b2210) object of class tiny_buffer
       loc = <object: 1,8de010>
 full_flag = 0

The only other state an object has is the methods that are currently executing on it or blocked waiting for its lock. A list of all such methods is available by typing ``concert methods'' to view them, or ``concert method'' to select one as the current context.


(cadb) concert method
0> (d1e210) method tiny_buffer put (i = 7)
1> (d1e410) method tiny_buffer isfull ()

select appropriate number: 1

The Context Forest

The context forest, as described above, represents the state of execution of a CA program. Any method invoked by another method is considered a child of the originating method, as long as the message send was synchronous. For asynchronous message sends, the new method is considered to be a whole new thread of execution, and its context is inserted at the root of the context forest. All currently executable contexts form the leaves of the forest, and the initial_messageand all asynchronous invocations make up the roots.

The following example programs and figures illustrate this notion. The first program uses only synchronous message sends, so the ``forest'' is actually a tree. The second example illustrates the effect of asynchronous (using the ``do'' construct) messages.


(function integer fib (i)
  (if (< i 2)
     (reply 1)
    (reply (+ (fib (- i 1)) (fib (- i 2))))))

(method osystem initial_message ()
  (reply (fib 2)))

This program could produce the graph shown in 1figure one at a certain point in the computation. The leaves are dashed, and the root is the initial_message.

A more complicated program produces a correspondingly more complex context forest. The following program uses asynchronous messages, which result in multiple roots of the context forest.


(function integer print_fib (i)
  (fib_value_is (global console) i (fib i)))

(method osystem initial_message ()
  (sequential
   (forall i from 1 below 3
     (do (print_fib i)))
   (reply done)))

This is shown in figure two, where the multiple root nodes generated by the asynchronous message sends are in square boxes.

Traversing the Context Forest

Navigating this context forest is analogous to walking the function call stack of a sequential language, except that there can be multiple ways to move ``down'' the chain. The Concert Debugger provides commands for accessing the leaves and the roots directly, and for moving up and down the forest. These commands are given below. To enter them in The GNU Debugger , use the prefix ``concert'' in front of each command; Emacs-Cadb has keys mapped to these commands, a summary of which is at the end of this document. The following commands choose an absolute position in the context forest.

leaves
to show all of the leaves in the context forest.
leaf
to choose one of the leaves as the current context.
roots
to show all of the roots in the context forest.
root
to choose one of the roots as the current context.

The following commands are used for navigating the context forest; all of them can be used with the concert show and concert goto commands. When used with show, they print out all available options; when used with goto, they change the current context, possibly prompting for a choice from a menu of options.

parent
for the current context's parent.
object
for the objects associated with the current context
child
for the child methods of the current context.

Note that the commands above are the, in so far as is possible, the same as those of the emulator. Examples of this output are shown below, using the second of the two examples given above.


(cadb) concert leaf
analyzing program state...done
a> (1abb8) function integer fib (i = <int:1>)
b> (1abd0) function integer fib (i = <int:1>)
c> (1abe0) function integer fib (i = <int:0>)
d> (1abe8) method osystem initial_message ()

choose appropriate letter: c

(cadb) concert current
(1abe0) function integer fib (i = <int:0>)
 at "/home/chien/dolby/ca/programs/fib/fib.ca", offset = 135
    token_let_var = 8;

(cadb) concert up

(cadb) concert current
(1abf8) function integer fib (i = <int:2>)
 at "/home/chien/dolby/ca/programs/fib/fib.ca", offset = 210
    token_let_var = 3;

(cadb) concert children
analyzing program state...done
a> (1abd0) function integer fib (i = <int:1>)
b> (1abe0) function integer fib (i = <int:0>)



Next: The Concert Interpreter Up: The Concert Debugger Users Previous: Interrupting Program Execution


Julian Dolby
Concurrent Systems Architecture Group