Maxima Manual
39.1 Source Level Debugging
Maxima has source level capabilities. A user can set a breakpoint at
a line in a file, and then step line by line from there. The call
stack may be examined, together with the variables bound at that
level. If the user is running the code under GNU emacs in a shell
window (dbl shell), or is running xmaxima the graphical
interface version, then if he stops at a break point, he will see his
current position in the source file which will be displayed in the
other half of the window, either highlighted in red, or with a little
arrow pointing at the right line. He can advance single lines at a
time by typing M-n (Alt-n) or alternately by entering :n. To
see the names of the keyword commands type :help (or :h). In general
commands may be abbreviated if the abbreviation is unique. If not
unique the alternatives will be listed.
Under Emacs you should run in a dbl shell, which requires the
dbl.el file in the elisp directory.
Make sure you install the elisp files or add the maxima elisp directory to
your path:
eg add the following to your `.emacs' file or the site-init.el
| | (setq load-path (cons "/usr/local/maxima-5.5/elisp" load-path))
(autoload 'dbl "dbl")
|
then in emacs
should start a shell window in which you can run programs, for example
maxima, gcl, gdb etc. This shell window also knows about source level
debugging, and display of source code in the other window.
| | maxima
Maxima 5.5 Wed Apr 18 19:02:00 CDT 2001 (with enhancements by W. Schelter).
Licensed under the GNU Public License (see file COPYING)
(C1) batchload("/tmp/joe.mac");
(D1) /tmp/joe.mac
(C2) :br joe
Turning on debugging debugmode(true)
Bkpt 0 for joe (in /tmp/joe.mac line 8)
(C2) foo(2,3);
Bkpt 0:(joe.mac 8)
(dbm:1) :bt <-- :bt typed here gives a backtrace
#0: joe(y=5)(joe.mac line 8)
#1: foo(x=2,y=3)(joe.mac line 5)
(joe.mac 9) <-- Here type M-n to advance line
(joe.mac 10) <-- Here type M-n to advance line
In the other buffer the source code
appears with an arrow.
(dbm:1) u; Investigate value of 'u
28
(dbm:1) u:33; Alter it to be 33
(dbm:1) :r :r Resumes the computation
(D3) 1094
|
The actual file /tmp/joe.mac is the following:
| |
foo(x,y):=(
x:x+2,
y:y+2,
x:joe(y),
x+y);
joe(y):=block([u:y^2],
u:u+3,
u:u^2,
u);
|
If you are running in Gnu Emacs then if you are looking at the
file joe.mac, you may set a break point at a certain line of that
file by typing C-x space. This figures out which function
your cursor is in, and then it sees which line of that function
you are on. If you are on say line 2 of joe, then it will
insert in the other window :br joe 2 the command to
break joe at its second line. To have this enabled you must have
maxima-mode.el on in the window in which the file joe.mac is visiting.
There are additional commands available in that file window, such as
evaluating the function into the maxima, by typing Alt-Control-x