Janet 1.5.0-719f7ba Documentation
(Other Versions: 1.5.0 1.4.0 1.3.1)

Debug Module

Index

debug/arg-stack debug/break debug/fbreak debug/lineage debug/stack debug/stacktrace debug/unbreak debug/unfbreak


debug/arg-stack cfunction
(debug/arg-stack fiber)

Gets all values currently on the fiber's argument stack. Normally, this should be empty unless the fiber signals while pushing arguments to make a function call. Returns a new array.

debug/break cfunction
(debug/break source byte-offset)

Sets a breakpoint with source a key at a given line and column. Will throw an error if the breakpoint location cannot be found. For example

	(debug/break "core.janet" 1000)

wil set a breakpoint at the 1000th byte of the file core.janet.

debug/fbreak cfunction
(debug/fbreak fun &opt pc)

Set a breakpoint in a given function. pc is an optional offset, which is in bytecode instructions. fun is a function value. Will throw an error if the offset is too large or negative.

debug/lineage cfunction
(debug/lineage fib)

Returns an array of all child fibers from a root fiber. This function is useful when a fiber signals or errors to an ancestor fiber. Using this function, the fiber handling the error can see which fiber raised the signal. This function should be used mostly for debugging purposes.

debug/stack cfunction
(debug/stack fib)

Gets information about the stack as an array of tables. Each table in the array contains information about a stack frame. The top most, current stack frame is the first table in the array, and the bottom most stack frame is the last value. Each stack frame contains some of the following attributes:

	:c - true if the stack frame is a c function invocation
	:column - the current source column of the stack frame
	:function - the function that the stack frame represents
	:line - the current source line of the stack frame
	:name - the human friendly name of the function
	:pc - integer indicating the location of the program counter
	:source - string with the file path or other identifier for the source code
	:slots - array of all values in each slot
	:tail - boolean indicating a tail call

debug/stacktrace cfunction
(debug/stacktrace fiber err)

Prints a nice looking stacktrace for a fiber. The error message err must be passed to the function as fiber's do not keep track of the last error they have thrown. Returns the fiber.

debug/unbreak cfunction
(debug/unbreak source line column)

Remove a breakpoint with a source key at a given line and column. Will throw an error if the breakpoint cannot be found.

debug/unfbreak cfunction
(debug/unfbreak fun &opt pc)

Unset a breakpoint set with debug/fbreak.