Method trace()

Method trace

int trace(int level, void|string facility, void|int all_threads)


This function changes the trace level for the subsystem identified by facility to level. If facility is zero or left out, it changes the global trace level which affects all subsystems.

Enabling tracing causes messages to be printed to stderr. A higher trace level includes the output from all lower levels. The lowest level is zero which disables all trace messages.

See the -t command-line option for more information.

Parameter level

If facility is specified then there is typically only one trace level for it, i.e. it's an on-or-off toggle. The global trace levels, when facility isn't specified, are:


Trace calls to Pike functions and garbage collector runs.


Trace calls to builtin functions.


Trace every interpreted opcode.


Also trace the opcode arguments.

Parameter facility

Valid facilities are:


Trace the doings of the garbage collector. The setting is never thread local. level has two different meanings:


Trace the start and end of each gc run.


Additionally show info about the collected garbage, to aid hunting down garbage problems. This currently shows gc'd trampolines. Note that the output can be very bulky and is somewhat low-level technical. Also note that pike currently has to be configured with --with-rtldebug to enable this.

Parameter all_threads

Trace levels are normally thread local, so changes affect only the current thread. To change the level in all threads, pass a nonzero value in this argument.


The old trace level in the current thread is returned.