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 compiled for
debugging using cmake -DCMAKE_BUILD_TYPE=Debug
, after which
all functions and predicates listed below 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:
These predicates require the system to be compiled for debugging
using
cmake -DCMAKE_BUILD_TYPE=Debug
.
These functions require the system to be compiled for debugging using
cmake -DCMAKE_BUILD_TYPE=Debug
.