[uim-commit] r2021 - branches/r5rs/sigscheme
yamaken at freedesktop.org
yamaken at freedesktop.org
Sat Nov 5 20:25:06 PST 2005
Author: yamaken
Date: 2005-11-05 20:25:02 -0800 (Sat, 05 Nov 2005)
New Revision: 2021
Modified:
branches/r5rs/sigscheme/error.c
branches/r5rs/sigscheme/eval.c
branches/r5rs/sigscheme/sigschemeinternal.h
branches/r5rs/sigscheme/storage-continuation.c
Log:
* This commit fixes the SEGV by broken backtrace information handlings
when a continuation switching has occur
* sigscheme/sigschemeinternal.h
- (Scm_PushTraceFrame, Scm_PopTraceFrame, Scm_TraceStack): New
function decl
* sigscheme/storage-continuation.c
- (trace_stack): New static variable
- (SigScm_InitContinuation, Scm_CallWithCurrentContinuation): Add
trace_stack handlings
- (Scm_PushTraceFrame, Scm_PopTraceFrame, Scm_TraceStack): New
function
* sigscheme/eval.c
- (scm_trace_root): Removed
- (Scm_eval): Follow the internal API change
* sigscheme/error.c
- (SigScm_ShowBacktrace): Ditto
Modified: branches/r5rs/sigscheme/error.c
===================================================================
--- branches/r5rs/sigscheme/error.c 2005-11-05 22:47:11 UTC (rev 2020)
+++ branches/r5rs/sigscheme/error.c 2005-11-06 04:25:02 UTC (rev 2021)
@@ -155,7 +155,7 @@
&& !SCM_SYMBOL_BOUNDP(var))
#if SCM_DEBUG
- struct trace_frame *f;
+ const struct trace_frame *f;
ScmObj env;
ScmObj obj;
ScmObj proc;
@@ -163,7 +163,7 @@
SigScm_ErrorPrintf(SCM_BACKTRACE_HEADER);
/* show each frame's obj */
- for (f = scm_trace_root; f; f = f->prev) {
+ for (f = Scm_TraceStack(); f; f = f->prev) {
#if SCM_DEBUG_BACKTRACE_SEP
SigScm_ErrorPrintf("------------------------------\n");
#endif /* SCM_DEBUG_BACKTRACE_SEP */
Modified: branches/r5rs/sigscheme/eval.c
===================================================================
--- branches/r5rs/sigscheme/eval.c 2005-11-05 22:47:11 UTC (rev 2020)
+++ branches/r5rs/sigscheme/eval.c 2005-11-06 04:25:02 UTC (rev 2021)
@@ -72,7 +72,6 @@
/*=======================================
Variable Declarations
=======================================*/
-struct trace_frame *scm_trace_root = NULL;
/*=======================================
File Local Function Declarations
@@ -485,10 +484,8 @@
#if SCM_DEBUG
struct trace_frame frame;
- frame.prev = scm_trace_root;
- frame.obj = obj;
- frame.env = env;
- scm_trace_root = &frame;
+
+ Scm_PushTraceFrame(&frame, obj, env);
#endif
state.env = env;
@@ -515,7 +512,7 @@
}
#if SCM_DEBUG
- scm_trace_root = frame.prev;
+ Scm_PopTraceFrame();
#endif
return ret;
}
Modified: branches/r5rs/sigscheme/sigschemeinternal.h
===================================================================
--- branches/r5rs/sigscheme/sigschemeinternal.h 2005-11-05 22:47:11 UTC (rev 2020)
+++ branches/r5rs/sigscheme/sigschemeinternal.h 2005-11-06 04:25:02 UTC (rev 2021)
@@ -345,6 +345,9 @@
ScmObj Scm_CallWithCurrentContinuation(ScmObj proc, ScmEvalState *eval_state);
void Scm_CallContinuation(ScmObj cont, ScmObj ret);
ScmObj Scm_DynamicWind(ScmObj before, ScmObj thunk, ScmObj after);
+void Scm_PushTraceFrame(struct trace_frame *frame, ScmObj obj, ScmObj env);
+void Scm_PopTraceFrame(void);
+const struct trace_frame *Scm_TraceStack(void);
/* storage-symbol.c */
void SigScm_InitSymbol(void);
Modified: branches/r5rs/sigscheme/storage-continuation.c
===================================================================
--- branches/r5rs/sigscheme/storage-continuation.c 2005-11-05 22:47:11 UTC (rev 2020)
+++ branches/r5rs/sigscheme/storage-continuation.c 2005-11-06 04:25:02 UTC (rev 2021)
@@ -68,6 +68,8 @@
static ScmObj continuation_thrown_obj = NULL;
static ScmObj continuation_stack = NULL;
+static struct trace_frame *trace_stack = NULL;
+
/*=======================================
File Local Function Declarations
=======================================*/
@@ -93,6 +95,7 @@
{
initialize_dynamic_extent();
initialize_continuation_env();
+ trace_stack = NULL;
}
void SigScm_FinalizeContinuation(void)
@@ -235,6 +238,7 @@
jmp_buf env;
ScmObj cont = SCM_FALSE;
ScmObj ret = SCM_FALSE;
+ struct trace_frame *saved_trace_stack;
cont = Scm_NewContinuation();
CONTINUATION_SET_JMPENV(cont, &env);
@@ -246,12 +250,14 @@
/* returned from longjmp */
ret = continuation_thrown_obj;
continuation_thrown_obj = SCM_FALSE; /* make ret sweepable */
+ trace_stack = saved_trace_stack;
enter_dynamic_extent(CONTINUATION_DYNEXT(cont));
eval_state->ret_type = SCM_RETTYPE_AS_IS;
return ret;
} else {
+ saved_trace_stack = trace_stack;
#if SCM_NESTED_CONTINUATION_ONLY
/* call proc with current continutation as (proc cont): This call must
* not be Scm_tailcall(), to preserve current stack until longjmp()
@@ -296,3 +302,24 @@
ERR("Scm_CallContinuation: called expired continuation");
}
}
+
+/*============================================================================
+ Trace Stack
+============================================================================*/
+void Scm_PushTraceFrame(struct trace_frame *frame, ScmObj obj, ScmObj env)
+{
+ frame->prev = trace_stack;
+ frame->obj = obj;
+ frame->env = env;
+ trace_stack = frame;
+}
+
+void Scm_PopTraceFrame(void)
+{
+ trace_stack = trace_stack->prev;
+}
+
+const struct trace_frame *Scm_TraceStack(void)
+{
+ return trace_stack;
+}
More information about the uim-commit
mailing list