[ Debugging | Reference Manual | Alphabetic Index ]

# spy +SpecList

Sets a spypoint for the procedure(s) in SpecList.

SpecList
  Sequence of expressions of the form Atom/Integer, Module:Atom/Integer, Atom or File:Line

## Description

This predicate sets spypoints on all the procedures given by SpecList, or sets a breakpoint on a call in a specific source line.

For setting spypoints, the procedure(s) are all of the form name/arity, or else of the form name, in which case all procedures with name name and any arity have spy points set.

For setting a breakpoint, SpecList should be of the form File:Line, where File is the name of a source file (atom/string) whose code is already loaded into ECLiPSe, and Line is an integer that specifies a line number in the file. Breakpoints can only be set in procedures that have been compiled in debug mode. A breakpoint will be added to the subgoal call that most closely matches the line number Line, i.e. the subgoal call is either on, or close to, line Line in File.

If not already debugging, the trace mode is switched on and set to leap.

When tracing, a leap command to the debugger will cause execution to continue until it reaches a spied predicate. Setting a spy-point on a non-existing procedure results in an error.

Note that spypoints can also be set using set_flag(Proc, spy, on).

### Modes and Determinism

- spy(++) is det

### Modules

This predicate is sensitive to its module context (tool predicate, see @/2).

### Exceptions

(4) instantiation fault
  SpecList is not instantiated.
(5) type error
  SpecList is not of the correct form
(6) out of range
  SpecList in the form File:Line did not correspond to a source file or breakpoint
(60) referring to an undefined procedure
  SpecList contains an undefined procedure.

## Examples

    Success:
          [eclipse]: [user].
           lower:-writeln(hi).
           higher:-lower.
           user        compiled 84 bytes in 0.00 seconds
          yes.
          [eclipse]: spy higher,writeln.
          spypoint added to higher / 0.
          spypoint added to writeln / 1.
          spypoint added to writeln / 2.
          yes.
          [eclipse]: higher.
           +(1) 0  CALL   higher (dbg)?- leap
           B+(3) 2  CALL   writeln(hi) (dbg)?- leap
           hi
           B+(3) 2  EXIT   writeln(hi) (dbg)?- leap
            +(1) 0  EXIT   higher (dbg)?- leap
           yes.
    Error:
          spy(I).         (Error 4).
          spy("l").       (Error 5).
          spy(foo).       (Error 60).

## See Also

nospy / 1, get_flag / 3, set_flag / 3