Sophie

Sophie

distrib > Mandriva > 8.1 > i586 > by-pkgid > 700475c8ae73fb4d57b6df4485c29e1c > files > 177

slang-doc-1.4.4-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
 <TITLE> A Guide to the S-Lang Language: Debugging</TITLE>
 <LINK HREF="slang-18.html" REL=next>
 <LINK HREF="slang-16.html" REL=previous>
 <LINK HREF="slang.html#toc17" REL=contents>
</HEAD>
<BODY>
<A HREF="slang-18.html">Next</A>
<A HREF="slang-16.html">Previous</A>
<A HREF="slang.html#toc17">Contents</A>
<HR>
<H2><A NAME="s17">17. Debugging</A></H2>

<P> 
<P>The current implementation provides no support for an interactive
debugger, although a future version will.  Nevertheless, <B>S-Lang</B> has
several features that aid the programmer in tracking down problems,
including function call tracebacks and the tracing of function calls.
However, the biggest debugging aid stems from the fact that the
language is interpreted permitting one to easily add debugging
statements to the code.
<P>To enable debugging information, add the lines
<BLOCKQUOTE><CODE>
<PRE>
    _debug_info = 1;
    _traceback = 1;
</PRE>
</CODE></BLOCKQUOTE>

to the top of the source file of the code containing the bug and the
reload the file.  Setting the <CODE>_debug_info</CODE> variable to
<CODE>1</CODE> causes line number information to be compiled into the
functions when the file is loaded.  The <CODE>_traceback</CODE> variable
controls whether or not traceback information should be generated.
If it is set to <CODE>1</CODE>, the values of local variables will be
dumped when the traceback is generated.  Setting this variable
to <CODE>-1</CODE> will cause only function names to be reported in the
traceback.
<P>Here is an example of a traceback report:
<BLOCKQUOTE><CODE>
<PRE>
    S-Lang Traceback: error
    S-Lang Traceback: verror
    S-Lang Traceback: (Error occurred on line 65)
    S-Lang Traceback: search_generic_search
      Local Variables:
        $0: Type: String_Type,  Value:  "Search forward:"
        $1: Type: Integer_Type, Value:  1
        $2: Type: Ref_Type,     Value:  _function_return_1
        $3: Type: String_Type,  Value:  "abcdefg"
        $4: Type: Integer_Type, Value:  1
    S-Lang Traceback: (Error occurred on line 72)
    S-Lang Traceback: search_forward
</PRE>
</CODE></BLOCKQUOTE>

There are several ways to read this report; perhaps the simplest is
to read it from the bottom.  This report says that on line <CODE>72</CODE>,
the <CODE>search_forward</CODE> function called the
<CODE>search_generic_search</CODE> function.  On line <CODE>65</CODE> it called the
<CODE>verror</CODE> function, which called <CODE>error</CODE>.  The
<CODE>search_generic_search</CODE> function contains <CODE>5</CODE> local variables
and are represented symbolically as <CODE>$0</CODE> through <CODE>$4</CODE>.
<P>
<P>
<P>
<HR>
<A HREF="slang-18.html">Next</A>
<A HREF="slang-16.html">Previous</A>
<A HREF="slang.html#toc17">Contents</A>
</BODY>
</HTML>