/* Debugging extensions for Guile
- * Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2006, 2008, 2009, 2010 Free Software Foundation
+ * Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2006, 2008, 2009, 2010, 2011, 2012 Free Software Foundation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
\f
+/*
+ * Debugging options.
+ */
+
+scm_t_option scm_debug_opts[] = {
+ { SCM_OPTION_BOOLEAN, "backwards", 0,
+ "Display backtrace in anti-chronological order." },
+ { SCM_OPTION_INTEGER, "width", 79, "Maximal width of backtrace." },
+ { SCM_OPTION_INTEGER, "depth", 20, "Maximal length of printed backtrace." },
+ { SCM_OPTION_BOOLEAN, "backtrace", 1, "Show backtrace on error." },
+ /* This default stack limit will be overridden by init_stack_limit(),
+ if we have getrlimit() and the stack limit is not INFINITY. But it is still
+ important, as some systems have both the soft and the hard limits set to
+ INFINITY; in that case we fall back to this value.
+
+ The situation is aggravated by certain compilers, which can consume
+ "beaucoup de stack", as they say in France.
+
+ See http://thread.gmane.org/gmane.lisp.guile.devel/8599/focus=8662 for
+ more discussion. This setting is 640 KB on 32-bit arches (should be enough
+ for anyone!) or a whoppin' 1280 KB on 64-bit arches.
+ */
+ { SCM_OPTION_INTEGER, "stack", 160000, "Stack size limit (measured in words; 0 = no check)." },
+ { SCM_OPTION_SCM, "show-file-name", SCM_BOOL_T_BITS,
+ "Show file names and line numbers "
+ "in backtraces when not `#f'. A value of `base' "
+ "displays only base names, while `#t' displays full names."},
+ { SCM_OPTION_BOOLEAN, "warn-deprecated", 0,
+ "Warn when deprecated features are used." },
+ { 0 },
+};
+
+
/* {Run time control of the debugging evaluator}
*/
scm_dynwind_critical_section (SCM_BOOL_F);
ans = scm_options (setting, scm_debug_opts, FUNC_NAME);
- if (SCM_N_FRAMES < 1)
- {
- scm_options (ans, scm_debug_opts, FUNC_NAME);
- SCM_OUT_OF_RANGE (1, setting);
- }
#ifdef STACK_CHECKING
scm_stack_checking_enabled_p = SCM_STACK_CHECKING_P;
#endif
}
#undef FUNC_NAME
-
-static void
-with_traps_before (void *data)
-{
- int *trap_flag = data;
- *trap_flag = SCM_TRAPS_P;
- SCM_TRAPS_P = 1;
-}
-
-static void
-with_traps_after (void *data)
-{
- int *trap_flag = data;
- SCM_TRAPS_P = *trap_flag;
-}
-
-static SCM
-with_traps_inner (void *data)
-{
- SCM thunk = SCM_PACK ((scm_t_bits) data);
- return scm_call_0 (thunk);
-}
-
-SCM_DEFINE (scm_with_traps, "with-traps", 1, 0, 0,
- (SCM thunk),
- "Call @var{thunk} with traps enabled.")
-#define FUNC_NAME s_scm_with_traps
-{
- int trap_flag;
- SCM_VALIDATE_THUNK (1, thunk);
- return scm_internal_dynamic_wind (with_traps_before,
- with_traps_inner,
- with_traps_after,
- (void *) SCM_UNPACK (thunk),
- &trap_flag);
-}
-#undef FUNC_NAME
-
\f
-SCM_SYMBOL (scm_sym_procname, "procname");
-SCM_SYMBOL (scm_sym_dots, "...");
SCM_SYMBOL (scm_sym_source, "source");
SCM_DEFINE (scm_procedure_name, "procedure-name", 1, 0, 0,
"Return the name of the procedure @var{proc}")
#define FUNC_NAME s_scm_procedure_name
{
- SCM name;
-
SCM_VALIDATE_PROC (1, proc);
while (SCM_STRUCTP (proc) && SCM_STRUCT_APPLICABLE_P (proc))
proc = SCM_STRUCT_PROCEDURE (proc);
- name = scm_procedure_property (proc, scm_sym_name);
- if (scm_is_false (name) && SCM_PROGRAM_P (proc))
- name = scm_program_name (proc);
- return name;
+ return scm_procedure_property (proc, scm_sym_name);
}
#undef FUNC_NAME
#undef FUNC_NAME
#endif
+SCM
+scm_local_eval (SCM exp, SCM env)
+{
+ static SCM local_eval_var = SCM_UNDEFINED;
+ static scm_i_pthread_mutex_t local_eval_var_mutex
+ = SCM_I_PTHREAD_MUTEX_INITIALIZER;
+
+ scm_i_scm_pthread_mutex_lock (&local_eval_var_mutex);
+ if (SCM_UNBNDP (local_eval_var))
+ local_eval_var = scm_c_public_variable ("ice-9 local-eval", "local-eval");
+ scm_i_pthread_mutex_unlock (&local_eval_var_mutex);
+
+ return scm_call_2 (SCM_VARIABLE_REF (local_eval_var), exp, env);
+}
+
static void
init_stack_limit (void)
{