1 /* Printing of backtraces and error messages
2 * Copyright (C) 1996,1997,1998,1999,2000,2001, 2003, 2004, 2006 Free Software Foundation
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27 #include "libguile/_scm.h"
36 #include "libguile/stacks.h"
37 #include "libguile/srcprop.h"
38 #include "libguile/struct.h"
39 #include "libguile/strports.h"
40 #include "libguile/throw.h"
41 #include "libguile/fluids.h"
42 #include "libguile/ports.h"
43 #include "libguile/strings.h"
44 #include "libguile/dynwind.h"
46 #include "libguile/validate.h"
47 #include "libguile/lang.h"
48 #include "libguile/backtrace.h"
49 #include "libguile/filesys.h"
50 #include "libguile/private-options.h"
52 /* {Error reporting and backtraces}
54 * Note that these functions shouldn't generate errors themselves.
57 /* Print parameters for error messages. */
59 #define DISPLAY_ERROR_MESSAGE_MAX_LEVEL 7
60 #define DISPLAY_ERROR_MESSAGE_MAX_LENGTH 10
62 /* Print parameters for failing expressions in error messages.
63 * (See also `print_params' below for backtrace print parameters.)
66 #define DISPLAY_EXPRESSION_MAX_LEVEL 2
67 #define DISPLAY_EXPRESSION_MAX_LENGTH 3
70 #define SCM_ASSERT(_cond, _arg, _pos, _subr) \
74 SCM scm_the_last_stack_fluid_var
;
77 display_header (SCM source
, SCM port
)
79 if (SCM_MEMOIZEDP (source
))
81 SCM fname
= scm_source_property (source
, scm_sym_filename
);
82 SCM line
= scm_source_property (source
, scm_sym_line
);
83 SCM col
= scm_source_property (source
, scm_sym_column
);
85 /* Dirk:FIXME:: Maybe we should store the _port_ rather than the
86 * filename with the source properties? Then we could in case of
87 * non-file ports give at least some more details than just
88 * "<unnamed port>". */
89 if (scm_is_true (fname
))
90 scm_prin1 (fname
, port
, 0);
92 scm_puts ("<unnamed port>", port
);
94 if (scm_is_true (line
) && scm_is_true (col
))
97 scm_intprint (scm_to_long (line
) + 1, 10, port
);
99 scm_intprint (scm_to_long (col
) + 1, 10, port
);
103 scm_puts ("ERROR", port
);
104 scm_puts (": ", port
);
108 struct display_error_message_data
{
112 scm_print_state
*pstate
;
119 display_error_message (struct display_error_message_data
*d
)
121 if (scm_is_string (d
->message
) && scm_is_true (scm_list_p (d
->args
)))
122 scm_simple_format (d
->port
, d
->message
, d
->args
);
124 scm_display (d
->message
, d
->port
);
125 scm_newline (d
->port
);
126 return SCM_UNSPECIFIED
;
130 before_display_error_message (struct display_error_message_data
*d
)
132 scm_print_state
*pstate
= d
->pstate
;
133 d
->old_fancyp
= pstate
->fancyp
;
134 d
->old_level
= pstate
->level
;
135 d
->old_length
= pstate
->length
;
137 pstate
->level
= DISPLAY_ERROR_MESSAGE_MAX_LEVEL
;
138 pstate
->length
= DISPLAY_ERROR_MESSAGE_MAX_LENGTH
;
142 after_display_error_message (struct display_error_message_data
*d
)
144 scm_print_state
*pstate
= d
->pstate
;
145 pstate
->fancyp
= d
->old_fancyp
;
146 pstate
->level
= d
->old_level
;
147 pstate
->length
= d
->old_length
;
151 scm_display_error_message (SCM message
, SCM args
, SCM port
)
153 struct display_error_message_data d
;
155 scm_print_state
*pstate
;
157 port
= scm_i_port_with_print_state (port
, SCM_UNDEFINED
);
158 print_state
= SCM_PORT_WITH_PS_PS (port
);
159 pstate
= SCM_PRINT_STATE (print_state
);
165 scm_internal_dynamic_wind ((scm_t_guard
) before_display_error_message
,
166 (scm_t_inner
) display_error_message
,
167 (scm_t_guard
) after_display_error_message
,
173 display_expression (SCM frame
, SCM pname
, SCM source
, SCM port
)
175 SCM print_state
= scm_make_print_state ();
176 scm_print_state
*pstate
= SCM_PRINT_STATE (print_state
);
177 pstate
->writingp
= 0;
179 pstate
->level
= DISPLAY_EXPRESSION_MAX_LEVEL
;
180 pstate
->length
= DISPLAY_EXPRESSION_MAX_LENGTH
;
181 if (scm_is_symbol (pname
) || scm_is_string (pname
))
183 if (SCM_FRAMEP (frame
)
184 && SCM_FRAME_EVAL_ARGS_P (frame
))
185 scm_puts ("While evaluating arguments to ", port
);
187 scm_puts ("In procedure ", port
);
188 scm_iprin1 (pname
, port
, pstate
);
189 if (SCM_MEMOIZEDP (source
))
191 scm_puts (" in expression ", port
);
192 pstate
->writingp
= 1;
193 scm_iprin1 (scm_i_unmemoize_expr (source
), port
, pstate
);
196 else if (SCM_MEMOIZEDP (source
))
198 scm_puts ("In expression ", port
);
199 pstate
->writingp
= 1;
200 scm_iprin1 (scm_i_unmemoize_expr (source
), port
, pstate
);
202 scm_puts (":\n", port
);
203 scm_free_print_state (print_state
);
206 struct display_error_args
{
216 display_error_body (struct display_error_args
*a
)
218 SCM current_frame
= SCM_BOOL_F
;
219 SCM source
= SCM_BOOL_F
;
220 SCM prev_frame
= SCM_BOOL_F
;
224 && SCM_STACKP (a
->stack
)
225 && SCM_STACK_LENGTH (a
->stack
) > 0)
227 current_frame
= scm_stack_ref (a
->stack
, SCM_INUM0
);
228 source
= SCM_FRAME_SOURCE (current_frame
);
229 prev_frame
= SCM_FRAME_PREV (current_frame
);
230 if (!SCM_MEMOIZEDP (source
) && scm_is_true (prev_frame
))
231 source
= SCM_FRAME_SOURCE (prev_frame
);
232 if (!scm_is_symbol (pname
)
233 && !scm_is_string (pname
)
234 && SCM_FRAME_PROC_P (current_frame
)
235 && scm_is_true (scm_procedure_p (SCM_FRAME_PROC (current_frame
))))
236 pname
= scm_procedure_name (SCM_FRAME_PROC (current_frame
));
238 if (scm_is_symbol (pname
) || scm_is_string (pname
) || SCM_MEMOIZEDP (source
))
240 display_header (source
, a
->port
);
241 display_expression (current_frame
, pname
, source
, a
->port
);
243 display_header (source
, a
->port
);
244 scm_display_error_message (a
->message
, a
->args
, a
->port
);
245 return SCM_UNSPECIFIED
;
248 struct display_error_handler_data
{
253 /* This is the exception handler for error reporting routines.
254 Note that it is very important that this handler *doesn't* try to
255 print more than the error tag, since the error very probably is
256 caused by an erroneous print call-back routine. If we would
257 try to print all objects, we would enter an infinite loop. */
259 display_error_handler (struct display_error_handler_data
*data
,
260 SCM tag
, SCM args SCM_UNUSED
)
262 SCM print_state
= scm_make_print_state ();
263 scm_puts ("\nException during displaying of ", data
->port
);
264 scm_puts (data
->mode
, data
->port
);
265 scm_puts (": ", data
->port
);
266 scm_iprin1 (tag
, data
->port
, SCM_PRINT_STATE (print_state
));
267 scm_putc ('\n', data
->port
);
268 return SCM_UNSPECIFIED
;
272 /* The function scm_i_display_error prints out a detailed error message. This
273 * function will be called directly within libguile to signal error messages.
274 * No parameter checks will be performed by scm_i_display_error. Thus, User
275 * code should rather use the function scm_display_error.
278 scm_i_display_error (SCM stack
, SCM port
, SCM subr
, SCM message
, SCM args
, SCM rest
)
280 struct display_error_args a
;
281 struct display_error_handler_data data
;
290 scm_internal_catch (SCM_BOOL_T
,
291 (scm_t_catch_body
) display_error_body
, &a
,
292 (scm_t_catch_handler
) display_error_handler
, &data
);
296 SCM_DEFINE (scm_display_error
, "display-error", 6, 0, 0,
297 (SCM stack
, SCM port
, SCM subr
, SCM message
, SCM args
, SCM rest
),
298 "Display an error message to the output port @var{port}.\n"
299 "@var{stack} is the saved stack for the error, @var{subr} is\n"
300 "the name of the procedure in which the error occurred and\n"
301 "@var{message} is the actual error message, which may contain\n"
302 "formatting instructions. These will format the arguments in\n"
303 "the list @var{args} accordingly. @var{rest} is currently\n"
305 #define FUNC_NAME s_scm_display_error
307 SCM_VALIDATE_OUTPUT_PORT (2, port
);
309 scm_i_display_error (stack
, port
, subr
, message
, args
, rest
);
311 return SCM_UNSPECIFIED
;
321 static int n_print_params
= 9;
322 static print_params_t default_print_params
[] = {
326 { 1, 4 }, { 1, 3 }, { 1, 2 }
328 static print_params_t
*print_params
= default_print_params
;
331 SCM_DEFINE (scm_set_print_params_x
, "set-print-params!", 1, 0, 0,
333 "Set the print parameters to the values from @var{params}.\n"
334 "@var{params} must be a list of two-element lists which must\n"
335 "hold two integer values.")
336 #define FUNC_NAME s_scm_set_print_params_x
341 print_params_t
*new_params
;
343 SCM_VALIDATE_NONEMPTYLIST_COPYLEN (2, params
, n
);
344 for (ls
= params
; !SCM_NULL_OR_NIL_P (ls
); ls
= SCM_CDR (ls
))
345 SCM_ASSERT (scm_ilength (SCM_CAR (params
)) == 2
346 && scm_is_unsigned_integer (SCM_CAAR (ls
), 0, INT_MAX
)
347 && scm_is_unsigned_integer (SCM_CADAR (ls
), 0, INT_MAX
),
350 s_scm_set_print_params_x
);
351 new_params
= scm_malloc (n
* sizeof (print_params_t
));
352 if (print_params
!= default_print_params
)
354 print_params
= new_params
;
355 for (i
= 0; i
< n
; ++i
)
357 print_params
[i
].level
= scm_to_int (SCM_CAAR (params
));
358 print_params
[i
].length
= scm_to_int (SCM_CADAR (params
));
359 params
= SCM_CDR (params
);
362 return SCM_UNSPECIFIED
;
368 indent (int n
, SCM port
)
371 for (i
= 0; i
< n
; ++i
)
372 scm_putc (' ', port
);
376 display_frame_expr (char *hdr
, SCM exp
, char *tlr
, int indentation
, SCM sport
, SCM port
, scm_print_state
*pstate
)
379 scm_t_ptob_descriptor
*ptob
= scm_ptobs
+ SCM_PTOBNUM (sport
);
382 pstate
->length
= print_params
[i
].length
;
383 ptob
->seek (sport
, 0, SEEK_SET
);
384 if (scm_is_pair (exp
))
386 pstate
->level
= print_params
[i
].level
- 1;
387 scm_iprlist (hdr
, exp
, tlr
[0], sport
, pstate
);
388 scm_puts (&tlr
[1], sport
);
392 pstate
->level
= print_params
[i
].level
;
393 scm_iprin1 (exp
, sport
, pstate
);
396 n
= ptob
->seek (sport
, 0, SEEK_CUR
);
399 while (indentation
+ n
> SCM_BACKTRACE_WIDTH
&& i
< n_print_params
);
400 ptob
->truncate (sport
, n
);
402 scm_display (scm_strport_to_string (sport
), port
);
406 display_application (SCM frame
, int indentation
, SCM sport
, SCM port
, scm_print_state
*pstate
)
408 SCM proc
= SCM_FRAME_PROC (frame
);
409 SCM name
= (scm_is_true (scm_procedure_p (proc
))
410 ? scm_procedure_name (proc
)
412 display_frame_expr ("[",
413 scm_cons (scm_is_true (name
) ? name
: proc
,
414 SCM_FRAME_ARGS (frame
)),
415 SCM_FRAME_EVAL_ARGS_P (frame
) ? " ..." : "]",
422 SCM_DEFINE (scm_display_application
, "display-application", 1, 2, 0,
423 (SCM frame
, SCM port
, SCM indent
),
424 "Display a procedure application @var{frame} to the output port\n"
425 "@var{port}. @var{indent} specifies the indentation of the\n"
427 #define FUNC_NAME s_scm_display_application
429 SCM_VALIDATE_FRAME (1, frame
);
430 if (SCM_UNBNDP (port
))
431 port
= scm_current_output_port ();
433 SCM_VALIDATE_OPOUTPORT (2, port
);
434 if (SCM_UNBNDP (indent
))
437 if (SCM_FRAME_PROC_P (frame
))
438 /* Display an application. */
440 SCM sport
, print_state
;
441 scm_print_state
*pstate
;
443 /* Create a string port used for adaptation of printing parameters. */
444 sport
= scm_mkstrport (SCM_INUM0
,
445 scm_make_string (scm_from_int (240),
450 /* Create a print state for printing of frames. */
451 print_state
= scm_make_print_state ();
452 pstate
= SCM_PRINT_STATE (print_state
);
453 pstate
->writingp
= 1;
456 display_application (frame
, scm_to_int (indent
), sport
, port
, pstate
);
464 SCM_SYMBOL (sym_base
, "base");
467 display_backtrace_get_file_line (SCM frame
, SCM
*file
, SCM
*line
)
469 SCM source
= SCM_FRAME_SOURCE (frame
);
470 *file
= *line
= SCM_BOOL_F
;
471 if (SCM_MEMOIZEDP (source
))
473 *file
= scm_source_property (source
, scm_sym_filename
);
474 *line
= scm_source_property (source
, scm_sym_line
);
476 else if (scm_is_pair (source
)
477 && scm_is_pair (scm_cdr (source
))
478 && scm_is_pair (scm_cddr (source
))
479 && !scm_is_pair (scm_cdddr (source
)))
481 /* (addr . (filename . (line . column))), from vm compilation */
482 *file
= scm_cadr (source
);
483 *line
= scm_caddr (source
);
488 display_backtrace_file (frame
, last_file
, port
, pstate
)
492 scm_print_state
*pstate
;
496 display_backtrace_get_file_line (frame
, &file
, &line
);
498 if (scm_is_eq (file
, *last_file
))
503 scm_puts ("In ", port
);
504 if (scm_is_false (file
))
505 if (scm_is_false (line
))
506 scm_puts ("unknown file", port
);
508 scm_puts ("current input", port
);
511 pstate
->writingp
= 0;
512 scm_iprin1 (file
, port
, pstate
);
513 pstate
->writingp
= 1;
515 scm_puts (":\n", port
);
519 display_backtrace_file_and_line (SCM frame
, SCM port
, scm_print_state
*pstate
)
523 display_backtrace_get_file_line (frame
, &file
, &line
);
525 if (scm_is_eq (SCM_PACK (SCM_SHOW_FILE_NAME
), sym_base
))
527 if (scm_is_false (file
))
529 if (scm_is_false (line
))
530 scm_putc ('?', port
);
532 scm_puts ("<stdin>", port
);
536 pstate
-> writingp
= 0;
538 scm_iprin1 ((scm_is_string (file
)?
539 scm_basename (file
, SCM_UNDEFINED
) : file
),
542 scm_iprin1 (file
, port
, pstate
);
544 pstate
-> writingp
= 1;
547 scm_putc (':', port
);
549 else if (scm_is_true (line
))
552 for (i
= scm_to_int (line
)+1; i
> 0; i
= i
/10, j
++)
557 if (scm_is_false (line
))
558 scm_puts (" ?", port
);
560 scm_intprint (scm_to_int (line
) + 1, 10, port
);
561 scm_puts (": ", port
);
565 display_frame (SCM frame
, int nfield
, int indentation
, SCM sport
, SCM port
, scm_print_state
*pstate
)
569 /* Announce missing frames? */
570 if (!SCM_BACKWARDS_P
&& SCM_FRAME_OVERFLOW_P (frame
))
572 indent (nfield
+ 1 + indentation
, port
);
573 scm_puts ("...\n", port
);
576 /* display file name and line number */
577 if (scm_is_true (SCM_PACK (SCM_SHOW_FILE_NAME
)))
578 display_backtrace_file_and_line (frame
, port
, pstate
);
580 /* Check size of frame number. */
581 n
= SCM_FRAME_NUMBER (frame
);
582 for (i
= 0, j
= n
; j
> 0; ++i
) j
/= 10;
584 /* Number indentation. */
585 indent (nfield
- (i
? i
: 1), port
);
588 scm_iprin1 (scm_from_int (n
), port
, pstate
);
590 /* Real frame marker */
591 scm_putc (SCM_FRAME_REAL_P (frame
) ? '*' : ' ', port
);
594 indent (indentation
, port
);
596 if (SCM_FRAME_PROC_P (frame
))
597 /* Display an application. */
598 display_application (frame
, nfield
+ 1 + indentation
, sport
, port
, pstate
);
600 /* Display a special form. */
602 SCM source
= SCM_FRAME_SOURCE (frame
);
603 SCM copy
= (scm_is_pair (source
)
604 ? scm_source_property (source
, scm_sym_copy
)
606 SCM umcopy
= (SCM_MEMOIZEDP (source
)
607 ? scm_i_unmemoize_expr (source
)
609 display_frame_expr ("(",
610 scm_is_pair (copy
) ? copy
: umcopy
,
612 nfield
+ 1 + indentation
,
617 scm_putc ('\n', port
);
619 /* Announce missing frames? */
620 if (SCM_BACKWARDS_P
&& SCM_FRAME_OVERFLOW_P (frame
))
622 indent (nfield
+ 1 + indentation
, port
);
623 scm_puts ("...\n", port
);
627 struct display_backtrace_args
{
632 SCM highlight_objects
;
636 display_backtrace_body (struct display_backtrace_args
*a
)
637 #define FUNC_NAME "display_backtrace_body"
639 int n_frames
, beg
, end
, n
, i
, j
;
640 int nfield
, indent_p
, indentation
;
641 SCM frame
, sport
, print_state
;
643 scm_print_state
*pstate
;
645 a
->port
= SCM_COERCE_OUTPORT (a
->port
);
647 /* Argument checking and extraction. */
648 SCM_VALIDATE_STACK (1, a
->stack
);
649 SCM_VALIDATE_OPOUTPORT (2, a
->port
);
650 n_frames
= scm_to_int (scm_stack_length (a
->stack
));
651 n
= scm_is_integer (a
->depth
) ? scm_to_int (a
->depth
) : SCM_BACKTRACE_DEPTH
;
654 beg
= scm_is_integer (a
->first
) ? scm_to_int (a
->first
) : 0;
662 if (scm_is_integer (a
->first
))
664 beg
= scm_to_int (a
->first
);
678 SCM_ASSERT (beg
>= 0 && beg
< n_frames
, a
->first
, SCM_ARG3
, s_display_backtrace
);
679 SCM_ASSERT (n
> 0, a
->depth
, SCM_ARG4
, s_display_backtrace
);
681 /* Create a string port used for adaptation of printing parameters. */
682 sport
= scm_mkstrport (SCM_INUM0
,
683 scm_make_string (scm_from_int (240), SCM_UNDEFINED
),
687 /* Create a print state for printing of frames. */
688 print_state
= scm_make_print_state ();
689 pstate
= SCM_PRINT_STATE (print_state
);
690 pstate
->writingp
= 1;
692 pstate
->highlight_objects
= a
->highlight_objects
;
694 /* First find out if it's reasonable to do indentation. */
702 frame
= scm_stack_ref (a
->stack
, scm_from_int (beg
));
703 for (i
= 0, j
= 0; i
< n
; ++i
)
705 if (SCM_FRAME_REAL_P (frame
))
707 if (j
> SCM_BACKTRACE_INDENT
)
712 frame
= (SCM_BACKWARDS_P
713 ? SCM_FRAME_PREV (frame
)
714 : SCM_FRAME_NEXT (frame
));
718 /* Determine size of frame number field. */
719 j
= SCM_FRAME_NUMBER (scm_stack_ref (a
->stack
, scm_from_int (end
)));
720 for (i
= 0; j
> 0; ++i
) j
/= 10;
724 frame
= scm_stack_ref (a
->stack
, scm_from_int (beg
));
726 last_file
= SCM_UNDEFINED
;
727 for (i
= 0; i
< n
; ++i
)
729 if (!scm_is_eq (SCM_PACK (SCM_SHOW_FILE_NAME
), sym_base
))
730 display_backtrace_file (frame
, &last_file
, a
->port
, pstate
);
732 display_frame (frame
, nfield
, indentation
, sport
, a
->port
, pstate
);
733 if (indent_p
&& SCM_FRAME_EVAL_ARGS_P (frame
))
735 frame
= (SCM_BACKWARDS_P
?
736 SCM_FRAME_PREV (frame
) : SCM_FRAME_NEXT (frame
));
739 scm_remember_upto_here_1 (print_state
);
741 return SCM_UNSPECIFIED
;
745 SCM_DEFINE (scm_display_backtrace_with_highlights
, "display-backtrace", 2, 3, 0,
746 (SCM stack
, SCM port
, SCM first
, SCM depth
, SCM highlights
),
747 "Display a backtrace to the output port @var{port}. @var{stack}\n"
748 "is the stack to take the backtrace from, @var{first} specifies\n"
749 "where in the stack to start and @var{depth} how many frames\n"
750 "to display. @var{first} and @var{depth} can be @code{#f},\n"
751 "which means that default values will be used.\n"
752 "If @var{highlights} is given it should be a list; the elements\n"
753 "of this list will be highlighted wherever they appear in the\n"
755 #define FUNC_NAME s_scm_display_backtrace_with_highlights
757 struct display_backtrace_args a
;
758 struct display_error_handler_data data
;
763 if (SCM_UNBNDP (highlights
))
764 a
.highlight_objects
= SCM_EOL
;
766 a
.highlight_objects
= highlights
;
767 data
.mode
= "backtrace";
769 scm_internal_catch (SCM_BOOL_T
,
770 (scm_t_catch_body
) display_backtrace_body
, &a
,
771 (scm_t_catch_handler
) display_error_handler
, &data
);
772 return SCM_UNSPECIFIED
;
777 scm_display_backtrace (SCM stack
, SCM port
, SCM first
, SCM depth
)
779 return scm_display_backtrace_with_highlights (stack
, port
, first
, depth
,
783 SCM_VARIABLE (scm_has_shown_backtrace_hint_p_var
, "has-shown-backtrace-hint?");
785 SCM_DEFINE (scm_backtrace_with_highlights
, "backtrace", 0, 1, 0,
787 "Display a backtrace of the stack saved by the last error\n"
788 "to the current output port. If @var{highlights} is given\n"
789 "it should be a list; the elements of this list will be\n"
790 "highlighted wherever they appear in the backtrace.")
791 #define FUNC_NAME s_scm_backtrace_with_highlights
793 SCM port
= scm_current_output_port ();
795 scm_fluid_ref (SCM_VARIABLE_REF (scm_the_last_stack_fluid_var
));
797 if (SCM_UNBNDP (highlights
))
798 highlights
= SCM_EOL
;
800 if (scm_is_true (the_last_stack
))
803 scm_puts ("Backtrace:\n", port
);
804 scm_display_backtrace_with_highlights (the_last_stack
,
810 if (scm_is_false (SCM_VARIABLE_REF (scm_has_shown_backtrace_hint_p_var
))
813 scm_puts ("Type \"(debug-enable 'backtrace)\" if you would like "
815 "automatically if an error occurs in the future.\n",
817 SCM_VARIABLE_SET (scm_has_shown_backtrace_hint_p_var
, SCM_BOOL_T
);
822 scm_puts ("No backtrace available.\n", port
);
824 return SCM_UNSPECIFIED
;
831 return scm_backtrace_with_highlights (SCM_EOL
);
837 scm_init_backtrace ()
839 SCM f
= scm_make_fluid ();
840 scm_the_last_stack_fluid_var
= scm_c_define ("the-last-stack", f
);
842 #include "libguile/backtrace.x"