Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Please login or create an account
Change language to: English - Français - Português - Русский
Scilabヘルプ >> Scilab > Debugging > debug

debug

enters the Scilab debugger mode

Syntax

debug

Description

debug enters the debug's mode for functions written in Scilab language. The prompt becomes debug>.

This mode allows you to manage breakpoints, launch execution with stop on error, execute a function step by step, ...

Commands available in debugging mode

h: Shows the debugger's help in the console.

help: In Scilab standard running mode (with GUIs), displays the debugger's help page in the help browser. Otherwise, displays the help in the console (as with "h").

(q)uit: Leaves the debug mode and returns to the normal Scilab mode.

(w)here or bt: Displays the callstack.

(e)xec or (r)un command : Executes the given Scilab command.

(d)isp var, or (p)rint var: Displays the value of the variable var.

(c)ontinue: Continues the execution.

(a)bort: Aborts the execution.

step(n)ext or next: Executes the next expression.

step(i)n or in: Executes the next expression in sub function.

step(o)ut or out: Executes the next expression in previous function.

(b)reakpoint or break: breakpoint function [line [condition]] : Adds a breakpoint in a function at line line. If a condition is specified, the breakpoint is enabled only if the condition is %t

(del)ete [n]: Removes all breakpoints. If n is specified: removes the breakpoint #n.

enable [n]: Enables all breakpoints. If n is specified: enables the breakpoint #n.

disable [n]: Disables all breakpoints. If n is specified: disables the breakpoint #n.

(s)how [n]: Shows all breakpoints information. If n is specified: shows the breakpoint #n.

How to debug a script

Debugging a series of Scilab instructions out of any function requires first to embed them in a dummy function. Example: We want to debug the following instructions

a = 1;
b = linspace(a, 3, 10);
c = exp(a + %i + c);

Then we must first rewrite them as

function script()
    a = 1;
    b = linspace(a, 3, 10);
    c = exp(a + %i + c);
endfunction

and execute this code (in normal Scilab mode) in order to define script() in Scilab. Then breakpoints can be defined and handled within the script() function as for any other function.

Examples

//function to overload cosine on string
function v=%c_cos(val)
    printf("val : %s\n", val);
    v = cos(evstr(val));
endfunction

//caller
function a=test_debug()
    b = cos("%pi");
    a = b * 3;
endfunction

debug
break test_debug
exec test_debug
where
stepin
disp val
continue
quit
function v=compute(val)
    v = 1;
    for i=1:val
        v = v * i;
    end
endfunction

debug
break compute 4 "i == 5"
exec compute(10)
disp val
disp i
disp v
continue
quit

History

バージョン記述
6.0.0 New version: console interface to Scilab 6 debugger.
Scilab Enterprises
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Jul 20 11:20:37 CEST 2021