![]() |
femtolisp: debugging, testing and common tasks | ![]() |
An error which reaches the C++ code is reported with the error of femtolisp and its stack. With TEXMACS_FL_TRACE=catch, the errors caught by catch are reported too: many are expected, since TeXmacs tests things inside catch.
Checks every tmscm of the list of roots at each collection. Use it when a crash looks like a value which moved.
Times the reading, the expansion and the compilation of the loaded files. (%profile-report) prints the totals and the hits of the cache, (%profile-heads-report) the expansion time by the first symbol of the forms, (%lazy-report) the number of stubs and of first calls.
Runs without the caches of compiled code.
Expands and compiles the function bodies when a file is loaded, with the late calls and the deferred errors of macros.
The size of each half of the heap at start, in MB.
Also (%gc-count), the number of collections so far, (%gc) and (%heap-size).
The stack printed with TEXMACS_FL_TRACE lists the calls with their arguments, the innermost first: at most 20 frames, with long arguments cut. A function which was left by a tail call does not appear. A frame (lambda …) is a function without a name, such as a function made by tm-define. A let has no frame: its variables are in the frame of its function (patch 0035), and do not appear. An argument which a closure captures and which is assigned shows as its box, a list of one element (patch 0034). A private function shows under its plain name f, not f@a/b: only the global variable which holds it is renamed. A frame (%lazy-compile (lambda …) …) means that the error came while a body was being compiled at its first call: the error is in that body, often a macro which failed to expand, and the function is the frame which follows, with its arguments in one list.
The name may be private to another module, or defined later than its use at the top level of a file. Look for f@… in (environment).
Often the reader: an octal character of Guile, #\04, is read as two data.
A raw fltm_value kept across an allocation, or a longjmp over a C++ function. Run with TEXMACS_FL_CHECK_ROOTS=1.
A macro at the top level of a file with an effect when it is expanded.
It should not happen: the caches follow the expansion of each form. If it does, run with TEXMACS_FL_NO_CACHE=1 to tell whether the cache is the cause, and see whether %cache-format should have been increased.
;; the source of a function, called or not
(procedure-source f)
;; its bytecode (that of a stub before its first call)
(disassemble f)
;; a private function of the module (a b)
(top-level-value (symbol "f@a/b"))
;; the private names of a module
(module-symbols (resolve-module '(a b)))
;; the late calls, with TEXMACS_FL_TRACE and TEXMACS_FL_EAGER
(%late-calls) |
write shows a function as #<procedure f>; bind *print-closures* to #t to see its code and constants.
TEXMACS_PATH=$PWD/TeXmacs TEXMACS_HOME_PATH=<a scratch directory> \
TeXmacs/bin/texmacs.bin -headless -x '(exit (catch #t
(lambda () (min 1 (run-all-tests)))
(lambda args (display* "error: " args "\n") 2)))' -q |
runs the regression suites of
progs/check
with the Vue interface, which needs -headless to run without a window (
tests/scheme/check.sh
does not pass it; with a Qt build, use that script with QT_QPA_PLATFORM=offscreen). The option -q must come after -x: the options are run in their order, and -q first would quit before the tests. (run-regression-suite "name") runs one suite. With femtolisp, two suites have failing checks (three in all, two of them in graphics-edit), which are not bugs of the interface:
htmltm: a width of 50% gives 0.5par where Guile gives 1/2par (no exact rationals);
graphics-edit: the order of the attributes of a with comes from the order of a hash table.
Run the suites twice with the same scratch directory: the first run fills the caches of compiled code, the second one uses them. A change of
boot-femtolisp.scm
should be tested both ways, and with TEXMACS_FL_EAGER=1. The two suites boot-s7 and compat-s7 are for S7 and do not run with femtolisp.
The benchmarks are the scripts of
docs/s7/bench
and
docs/femtolisp/bench/ui.scm
, run on several builds by
docs/femtolisp/bench/run.sh
. Compare builds by alternating them on the same machine, and take the times without a profiler: sampling slows femtolisp more than S7.
Define it in
compat-femtolisp.scm
with define-public, after checking that the glue does not define it. If the name is a builtin of femtolisp with another meaning, use define-override in
r5rs-femtolisp.scm
.
For a function of TeXmacs, add it to the glue, as for the other interpreters. For a function which only femtolisp needs, write it in
fl_core.c
with the signature of the builtins of femtolisp and add it to fltm_builtin_info; there, an error is raised with the functions of femtolisp (type_error, bounds_error, argcount; lerrorf for the others), since no C++ is involved.
Keep it in a tmscm (or an object), never in a fltm_value.
Its expansion must not register anything: return code which does it. The expansion must not contain a call of the macro itself with the same arguments.
The code is in
boot-femtolisp.scm
. Increase %cache-format if the same expansion now compiles to other code, test with and without the caches, and measure a boot with TEXMACS_FL_PROFILE=1.