1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +02:00

Merge GDS (except for breakpoints) from CVS HEAD:

* debugger/commands.scm (evaluate, info-args, info-frame,
position, up, down): Improve/fix doc strings.

* Makefile.am (SUBDIRS): Add debugging.
(ice9_sources): Add gds-client.scm and gds-server.scm.

* scheme-debugging.texi: Remove lots of text that is now
duplicated (exactly) elsewhere, leaving only the `Tracing' node.

* guile.texi: Replace `Debugging Features' (scheme-debugging.texi)
by `Using Guile Interactively' and `Using Guile in Emacs'
(scheme-using.texi).  Move the `Tracing' content of
scheme-debugging.texi to the Modules section.

* api-options.texi (Evaluator trap options): Move doc for
with-traps and debug-object? to here.

* api-modules.texi (Included Guile Modules): Change reference from
`Debugging Features' to `Tracing'.

* api-evaluation.texi (Evaluator Behaviour): Add reference to
`Evaluator trap options'.

* api-debug.texi (Examining the Stack): Minor improvements to
display-backtrace doc.

* api-debug.texi (Debug on Error): New text on how to catch errors
and the error stack.

* api-debug.texi (High Level Traps): New.

* api-debug.texi (Debugging): New intro text.  New subsection
"Evaluation Model".  Moved existing subsections "Capturing the
Stack or Innermost Stack Frame", "Examining the Stack", "Examining
Stack Frames", "Source Properties", "Decoding Memoized Source
Expressions" and "Starting a New Stack" under "Evaluation Model".
(Capturing the Stack or Innermost Stack Frame): Some new text, and
correction to doc for last-stack-frame.
(Debug on Error): Renamed from "Interactive Debugging".

* configure.in (AC_CONFIG_FILES): Add emacs/Makefile and
ice-9/debugging/Makefile.

* Makefile.am (SUBDIRS): Add emacs.
This commit is contained in:
Neil Jerram 2008-03-12 00:57:41 +00:00
parent 51d237110f
commit b0f07fa20c
14 changed files with 1638 additions and 447 deletions

View file

@ -1,3 +1,10 @@
2008-03-12 Neil Jerram <neil@ossau.uklinux.net>
* configure.in (AC_CONFIG_FILES): Add emacs/Makefile and
ice-9/debugging/Makefile.
* Makefile.am (SUBDIRS): Add emacs.
2008-02-23 Neil Jerram <neil@ossau.uklinux.net>
* FAQ: New file.

View file

@ -24,7 +24,7 @@
#
AUTOMAKE_OPTIONS = 1.10
SUBDIRS = oop libguile ice-9 guile-config guile-readline \
SUBDIRS = oop libguile ice-9 guile-config guile-readline emacs \
scripts srfi doc examples test-suite benchmark-suite lang am
bin_SCRIPTS = guile-tools

View file

@ -1442,6 +1442,7 @@ AC_CONFIG_FILES([
doc/r5rs/Makefile
doc/ref/Makefile
doc/tutorial/Makefile
emacs/Makefile
examples/Makefile
examples/box-dynamic-module/Makefile
examples/box-dynamic/Makefile
@ -1453,6 +1454,7 @@ AC_CONFIG_FILES([
guile-config/Makefile
ice-9/Makefile
ice-9/debugger/Makefile
ice-9/debugging/Makefile
lang/Makefile
lang/elisp/Makefile
lang/elisp/internals/Makefile

View file

@ -1,5 +1,41 @@
2008-03-12 Neil Jerram <neil@ossau.uklinux.net>
* scheme-debugging.texi: Remove lots of text that is now
duplicated (exactly) elsewhere, leaving only the `Tracing' node.
* guile.texi: Replace `Debugging Features' (scheme-debugging.texi)
by `Using Guile Interactively' and `Using Guile in Emacs'
(scheme-using.texi). Move the `Tracing' content of
scheme-debugging.texi to the Modules section.
* api-options.texi (Evaluator trap options): Move doc for
with-traps and debug-object? to here.
* api-modules.texi (Included Guile Modules): Change reference from
`Debugging Features' to `Tracing'.
* api-evaluation.texi (Evaluator Behaviour): Add reference to
`Evaluator trap options'.
* api-debug.texi (Examining the Stack): Minor improvements to
display-backtrace doc.
* api-debug.texi (Debug on Error): New text on how to catch errors
and the error stack.
* api-debug.texi (High Level Traps): New.
* api-debug.texi (Debugging): New intro text. New subsection
"Evaluation Model". Moved existing subsections "Capturing the
Stack or Innermost Stack Frame", "Examining the Stack", "Examining
Stack Frames", "Source Properties", "Decoding Memoized Source
Expressions" and "Starting a New Stack" under "Evaluation Model".
(Capturing the Stack or Innermost Stack Frame): Some new text, and
correction to doc for last-stack-frame.
(Debug on Error): Renamed from "Interactive Debugging".
* Makefile (guile_TEXINFOS): Add scheme-using.texi.
* scheme-using.texi: New (merged with modifications from CVS
HEAD).

View file

@ -56,6 +56,7 @@ guile_TEXINFOS = preface.texi \
gh.texi \
api-overview.texi \
scheme-debugging.texi \
scheme-using.texi \
indices.texi \
script-getopt.texi \
data-rep.texi \

File diff suppressed because it is too large Load diff

View file

@ -629,6 +629,9 @@ Like @code{help}, but also print programmer options.
Modify the evaluator options. @code{trap-enable} should be used with boolean
options and switches them on, @code{trap-disable} switches them off.
@code{trap-set!} can be used to set an option to a specific value.
See @ref{Evaluator trap options} for more information on the available
trap handlers.
@end deffn
@deffn {Scheme Procedure} evaluator-traps-interface [setting]

View file

@ -679,7 +679,7 @@ Guile starts up.
@item (ice-9 debug)
Mikael Djurfeldt's source-level debugging support for Guile
(@pxref{Debugging Features}).
(@pxref{Tracing}).
@item (ice-9 expect)
Actions based on matching input from a port (@pxref{Expect}).

View file

@ -612,6 +612,16 @@ way.
@var{retval} is the return value.
@end deffn
@deffn {Scheme Procedure} with-traps thunk
@deffnx {C Function} scm_with_traps (thunk)
Call @var{thunk} with traps enabled.
@end deffn
@deffn {Scheme Procedure} debug-object? obj
@deffnx {C Function} scm_debug_object_p (obj)
Return @code{#t} if @var{obj} is a debug object.
@end deffn
@node Debugger options
@subsubsection Debugger options

View file

@ -137,7 +137,7 @@ x
@comment The title is printed in a large font.
@title Guile Reference Manual
@subtitle Edition @value{MANUAL-EDITION}, for use with Guile @value{VERSION}
@c @subtitle $Id: guile.texi,v 1.44.2.1 2006-10-04 21:40:24 kryde Exp $
@c @subtitle $Id: guile.texi,v 1.44.2.2 2008-03-12 00:57:40 ossau Exp $
@c See preface.texi for the list of authors
@author The Guile Developers
@ -219,14 +219,15 @@ etc. that make up Guile's application programming interface (API),
* Basic Ideas:: Basic ideas in Scheme.
* Guile Scheme:: Guile's implementation of Scheme.
* Guile Scripting:: How to write Guile scripts.
* Debugging Features:: Features for finding errors.
* Using Guile Interactively:: Guile's REPL features.
* Using Guile in Emacs:: Guile and Emacs.
* Further Reading:: Where to find out more about Scheme.
@end menu
@include scheme-ideas.texi
@include scheme-intro.texi
@include scheme-scripts.texi
@include scheme-debugging.texi
@include scheme-using.texi
@include scheme-reading.texi
@node Programming in C
@ -302,7 +303,7 @@ available through both Scheme and C interfaces.
* Options and Config:: Configuration, features and runtime options.
* Translation:: Support for translating other languages.
* Internationalization:: Support for gettext, etc.
* Debugging:: Internal debugging interface.
* Debugging:: Debugging infrastructure and Scheme interface.
* GH:: The deprecated GH interface.
@end menu
@ -347,6 +348,7 @@ available through both Scheme and C interfaces.
* Buffered Input:: Ports made from a reader function.
* Expect:: Controlling interactive programs with Guile.
* The Scheme shell (scsh):: Using scsh interfaces in Guile.
* Tracing:: Tracing program execution.
@end menu
@include slib.texi
@ -357,6 +359,7 @@ available through both Scheme and C interfaces.
@include misc-modules.texi
@include expect.texi
@include scsh.texi
@include scheme-debugging.texi
@include data-rep.texi
@include fdl.texi

View file

@ -5,251 +5,8 @@
@c See the file guile.texi for copying conditions.
@page
@node Debugging Features
@section Debugging Features
Guile includes debugging tools to help you work out what is going wrong
when a program signals an error or behaves differently to how you would
expect. This chapter describes how to use these tools.
@menu
* Debug Last Error:: Debugging the most recent error.
* Interactive Debugger:: Using the interactive debugger.
* Tracing:: Tracing program execution.
@end menu
@node Debug Last Error
@subsection Debugging the Most Recent Error
When an error is signalled, Guile remembers the execution context where
the error occurred. By default, Guile then displays only the most
immediate information about where and why the error occurred, for
example:
@c Note: line break in "enter the debugger" to avoid an over-long
@c line in both info and DVI.
@lisp
(make-string (* 4 (+ 3 #\s)) #\space)
@print{}
standard input:2:19: In procedure + in expression (+ 3 #\s):
standard input:2:19: Wrong type argument: #\s
ABORT: (wrong-type-arg)
Type "(backtrace)" to get more information or "(debug)" to enter
the debugger.
@end lisp
@noindent
However, as the message above says, you can obtain much more
information about the context of the error by typing
@code{(backtrace)} or @code{(debug)}.
@code{(backtrace)} displays the Scheme call stack at the point where the
error occurred:
@lisp
(backtrace)
@print{}
Backtrace:
In standard input:
2: 0* [make-string ...
2: 1* [* 4 ...
2: 2* [+ 3 #\s]
Type "(debug-enable 'backtrace)" if you would like a backtrace
automatically if an error occurs in the future.
@end lisp
@noindent
In a more complex scenario than this one, this can be extremely useful
for understanding where and why the error occurred. For more on the
format of the displayed backtrace, see the subsection below.
@code{(debug)} takes you into Guile's interactive debugger, which
provides commands that allow you to
@itemize @bullet
@item
display the Scheme call stack at the point where the error occurred
(the @code{backtrace} command --- see @ref{Display Backtrace})
@item
move up and down the call stack, to see in detail the expression being
evaluated, or the procedure being applied, in each @dfn{frame} (the
@code{up}, @code{down}, @code{frame}, @code{position}, @code{info args}
and @code{info frame} commands --- see @ref{Frame Selection} and
@ref{Frame Information})
@item
examine the values of variables and expressions in the context of each
frame (the @code{evaluate} command --- see @ref{Frame Evaluation}).
@end itemize
Use of the interactive debugger, including these commands, is described
in @ref{Interactive Debugger}.
@node Interactive Debugger
@subsection Using the Interactive Debugger
Guile's interactive debugger is a command line application that accepts
commands from you for examining the stack and, if at a breakpoint, for
continuing program execution in various ways. Unlike in the normal
Guile REPL, commands are typed mostly without parentheses.
When you first enter the debugger, it introduces itself with a message
like this:
@lisp
This is the Guile debugger -- for help, type `help'.
There are 3 frames on the stack.
Frame 2 at standard input:36:19
[+ 3 #\s]
debug>
@end lisp
@noindent
``debug>'' is the debugger's prompt, and a reminder that you are not
in the normal Guile REPL. In case you find yourself in the debugger by
mistake, the @code{quit} command will return you to the REPL.
@deffn {Debugger Command} quit
Exit the debugger.
@end deffn
The other available commands are described in the following subsections.
@menu
* Display Backtrace:: backtrace.
* Frame Selection:: up, down, frame.
* Frame Information:: info args, info frame, position.
* Frame Evaluation:: evaluate.
@end menu
@node Display Backtrace
@subsubsection Display Backtrace
The @code{backtrace} command, which can also be invoked as @code{bt} or
@code{where}, displays the call stack (aka backtrace) at the point where
the debugger was entered:
@lisp
debug> bt
In standard input:
36: 0* [make-string ...
36: 1* [* 4 ...
36: 2* [+ 3 #\s]
@end lisp
@deffn {Debugger Command} backtrace [count]
@deffnx {Debugger Command} bt [count]
@deffnx {Debugger Command} where [count]
Print backtrace of all stack frames, or of the innermost @var{count}
frames. With a negative argument, print the outermost -@var{count}
frames. If the number of frames isn't explicitly given, the debug
option @code{depth} determines the maximum number of frames printed.
@end deffn
The format of the displayed backtrace is the same as for the
@code{backtrace} procedure.
@node Frame Selection
@subsubsection Frame Selection
A call stack consists of a sequence of stack @dfn{frames}, with each
frame describing one level of the nested evaluations and applications
that the program was executing when it hit a breakpoint or an error.
Frames are numbered such that frame 0 is the outermost --- i.e. the
operation on the call stack that began least recently --- and frame N-1
the innermost (where N is the total number of frames on the stack).
When you enter the debugger, the innermost frame is selected, which
means that the commands for getting information about the ``current''
frame, or for evaluating expressions in the context of the current
frame, will do so by default with respect to the innermost frame. To
select a different frame, so that these operations will apply to it
instead, use the @code{up}, @code{down} and @code{frame} commands like
this:
@lisp
debug> up
Frame 1 at standard input:36:14
[* 4 ...
debug> frame 0
Frame 0 at standard input:36:1
[make-string ...
debug> down
Frame 1 at standard input:36:14
[* 4 ...
@end lisp
@deffn {Debugger Command} up [n]
Move @var{n} frames up the stack. For positive @var{n}, this
advances toward the outermost frame, to lower frame numbers, to
frames that have existed longer. @var{n} defaults to one.
@end deffn
@deffn {Debugger Command} down [n]
Move @var{n} frames down the stack. For positive @var{n}, this
advances toward the innermost frame, to higher frame numbers, to frames
that were created more recently. @var{n} defaults to one.
@end deffn
@deffn {Debugger Command} frame [n]
Select and print a stack frame. With no argument, print the selected
stack frame. (See also ``info frame''.) An argument specifies the
frame to select; it must be a stack-frame number.
@end deffn
@node Frame Information
@subsubsection Frame Information
The following commands return detailed information about the currently
selected frame.
@deffn {Debugger Command} {info frame}
Display a verbose description of the selected frame. The information
that this command provides is equivalent to what can be deduced from the
one line summary for the frame that appears in a backtrace, but is
presented and explained more clearly.
@end deffn
@deffn {Debugger Command} {info args}
Display the argument variables of the current stack frame. Arguments
can also be seen in the backtrace, but are presented more clearly by
this command.
@end deffn
@deffn {Debugger Command} position
Display the name of the source file that the current expression comes
from, and the line and column number of the expression's opening
parenthesis within that file. This information is only available when
the @code{positions} read option is enabled (@pxref{Reader options}).
@end deffn
@node Frame Evaluation
@subsubsection Frame Evaluation
The @code{evaluate} command is most useful for querying the value of a
variable, either global or local, in the environment of the selected
stack frame, but it can be used more generally to evaluate any
expression.
@deffn {Debugger Command} evaluate expression
Evaluate an expression in the environment of the selected stack frame.
The expression must appear on the same line as the command, however it
may be continued over multiple lines.
@end deffn
@node Tracing
@subsection Tracing
@section Tracing
The @code{(ice-9 debug)} module implements tracing of procedure
applications. When a procedure is @dfn{traced}, it means that every

View file

@ -1,5 +1,11 @@
2008-03-12 Neil Jerram <neil@ossau.uklinux.net>
* debugger/commands.scm (evaluate, info-args, info-frame,
position, up, down): Improve/fix doc strings.
* Makefile.am (SUBDIRS): Add debugging.
(ice9_sources): Add gds-client.scm and gds-server.scm.
* debugging/Makefile.am, debugging/example-fns.scm,
debugging/ice-9-debugger-extensions.scm, debugging/steps.scm,
debugging/trace.scm, debugging/traps.scm, debugging/trc.scm: New

View file

@ -21,7 +21,7 @@
AUTOMAKE_OPTIONS = gnu
SUBDIRS = debugger
SUBDIRS = debugger debugging
# These should be installed and distributed.
ice9_sources = \
@ -35,7 +35,8 @@ ice9_sources = \
streams.scm string-fun.scm syncase.scm threads.scm \
buffered-input.scm time.scm history.scm channel.scm \
pretty-print.scm ftw.scm gap-buffer.scm occam-channel.scm \
weak-vector.scm deprecated.scm list.scm serialize.scm
weak-vector.scm deprecated.scm list.scm serialize.scm \
gds-client.scm gds-server.scm
subpkgdatadir = $(pkgdatadir)/${GUILE_EFFECTIVE_VERSION}/ice-9
subpkgdata_DATA = $(ice9_sources)

View file

@ -67,9 +67,9 @@ If the number of frames isn't explicitly given, the debug option
(throw 'continue))
(define (evaluate state expression)
"Evaluate an expression.
The expression must appear on the same line as the command,
however it may be continued over multiple lines."
"Evaluate an expression in the environment of the selected stack frame.
The expression must appear on the same line as the command, however it
may be continued over multiple lines."
(let ((source (frame-source (stack-ref (state-stack state)
(state-index state)))))
(if (not source)
@ -100,18 +100,26 @@ however it may be continued over multiple lines."
(lambda args args)))))
(define (info-args state)
"Argument variables of current stack frame."
"Display the argument variables of the current stack frame.
Arguments can also be seen in the backtrace, but are presented more
clearly by this command."
(let ((index (state-index state)))
(let ((frame (stack-ref (state-stack state) index)))
(write-frame-index-long frame)
(write-frame-args-long frame))))
(define (info-frame state)
"All about selected stack frame."
"Display a verbose description of the selected frame. The
information that this command provides is equivalent to what can be
deduced from the one line summary for the frame that appears in a
backtrace, but is presented and explained more clearly."
(write-state-long state))
(define (position state)
"Display the position of the current expression."
"Display the name of the source file that the current expression
comes from, and the line and column number of the expression's opening
parenthesis within that file. This information is only available when
the 'positions read option is enabled."
(let* ((frame (stack-ref (state-stack state) (state-index state)))
(source (frame-source frame)))
(if (not source)
@ -124,14 +132,14 @@ however it may be continued over multiple lines."
(define (up state n)
"Move @var{n} frames up the stack. For positive @var{n}, this
advances toward the outermost frame, to higher frame numbers, to
advances toward the outermost frame, to lower frame numbers, to
frames that have existed longer. @var{n} defaults to one."
(set-stack-index! state (+ (state-index state) (or n 1)))
(write-state-short state))
(define (down state n)
"Move @var{n} frames down the stack. For positive @var{n}, this
advances toward the innermost frame, to lower frame numbers, to frames
advances toward the innermost frame, to higher frame numbers, to frames
that were created more recently. @var{n} defaults to one."
(set-stack-index! state (- (state-index state) (or n 1)))
(write-state-short state))