/[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.14 by pmai, Mon Jul 12 23:44:07 2004 UTC revision 1.15 by rtoy, Thu Mar 17 23:13:55 2005 UTC
# Line 23  Line 23 
23  #include "gencgc.h"  #include "gencgc.h"
24  #endif  #endif
25    
26    /*
27     * See MAKE-BOGUS-LRA in code/debug-int.lisp for these values.  (We
28     * really should generate these from the Lisp code.)
29     */
30  #define REAL_LRA_SLOT 0  #define REAL_LRA_SLOT 0
31  #ifndef i386  #ifndef i386
32  #define KNOWN_RETURN_P_SLOT 1  #define KNOWN_RETURN_P_SLOT 1
# Line 61  void breakpoint_do_displaced_inst(os_con Line 65  void breakpoint_do_displaced_inst(os_con
65      arch_do_displaced_inst(scp, orig_inst);      arch_do_displaced_inst(scp, orig_inst);
66  }  }
67    
68  #ifndef i386  #if !(defined(i386) || (0 && defined(sparc) && defined(GENCGC)))
69  static lispobj find_code(os_context_t *scp)  static lispobj find_code(os_context_t *scp)
70  {  {
71  #ifdef reg_CODE  #ifdef reg_CODE
# Line 82  static lispobj find_code(os_context_t *s Line 86  static lispobj find_code(os_context_t *s
86  }  }
87  #endif  #endif
88    
89  #ifdef i386  #if defined(i386) || (0 && defined(sparc) && defined(GENCGC))
90  static lispobj find_code(os_context_t *scp)  static lispobj find_code(os_context_t *scp)
91  {  {
92    lispobj *codeptr = component_ptr_from_pc(SC_PC(scp));    lispobj *codeptr = component_ptr_from_pc(SC_PC(scp));
# Line 94  static lispobj find_code(os_context_t *s Line 98  static lispobj find_code(os_context_t *s
98  }  }
99  #endif  #endif
100    
101  static int compute_offset(os_context_t *scp, lispobj code)  static int compute_offset(os_context_t *scp, lispobj code, boolean function_end)
102  {  {
103      if (code == NIL)      if (code == NIL)
104          return 0;          return 0;
# Line 113  static int compute_offset(os_context_t * Line 117  static int compute_offset(os_context_t *
117              return 0;              return 0;
118          else {          else {
119              int offset = pc - code_start;              int offset = pc - code_start;
120              if (offset >= codeptr->code_size)              if (offset >= codeptr->code_size) {
121                  if (function_end) {
122    #ifdef sparc
123                    /*
124                     * We're in a function end breakpoint.  Compute the
125                     * offset from the (known) breakpoint location and the
126                     * beginning of the breakpoint guts.  (See *-assem.S.)
127                     *
128                     * Then make the offset negative so the caller knows
129                     * that the offset is not from the code object.
130                     */
131                    extern char function_end_breakpoint_trap;
132                    extern char function_end_breakpoint_guts;
133    
134                    offset = &function_end_breakpoint_trap - &function_end_breakpoint_guts;
135                    return make_fixnum(-offset);
136    #else
137                    return 0;
138    #endif
139                  } else {
140                  return 0;                  return 0;
141              else                }
142                  return make_fixnum(offset);              } else {
143                  return make_fixnum(offset);
144                }
145          }          }
146      }      }
147  }  }
# Line 131  void handle_breakpoint(int signal, int s Line 156  void handle_breakpoint(int signal, int s
156      code = find_code(scp);      code = find_code(scp);
157    
158      funcall3(SymbolFunction(HANDLE_BREAKPOINT),      funcall3(SymbolFunction(HANDLE_BREAKPOINT),
159               compute_offset(scp, code),               compute_offset(scp, code, 0),
160               code,               code,
161               alloc_sap(scp));               alloc_sap(scp));
162    
# Line 157  void handle_breakpoint(int signal, int s Line 182  void handle_breakpoint(int signal, int s
182      sigsetmask(scp->sc_mask);      sigsetmask(scp->sc_mask);
183  #endif  #endif
184      funcall3(SymbolFunction(HANDLE_BREAKPOINT),      funcall3(SymbolFunction(HANDLE_BREAKPOINT),
185               compute_offset(scp, code),               compute_offset(scp, code, 0),
186               code,               code,
187               scp_sap);               scp_sap);
188    
# Line 171  void *handle_function_end_breakpoint(int Line 196  void *handle_function_end_breakpoint(int
196  {  {
197      lispobj code, lra;      lispobj code, lra;
198      struct code *codeptr;      struct code *codeptr;
199        int offset;
200    
201      fake_foreign_function_call(scp);      fake_foreign_function_call(scp);
202    
203      code = find_code(scp);      code = find_code(scp);
204      codeptr = (struct code *)PTR(code);      codeptr = (struct code *)PTR(code);
205        offset = compute_offset(scp, code, 1);
206    
207        if (offset < 0)
208          {
209            /*
210             * We were in the function end breakpoint.  Which means we are
211             * in a bogus LRA, so compute where the code-component of this
212             * bogus lra object starts.  Adjust code, and codeptr
213             * appropriately so the breakpoint handler can do the right
214             * thing.
215             */
216            unsigned long pc;
217    
218            pc = SC_PC(scp);
219    
220            offset = -offset;
221            /*
222             * Some magic here.  pc points to the trap instruction.  The
223             * offset gives us where the function_end_breakpoint_guts
224             * begins.  But we need to back up some more to get to the
225             * code-component object.  The magic 2 below is
226             */
227            code = pc - fixnum_value(offset);
228            code -= sizeof(struct code) + BOGUS_LRA_CONSTANTS*sizeof(lispobj);
229            code += type_OtherPointer;
230            codeptr = (struct code *) PTR(code);
231          }
232    
233      funcall3(SymbolFunction(HANDLE_BREAKPOINT),      funcall3(SymbolFunction(HANDLE_BREAKPOINT),
234               compute_offset(scp, code),               offset,
235               code,               code,
236               alloc_sap(scp));               alloc_sap(scp));
237    
238        /*
239         * Breakpoint handling done, so get the real LRA where we're
240         * supposed to return to so we can return there.
241         */
242      lra = codeptr->constants[REAL_LRA_SLOT];      lra = codeptr->constants[REAL_LRA_SLOT];
243  #ifdef reg_CODE  #ifdef reg_CODE
244        /*
245         * With the known-return convention, we definitely do NOT want to
246         * mangle the CODE register because it isn't pointing to the bogus
247         * LRA but to the actual routine.
248         */
249      if (codeptr->constants[KNOWN_RETURN_P_SLOT] == NIL)      if (codeptr->constants[KNOWN_RETURN_P_SLOT] == NIL)
250          SC_REG(scp, reg_CODE) = lra;          SC_REG(scp, reg_CODE) = lra;
251  #endif  #endif
# Line 213  void *handle_function_end_breakpoint(int Line 275  void *handle_function_end_breakpoint(int
275      sigsetmask(scp->sc_mask);      sigsetmask(scp->sc_mask);
276  #endif  #endif
277      funcall3(SymbolFunction(HANDLE_BREAKPOINT),      funcall3(SymbolFunction(HANDLE_BREAKPOINT),
278               compute_offset(scp, code),               compute_offset(scp, code, 1),
279               code,               code,
280               scp_sap);               scp_sap);
281    

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

  ViewVC Help
Powered by ViewVC 1.1.5