comparison src/eval.c @ 116:9f59509498e1 r20-1b10

Import from CVS: tag r20-1b10
author cvs
date Mon, 13 Aug 2007 09:23:06 +0200
parents 1040fe1366ac
children 538048ae2ab8
comparison
equal deleted inserted replaced
115:f109f7dabbe2 116:9f59509498e1
38 #include "buffer.h" 38 #include "buffer.h"
39 #include "console.h" 39 #include "console.h"
40 #include "opaque.h" 40 #include "opaque.h"
41 41
42 struct backtrace *backtrace_list; 42 struct backtrace *backtrace_list;
43
44 /* Note you must always fill all of the fields in a backtrace structure
45 before pushing them on the backtrace_list. The profiling code depends
46 on this. */
47
48 #define PUSH_BACKTRACE(bt) \
49 do { (bt).next = backtrace_list; backtrace_list = &(bt); } while (0)
50
51 #define POP_BACKTRACE(bt) \
52 do { backtrace_list = (bt).next; } while (0)
43 53
44 /* This is the list of current catches (and also condition-cases). 54 /* This is the list of current catches (and also condition-cases).
45 This is a stack: the most recent catch is at the head of the 55 This is a stack: the most recent catch is at the head of the
46 list. Catches are created by declaring a 'struct catchtag' 56 list. Catches are created by declaring a 'struct catchtag'
47 locally, filling the .TAG field in with the tag, and doing 57 locally, filling the .TAG field in with the tag, and doing
2580 if (CONSP (final) || SUBRP (final) || COMPILED_FUNCTIONP (final)) 2590 if (CONSP (final) || SUBRP (final) || COMPILED_FUNCTIONP (final))
2581 { 2591 {
2582 #ifdef EMACS_BTL 2592 #ifdef EMACS_BTL
2583 backtrace.id_number = 0; 2593 backtrace.id_number = 0;
2584 #endif 2594 #endif
2585 backtrace.next = backtrace_list;
2586 backtrace_list = &backtrace;
2587 backtrace.function = &Qcall_interactively; 2595 backtrace.function = &Qcall_interactively;
2588 backtrace.args = &cmd; 2596 backtrace.args = &cmd;
2589 backtrace.nargs = 1; 2597 backtrace.nargs = 1;
2590 backtrace.evalargs = 0; 2598 backtrace.evalargs = 0;
2591 backtrace.pdlcount = specpdl_depth (); 2599 backtrace.pdlcount = specpdl_depth ();
2592 backtrace.debug_on_exit = 0; 2600 backtrace.debug_on_exit = 0;
2601 PUSH_BACKTRACE (backtrace);
2593 2602
2594 final = Fcall_interactively (cmd, record, keys); 2603 final = Fcall_interactively (cmd, record, keys);
2595 2604
2596 backtrace_list = backtrace.next; 2605 POP_BACKTRACE (backtrace);
2597 return (final); 2606 return (final);
2598 } 2607 }
2599 else if (STRINGP (final) || VECTORP (final)) 2608 else if (STRINGP (final) || VECTORP (final))
2600 { 2609 {
2601 return Fexecute_kbd_macro (final, prefixarg); 2610 return Fexecute_kbd_macro (final, prefixarg);
2915 2924
2916 #ifdef EMACS_BTL 2925 #ifdef EMACS_BTL
2917 backtrace.id_number = 0; 2926 backtrace.id_number = 0;
2918 #endif 2927 #endif
2919 backtrace.pdlcount = specpdl_depth_counter; 2928 backtrace.pdlcount = specpdl_depth_counter;
2920 backtrace.next = backtrace_list;
2921 backtrace_list = &backtrace;
2922 backtrace.function = &original_fun; /* This also protects them from gc */ 2929 backtrace.function = &original_fun; /* This also protects them from gc */
2923 backtrace.args = &original_args; 2930 backtrace.args = &original_args;
2924 backtrace.nargs = UNEVALLED; 2931 backtrace.nargs = UNEVALLED;
2925 backtrace.evalargs = 1; 2932 backtrace.evalargs = 1;
2926 backtrace.debug_on_exit = 0; 2933 backtrace.debug_on_exit = 0;
2934 PUSH_BACKTRACE (backtrace);
2927 2935
2928 if (debug_on_next_call) 2936 if (debug_on_next_call)
2929 do_debug_on_call (Qt); 2937 do_debug_on_call (Qt);
2930 2938
2931 /* At this point, only original_fun and original_args 2939 /* At this point, only original_fun and original_args
2997 val = make_int (1); 3005 val = make_int (1);
2998 } 3006 }
2999 #endif 3007 #endif
3000 if (backtrace.debug_on_exit) 3008 if (backtrace.debug_on_exit)
3001 val = do_debug_on_exit (val); 3009 val = do_debug_on_exit (val);
3002 backtrace_list = backtrace.next; 3010 POP_BACKTRACE (backtrace);
3003 UNGCPRO; 3011 UNGCPRO;
3004 return (val); 3012 return (val);
3005 } 3013 }
3006 3014
3007 else 3015 else
3070 val = make_int (1); 3078 val = make_int (1);
3071 } 3079 }
3072 #endif 3080 #endif
3073 if (backtrace.debug_on_exit) 3081 if (backtrace.debug_on_exit)
3074 val = do_debug_on_exit (val); 3082 val = do_debug_on_exit (val);
3075 backtrace_list = backtrace.next; 3083 POP_BACKTRACE (backtrace);
3076 return (val); 3084 return (val);
3077 } 3085 }
3078 3086
3079 3087
3080 Lisp_Object 3088 Lisp_Object
3105 3113
3106 #ifdef EMACS_BTL 3114 #ifdef EMACS_BTL
3107 backtrace.id_number = 0; 3115 backtrace.id_number = 0;
3108 #endif 3116 #endif
3109 backtrace.pdlcount = specpdl_depth_counter; 3117 backtrace.pdlcount = specpdl_depth_counter;
3110 backtrace.next = backtrace_list;
3111 backtrace.function = &args[0]; 3118 backtrace.function = &args[0];
3112 backtrace.args = &args[1]; 3119 backtrace.args = &args[1];
3113 backtrace.nargs = nargs; 3120 backtrace.nargs = nargs;
3114 backtrace.evalargs = 0; 3121 backtrace.evalargs = 0;
3115 backtrace.debug_on_exit = 0; 3122 backtrace.debug_on_exit = 0;
3116 /* XEmacs: make sure this is done last so we don't get race 3123 PUSH_BACKTRACE (backtrace);
3117 conditions in the profiling code. */
3118 backtrace_list = &backtrace;
3119 3124
3120 if (debug_on_next_call) 3125 if (debug_on_next_call)
3121 do_debug_on_call (Qlambda); 3126 do_debug_on_call (Qlambda);
3122 3127
3123 retry: 3128 retry:
3202 } 3207 }
3203 } 3208 }
3204 lisp_eval_depth--; 3209 lisp_eval_depth--;
3205 if (backtrace.debug_on_exit) 3210 if (backtrace.debug_on_exit)
3206 val = do_debug_on_exit (val); 3211 val = do_debug_on_exit (val);
3207 backtrace_list = backtrace.next; 3212 POP_BACKTRACE (backtrace);
3208 return val; 3213 return val;
3209 } 3214 }
3210 3215
3211 DEFUN ("funcall", Ffuncall, 1, MANY, 0, /* 3216 DEFUN ("funcall", Ffuncall, 1, MANY, 0, /*
3212 Call first argument as a function, passing remaining arguments to it. 3217 Call first argument as a function, passing remaining arguments to it.