Node:FDBG Annotation, Next:, Previous:FDBG Debugger Commands, Up:FDBG Basics



Annotating Programs

In order to use FDBG efficiently, you have to make some changes to your CLP(FD) program. Fortunately the calls you have to add are not numerous, and when FDBG is turned off they don't decrease efficiency significantly or modify the behavior of your program. On the other hand, they are necessary to make FDBG output easier to understand.

Assign names to the more important and more frequently occurring variables by inserting fdbg_assign_name/2 calls at the beginning of your program. It is advisable to assign names to variables in larger batches (i.e. as lists or compound terms) with a single call.

Use pre-defined labeling predicates if possible. If you define your own labeling predicates and you want to use them even in the debugging session, then you should follow these guidelines:

  1. Add a call to clpfd:fdbg_start_labeling(+Var) at the beginning of the predicate doing a labeling attempt, and pass the currently labeled variable as an argument to the call.
  2. Call clpfd:fdbg_labeling_step(+Var, +Step) before each labeling step. Step should be a compound term describing the labeling step, this will be
    1. printed "as is" by the built-in visualizer as the mode of the labeling step (see FDBG Built-In Visualizers)--you can use portray/1 to determine how it should be printed;
    2. passed as step(Step) to the user defined labeling visualizers in their Event argument; see FDBG Writing Visualizers.

This way FDBG can inform you about the labeling events created by your labeling predicates exactly like it would do in the case of internal labeling. If you ignore these rules FDBG won't be able to distinguish labeling events from other FDBG events any more.