Maxima – 217 – Debugging

ms1

Continuo da qui, copio dal Reference Manual, PDF scaricabile da qui, sono a p.661.

Source Level Debugging

Maxima has a built-in source level debugger. The user can set a breakpoint at a function, and then step line by line from there. The call stack may be examined, together with the variables bound at that level.

The command :help or :h shows the list of debugger commands. (In general, commands may be abbreviated if the abbreviation is unique. If not unique, the alternatives will be listed.) Within the debugger, the user can also use any ordinary Maxima functions to examine, define, and manipulate variables and expressions.

A breakpoint is set by the :br command at the Maxima prompt. Within the debugger, the user can advance one line at a time using the :n (“next”) command. The :bt (“back-trace”) command shows a list of stack frames. The :r (“resume”) command exits the debugger and continues with execution.

(%i1) load ("foobar.mac");

(%o1)                           foobar.mac

(%i2) :br foo
Turning on debugging debugmode(true)
Bkpt 0 for foo (in foobar.mac line 1)

(%i2) bar (2,3);
Bkpt 0:(foobar.mac 1)
foobar.mac:1::

(dbm:1) :bt                        <-- :bt typed here gives a backtrace
#0: foo(y=5)(foobar.mac line 1)
#1: bar(x=2,y=3)(foobar.mac line 9)

(dbm:1) :n                         <-- Here type :n to advance line
(foobar.mac 2)
foobar.mac:2::

(dbm:1) :n                         <-- Here type :n to advance line
(foobar.mac 3)
foobar.mac:3::

(dbm:1) u;                         <-- Investigate value of u
28

(dbm:1) u: 33;                     <-- Change u to be 33
33

(dbm:1) :r                         <-- Type :r to resume the computation

(%o2)                                1094

Problema di versione: da me non funziona come previsto.

The file foobar.mac is the following:

foo(y) := block ([u:y^2],
  u: u+3,
  u: u^2,
  u);

bar(x,y) := (
  x: x+2,
  y: y+2,
  x: foo(y),
  x+y);

Use of the debugger through Emacs: sì, si può ma salto.

Comandi chiave (keyword)

Keyword commands are special keywords which are not interpreted as Maxima expressions.

A keyword command can be entered at the Maxima prompt or the debugger prompt, although not at the break prompt. Keyword commands start with a colon, ’:’. For example, to evaluate a Lisp form you may type :lisp followed by the form to be evaluated.

%i1) :lisp (+ 2 3)

5

The number of arguments taken depends on the particular command. Also, you need not type the whole command, just enough to be unique among the break keywords. Thus :br would suffice for :break.

The keyword commands are listed below.

  • :break F n Set a breakpoint in function F at line offset n from the beginning of the function. If F is given as a string, then it is assumed to be a file, and n is the offset from the beginning of the file. The offset is optional. If not given, it is assumed to be zero (first line of the function or file).
  • :bt Print a backtrace of the stack frames
  • :continue Continue the computation
  • :delete Delete the specified breakpoints, or all if none are specified
  • :disable Disable the specified breakpoints, or all if none are specified
  • :enable Enable the specified breakpoints, or all if none are specified
  • :frame n Print stack frame n, or the current frame if none is specified
  • :help Print help on a debugger command, or all commands if none is specified
  • :info Print information about item
  • :lisp some-form Evaluate some-form as a Lisp form
  • :lisp-quiet some-form Evaluate Lisp form some-form without any output
  • :next Like :step, except :next steps over function calls
  • :quit Quit the current debugger level without completing the computation
  • :resume Continue the computation
  • :step Continue the computation until it reaches a new source line
  • :top Return to the Maxima prompt (from any debugger level) without completing the computation

Seguono (nella Reference) le funzioni e variabili per il debugging. Salto tutto, passo avanti.

Posta un commento o usa questo indirizzo per il trackback.

Trackback

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...

Questo sito utilizza Akismet per ridurre lo spam. Scopri come vengono elaborati i dati derivati dai commenti.

%d blogger hanno fatto clic su Mi Piace per questo: