Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The Daffodil Command Line Interface (CLI) comes with a built-in interactive debugger that pauses parsing and allows for user inspection of the parsing state. To start Daffodil in debugger mode, provide the global --debug/-d option, for example:

Code Block
languagebash
daffodil --debug [cmd_file] parse --schema schema.dfdl.xsd input.dat

Enabling the debugger displays a (debug) prompt, at which point various commands can be entered to control parsing and inspect Daffodil state.

 Note that you can optionally provide a file to the --debug option. Each line in the file will be provided to the debugger as if it was type by the user.

Below is the list of commands and their descriptions.

Commands 

...

break

...

<element_id>

...

Create a breakpoint, causing the debugger to stop when the element with the <element_id> name is created.

...

break foo

...

clear

...

clear

...

Continue parsing the input data until parsing is complete. All breakpoints are ignored.

...

condition

...

<breakpoint_id>
<dfdl_expression>

...

Set a condition on a specified breakpoint. When a breakpoint is encountered, the debugger only pauses if the DFDL expression evaluates to true. If the result of the DFDL expressions is not a boolean value, it is treated as false.

...

condition 1 dfdl:occursIndex() eq 3

...

continue

...

Continue parsing the input data until a breakpoint is encountered. At which point, pause parsing and display a debugger console to the user.

...

continue

...

delete

...

<type> <id>

...

Remove a breakpoint or display. Valid values for <type> are "breakpoint" and "display".

...

delete breakpoint 1
delete display 1

...

disable

...

<type> <id>

...

Disable a breakpoint or display. Valid values for <type> are "breakpoint" and "display".

...

disable breakpoint 1
disable display 1

...

display

...

<debugger_command>

...

Execute a debugger command every time a debugger console is displayed to the user.

...

display info infoset

...

enable

...

<type> <id>

...

Enable a breakpoint or display. Valid values for <type> are "breakpoint" and "display".

...

enable breakpoint 1
enable display 1

...

eval

...

<dfdl_expression>

...

Evaluate a DFDL expression. If the expression evaluates to a complex element, then the XML representation for the complex element is displayed. If the expression evaluates to a simple type, then the value of the simple type is display.

...

eval dfdl:occursIndex()
eval /ex:file/line[1]

...

help

...

[command]

...

Display help. If a command is given, display help information specific to that command and its subcommands.

...

help
help info

...

Display the history of commands. If an argument is given, write the history to the specified file rather then printing it to the screen.

...

history

history out.txt

...

info

...

<item>...

...

Print internal information to the console. <item> can be specified multiple times to display multiple pieces of information.

The valid items are:

ItemShort ItemDescription
arrayIndex

ai

display the current array limit
bitLimitbldisplay the current bit limit
bitPositionbpdisplay the current bit position
breakpointsbdisplay the list of breakpoints
childIndexcidisplay the child index
dataddisplay the input data
delimiterStackdsdisplay the current delimiter stack
diffdiffdisplay the differences from the previous state
discriminatordisdisplay whether or not a discriminator is set
displaysdidisplay the current 'display' expressions
foundDelimiterfddisplay the most recently found delimiter
groupIndexgidisplay the current group index
infosetidisplay the current infoset
occursBoundsobdisplay the current occurs bounds
parserpdisplay the current parser
pathpathdisplay the current schema component designator/path
unparserudisplay the current unparser

...

info data infoset

...

quit

...

quit

...

set

...

<setting> <value>

...

Change a debugger setting. The valid settings are:

SettingValue TypeDescriptionDefault
breakOnFailureboolean

Set whether or not the debugger should break on failures. If set to false the normal processing occurs. If set to true, any errors cause a break. Note that due to the backtracking behavior, not all failures are fatal.

false
breakOnlyOnCreationboolean

Set whether or not breakpoints should only be evaluated on element creation. <value> must be either true/false or 1/0. If true, breakpoints only stop on element creation. If false, breakpoints stop anytime a parser interacts with an element.

true
dataLengthinteger

Set the number of bytes to display when displaying input data. If negative, display all input data. This only affects the 'info data' command.

70
infosetLinesinteger

Set the maximum number of lines to display when displaying the infoset. This only affects the 'info infoset' command. This shows the last <value> lines of the infoset. If <value> is less than or equal to zero, the entire infoset is printed.

-1
removeHiddenboolean

Set whether or not hidden elements (e.g through the use of dfdl:hiddenGroupRef) should be displayed. This effects the 'eval' and 'info infoset' commands. <value> must be either true/false or 1/0.

false
representationstringSet the output when displaying data. <value> must be either 'text' or 'binary'."text"
wrapLengthinteger

Set the number of characters at which point output wraps. This only affects the 'info data' and 'info infoset' commands. A length less than or equal to zero disables wrapping.

80

...

set dataLength -1
set wrapLength 50
set removeHidden true

...

step

...

s

...

Perform a single parse action, pause parsing, and display a debugger prompt.

...

step

...

trace

...

t

...

Continue parsing the input data until a breakpoint is encountered, while running display commands after every parse step. When a breakpoint is encountered, pause parsing and display a debugger console to the user.

...

this page has moved to https://daffodil.apache.org/debugger/