GNU TeXmacsUser manualReferenceAboutEnglish
Debugging, known issues and limitations

1.Debugging the machinery

The basic techniques for debugging a plug-in (running the helper program by hand, checking the detection, using the standard error) are described in debugging plug-ins. This section lists the additional tools which are useful when the problem is in the connection machinery itself.

1.1.Debugging flags

The flags are set on the command line (-debug-io), in the Debug menu (available after enabling Tools\(\rightarrow\)Debugging tool), or from Scheme with (debug-set "io" #t); they correspond to the C++ macros DEBUG_IO, DEBUG_AUTO and DEBUG_VERBOSE of

Kernel/Abstractions/basic.hpp

.

io

The POSIX pipe link prints every chunk it receives and, preceded by [INPUT], every string it sends, with the control characters shown as [BEGIN], [END], [ESCAPE], [COMMAND] and [ABORT] (debug_io_string). The Qt pipe link does the same, but prefixes each received chunk with [OUTPUT n], where n is the QProcess channel (0 for the standard output, 1 for the standard error). After each complete output (the closing DATA_END of the outermost block), connection_rep::read prints a horizontal rule. Command line links print the command they launch, request links the request, and the output parser reports output which it ignored because of a DATA_ABORT.

auto

Pipe links print the launch command, and dynamic links the result of symbol_install.

verbose

connection_start prints Starting session 'ses' whenever it creates a connection.

1.2.Inspecting the state from Scheme

In a Scheme session, the state of a connection can be inspected with the glue functions and the exported functions of the request queue, for instance:

(connection-info "maxima" "default") ; launcher description
(connection-status "maxima" "default") ; 0, 2 or 3
(length (pending-ref "maxima" "default")) ; queued requests
(plugin-prompt "maxima" "default") ; last prompt

A session which is stuck (status 3 with a non-empty queue) can be reset with Interrupt execution (which empties the queue even if the program does not react) followed by Close session. The display* calls which are commented out at the beginning of the call-backs in

plugin-eval.scm

and

session-edit.scm

are a convenient way to trace the scheduler.

The protocol can also be exercised without any program: a launcher such as

printf '\002verbatim:hello\n\002prompt#> \005\005'; cat > /dev/null

prints a banner and a prompt and then waits forever. With Qt pipes, this has to be wrapped as sh -c "…", see below.

1.3.Typical symptoms

The session stays busy forever

The outermost block was not closed, or the program did not flush its standard output after the final DATA_END. If this already happens right after the creation of the session, the banner is the culprit: as long as the start request is not complete, all evaluations stay in the queue. Another cause is a launch failure with Qt pipes (see below).

Outputs are shifted by one request

The program closes more than one outermost block per request, for instance by sending the prompt as a separate block after the output instead of nesting it inside. If the second DATA_END arrives after the next request was sent, it terminates that request prematurely.

Output appears in bursts

The program writes to a pipe and therefore uses block buffering; it must flush its output. This is invisible when the program is tested in a terminal.

Output is lost after an interrupt

See the race described below.

A custom channel never shows up

Channels other than output, error, prompt and input are only delivered to handlers declared with :handler, and the table of handlers is cached on first use.

2.Known issues

The following problems are visible in the current sources. The first three are already known upstream.

2.1.Socket connections are not implemented

The :socket option produces a launcher description (tuple "socket" host port), but connection_start has no branch for it, and the socket functions declared in

tm_link.hpp

are not defined (see sockets). Worse, when connection_start is called for the first time with a description which matches none of its branches, the variable con is still the nil connection when the code reaches con->info= t, which dereferences a null pointer.

2.2.Startup of dynamic links is keyed by the plug-in name

connection_rep::start only reads the startup message of a link immediately if the plug-in is called dynlink, the name of the example plug-in in

src/TeXmacs/examples/plugins/dynlink

:

if (name == "dynlink") {
  this->listen ();
  status = WAITING_FOR_OUTPUT;
}

For any other plug-in with a :link option, dynamic links being neither polled nor connected to notifiers, the startup message is never read, the connection never reports that it is waiting for input, and the start request of the session is never completed. The test should be on the type of the link (the launcher description (tuple "dynlink" …)) rather than on the name of the plug-in.

2.3.The :prioritary option has no effect

The value of :prioritary is stored in the plug-in cache, but it is read before the cache is loaded; see known limitations in the description of the plug-in internals.

2.4.Further problems

3.Design limitations

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".