Flowlog CLI and REPL (flowlog.c)

This document describes the Flowlog command-line interface and REPL behavior for the binary built from flowlog.c.

The Flowlog binary is:

Code references (section markers in flowlog.c):

CLI usage

Show help (SUBSECTION 26.1):

./flowlog --help

Show version (SUBSECTION 26.1):

./flowlog --version

Interactive REPL (default)

Empty program:

./flowlog

Load a program and enter REPL:

./flowlog program.pl

You can also use the explicit file flag:

./flowlog -f program.pl

Run a one-shot query

./flowlog program.pl -g "goal."

Query against an empty program:

./flowlog -g "goal."

Thread count

Override the worker-thread count:

./flowlog --threads 12 program.pl -g "goal."

Aliases accepted by the binary:

Engine selection

Select the execution engine (SUBSECTION 26.1):

./flowlog --engine wamvm program.pl -g "goal."

Values:

If wam or wamvm is requested but Flowlog falls back to the interpreter, it prints a warning to stderr by default (SECTION 24). Disable this warning with:

To ensure the wamvm engine does not fall back to the WAM-lite solver for unsupported programs/queries, set (SECTION 24):

You can also introspect which engine actually ran a query (SECTIONS 22/23/24):

?- current_prolog_flag(flowlog_engine_active, Engine).

Parallel profile

Select a parallelism profile (equivalent to set_prolog_flag(flowlog_parallel_profile, ...)) (SUBSECTION 26.1 and SECTIONS 22/23/24):

./flowlog --parallel-profile fast program.pl -g "goal."

Values:

Defaults (unless your program overrides flags with :- set_prolog_flag/2 directives):

Tracing

Enable Prolog-style trace ports (CALL/EXIT/REDO/FAIL) on stderr (SUBSECTION 26.1):

./flowlog --trace program.pl -g "goal."

Enable internal (C/VM) tracing on stderr (SUBSECTION 26.1):

./flowlog --itrace program.pl -g "goal."

Only emit internal trace lines when C stack usage reaches a new peak (SUBSECTION 26.1 and SECTION 06):

./flowlog --itrace-watermark program.pl -g "goal."

Throw a catchable exception before a hard C-stack SIGSEGV overflow (SUBSECTION 26.1 and SECTION 06):

./flowlog --cstack-limit 32MB program.pl -g "goal."

--cstack-limit accepts raw bytes or a K/M/G suffix (optionally followed by B), for example 65536, 64K, 8MB.

If you still hit a SIGSEGV (for example due to a true C stack overflow), you can enable a best-effort crash dump of the last recorded trace frames (SUBSECTION 26.1 and SECTION 06):

./flowlog --segv-trace program.pl -g "goal."

Notes:

REPL behavior

Prompts and non-interactive mode

Meta-commands

The REPL supports a small set of meta-commands (single-line, no trailing . required):

And the ISO-style “regular” commands:

Loading code interactively

The REPL supports the common Prolog top-level convenience:

Use one of:

Output format

Flowlog prints output in a stable, test-friendly format (SECTION 17):

Environment variables

Tracing / stack debugging

Main stack sizing (Linux / small RLIMIT_STACK)

Some systems (notably Linux) default to a small main-thread stack (often 8 MiB). Deep interpreter recursion (for example when running quad tests in --engine tree) can exhaust this stack.

Flowlog can automatically run its main loop on a dedicated pthread with a larger stack:

History

Parallelism tuning

Debugging OR-par

Exit codes