# 2 Invoking the Debugger

There are several ways to start Ozcar: from the Oz Programming Interface, during interactive development; and from the shell, to debug standalone applications. Furthermore, an API is provided to enable user applications to control the debugger.

Startup Effects

When Ozcar is started, the following actions will be performed:

- The interaction window is opened.

- Concurrent threads are observed: When a thread reaches a breakpoint or raises an unhandled exception, the debugger takes control of this thread. This is called attaching a thread.

- When running under the OPI, the compiler's switches are configured to generate code with debug information.

## 2.1 Debugging within the Oz Programming Interface

Ozcar can directly be started from the OPI using the Oz menu. This executes the Emacs command `oz-debugger` (see also Chapter 5 of ``The Oz Programming Interface''), which is also bound to the key sequence C-. C-. d by default. Any code you feed within the OPI will now run under control of the debugger.

Suspending Ozcar

With a prefix argument (C-u C-. C-. d), Ozcar is suspended and its window is closed. Note that this means that all attached threads remain under the control of the debugger (but no new threads will be attached). Starting Ozcar again will allow you to continue debugging exactly where you stopped.

## 2.2 Debugging Standalone Applications

It is also possible to run standalone applications under control of the debugger. For this purpose, the `ozd` application is provided (which, incidentally, is itself an Oz application). For instance, to debug an application `foo`, run `ozd` as follows:

> `ozd -E foo --` args

This invokes Ozcar, with an associated Emacs for source handling (since the `-E` option was given), and attaches the main thread of the application `foo`.

Command Line Options

For more information on `ozd`'s command line options, refer to Chapter 4 of ``Oz Shell Utilities''.

## 2.3 Invoking Ozcar through its API

Ozcar is implemented as an Oz functor and as such is immediately available to the application programmer. After importing the module `Ozcar` from its URL `x-oz://system/Ozcar`, Ozcar can be opened by `{Ozcar.open}` and suspended again by `{Ozcar.close}`. A detailed description of the API is given in Appendix B.