1996-10-14 03:24:16 +00:00
|
|
|
|
/* Printing of backtraces and error messages
|
2014-02-27 22:04:39 -05:00
|
|
|
|
* Copyright (C) 1996,1997,1998,1999,2000,2001, 2003, 2004, 2006, 2009,
|
|
|
|
|
|
* 2010, 2011, 2014 Free Software Foundation
|
1996-10-14 03:24:16 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
|
|
* as published by the Free Software Foundation; either version 3 of
|
|
|
|
|
|
* the License, or (at your option) any later version.
|
1996-10-14 03:24:16 +00:00
|
|
|
|
*
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* This library is distributed in the hope that it will be useful, but
|
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
* Lesser General Public License for more details.
|
1996-10-14 03:24:16 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
|
|
* 02110-1301 USA
|
2003-04-05 19:15:35 +00:00
|
|
|
|
*/
|
1996-10-14 03:24:16 +00:00
|
|
|
|
|
2008-09-13 15:35:27 +02:00
|
|
|
|
#ifdef HAVE_CONFIG_H
|
2003-03-25 23:52:40 +00:00
|
|
|
|
# include <config.h>
|
|
|
|
|
|
#endif
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
2001-07-03 15:27:56 +00:00
|
|
|
|
#include <stdio.h>
|
1999-09-12 02:23:39 +00:00
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/_scm.h"
|
1999-09-22 04:36:56 +00:00
|
|
|
|
|
1999-09-15 15:22:07 +00:00
|
|
|
|
#include <unistd.h>
|
2001-06-26 17:53:09 +00:00
|
|
|
|
#ifdef HAVE_IO_H
|
|
|
|
|
|
#include <io.h>
|
|
|
|
|
|
#endif
|
1999-09-15 15:22:07 +00:00
|
|
|
|
|
2010-07-15 12:11:34 +02:00
|
|
|
|
#include "libguile/deprecation.h"
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/stacks.h"
|
|
|
|
|
|
#include "libguile/srcprop.h"
|
|
|
|
|
|
#include "libguile/struct.h"
|
|
|
|
|
|
#include "libguile/strports.h"
|
|
|
|
|
|
#include "libguile/throw.h"
|
|
|
|
|
|
#include "libguile/fluids.h"
|
|
|
|
|
|
#include "libguile/ports.h"
|
|
|
|
|
|
#include "libguile/strings.h"
|
2003-05-12 20:46:52 +00:00
|
|
|
|
#include "libguile/dynwind.h"
|
replace frame implementation with VM frames
* libguile/stacks.h: Rework so that a stack doesn't copy information out
of VM frames, it just holds onto a VM frame, along with the stack id
and length. VM frames are now the only representation of frames in
Guile.
(scm_t_info_frame, SCM_FRAME_N_SLOTS, SCM_FRAME_REF, SCM_FRAME_NUMBER)
(SCM_FRAME_FLAGS, SCM_FRAME_SOURCE, SCM_FRAME_PROC, SCM_FRAME_ARGS)
(SCM_FRAME_PREV, SCM_FRAME_NEXT)
(SCM_FRAMEF_VOID, SCM_FRAMEF_REAL, SCM_FRAMEF_PROC)
(SCM_FRAMEF_EVAL_ARGS, SCM_FRAMEF_OVERFLOW)
(SCM_FRAME_VOID_P, SCM_FRAME_REAL_P, SCM_FRAME_PROC_P)
(SCM_FRAME_EVAL_ARGS_P, SCM_FRAME_OVERFLOW_P): Remove these macros
corresponding to the old frame implementation.
(scm_frame_p scm_frame_source, scm_frame_procedure)
(scm_frame_arguments): These definitions are now in frames.h.
(scm_last_stack_frame): Remove declaration of previously-removed
constructor. Probably should re-instate it though.
(scm_frame_number, scm_frame_previous, scm_frame_next)
(scm_frame_real_p, scm_frame_procedure_p, scm_frame_evaluating_args_p)
(scm_frame_overflow_p) : Remove these procedures corresponding to the
old stack implementation.
* libguile/stacks.c: Update for new frames implementation.
* libguile/frames.h:
* libguile/frames.c: Rename functions operating on VM frames to have a
scm_frame prefix, not scm_vm_frame -- because they really are the only
frames we have. Rename corresponding Scheme functions too, from
vm-frame-foo to frame-foo.
* libguile/deprecated.h: Remove scm_stack and scm_info_frame data types.
* libguile/vm.c (vm_dispatch_hook): Adapt to scm_c_make_frame name
change.
* module/system/vm/frame.scm: No need to export functions provided
frames.c now, as we load those procedures into the default environment
now. Rename functions, and remove a couple of outdated, unused
functions. The bottom half of this file is still bitrotten, though.
* libguile/backtrace.c: Rework to operate on the new frame
representation. Also fix a bug displaying file names for compiled
procedures.
* libguile/init.c: Load the VM much earlier, just because we can. Also
it allows us to have frames.[ch] loaded in time for stacks to be
initialized, so that scm_frame_arguments can do the right thing.
2009-12-03 13:09:58 +01:00
|
|
|
|
#include "libguile/frames.h"
|
1996-10-14 03:24:16 +00:00
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/validate.h"
|
|
|
|
|
|
#include "libguile/backtrace.h"
|
2001-05-25 00:19:36 +00:00
|
|
|
|
#include "libguile/filesys.h"
|
* backtrace.c, debug.c, debug.h, deprecation.c, eq.c, eval.c
eval.h, gsubr.c, init.c, macros.c, print.c, print.h, read.c,
read.h, stacks.c, symbols.c, throw.c: use private-options.h
* private-options.h: new file: contain hardcoded option
definitions.
2007-01-22 15:14:40 +00:00
|
|
|
|
#include "libguile/private-options.h"
|
1996-10-14 03:24:16 +00:00
|
|
|
|
|
|
|
|
|
|
/* {Error reporting and backtraces}
|
|
|
|
|
|
*
|
|
|
|
|
|
* Note that these functions shouldn't generate errors themselves.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2011-02-11 13:13:26 +01:00
|
|
|
|
static SCM
|
|
|
|
|
|
boot_print_exception (SCM port, SCM frame, SCM key, SCM args)
|
|
|
|
|
|
#define FUNC_NAME "boot-print-exception"
|
|
|
|
|
|
{
|
2016-04-26 23:07:28 +02:00
|
|
|
|
scm_puts ("Throw to key ", port);
|
2011-02-11 13:13:26 +01:00
|
|
|
|
scm_write (key, port);
|
2016-04-26 23:07:28 +02:00
|
|
|
|
scm_puts (" with args ", port);
|
2011-02-11 13:13:26 +01:00
|
|
|
|
scm_write (args, port);
|
|
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
2014-01-23 11:37:36 -05:00
|
|
|
|
static SCM print_exception_var;
|
2016-04-01 21:31:06 +02:00
|
|
|
|
static SCM print_frame_var;
|
|
|
|
|
|
static SCM kw_count;
|
|
|
|
|
|
static SCM print_frames_var;
|
|
|
|
|
|
static SCM frame_to_stack_vector_var;
|
2014-01-23 11:37:36 -05:00
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
init_print_exception_var (void)
|
|
|
|
|
|
{
|
|
|
|
|
|
print_exception_var
|
|
|
|
|
|
= scm_module_variable (scm_the_root_module (),
|
|
|
|
|
|
scm_from_latin1_symbol ("print-exception"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-01 21:31:06 +02:00
|
|
|
|
static void
|
|
|
|
|
|
init_print_frame_var (void)
|
|
|
|
|
|
{
|
|
|
|
|
|
print_frame_var =
|
|
|
|
|
|
scm_c_public_variable ("system repl debug", "print-frame");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
init_print_frames_var_and_frame_to_stack_vector_var (void)
|
|
|
|
|
|
{
|
|
|
|
|
|
kw_count = scm_from_latin1_keyword ("count");
|
|
|
|
|
|
print_frames_var =
|
|
|
|
|
|
scm_c_public_variable ("system repl debug", "print-frames");
|
|
|
|
|
|
frame_to_stack_vector_var =
|
|
|
|
|
|
scm_c_public_variable ("system repl debug", "frame->stack-vector");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-02-11 13:13:26 +01:00
|
|
|
|
SCM
|
|
|
|
|
|
scm_print_exception (SCM port, SCM frame, SCM key, SCM args)
|
|
|
|
|
|
#define FUNC_NAME "print-exception"
|
|
|
|
|
|
{
|
2014-01-23 11:37:36 -05:00
|
|
|
|
static scm_i_pthread_once_t once = SCM_I_PTHREAD_ONCE_INIT;
|
|
|
|
|
|
scm_i_pthread_once (&once, init_print_exception_var);
|
2011-02-11 13:13:26 +01:00
|
|
|
|
|
|
|
|
|
|
SCM_VALIDATE_OPOUTPORT (1, port);
|
|
|
|
|
|
if (scm_is_true (frame))
|
|
|
|
|
|
SCM_VALIDATE_FRAME (2, frame);
|
|
|
|
|
|
SCM_VALIDATE_SYMBOL (3, key);
|
|
|
|
|
|
SCM_VALIDATE_LIST (4, args);
|
|
|
|
|
|
|
2014-01-23 11:37:36 -05:00
|
|
|
|
return scm_call_4 (scm_variable_ref (print_exception_var),
|
2011-02-11 13:13:26 +01:00
|
|
|
|
port, frame, key, args);
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-05-12 20:46:52 +00:00
|
|
|
|
/* Print parameters for error messages. */
|
|
|
|
|
|
|
|
|
|
|
|
#define DISPLAY_ERROR_MESSAGE_MAX_LEVEL 7
|
|
|
|
|
|
#define DISPLAY_ERROR_MESSAGE_MAX_LENGTH 10
|
|
|
|
|
|
|
|
|
|
|
|
/* Print parameters for failing expressions in error messages.
|
|
|
|
|
|
* (See also `print_params' below for backtrace print parameters.)
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#define DISPLAY_EXPRESSION_MAX_LEVEL 2
|
|
|
|
|
|
#define DISPLAY_EXPRESSION_MAX_LENGTH 3
|
|
|
|
|
|
|
1996-10-14 03:24:16 +00:00
|
|
|
|
#undef SCM_ASSERT
|
|
|
|
|
|
#define SCM_ASSERT(_cond, _arg, _pos, _subr) \
|
|
|
|
|
|
if (!(_cond)) \
|
|
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
|
2011-02-11 13:13:26 +01:00
|
|
|
|
|
1996-12-10 01:41:37 +00:00
|
|
|
|
void
|
1999-12-12 20:35:02 +00:00
|
|
|
|
scm_display_error_message (SCM message, SCM args, SCM port)
|
1996-10-14 03:24:16 +00:00
|
|
|
|
{
|
2011-02-11 15:03:38 +01:00
|
|
|
|
scm_print_exception (port, SCM_BOOL_F, scm_misc_error_key,
|
|
|
|
|
|
scm_list_3 (SCM_BOOL_F, message, args));
|
1997-09-24 20:18:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2001-01-24 15:58:46 +00:00
|
|
|
|
|
|
|
|
|
|
/* The function scm_i_display_error prints out a detailed error message. This
|
|
|
|
|
|
* function will be called directly within libguile to signal error messages.
|
|
|
|
|
|
* No parameter checks will be performed by scm_i_display_error. Thus, User
|
|
|
|
|
|
* code should rather use the function scm_display_error.
|
|
|
|
|
|
*/
|
|
|
|
|
|
void
|
2010-07-15 12:11:34 +02:00
|
|
|
|
scm_i_display_error (SCM frame, SCM port, SCM subr, SCM message, SCM args, SCM rest)
|
1997-09-24 20:18:54 +00:00
|
|
|
|
{
|
2011-02-11 15:03:38 +01:00
|
|
|
|
scm_print_exception (port, frame, scm_misc_error_key,
|
|
|
|
|
|
scm_list_3 (subr, message, args));
|
2001-01-24 15:58:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_display_error, "display-error", 6, 0, 0,
|
2010-07-15 12:11:34 +02:00
|
|
|
|
(SCM frame, SCM port, SCM subr, SCM message, SCM args, SCM rest),
|
2001-02-16 15:21:21 +00:00
|
|
|
|
"Display an error message to the output port @var{port}.\n"
|
2010-07-15 12:11:34 +02:00
|
|
|
|
"@var{frame} is the frame in which the error occurred, @var{subr} is\n"
|
2002-03-15 10:37:40 +00:00
|
|
|
|
"the name of the procedure in which the error occurred and\n"
|
2001-02-16 15:21:21 +00:00
|
|
|
|
"@var{message} is the actual error message, which may contain\n"
|
|
|
|
|
|
"formatting instructions. These will format the arguments in\n"
|
|
|
|
|
|
"the list @var{args} accordingly. @var{rest} is currently\n"
|
|
|
|
|
|
"ignored.")
|
2001-01-24 15:58:46 +00:00
|
|
|
|
#define FUNC_NAME s_scm_display_error
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_VALIDATE_OUTPUT_PORT (2, port);
|
|
|
|
|
|
|
2012-01-08 16:37:22 +01:00
|
|
|
|
#if SCM_ENABLE_DEPRECATED
|
|
|
|
|
|
if (SCM_STACKP (frame))
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_c_issue_deprecation_warning
|
|
|
|
|
|
("Passing a stack as the first argument to `scm_display_error' is "
|
|
|
|
|
|
"deprecated. Pass a frame instead.");
|
|
|
|
|
|
if (SCM_STACK_LENGTH (frame))
|
|
|
|
|
|
frame = scm_stack_ref (frame, SCM_INUM0);
|
|
|
|
|
|
else
|
|
|
|
|
|
frame = SCM_BOOL_F;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2010-07-15 12:11:34 +02:00
|
|
|
|
scm_i_display_error (frame, port, subr, message, args, rest);
|
2001-01-24 15:58:46 +00:00
|
|
|
|
|
1996-10-14 03:24:16 +00:00
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-10-14 03:24:16 +00:00
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_display_application, "display-application", 1, 2, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM frame, SCM port, SCM indent),
|
2001-02-16 15:21:21 +00:00
|
|
|
|
"Display a procedure application @var{frame} to the output port\n"
|
|
|
|
|
|
"@var{port}. @var{indent} specifies the indentation of the\n"
|
|
|
|
|
|
"output.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_display_application
|
1997-03-07 21:42:32 +00:00
|
|
|
|
{
|
2016-04-01 21:31:06 +02:00
|
|
|
|
static scm_i_pthread_once_t once = SCM_I_PTHREAD_ONCE_INIT;
|
|
|
|
|
|
scm_i_pthread_once (&once, init_print_frame_var);
|
1996-10-14 03:24:16 +00:00
|
|
|
|
|
2016-04-01 21:31:06 +02:00
|
|
|
|
/* FIXME perhaps: ignoring indent. But really we should deprecate
|
|
|
|
|
|
this procedure in favor of print-frame. */
|
|
|
|
|
|
return scm_call_2 (scm_variable_ref (print_frame_var), frame, port);
|
1996-10-14 03:24:16 +00:00
|
|
|
|
}
|
2016-04-01 21:31:06 +02:00
|
|
|
|
#undef FUNC_NAME
|
1996-10-14 03:24:16 +00:00
|
|
|
|
|
1997-09-24 20:18:54 +00:00
|
|
|
|
struct display_backtrace_args {
|
|
|
|
|
|
SCM stack;
|
|
|
|
|
|
SCM port;
|
|
|
|
|
|
SCM first;
|
|
|
|
|
|
SCM depth;
|
2004-09-23 17:51:53 +00:00
|
|
|
|
SCM highlight_objects;
|
1997-09-24 20:18:54 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
2001-06-23 15:25:57 +00:00
|
|
|
|
display_backtrace_body (struct display_backtrace_args *a)
|
2016-04-01 21:31:06 +02:00
|
|
|
|
#define FUNC_NAME "display-backtrace"
|
1996-10-14 03:24:16 +00:00
|
|
|
|
{
|
2016-04-01 21:31:06 +02:00
|
|
|
|
static scm_i_pthread_once_t once = SCM_I_PTHREAD_ONCE_INIT;
|
|
|
|
|
|
SCM frames;
|
|
|
|
|
|
|
|
|
|
|
|
scm_i_pthread_once (&once,
|
|
|
|
|
|
init_print_frames_var_and_frame_to_stack_vector_var);
|
1996-10-14 03:24:16 +00:00
|
|
|
|
|
* filesys.c (scm_close, set_element, get_element, scm_chown,
scm_chmod, scm_stat, scm_truncate_file, scm_fcntl, scm_fsync): Use
SCM_COERCE_OUTPORT to cope with the printstate/port magic.
* ports.c (scm_port_revealed, scm_set_port_revealed_x,
scm_close_port, scm_port_line, scm_set_port_line_x,
scm_port_column, scm_set_port_column_x, scm_port_filename,
scm_set_port_filename_x, scm_port_mode,
scm_close_all_ports_except, scm_set_current_output_port,
scm_set_current_error_port): Likewise
* ioext.c (scm_redirect_port, scm_dup_to_fdes, scm_freopen,
scm_ftell, scm_fileno, scm_isatty_p, scm_primitive_move_to_fdes):
Likewise
* posix.c (scm_ttyname, scm_tcgetpgrp, scm_tcsetpgrp): Likewise
* backtrace.c (display_backtrace_body): Likewise
* fports (scm_setvbuf): Likewise
* socket.c (scm_getsockopt, scm_setsockopt, scm_shutdown,
scm_connect, scm_bind, scm_listen, scm_accept, scm_getsockname,
scm_getpeername, scm_send, scm_sendto): Likewise
* unif.c (scm_uniform_array_write): Likewise
1997-10-25 21:54:12 +00:00
|
|
|
|
a->port = SCM_COERCE_OUTPORT (a->port);
|
|
|
|
|
|
|
1996-10-14 03:24:16 +00:00
|
|
|
|
/* Argument checking and extraction. */
|
2001-06-23 15:25:57 +00:00
|
|
|
|
SCM_VALIDATE_STACK (1, a->stack);
|
|
|
|
|
|
SCM_VALIDATE_OPOUTPORT (2, a->port);
|
1997-09-24 20:18:54 +00:00
|
|
|
|
|
2016-04-01 21:31:06 +02:00
|
|
|
|
if (scm_is_false (a->first))
|
|
|
|
|
|
a->first = SCM_INUM0;
|
|
|
|
|
|
if (scm_is_false (a->depth))
|
|
|
|
|
|
a->depth = scm_from_int (SCM_BACKTRACE_DEPTH);
|
|
|
|
|
|
|
|
|
|
|
|
if (scm_is_false (scm_less_p (a->first, scm_stack_length (a->stack))))
|
|
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
|
|
|
|
|
|
frames = scm_call_1 (scm_variable_ref (frame_to_stack_vector_var),
|
|
|
|
|
|
scm_stack_ref (a->stack, a->first));
|
|
|
|
|
|
|
|
|
|
|
|
/* FIXME: highlight_objects */
|
|
|
|
|
|
scm_call_4 (scm_variable_ref (print_frames_var), frames, a->port,
|
|
|
|
|
|
kw_count, a->depth);
|
2001-03-31 21:19:50 +00:00
|
|
|
|
|
1997-09-24 20:18:54 +00:00
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1997-09-24 20:18:54 +00:00
|
|
|
|
|
2011-02-11 15:03:38 +01:00
|
|
|
|
static SCM
|
|
|
|
|
|
error_during_backtrace (void *data, SCM tag, SCM throw_args)
|
|
|
|
|
|
{
|
2011-10-24 17:58:22 +02:00
|
|
|
|
SCM port = SCM_PACK_POINTER (data);
|
2011-02-11 15:03:38 +01:00
|
|
|
|
|
2016-04-26 23:07:28 +02:00
|
|
|
|
scm_puts ("Exception thrown while printing backtrace:\n", port);
|
2011-02-11 15:03:38 +01:00
|
|
|
|
scm_print_exception (port, SCM_BOOL_F, tag, throw_args);
|
|
|
|
|
|
|
|
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-11-02 22:49:14 +00:00
|
|
|
|
SCM_DEFINE (scm_display_backtrace_with_highlights, "display-backtrace", 2, 3, 0,
|
2004-09-23 17:51:53 +00:00
|
|
|
|
(SCM stack, SCM port, SCM first, SCM depth, SCM highlights),
|
2006-08-28 22:17:26 +00:00
|
|
|
|
"Display a backtrace to the output port @var{port}. @var{stack}\n"
|
2001-02-16 15:21:21 +00:00
|
|
|
|
"is the stack to take the backtrace from, @var{first} specifies\n"
|
2006-08-28 22:17:26 +00:00
|
|
|
|
"where in the stack to start and @var{depth} how many frames\n"
|
|
|
|
|
|
"to display. @var{first} and @var{depth} can be @code{#f},\n"
|
2004-09-23 18:42:59 +00:00
|
|
|
|
"which means that default values will be used.\n"
|
2006-08-28 22:17:26 +00:00
|
|
|
|
"If @var{highlights} is given it should be a list; the elements\n"
|
|
|
|
|
|
"of this list will be highlighted wherever they appear in the\n"
|
|
|
|
|
|
"backtrace.")
|
2004-09-23 17:51:53 +00:00
|
|
|
|
#define FUNC_NAME s_scm_display_backtrace_with_highlights
|
1997-09-24 20:18:54 +00:00
|
|
|
|
{
|
1998-07-12 13:22:51 +00:00
|
|
|
|
struct display_backtrace_args a;
|
|
|
|
|
|
a.stack = stack;
|
|
|
|
|
|
a.port = port;
|
2016-04-01 21:31:06 +02:00
|
|
|
|
a.first = SCM_UNBNDP (first) ? SCM_BOOL_F : first;
|
|
|
|
|
|
a.depth = SCM_UNBNDP (depth) ? SCM_BOOL_F : depth;
|
|
|
|
|
|
a.highlight_objects = SCM_UNBNDP (highlights) ? SCM_EOL : highlights;
|
2011-02-11 15:03:38 +01:00
|
|
|
|
|
1997-09-24 20:18:54 +00:00
|
|
|
|
scm_internal_catch (SCM_BOOL_T,
|
2001-06-14 19:50:43 +00:00
|
|
|
|
(scm_t_catch_body) display_backtrace_body, &a,
|
2011-10-24 17:58:22 +02:00
|
|
|
|
(scm_t_catch_handler) error_during_backtrace, SCM_UNPACK_POINTER (port));
|
2011-02-11 15:03:38 +01:00
|
|
|
|
|
1996-10-14 03:24:16 +00:00
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-10-14 03:24:16 +00:00
|
|
|
|
|
2004-09-23 17:51:53 +00:00
|
|
|
|
SCM
|
|
|
|
|
|
scm_display_backtrace (SCM stack, SCM port, SCM first, SCM depth)
|
|
|
|
|
|
{
|
|
|
|
|
|
return scm_display_backtrace_with_highlights (stack, port, first, depth,
|
|
|
|
|
|
SCM_EOL);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2001-05-15 14:57:22 +00:00
|
|
|
|
SCM_VARIABLE (scm_has_shown_backtrace_hint_p_var, "has-shown-backtrace-hint?");
|
1997-02-10 01:01:54 +00:00
|
|
|
|
|
2004-09-23 17:51:53 +00:00
|
|
|
|
SCM_DEFINE (scm_backtrace_with_highlights, "backtrace", 0, 1, 0,
|
|
|
|
|
|
(SCM highlights),
|
2010-06-19 13:43:33 +02:00
|
|
|
|
"Display a backtrace of the current stack to the current\n"
|
|
|
|
|
|
"output port. If @var{highlights} is given, it should be\n"
|
|
|
|
|
|
"a list; the elements of this list will be highlighted\n"
|
|
|
|
|
|
"wherever they appear in the backtrace.")
|
2004-09-23 17:51:53 +00:00
|
|
|
|
#define FUNC_NAME s_scm_backtrace_with_highlights
|
1997-02-10 01:01:54 +00:00
|
|
|
|
{
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM port = scm_current_output_port ();
|
2010-06-19 13:43:33 +02:00
|
|
|
|
SCM stack = scm_make_stack (SCM_BOOL_T, SCM_EOL);
|
|
|
|
|
|
|
2004-09-23 17:51:53 +00:00
|
|
|
|
if (SCM_UNBNDP (highlights))
|
|
|
|
|
|
highlights = SCM_EOL;
|
|
|
|
|
|
|
2010-06-19 13:43:33 +02:00
|
|
|
|
scm_newline (port);
|
2016-04-26 23:07:28 +02:00
|
|
|
|
scm_puts ("Backtrace:\n", port);
|
2010-06-19 13:43:33 +02:00
|
|
|
|
scm_display_backtrace_with_highlights (stack, port, SCM_BOOL_F, SCM_BOOL_F,
|
|
|
|
|
|
highlights);
|
|
|
|
|
|
scm_newline (port);
|
|
|
|
|
|
|
1997-02-10 01:01:54 +00:00
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1997-02-10 01:01:54 +00:00
|
|
|
|
|
2004-09-23 17:51:53 +00:00
|
|
|
|
SCM
|
|
|
|
|
|
scm_backtrace (void)
|
|
|
|
|
|
{
|
|
|
|
|
|
return scm_backtrace_with_highlights (SCM_EOL);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
1996-10-14 03:24:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
scm_init_backtrace ()
|
|
|
|
|
|
{
|
2011-02-11 13:13:26 +01:00
|
|
|
|
scm_c_define_gsubr ("print-exception", 4, 0, 0, boot_print_exception);
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/backtrace.x"
|
1996-10-14 03:24:16 +00:00
|
|
|
|
}
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|