aboutsummaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/eval.c b/src/eval.c
index 5b43b81a6ca..544dfc25af9 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -56,8 +56,6 @@ Lisp_Object Vrun_hooks;
56/* FIXME: We should probably get rid of this! */ 56/* FIXME: We should probably get rid of this! */
57Lisp_Object Vsignaling_function; 57Lisp_Object Vsignaling_function;
58 58
59int backtrace_byte_offset = -1;
60
61/* These would ordinarily be static, but they need to be visible to GDB. */ 59/* These would ordinarily be static, but they need to be visible to GDB. */
62bool backtrace_p (union specbinding *) EXTERNALLY_VISIBLE; 60bool backtrace_p (union specbinding *) EXTERNALLY_VISIBLE;
63Lisp_Object *backtrace_args (union specbinding *) EXTERNALLY_VISIBLE; 61Lisp_Object *backtrace_args (union specbinding *) EXTERNALLY_VISIBLE;
@@ -65,7 +63,6 @@ Lisp_Object backtrace_function (union specbinding *) EXTERNALLY_VISIBLE;
65union specbinding *backtrace_next (union specbinding *) EXTERNALLY_VISIBLE; 63union specbinding *backtrace_next (union specbinding *) EXTERNALLY_VISIBLE;
66union specbinding *backtrace_top (void) EXTERNALLY_VISIBLE; 64union specbinding *backtrace_top (void) EXTERNALLY_VISIBLE;
67 65
68static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *);
69static Lisp_Object apply_lambda (Lisp_Object, Lisp_Object, ptrdiff_t); 66static Lisp_Object apply_lambda (Lisp_Object, Lisp_Object, ptrdiff_t);
70static Lisp_Object lambda_arity (Lisp_Object); 67static Lisp_Object lambda_arity (Lisp_Object);
71 68
@@ -146,7 +143,7 @@ backtrace_bytecode_offset (union specbinding *pdl)
146 return pdl->bt.bytecode_offset; 143 return pdl->bt.bytecode_offset;
147} 144}
148 145
149static bool 146bool
150backtrace_debug_on_exit (union specbinding *pdl) 147backtrace_debug_on_exit (union specbinding *pdl)
151{ 148{
152 eassert (pdl->kind == SPECPDL_BACKTRACE); 149 eassert (pdl->kind == SPECPDL_BACKTRACE);
@@ -354,7 +351,7 @@ call_debugger (Lisp_Object arg)
354 return unbind_to (count, val); 351 return unbind_to (count, val);
355} 352}
356 353
357static void 354void
358do_debug_on_call (Lisp_Object code, ptrdiff_t count) 355do_debug_on_call (Lisp_Object code, ptrdiff_t count)
359{ 356{
360 debug_on_next_call = 0; 357 debug_on_next_call = 0;
@@ -2146,6 +2143,27 @@ grow_specpdl (void)
2146} 2143}
2147 2144
2148ptrdiff_t 2145ptrdiff_t
2146record_in_backtrace_with_offset (Lisp_Object function, Lisp_Object *args,
2147 ptrdiff_t nargs, int offset)
2148{
2149 ptrdiff_t count = SPECPDL_INDEX ();
2150
2151 eassert (nargs >= UNEVALLED);
2152 specpdl_ptr->bt.kind = SPECPDL_BACKTRACE;
2153 specpdl_ptr->bt.debug_on_exit = false;
2154 specpdl_ptr->bt.function = function;
2155 current_thread->stack_top = specpdl_ptr->bt.args = args;
2156 specpdl_ptr->bt.nargs = nargs;
2157 specpdl_ptr->bt.bytecode_offset = -1;
2158 union specbinding *nxt = backtrace_top ();
2159 if (backtrace_p (nxt) && nxt->kind == SPECPDL_BACKTRACE)
2160 nxt->bt.bytecode_offset = offset;
2161 grow_specpdl ();
2162
2163 return count;
2164}
2165
2166ptrdiff_t
2149record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs) 2167record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs)
2150{ 2168{
2151 ptrdiff_t count = SPECPDL_INDEX (); 2169 ptrdiff_t count = SPECPDL_INDEX ();
@@ -2156,10 +2174,7 @@ record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs)
2156 specpdl_ptr->bt.function = function; 2174 specpdl_ptr->bt.function = function;
2157 current_thread->stack_top = specpdl_ptr->bt.args = args; 2175 current_thread->stack_top = specpdl_ptr->bt.args = args;
2158 specpdl_ptr->bt.nargs = nargs; 2176 specpdl_ptr->bt.nargs = nargs;
2159 union specbinding *nxt = specpdl_ptr; 2177 specpdl_ptr->bt.bytecode_offset = -1;
2160 nxt = backtrace_next(nxt);
2161 if (nxt->kind == SPECPDL_BACKTRACE)
2162 nxt->bt.bytecode_offset = backtrace_byte_offset;
2163 grow_specpdl (); 2178 grow_specpdl ();
2164 2179
2165 return count; 2180 return count;
@@ -2965,7 +2980,7 @@ apply_lambda (Lisp_Object fun, Lisp_Object args, ptrdiff_t count)
2965 FUN must be either a lambda-expression, a compiled-code object, 2980 FUN must be either a lambda-expression, a compiled-code object,
2966 or a module function. */ 2981 or a module function. */
2967 2982
2968static Lisp_Object 2983Lisp_Object
2969funcall_lambda (Lisp_Object fun, ptrdiff_t nargs, 2984funcall_lambda (Lisp_Object fun, ptrdiff_t nargs,
2970 register Lisp_Object *arg_vector) 2985 register Lisp_Object *arg_vector)
2971{ 2986{
@@ -3053,7 +3068,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs,
3053 arg = Qnil; 3068 arg = Qnil;
3054 3069
3055 /* Bind the argument. */ 3070 /* Bind the argument. */
3056 if (!NILP (lexenv) && SYMBOLP (next)) 3071 if (!NILP (lexenv))
3057 /* Lexically bind NEXT by adding it to the lexenv alist. */ 3072 /* Lexically bind NEXT by adding it to the lexenv alist. */
3058 lexenv = Fcons (Fcons (next, arg), lexenv); 3073 lexenv = Fcons (Fcons (next, arg), lexenv);
3059 else 3074 else