]>
Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* OBSOLETE /* GOULD RISC target-dependent code for GDB, the GNU debugger. */ |
2 | /* OBSOLETE Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc. */ | |
3 | /* OBSOLETE */ | |
4 | /* OBSOLETE This file is part of GDB. */ | |
5 | /* OBSOLETE */ | |
6 | /* OBSOLETE This program is free software; you can redistribute it and/or modify */ | |
7 | /* OBSOLETE it under the terms of the GNU General Public License as published by */ | |
8 | /* OBSOLETE the Free Software Foundation; either version 2 of the License, or */ | |
9 | /* OBSOLETE (at your option) any later version. */ | |
10 | /* OBSOLETE */ | |
11 | /* OBSOLETE This program is distributed in the hope that it will be useful, */ | |
12 | /* OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of */ | |
13 | /* OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ | |
14 | /* OBSOLETE GNU General Public License for more details. */ | |
15 | /* OBSOLETE */ | |
16 | /* OBSOLETE You should have received a copy of the GNU General Public License */ | |
17 | /* OBSOLETE along with this program; if not, write to the Free Software */ | |
18 | /* OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *x/ */ | |
19 | /* OBSOLETE */ | |
20 | /* OBSOLETE #include "defs.h" */ | |
21 | /* OBSOLETE #include "symtab.h" */ | |
22 | /* OBSOLETE #include "frame.h" */ | |
23 | /* OBSOLETE #include "gdbcore.h" */ | |
24 | /* OBSOLETE #if defined GOULD_PN */ | |
25 | /* OBSOLETE #include "opcode/pn.h" */ | |
26 | /* OBSOLETE #else */ | |
27 | /* OBSOLETE #include "opcode/np1.h" */ | |
28 | /* OBSOLETE #endif */ | |
29 | /* OBSOLETE */ | |
30 | /* OBSOLETE /* GOULD RISC instructions are never longer than this many bytes. *x/ */ | |
31 | /* OBSOLETE #define MAXLEN 4 */ | |
32 | /* OBSOLETE */ | |
33 | /* OBSOLETE /* Number of elements in the opcode table. *x/ */ | |
34 | /* OBSOLETE #define NOPCODES (sizeof gld_opcodes / sizeof gld_opcodes[0]) */ | |
35 | /* OBSOLETE */ | |
36 | /* OBSOLETE int */ | |
37 | /* OBSOLETE gould_frame_chain_valid (chain, fi) */ | |
38 | /* OBSOLETE CORE_ADDR chain; */ | |
39 | /* OBSOLETE struct frame_info *fi; /* not used here *x/ */ | |
40 | /* OBSOLETE { */ | |
41 | /* OBSOLETE return (chain != 0 && chain != (thisframe)->frame); */ | |
42 | /* OBSOLETE } */ | |
43 | /* OBSOLETE */ | |
44 | /* OBSOLETE /* Both gcc and cc return small structs in registers (i.e. in GDB */ | |
45 | /* OBSOLETE terminology, small structs don't use the struct return convention). *x/ */ | |
46 | /* OBSOLETE int */ | |
47 | /* OBSOLETE gould_use_struct_convention (gcc_p, type) */ | |
48 | /* OBSOLETE int gcc_p; */ | |
49 | /* OBSOLETE struct type *type; */ | |
50 | /* OBSOLETE { */ | |
51 | /* OBSOLETE return (TYPE_LENGTH(type) > 8); */ | |
52 | /* OBSOLETE } */ | |
53 | /* OBSOLETE */ | |
54 | /* OBSOLETE */ | |
55 | /* OBSOLETE \f */ | |
56 | /* OBSOLETE /* Print the GOULD instruction at address MEMADDR in debugged memory, */ | |
57 | /* OBSOLETE on STREAM. Returns length of the instruction, in bytes. *x/ */ | |
58 | /* OBSOLETE */ | |
59 | /* OBSOLETE int */ | |
60 | /* OBSOLETE gould_print_insn (memaddr, stream) */ | |
61 | /* OBSOLETE CORE_ADDR memaddr; */ | |
62 | /* OBSOLETE FILE *stream; */ | |
63 | /* OBSOLETE { */ | |
c5aa993b JM |
64 | /* OBSOLETE unsigned char buffer[MAXLEN]; */ |
65 | /* OBSOLETE register int i; */ | |
66 | /* OBSOLETE register char *d; */ | |
67 | /* OBSOLETE register int bestmask; */ | |
68 | /* OBSOLETE unsigned best; */ | |
69 | /* OBSOLETE int temp, index, bestlen; */ | |
70 | /* OBSOLETE */ | |
71 | /* OBSOLETE read_memory (memaddr, buffer, MAXLEN); */ | |
72 | /* OBSOLETE */ | |
73 | /* OBSOLETE bestmask = 0; */ | |
74 | /* OBSOLETE index = -1; */ | |
75 | /* OBSOLETE best = 0xffffffff; */ | |
76 | /* OBSOLETE for (i = 0; i < NOPCODES; i++) */ | |
77 | /* OBSOLETE { */ | |
78 | /* OBSOLETE register unsigned int opcode = gld_opcodes[i].opcode; */ | |
79 | /* OBSOLETE register unsigned int mask = gld_opcodes[i].mask; */ | |
80 | /* OBSOLETE register unsigned int len = gld_opcodes[i].length; */ | |
81 | /* OBSOLETE register unsigned int test; */ | |
82 | /* OBSOLETE */ | |
83 | /* OBSOLETE /* Get possible opcode bytes into integer *x/ */ | |
84 | /* OBSOLETE test = buffer[0] << 24; */ | |
85 | /* OBSOLETE test |= buffer[1] << 16; */ | |
86 | /* OBSOLETE test |= buffer[2] << 8; */ | |
87 | /* OBSOLETE test |= buffer[3]; */ | |
88 | /* OBSOLETE */ | |
89 | /* OBSOLETE /* Mask with opcode and see if match *x/ */ | |
90 | /* OBSOLETE if ((opcode & mask) == (test & mask)) */ | |
91 | /* OBSOLETE { */ | |
92 | /* OBSOLETE /* See if second or third match *x/ */ | |
93 | /* OBSOLETE if (index >= 0) */ | |
94 | /* OBSOLETE { */ | |
95 | /* OBSOLETE /* Take new one if it looks good *x/ */ | |
96 | /* OBSOLETE if (bestlen == MAXLEN && len == MAXLEN) */ | |
97 | /* OBSOLETE { */ | |
98 | /* OBSOLETE /* See if lower bits matched *x/ */ | |
99 | /* OBSOLETE if (((bestmask & 3) == 0) && */ | |
100 | /* OBSOLETE ((mask & 3) != 0)) */ | |
101 | /* OBSOLETE { */ | |
102 | /* OBSOLETE bestmask = mask; */ | |
103 | /* OBSOLETE bestlen = len; */ | |
104 | /* OBSOLETE best = test; */ | |
105 | /* OBSOLETE index = i; */ | |
106 | /* OBSOLETE } */ | |
107 | /* OBSOLETE } */ | |
108 | /* OBSOLETE } */ | |
109 | /* OBSOLETE else */ | |
110 | /* OBSOLETE { */ | |
111 | /* OBSOLETE /* First match, save it *x/ */ | |
112 | /* OBSOLETE bestmask = mask; */ | |
113 | /* OBSOLETE bestlen = len; */ | |
114 | /* OBSOLETE best = test; */ | |
115 | /* OBSOLETE index = i; */ | |
116 | /* OBSOLETE } */ | |
117 | /* OBSOLETE } */ | |
118 | /* OBSOLETE } */ | |
119 | /* OBSOLETE */ | |
120 | /* OBSOLETE /* Handle undefined instructions. *x/ */ | |
121 | /* OBSOLETE if (index < 0) */ | |
122 | /* OBSOLETE { */ | |
123 | /* OBSOLETE fprintf (stream, "undefined 0%o",(buffer[0]<<8)+buffer[1]); */ | |
124 | /* OBSOLETE return 2; */ | |
125 | /* OBSOLETE } */ | |
126 | /* OBSOLETE */ | |
127 | /* OBSOLETE /* Print instruction name *x/ */ | |
128 | /* OBSOLETE fprintf (stream, "%-12s", gld_opcodes[index].name); */ | |
129 | /* OBSOLETE */ | |
130 | /* OBSOLETE /* Adjust if short instruction *x/ */ | |
131 | /* OBSOLETE if (gld_opcodes[index].length < 4) */ | |
132 | /* OBSOLETE { */ | |
133 | /* OBSOLETE best >>= 16; */ | |
134 | /* OBSOLETE i = 0; */ | |
135 | /* OBSOLETE } */ | |
136 | /* OBSOLETE else */ | |
137 | /* OBSOLETE { */ | |
138 | /* OBSOLETE i = 16; */ | |
139 | /* OBSOLETE } */ | |
140 | /* OBSOLETE */ | |
141 | /* OBSOLETE /* Dump out instruction arguments *x/ */ | |
142 | /* OBSOLETE for (d = gld_opcodes[index].args; *d; ++d) */ | |
143 | /* OBSOLETE { */ | |
144 | /* OBSOLETE switch (*d) */ | |
145 | /* OBSOLETE { */ | |
146 | /* OBSOLETE case 'f': */ | |
147 | /* OBSOLETE fprintf (stream, "%d", (best >> (7 + i)) & 7); */ | |
148 | /* OBSOLETE break; */ | |
149 | /* OBSOLETE case 'r': */ | |
150 | /* OBSOLETE fprintf (stream, "r%d", (best >> (7 + i)) & 7); */ | |
151 | /* OBSOLETE break; */ | |
152 | /* OBSOLETE case 'R': */ | |
153 | /* OBSOLETE fprintf (stream, "r%d", (best >> (4 + i)) & 7); */ | |
154 | /* OBSOLETE break; */ | |
155 | /* OBSOLETE case 'b': */ | |
156 | /* OBSOLETE fprintf (stream, "b%d", (best >> (7 + i)) & 7); */ | |
157 | /* OBSOLETE break; */ | |
158 | /* OBSOLETE case 'B': */ | |
159 | /* OBSOLETE fprintf (stream, "b%d", (best >> (4 + i)) & 7); */ | |
160 | /* OBSOLETE break; */ | |
161 | /* OBSOLETE case 'v': */ | |
162 | /* OBSOLETE fprintf (stream, "b%d", (best >> (7 + i)) & 7); */ | |
163 | /* OBSOLETE break; */ | |
164 | /* OBSOLETE case 'V': */ | |
165 | /* OBSOLETE fprintf (stream, "b%d", (best >> (4 + i)) & 7); */ | |
166 | /* OBSOLETE break; */ | |
167 | /* OBSOLETE case 'X': */ | |
168 | /* OBSOLETE temp = (best >> 20) & 7; */ | |
169 | /* OBSOLETE if (temp) */ | |
170 | /* OBSOLETE fprintf (stream, "r%d", temp); */ | |
171 | /* OBSOLETE else */ | |
172 | /* OBSOLETE putc ('0', stream); */ | |
173 | /* OBSOLETE break; */ | |
174 | /* OBSOLETE case 'A': */ | |
175 | /* OBSOLETE temp = (best >> 16) & 7; */ | |
176 | /* OBSOLETE if (temp) */ | |
177 | /* OBSOLETE fprintf (stream, "(b%d)", temp); */ | |
178 | /* OBSOLETE break; */ | |
179 | /* OBSOLETE case 'S': */ | |
180 | /* OBSOLETE fprintf (stream, "#%d", best & 0x1f); */ | |
181 | /* OBSOLETE break; */ | |
182 | /* OBSOLETE case 'I': */ | |
183 | /* OBSOLETE fprintf (stream, "#%x", best & 0xffff); */ | |
184 | /* OBSOLETE break; */ | |
185 | /* OBSOLETE case 'O': */ | |
186 | /* OBSOLETE fprintf (stream, "%x", best & 0xffff); */ | |
187 | /* OBSOLETE break; */ | |
188 | /* OBSOLETE case 'h': */ | |
189 | /* OBSOLETE fprintf (stream, "%d", best & 0xfffe); */ | |
190 | /* OBSOLETE break; */ | |
191 | /* OBSOLETE case 'd': */ | |
192 | /* OBSOLETE fprintf (stream, "%d", best & 0xfffc); */ | |
193 | /* OBSOLETE break; */ | |
194 | /* OBSOLETE case 'T': */ | |
195 | /* OBSOLETE fprintf (stream, "%d", (best >> 8) & 0xff); */ | |
196 | /* OBSOLETE break; */ | |
197 | /* OBSOLETE case 'N': */ | |
198 | /* OBSOLETE fprintf (stream, "%d", best & 0xff); */ | |
199 | /* OBSOLETE break; */ | |
200 | /* OBSOLETE default: */ | |
201 | /* OBSOLETE putc (*d, stream); */ | |
202 | /* OBSOLETE break; */ | |
203 | /* OBSOLETE } */ | |
204 | /* OBSOLETE } */ | |
205 | /* OBSOLETE */ | |
206 | /* OBSOLETE /* Return length of instruction *x/ */ | |
207 | /* OBSOLETE return (gld_opcodes[index].length); */ | |
c906108c SS |
208 | /* OBSOLETE } */ |
209 | /* OBSOLETE */ | |
210 | /* OBSOLETE /* */ | |
211 | /* OBSOLETE * Find the number of arguments to a function. */ | |
212 | /* OBSOLETE *x/ */ | |
213 | /* OBSOLETE findarg(frame) */ | |
c5aa993b | 214 | /* OBSOLETE struct frame_info *frame; */ |
c906108c | 215 | /* OBSOLETE { */ |
c5aa993b JM |
216 | /* OBSOLETE register struct symbol *func; */ |
217 | /* OBSOLETE register unsigned pc; */ | |
c906108c SS |
218 | /* OBSOLETE */ |
219 | /* OBSOLETE #ifdef notdef */ | |
c5aa993b JM |
220 | /* OBSOLETE /* find starting address of frame function *x/ */ |
221 | /* OBSOLETE pc = get_pc_function_start (frame->pc); */ | |
c906108c | 222 | /* OBSOLETE */ |
c5aa993b JM |
223 | /* OBSOLETE /* find function symbol info *x/ */ |
224 | /* OBSOLETE func = find_pc_function (pc); */ | |
c906108c | 225 | /* OBSOLETE */ |
c5aa993b JM |
226 | /* OBSOLETE /* call blockframe code to look for match *x/ */ |
227 | /* OBSOLETE if (func != NULL) */ | |
c906108c SS |
228 | /* OBSOLETE return (func->value.block->nsyms / sizeof(int)); */ |
229 | /* OBSOLETE #endif */ | |
230 | /* OBSOLETE */ | |
231 | /* OBSOLETE return (-1); */ | |
232 | /* OBSOLETE } */ | |
233 | /* OBSOLETE */ | |
234 | /* OBSOLETE /* */ | |
235 | /* OBSOLETE * In the case of the NPL, the frame's norminal address is Br2 and the */ | |
236 | /* OBSOLETE * previous routines frame is up the stack X bytes. Finding out what */ | |
237 | /* OBSOLETE * 'X' is can be tricky. */ | |
238 | /* OBSOLETE * */ | |
239 | /* OBSOLETE * 1.) stored in the code function header xA(Br1). */ | |
240 | /* OBSOLETE * 2.) must be careful of recurssion. */ | |
241 | /* OBSOLETE *x/ */ | |
242 | /* OBSOLETE CORE_ADDR */ | |
243 | /* OBSOLETE findframe(thisframe) */ | |
244 | /* OBSOLETE struct frame_info *thisframe; */ | |
245 | /* OBSOLETE { */ | |
246 | /* OBSOLETE register CORE_ADDR pointer; */ | |
247 | /* OBSOLETE CORE_ADDR framechain(); */ | |
248 | /* OBSOLETE #if 0 */ | |
249 | /* OBSOLETE struct frame_info *frame; */ | |
250 | /* OBSOLETE */ | |
251 | /* OBSOLETE /* Setup toplevel frame structure *x/ */ | |
252 | /* OBSOLETE frame->pc = read_pc(); */ | |
253 | /* OBSOLETE frame->next_frame = 0; */ | |
c5aa993b | 254 | /* OBSOLETE frame->frame = read_register (SP_REGNUM); /* Br2 *x/ */ |
c906108c SS |
255 | /* OBSOLETE */ |
256 | /* OBSOLETE /* Search for this frame (start at current Br2) *x/ */ | |
257 | /* OBSOLETE do */ | |
258 | /* OBSOLETE { */ | |
c5aa993b JM |
259 | /* OBSOLETE pointer = framechain(frame); */ |
260 | /* OBSOLETE frame->next_frame = frame->frame; */ | |
261 | /* OBSOLETE frame->frame = pointer; */ | |
262 | /* OBSOLETE frame->pc = FRAME_SAVED_PC(frame); */ | |
c906108c SS |
263 | /* OBSOLETE } */ |
264 | /* OBSOLETE while (frame->next_frame != thisframe); */ | |
265 | /* OBSOLETE #endif */ | |
266 | /* OBSOLETE */ | |
267 | /* OBSOLETE pointer = framechain (thisframe); */ | |
268 | /* OBSOLETE */ | |
269 | /* OBSOLETE /* stop gap for now, end at __base3 *x/ */ | |
270 | /* OBSOLETE if (thisframe->pc == 0) */ | |
c5aa993b | 271 | /* OBSOLETE return 0; */ |
c906108c SS |
272 | /* OBSOLETE */ |
273 | /* OBSOLETE return pointer; */ | |
274 | /* OBSOLETE } */ | |
275 | /* OBSOLETE */ | |
276 | /* OBSOLETE /* */ | |
277 | /* OBSOLETE * Gdb front-end and internal framechain routine. */ | |
278 | /* OBSOLETE * Go back up stack one level. Tricky... */ | |
279 | /* OBSOLETE *x/ */ | |
280 | /* OBSOLETE CORE_ADDR */ | |
281 | /* OBSOLETE framechain(frame) */ | |
282 | /* OBSOLETE register struct frame_info *frame; */ | |
283 | /* OBSOLETE { */ | |
284 | /* OBSOLETE register CORE_ADDR func, prevsp; */ | |
285 | /* OBSOLETE register unsigned value; */ | |
286 | /* OBSOLETE */ | |
287 | /* OBSOLETE /* Get real function start address from internal frame address *x/ */ | |
288 | /* OBSOLETE func = get_pc_function_start(frame->pc); */ | |
289 | /* OBSOLETE */ | |
290 | /* OBSOLETE /* If no stack given, read register Br1 "(sp)" *x/ */ | |
291 | /* OBSOLETE if (!frame->frame) */ | |
c5aa993b | 292 | /* OBSOLETE prevsp = read_register (SP_REGNUM); */ |
c906108c | 293 | /* OBSOLETE else */ |
c5aa993b | 294 | /* OBSOLETE prevsp = frame->frame; */ |
c906108c SS |
295 | /* OBSOLETE */ |
296 | /* OBSOLETE /* Check function header, case #2 *x/ */ | |
297 | /* OBSOLETE value = read_memory_integer (func, 4); */ | |
298 | /* OBSOLETE if (value) */ | |
299 | /* OBSOLETE { */ | |
c5aa993b JM |
300 | /* OBSOLETE /* 32bit call push value stored in function header *x/ */ |
301 | /* OBSOLETE prevsp += value; */ | |
c906108c SS |
302 | /* OBSOLETE } */ |
303 | /* OBSOLETE else */ | |
304 | /* OBSOLETE { */ | |
c5aa993b JM |
305 | /* OBSOLETE /* read half-word from suabr at start of function *x/ */ |
306 | /* OBSOLETE prevsp += read_memory_integer (func + 10, 2); */ | |
c906108c SS |
307 | /* OBSOLETE } */ |
308 | /* OBSOLETE */ | |
309 | /* OBSOLETE return (prevsp); */ | |
310 | /* OBSOLETE } */ |