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

Contents of /src/lisp/breakpoint.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3.1.1 - (show annotations) (vendor branch)
Mon Oct 24 19:45:36 1994 UTC (19 years, 6 months ago) by ram
Branch: solaris_patch
Changes since 1.3: +1 -0 lines
File MIME type: text/plain
Solaris patches.
1 #include <stdio.h>
2 #include <signal.h>
3
4 #include "lisp.h"
5 #include "os.h"
6 #include "internals.h"
7 #include "interrupt.h"
8 #include "arch.h"
9 #include "lispregs.h"
10 #include "globals.h"
11 #include "alloc.h"
12 #include "breakpoint.h"
13
14 #define REAL_LRA_SLOT 0
15 #define KNOWN_RETURN_P_SLOT 1
16 #define BOGUS_LRA_CONSTANTS 2
17
18 static void *compute_pc(lispobj code_obj, int pc_offset)
19 {
20 struct code *code;
21
22 code = (struct code *)PTR(code_obj);
23 return (void *)((char *)code + HeaderValue(code->header)*sizeof(lispobj)
24 + pc_offset);
25 }
26
27 unsigned long breakpoint_install(lispobj code_obj, int pc_offset)
28 {
29 return arch_install_breakpoint(compute_pc(code_obj, pc_offset));
30 }
31
32 void breakpoint_remove(lispobj code_obj, int pc_offset,
33 unsigned long orig_inst)
34 {
35 arch_remove_breakpoint(compute_pc(code_obj, pc_offset), orig_inst);
36 }
37
38 void breakpoint_do_displaced_inst(struct sigcontext *scp,
39 unsigned long orig_inst)
40 {
41 #ifndef hpux
42 undo_fake_foreign_function_call(scp);
43 #endif
44 arch_do_displaced_inst(scp, orig_inst);
45 }
46
47 static lispobj find_code(struct sigcontext *scp)
48 {
49 #ifdef reg_CODE
50 lispobj code = SC_REG(scp, reg_CODE), header;
51
52 if (LowtagOf(code) != type_OtherPointer)
53 return NIL;
54
55 header = *(lispobj *)(code-type_OtherPointer);
56
57 if (TypeOf(header) == type_CodeHeader)
58 return code;
59 else
60 return code - HeaderValue(header)*sizeof(lispobj);
61 #else
62 return NIL;
63 #endif
64 }
65
66 static int compute_offset(struct sigcontext *scp, lispobj code)
67 {
68 if (code == NIL)
69 return 0;
70 else {
71 unsigned long code_start;
72 struct code *codeptr = (struct code *)PTR(code);
73 #ifdef parisc
74 unsigned long pc = SC_PC(scp) & ~3;
75 #else
76 unsigned long pc = SC_PC(scp);
77 #endif
78
79 code_start = (unsigned long)codeptr
80 + HeaderValue(codeptr->header)*sizeof(lispobj);
81 if (pc < code_start)
82 return 0;
83 else {
84 int offset = pc - code_start;
85 if (offset >= codeptr->code_size)
86 return 0;
87 else
88 return make_fixnum(offset);
89 }
90 }
91 }
92
93 void handle_breakpoint(int signal, int subcode, struct sigcontext *scp)
94 {
95 lispobj code;
96
97 fake_foreign_function_call(scp);
98
99 code = find_code(scp);
100 funcall3(SymbolFunction(HANDLE_BREAKPOINT),
101 compute_offset(scp, code),
102 code,
103 alloc_sap(scp));
104
105 undo_fake_foreign_function_call(scp);
106 }
107
108 void *handle_function_end_breakpoint(int signal, int subcode,
109 struct sigcontext *scp)
110 {
111 lispobj code, lra;
112 struct code *codeptr;
113
114 fake_foreign_function_call(scp);
115
116 code = find_code(scp);
117 codeptr = (struct code *)PTR(code);
118
119 funcall3(SymbolFunction(HANDLE_BREAKPOINT),
120 compute_offset(scp, code),
121 code,
122 alloc_sap(scp));
123
124 lra = codeptr->constants[REAL_LRA_SLOT];
125 #ifdef reg_CODE
126 if (codeptr->constants[KNOWN_RETURN_P_SLOT] == NIL)
127 SC_REG(scp, reg_CODE) = lra;
128 #endif
129
130 undo_fake_foreign_function_call(scp);
131
132 return (void *)(lra-type_OtherPointer+sizeof(lispobj));
133 }

  ViewVC Help
Powered by ViewVC 1.1.5