/[cmucl]/src/lisp/breakpoint.c
ViewVC logotype

Diff of /src/lisp/breakpoint.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.24 by rtoy, Fri Sep 5 22:03:12 2008 UTC revision 1.25 by rtoy, Wed Sep 10 13:46:43 2008 UTC
# Line 24  Line 24 
24  #endif  #endif
25    
26  /*  /*
27   * See MAKE-BOGUS-LRA in code/debug-int.lisp for these values.  (We   * See MAKE-BOGUS-LRA in code/debug-int.lisp for these values.
28   * really should generate these from the Lisp code.)   *
29     * Note: In debug-int.lisp, real-lra-slot and known-return-p-slot are
30     * offsets from the start of the code object.  But in the C code here,
31     * it is the offset from the constants vector in the code object.  The
32     * difference between the two is vm:code-constants-offset.
33   */   */
34  #define REAL_LRA_SLOT 0  #define REAL_LRA_SLOT 0
35  #ifndef i386  #ifndef i386
# Line 200  compute_offset(os_context_t * scp, lispo Line 204  compute_offset(os_context_t * scp, lispo
204              int offset = pc - code_start;              int offset = pc - code_start;
205    
206              if (offset >= codeptr->code_size) {              if (offset >= codeptr->code_size) {
207                  if (function_end) {                  return 0;
 #if defined(sparc) || (defined(DARWIN) && defined(__ppc__))  
                     /*  
                      * We're in a function end breakpoint.  Compute the  
                      * offset from the (known) breakpoint location and the  
                      * beginning of the breakpoint guts.  (See *-assem.S.)  
                      *  
                      * Then make the offset negative so the caller knows  
                      * that the offset is not from the code object.  
                      */  
                     extern char function_end_breakpoint_trap;  
                     extern char function_end_breakpoint_guts;  
   
                     offset =  
                         &function_end_breakpoint_trap -  
                         &function_end_breakpoint_guts;  
                     return make_fixnum(-offset);  
 #else  
                     return 0;  
 #endif  
                 } else {  
                     return 0;  
                 }  
208              } else {              } else {
209                  return make_fixnum(offset);                  return make_fixnum(offset);
210              }              }
# Line 280  handle_function_end_breakpoint(int signa Line 262  handle_function_end_breakpoint(int signa
262      lispobj code, lra;      lispobj code, lra;
263      struct code *codeptr;      struct code *codeptr;
264      int offset;      int offset;
265        int known_return_p;
266    
267      fake_foreign_function_call(scp);      fake_foreign_function_call(scp);
268    
269      code = find_code(scp);      code = find_code(scp);
# Line 311  handle_function_end_breakpoint(int signa Line 294  handle_function_end_breakpoint(int signa
294           * Some magic here.  pc points to the trap instruction.  The           * Some magic here.  pc points to the trap instruction.  The
295           * offset gives us where the function_end_breakpoint_guts           * offset gives us where the function_end_breakpoint_guts
296           * begins.  But we need to back up some more to get to the           * begins.  But we need to back up some more to get to the
297           * code-component object.  The magic 2 below is           * code-component object.  See MAKE-BOGUS-LRA in
298             * debug-int.lisp
299           */           */
300          code = pc - fixnum_value(offset);          code = pc - fixnum_value(offset);
301          code -= sizeof(struct code) + BOGUS_LRA_CONSTANTS * sizeof(lispobj);          code -= sizeof(struct code) + BOGUS_LRA_CONSTANTS * sizeof(lispobj);
# Line 326  handle_function_end_breakpoint(int signa Line 310  handle_function_end_breakpoint(int signa
310  #endif  #endif
311      }      }
312    
     /*  
      * Breakpoint handling done, so get the real LRA where we're  
      * supposed to return to so we can return there.  
      */  
313      lra = codeptr->constants[REAL_LRA_SLOT];      lra = codeptr->constants[REAL_LRA_SLOT];
314  #ifdef reg_CODE  
315      /*      known_return_p = codeptr->constants[KNOWN_RETURN_P_SLOT] != NIL;
      * With the known-return convention, we definitely do NOT want to  
      * mangle the CODE register because it isn't pointing to the bogus  
      * LRA but to the actual routine.  
      */  
     if (codeptr->constants[KNOWN_RETURN_P_SLOT] == NIL)  
         SC_REG(scp, reg_CODE) = lra;  
 #endif  
316    
317      {      {
318          lispobj saved_gc_inhibit;          lispobj *args = current_control_stack_pointer;
319    
320            /*
321             * Because HANDLE_BREAKPOINT can GC, the LRA could move, and
322             * we need to know where it went so we can return to the
323             * correct place.  We do this by saving the LRA on the Lisp
324             * stack.  If GC moves the LRA, the stack entry will get
325             * updated appropriately too.
326             */
327            current_control_stack_pointer += 1;
328            args[0] = lra;
329    
 #ifdef GC_INHIBIT  
         saved_gc_inhibit = SymbolValue(GC_INHIBIT);  
         SetSymbolValue(GC_INHIBIT, T);  
 #endif  
330          funcall3(SymbolFunction(HANDLE_BREAKPOINT), offset, code, alloc_sap(scp));          funcall3(SymbolFunction(HANDLE_BREAKPOINT), offset, code, alloc_sap(scp));
331    
332  #ifdef GC_INHIBIT          /*
333          SetSymbolValue(GC_INHIBIT, saved_gc_inhibit);           * Breakpoint handling done.  Get the (possibly changed) LRA
334             * value off the stack so we know where to return to.
335             */
336            lra = args[0];
337            current_control_stack_pointer -= 1;
338    
339    #ifdef reg_CODE
340            /*
341             * With the known-return convention, we definitely do NOT want
342             * to mangle the CODE register because it isn't pointing to
343             * the bogus LRA but to the actual routine.
344             */
345            if (!known_return_p) {
346                SC_REG(scp, reg_CODE) = lra;
347            }
348  #endif  #endif
349      }      }
350    

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

  ViewVC Help
Powered by ViewVC 1.1.5