3 A First Interaction

So, how can Ozcar actually be used? Consider the following small program:

local 
   S = 'hello' 
in 
   {Show S # ' world!'}
end

Attaching the Thread

Let's check how this code is executed by the virtual machine of mozart - step by step. The default behaviour of Ozcar is to ``catch'' all threads which are created by Emacs queries, so all you have to do in order to debug the code is to feed it in the normal way, for example using the Emacs function oz-feed-paragraph (C-c C-p). You will see Ozcar printing the following:


Picture 3.1: The main window after feeding the program


First, you are informed by the status line that there has been attached a new thread with thread number 53, and this thread was selected automatically. In the thread forest window, you see a node, labeled with the thread number, and tagged with an asterix.

Checking the Environment

The thread has been stopped directly after its creation, so the stack window displays a single stack frame, containing the first application of the program, S = 'hello', which is, translated into core syntax, {Value.'='_ hello}. The variable name seems to be lost, and in fact, it is, at least in the stack window. But, there is no need to despair, we have our variable windows, and indeed, the variable S can be found in the local environment, still unbound (visualized by the underscore char). The right arrow at the beginning of the line in the stack window means: You are about to apply the function, but you haven't yet! The number beside the arrow means: This is stack frame number one.

In Emacs, the source line which contains {Value.'='_ hello} is highlighted, like this:


Picture 3.2: Emacs shows the exact position of the stopped thread


Single Stepping

Now, how can we apply the function Value.'='? One way is to use the mouse, clicking on the button in the top left corner of the main window. This activates the function ``step into'', which would enter the body of the current application. But since ``Value.'=''' is a primitive procedure with an implementation in C++, there is no visible body and thus, execution stops again directly after leaving the application, detectable by the left arrow at the beginning of the stack frame line.

Detaching the Thread

You can click another two times on the button to apply also the ``Show'' application. Finally, the stack is empty, and the thread terminates. You see the thread's node in the thread view changing it's color to grey. To detach the thread, simply click on the button.


Benjamin Lorenz
Version 1.2.5 (20040201)