Cicode Programming Reference > Cicode Function Categories > Miscellaneous Functions Introduction > CodeTrace


Traces Cicode into the Kernel and the SYSLOG.DAT file. Use this function for finding bugs in your Cicode. It will trace the functions called, the arguments to those functions, and their return values. It will also trace any errors, writes to the I/O devices, and task state changes.

Note: Use this function only during system development; it can cause excessive loading on the CPU.



Only use the CodeTrace() function during system development and testing. This function is not intended for use in an operational system.

Failure to follow these instructions can result in death, serious injury, or equipment damage.


CodeTrace(hTask, nMode)


The Cicode task handle as returned from TaskHnd() function or any of the following special values:

0 - Foreground Cicode.

-2 - The next created task.

-3 - New created tasks.

-4 - All tasks.


The mode of the trace:

0 - Tracing off

1 - Trace user Cicode functions calls

2 - Trace built-in function calls

4 - Trace errors

8 - Trace writes to the I/O devices

16 - Trace task state changes

-1 - All modes (except 0)

Return Value

0 (zero) if successful, otherwise an error is returned.

Related Functions

Assert, TaskHnd, DebugMsg, DebugMsgSet, TraceMsg, ErrLog


// Start tracing errors
CodeTrace(TaskHnd(), 4);
// Stop tracing
CodeTrace(TaskHnd(), 0);
// trace functions in new task
CodeTrace(-2, 1 + 2);
TaskNew("MyFunc", "data", 0);

See Also

Miscellaneous Functions