4 Sample Debugging Session

In the following, we will perform a first sample session to get a feeling of how threads behave under the control of Ozcar. For this, we'll use the following small program:

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

Attaching the Thread

Let's check how this code is executed - step by step. By default, Ozcar attaches all threads created by feeding code in the OPI, so this is what we're going to do, for example using oz-feed-paragraph (C-. C-p). Ozcar responds as shown in Picture 4.1.


Picture 4.1: The Main Window after Feeding the Program


The status line informs us that a new thread with ID 53 has been attached, and it was immediately selected. Accordingly, the thread forest contains a singleton tree with a node labeled 53 and marked with an asterisk.

Stack and Environment

The thread has been stopped immediately after its creation, so the Stack View displays a single frame, containing the first application in the program, S = 'hello', which, expressed in Oz core syntax, corresponds to {Value.'=' _ hello}. Instead of the variable name the variable's value is displayed in the Stack View (where the underscore stands for a logic variable). If we explicitly needed to check what the value of S is, we could look it up in the Local Variables View.

Source View

If we look over to Emacs, we'll find that the source line which corresponds to {Value.'=' _ hello} is highlighted, as shown in Picture 4.2.


Picture 4.2: Emacs Showing the Position of the Stopped Thread


Single-Stepping

The right arrow at the beginning of the current stack frame means: We are about to apply the function, but we haven't yet! One way to do this is to use the Step Into () action, which continues execution, but only until the next stop within the body of the applied procedure. In this case, Value.'=' is a primitive procedure, which is why execution only stops when the application returns, indicated by the arrow in the stack frame turning into a left arrow. Note also that the arguments of the procedure have been updated.

Detaching the Thread

Performing the Step Into action another two times, we also evaluate the application of the primitive procedure Show, after which the stack becomes empty, and the thread terminates. Accordingly, the thread's node in the thread forest turns gray. We'll now detach this thread using the Detach () action.


Benjamin Lorenz and Leif Kornstaedt
Version 1.4.0 (20080702)