Trace facility

C Scripting Language
Reference Manual
Version 4.4.0

<< Back  End  Next >>
 
 
INDEX
Introduction
Installation
Using the CSL executive
Language
   Comments
   Numbers
   Literals
   Var and const
   Operators
   Statements and blocks
   Program flow
   Trace facility
   Exception handling
   Functions
   Predefined identifiers
Directives
System library
String library
Math library
Regular expression lib.
File library
Database library
Async Communication
Registry/Profile handling
Windows control
C API
C++ Class Interface
CSL links
  

The trace facility allows tracing of p-code (the interpreted meta-code), function and block entry/exit, and expressions/messages. Trace output is sent to stderr and so can be redirected to a file in case. Trace facility is made up by a set of elements:

Example (trace.csl):

#loadLibrary 'ZcSysLib'
 
test(const &arr[])
{
  var evens = 0, odds = 0;
  for (var i = 0; i < sizeof(arr); i++) {
    #block 'for block'
    trace 'value = '|arr[i];
    if (arr[i] % 2) {
      #block 'odd branch'
      odds++;
      trace 'odds = '|odds;
    } else {
      #block 'even branch'
      evens++;
      trace 'evens = '|evens;
    }
  }
}
 
main()
{
  sysTrace(sysTraceCode);
  const vals = { 3, 12, 17 };
  sysTrace(sysTraceInfo);
  test(vals);
  sysTrace(sysTraceNone);
}

Output when run:

#
#trace.csl: var main()
#
#address  opcode parameter            tos                  tos-1
#-------- ------ -------------------- -------------------- --------------------
#       3 pop                         1                    <stack bottom>
#       4 push                        <stack bottom>
#       5 push   vals[3]                                   <stack bottom>
#       6 allc                        vals[3]
#       7 push   3                    <stack bottom>
#       8 push   vals[0]              3                    <stack bottom>
#       9 storc                       vals[0]              3
#      10 push   12                   <stack bottom>
#      11 push   vals[1]              12                   <stack bottom>
#      12 storc                       vals[1]              12
#      13 push   17                   <stack bottom>
#      14 push   vals[2]              17                   <stack bottom>
#      15 storc                       vals[2]              17
#      16 push   14                   <stack bottom>
#      17 push   1                    14                   <stack bottom>
#      18 call   sysTrace             1                    14
-ZcSysLib: var sysTrace([const mode])
+trace.csl: var test(const &arr[])
 +for block
  >value = 3
  +odd branch
   >odds = 1
  -odd branch
 -for block
 +for block
  >value = 12
  +even branch
   >evens = 1
  -even branch
 -for block
 +for block
  >value = 17
  +odd branch
   >odds = 2
  -odd branch
 -for block
-trace.csl: var test(const &arr[])
+ZcSysLib: var sysTrace([const mode])
  Copyright © IBK Landquart Last revision: 27.05.2002 << Back  Top  Next >>