en fr

Sysquake Pro – Table of Contents

Sysquake – Table of Contents

Sysquake for LaTeX – Table of Contents

Debugging Functions

dbclear

Remove a breakpoint.

Syntax

dbclear fun
dbclear fun line
dbclear('fun', line)
dbclear

Description

dbclear fun removes all breakpoints in function fun. dbclear fun line or dbclear('fun',line) removes the breakpoint in function fun at line number line.

Without argument, dbclear removes all breakpoints.

See also

dbstop, dbstatus

dbcont

Resume execution.

Syntax

dbcont

Description

When execution has been suspended by a breakpoint or dbhalt, it can be resumed from the command-line interface with dbcont.

See also

dbstop, dbhalt, dbstep, dbquit

dbhalt

Suspend execution.

Syntax

dbhalt

Description

In a function, dbhalt suspends normal execution as if a breakpoint had been reached. Commands dbstep, dbcont and dbquit can then be used from the command line to resume or abort execution.

See also

dbstop, dbcont, dbquit

dbquit

Abort suspended execution.

Syntax

dbquit

Description

When execution has been suspended by a breakpoint or dbhalt, it can be aborted completely from the command-line interface with dbquit.

See also

dbstop, dbcont, dbhalt

dbstack

Chain of function calls.

Syntax

dbstack
s = dbstack
dbstack all
s = dbstack('all')

Description

dbstack displays the chain of function calls which lead to the current execution point, with the line number where the call to the subfunction is made. It can be executed in a function or from the command-line interface when execution is suspended with a breakpoint or dbhalt.

dbstack all (or dbstack('all')) displays the whole stack of function calls. For instance, if two executions are successively suspended at breakpoints, dbstack displays only the second chain of function calls, while dbstack all displays all functions.

With an output argument, dbstack returns the result as a structure array. Field name contains the function name (or class and method names), and field line the line number. Note that you cannot assign the result of dbstack to a new variable in suspended mode.

Examples

use stat
dbstop prctile
iqr(rand(1,1000))
  <prctile:45>  if nargin < 3
dbstack
  stat/prctile;45
  stat/iqr;69

See also

dbstop, dbhalt

dbstatus

Display list of breakpoints.

Syntax

dbstatus
dbstatus fun

Description

dbstatus displays the list of all breakpoints. dbstatus fun displays the list of breakpoints in function fun.

See also

dbstop, dbclear, dbtype

dbstep

Execute a line of instructions.

Syntax

dbstep
dbstep in
dbstep out

Description

When normal execution is suspended after a breakpoint set with dbstop or the execution of function dbhalt, dbstep, issued from the command line, executes the next line of the suspended function. If the line is the last one of the function, execution resumes in the calling function.

dbstep in has the same effect as dbstep, except if a subfunction is called. In this case, execution is suspended at the beginning of the subfunction.

dbstep out resumes execution in the current function and suspends it in the calling function.

Example

Load library stdlib and put a breakpoint at the beginning of function hankel:

use stdlib
dbstop hankel

Start execution of function hankel until the breakpoint is reached (the next line to be executed is displayed):

hankel(1:3,3:8)
  <hankel:21>   c = c(:);

When the execution is suspended, any function can be called. Local variables of the function can be accessed and changed; but no new variable can be created. Here, the list of variables and the value of c are displayed:

info v
  M (not defined)
  c (1x3)
  r (1x6)
  m (not defined)
  n (not defined)
  ix (not defined)
  M1 (not defined)
c
  c =
    1 2 3

Display the stack of function calls:

dbstack
  stdlib/hankel;21

Execute next line (typing Return with an empty command has the same effect as typing dbstep):

dbstep
  <hankel:22>   m = length(c);

Continue until the end; then normal execution is resumed:

dbcont
  ans =
    1 2 3 4 5 6
	2 3 4 5 6 7
	3 4 5 6 7 8

Display breakpoint and clear it:

dbstatus
  stdlib/hankel;0
dbclear

See also

dbstop, dbcont, dbquit

dbstop

Set a breakpoint.

Syntax

dbstop fun
dbstop fun line
dbstop('fun', line)

Description

dbstop fun sets a breakpoint at the beginning of function fun. dbstop fun line or dbstop('fun',line) sets a breakpoint in function fun at line line.

When LME executes a line where a breakpoint has been set, it suspends execution and returns to the command-line interface. The user can inspect or change variables, executes expressions or other functions, continue execution with dbstep or dbcont, or abort execution with dbquit.

Example

use stdlib
dbstop cart2pol
dbstatus
  stdlib/cart2pol;0
dbclear cart2pol

See also

dbhalt, dbclear, dbstatus, dbstep, dbcont, dbquit, dbtype

dbtype

Display source code with line numbers, breakpoints, and current execution point.

Syntax

dbtype fun
dbtype
dbtype('fun', fd=fd)
src = dbtype('fun')

Description

dbtype fun displays the source code of function fun with line numbers, breakpoints, and the position where execution is suspended (if it is in fun). Without argument, dbtype displays the function which is suspended.

dbtype can be used at any time to check the source code of any function known to LME.

By defulat, dbtype displays the source code to the standard output channel. A file descriptor can be specified as a named argument fd.

With an output argument, dbtype returns the function source code as a string.

Example

use stdlib
dbstop cart2pol
(phi, r) = cart2pol(1, 2);
  <cart2pol:99>   r = hypot(x, y);
dbstep
  <cart2pol:100>   phi = atan2(y, x);
dbtype
   #  97 function (phi, r, z) = cart2pol(x, y, z)
      98 	
      99 	r = hypot(x, y);
  >  100 	phi = atan2(y, x);

See also

dbstatus, dbstack, echo

echo

Echo of code before its execution.

Syntax

echo on
echo off
echo fun on
echo(state)
echo(state, fd)
echo(fun, state)
echo(fun, state, fd)

Description

echo on enables the display of an echo of each line of function code before execution. The display includes the function name and the line number. echo off disables the echo.

The argument can also be passed as a boolean value with the functional form echo(state): echo on is equivalent to echo(true).

echo fun on enables echo for function named fun only. echo fun off disables echo (the function name is ignored); echo off has the same effect.

By default, the echo is output to the standard error channel (file descriptor 2). Another file descriptor can be specified as an additional numeric argument, with the functional form only.

Example

Trace of a function:

use stdlib
echo on
C = compan([2,5,4]);
  compan  26  if min(size(v)) > 1
  compan  29  v = v(:).';
  compan  30  n = length(v);
  compan  31  M = [-v(2:end)/v(1); eye(n-2, n-1)];

Echo stored into a file 'log.txt':

fd = fopen('log.txt', 'w');
echo(true, fd);
...
echo off
fclose(fd);

See also

dbtype