Next Previous Contents

15. Debugging Functions

15.1 _clear_error

Synopsis

Clear an error condition

Usage

_clear_error ()

Description

This function may be used in error-blocks to clear the error that triggered execution of the error block. Execution resumes following the statement, in the scope of the error-block, that triggered the error.

Example

Consider the following wrapper around the putenv function:

    define try_putenv (name, value)
    {
       variable status;
       ERROR_BLOCK
        {
          _clear_error ();
          status = -1;
        }
       status = 0;
       putenv (sprintf ("%s=%s", name, value);
       return status;
    }
If putenv fails, it generates an error condition, which the try_putenv function catches and clears. Thus try_putenv is a function that returns -1 upon failure and 0 upon success.
See Also

_trace_function, _slangtrace, _traceback

15.2 _slangtrace

Synopsis

Turn function tracing on or off.

Usage

Integer_Type _slangtrace

Description

The _slangtrace variable is a debugging aid that when set to a non-zero value enables tracing when function declared by _trace_function is entered. If the value is greater than zero, both intrinsic and user defined functions will get traced. However, if set to a value less than zero, intrinsic functions will not get traced.

See Also

_trace_function, _traceback, _print_stack

15.3 _trace_function

Synopsis

Set the function to trace

Usage

_trace_function (String_Type f)

Description

_trace_function declares that the S-lang function with name f is to be traced when it is called. Calling _trace_function does not in itself turn tracing on. Tracing is turned on only when the variable _slangtrace is non-zero.

See Also

_slangtrace, _traceback

15.4 _traceback

Synopsis

Generate a traceback upon error

Usage

Integer_Type _traceback

Description

_traceback is an intrinsic integer variable whose value controls whether or not a traceback of the call stack is to be generated upon error. If _traceback is greater than zero, a full traceback will be generated, which includes the values of local variables. If the value is less than zero, a traceback will be generated without local variable information, and if _traceback is zero the traceback will not be generated.

Local variables are represented in the form $n where n is an integer numbered from zero. More explicitly, $0 represents the first local variable, $1 represents the second, and so on. Please note that function parameters are local variables and that the first parameter corresponds to $0.

See Also

_slangtrace, error


Next Previous Contents