There are some errors that occur very often in CA programs. Some, such as passing the wrong number of arguments to a method, will be caught by the runtime system; however, there are some that the debugger provides special support for detecting.
A hanging context is one that is waiting for reply that will never come. The most common way for this to happen is when the reply statement is left out of a method, and then its caller will wait forever for the reply which does not exist. Hanging contexts are always errors, and leaving the reply statement off a method is a fairly common error. Hence, The Concert Debugger provides a commands to view these contexts, which are detailed below.
- hanging
- show a list of the hanging contexts in the system.
- hung
- choose a hanging context to be the current context.
For example, the following program will produce hanging contexts because the reply was left out of the drunk function. Thus, the drink method will hang, waiting for a reply from drunk forever. The initial_messagewill hang too, but it, until sober returns, it will have some replies that will come back, and the debugger cannot always detect it as hanging until that ceases to be true.
(function rootclass drunk (i)
(+ i 9))
(function rootclass drink (i)
(reply (drunk i)))
(function rootclass sober (i)
(reply (+ i 7)))
(method initial_message ()
(sequential
(concurrent
(drink 5)
(sober 5))
(reply done)))
Figure three illustrates the context forest created by this program. Once the leaf drunk terminates, the drink function will still be waiting for a reply that will never come. And once the sober function terminates, the initial_messageand drink will wait forever.
Because the CA system functions are all defined in the standard prologue, it is possible to set breakpoints in them, not just in the user code. This can be helpful for finding certain types of error. For example, the sibling method for aggregates is defined in the standard prologue, so you can put a breakpoint in that method to catch sibling bounds errors.
The standard prologue is an integral part of the Concert system, and it can be found in the CONCERT_ROOT_PATH/lib/standard-prologue.ca file. While breakpoints can be set in this file, it must not be modified in any way, as this can cause problems for the Concert system.