/[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.6 by ram, Thu Oct 27 17:13:54 1994 UTC revision 1.6.2.3 by pw, Sat Mar 23 18:51:00 2002 UTC
# Line 19  Line 19 
19  #include "globals.h"  #include "globals.h"
20  #include "alloc.h"  #include "alloc.h"
21  #include "breakpoint.h"  #include "breakpoint.h"
22    #if defined GENCGC
23    #include "gencgc.h"
24    #endif
25    
26  #define REAL_LRA_SLOT 0  #define REAL_LRA_SLOT 0
27    #ifndef i386
28  #define KNOWN_RETURN_P_SLOT 1  #define KNOWN_RETURN_P_SLOT 1
29  #define BOGUS_LRA_CONSTANTS 2  #define BOGUS_LRA_CONSTANTS 2
30    #else
31    #define KNOWN_RETURN_P_SLOT 2
32    #define BOGUS_LRA_CONSTANTS 3
33    #endif
34    
35  static void *compute_pc(lispobj code_obj, int pc_offset)  static void *compute_pc(lispobj code_obj, int pc_offset)
36  {  {
37      struct code *code;      struct code *code;
38    
39      code = (struct code *)PTR(code_obj);      code = (struct code *)PTR(code_obj);
40      return (void *)((char *)code + HeaderValue(code->header)*sizeof(lispobj)      return (void *)((char *)code + HeaderValue(code->header) * sizeof(lispobj)
41                      + pc_offset);                      + pc_offset);
42  }  }
43    
# Line 47  void breakpoint_remove(lispobj code_obj, Line 55  void breakpoint_remove(lispobj code_obj,
55  void breakpoint_do_displaced_inst(struct sigcontext *scp,  void breakpoint_do_displaced_inst(struct sigcontext *scp,
56                                    unsigned long orig_inst)                                    unsigned long orig_inst)
57  {  {
58  #if !defined(hpux) && !defined(irix)  #if !defined(hpux) && !defined(irix) && !defined(i386)
59      undo_fake_foreign_function_call(scp);      undo_fake_foreign_function_call(scp);
60  #endif  #endif
61      arch_do_displaced_inst(scp, orig_inst);      arch_do_displaced_inst(scp, orig_inst);
62  }  }
63    
64    #ifndef i386
65  static lispobj find_code(struct sigcontext *scp)  static lispobj find_code(struct sigcontext *scp)
66  {  {
67  #ifdef reg_CODE  #ifdef reg_CODE
# Line 71  static lispobj find_code(struct sigconte Line 80  static lispobj find_code(struct sigconte
80      return NIL;      return NIL;
81  #endif  #endif
82  }  }
83    #endif
84    
85    #ifdef i386
86    static lispobj find_code(struct sigcontext *scp)
87    {
88      lispobj *codeptr = component_ptr_from_pc(SC_PC(scp));
89    
90      if (codeptr == NULL)
91        return NIL;
92      else
93        return (lispobj) codeptr | type_OtherPointer;
94    }
95    #endif
96    
97  static int compute_offset(struct sigcontext *scp, lispobj code)  static int compute_offset(struct sigcontext *scp, lispobj code)
98  {  {
# Line 99  static int compute_offset(struct sigcont Line 121  static int compute_offset(struct sigcont
121      }      }
122  }  }
123    
124    #ifndef i386
125  void handle_breakpoint(int signal, int subcode, struct sigcontext *scp)  void handle_breakpoint(int signal, int subcode, struct sigcontext *scp)
126  {  {
127      lispobj code;      lispobj code;
# Line 106  void handle_breakpoint(int signal, int s Line 129  void handle_breakpoint(int signal, int s
129      fake_foreign_function_call(scp);      fake_foreign_function_call(scp);
130    
131      code = find_code(scp);      code = find_code(scp);
132    
133      funcall3(SymbolFunction(HANDLE_BREAKPOINT),      funcall3(SymbolFunction(HANDLE_BREAKPOINT),
134               compute_offset(scp, code),               compute_offset(scp, code),
135               code,               code,
# Line 113  void handle_breakpoint(int signal, int s Line 137  void handle_breakpoint(int signal, int s
137    
138      undo_fake_foreign_function_call(scp);      undo_fake_foreign_function_call(scp);
139  }  }
140    #else
141    void handle_breakpoint(int signal, int subcode, struct sigcontext *scp)
142    {
143        lispobj code, scp_sap=alloc_sap(scp);
144    
145        fake_foreign_function_call(scp);
146    
147        code = find_code(scp);
148    
149        /*
150         * Don't disallow recursive breakpoint traps.  Otherwise, we can't
151         * use debugger breakpoints anywhere in here.
152         */
153    
154    #if defined POSIX_SIGS
155        sigprocmask(SIG_SETMASK,&scp->sc_mask,NULL);
156    #else
157        sigsetmask(scp->sc_mask);
158    #endif
159        funcall3(SymbolFunction(HANDLE_BREAKPOINT),
160                 compute_offset(scp, code),
161                 code,
162                 scp_sap);
163    
164        undo_fake_foreign_function_call(scp);
165    }
166    #endif
167    
168    #ifndef i386
169  void *handle_function_end_breakpoint(int signal, int subcode,  void *handle_function_end_breakpoint(int signal, int subcode,
170                                       struct sigcontext *scp)                                       struct sigcontext *scp)
171  {  {
# Line 135  void *handle_function_end_breakpoint(int Line 187  void *handle_function_end_breakpoint(int
187      if (codeptr->constants[KNOWN_RETURN_P_SLOT] == NIL)      if (codeptr->constants[KNOWN_RETURN_P_SLOT] == NIL)
188          SC_REG(scp, reg_CODE) = lra;          SC_REG(scp, reg_CODE) = lra;
189  #endif  #endif
190        undo_fake_foreign_function_call(scp);
191        return (void *)(lra-type_OtherPointer+sizeof(lispobj));
192    }
193    #else
194    void *handle_function_end_breakpoint(int signal, int subcode,
195                                         struct sigcontext *scp)
196    {
197        lispobj code, scp_sap=alloc_sap(scp);
198        struct code *codeptr;
199    
200        fake_foreign_function_call(scp);
201    
202        code = find_code(scp);
203        codeptr = (struct code *) PTR(code);
204    
205        /*
206         * Don't disallow recursive breakpoint traps.  Otherwise, we can't
207         * use debugger breakpoints anywhere in here.
208         */
209    
210    #if defined POSIX_SIGS
211        sigprocmask(SIG_SETMASK,&scp->sc_mask,NULL);
212    #else
213        sigsetmask(scp->sc_mask);
214    #endif
215        funcall3(SymbolFunction(HANDLE_BREAKPOINT),
216                 compute_offset(scp, code),
217                 code,
218                 scp_sap);
219    
220      undo_fake_foreign_function_call(scp);      undo_fake_foreign_function_call(scp);
221    
222      return (void *)(lra-type_OtherPointer+sizeof(lispobj));      return compute_pc(codeptr->constants[REAL_LRA_SLOT],
223                          fixnum_value(codeptr->constants[REAL_LRA_SLOT + 1]));
224  }  }
225    #endif

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.6.2.3

  ViewVC Help
Powered by ViewVC 1.1.5