The functions in this section are primarily intended for debugging
foreign extensions or embedded Prolog. Violating the constraints of the
foreign interface often leads to crashes in a subsequent garbage
collection. If this happens, the system needs to be recompiled with the
cflags -DO_DEBUG
. This is normally achieved by editing
src/Makefile
and changing the definition of COFLAGS
to the value below. The -gdwarf-2 -g3
provides detailed
debugging information for gcc. If you use another C compiler you
may need other flags.
COFLAGS=-DO_DEBUG -gdwarf-2 -g3
After recompiling the Prolog kernel all functions listed above are available to use from the debugger (e.g. gdb) or can be placed at critical location in your code or the system code.
user_error
stream. Depth
is the number of frames to dump. Flags is a bitwise or of the
following constants:
(gdb) printf "%s", PL_backtrace_string(25,0)
The source distribution provides the script scripts/swipl-bt
that exploits gdb and PL_backtrace_string()
to print stack traces in various formats for a SWI-Prolog process, given
its process id.
TRUE
this is actually implemented in the current version and
FALSE
otherwise. The actual implementation only exists if
the system is compiled with the cflag -DO_DEBUG
or
-DO_MAINTENANCE
. This is not the default.TRUE
this is actually implemented in the current
version and FALSE
otherwise. The actual implementation only
exists if the system is compiled with the cflag -DO_DEBUG
or
-DO_MAINTENANCE
. This is not the default.
The Prolog kernel sources use the macro DEBUG(Topic, Code).
These macros are disabled in the production version and must be enabled
by recompiling the system as described above. Specific topics can be
enabled and disabled using the predicates prolog_debug/1
and
prolog_nodebug/1.
In addition, they can be activated from the commandline using
commandline option -d topics
, where
topics is a comma-separated list of debug topics to enable.
For example, the code below adds many consistency checks and prints
messages if the Prolog signal handler dispatches signals.
$ swipl -d chk_secure,msg_signal
src/pl-debug.h
. Please search the sources to find out what
is actually printed and when. We highlight one topic here: