Commit | Line | Data |
---|---|---|
dd3b648e RP |
1 | /* Copyright (C) 1986, 1987, 1988, 1989, 1990 Free Software Foundation, Inc. |
2 | ||
3 | This file is part of GDB. | |
4 | ||
5 | GDB is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
7 | the Free Software Foundation; either version 1, or (at your option) | |
8 | any later version. | |
9 | ||
10 | GDB is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with GDB; see the file COPYING. If not, write to | |
17 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
18 | ||
19 | /* This is currently for a 88000 running DGUX. If other 88k ports are | |
20 | done, OS-specific stuff should be moved (see tm-68k.h, for example). */ | |
21 | /* g++ support is not yet included. */ | |
22 | ||
23 | #include "tdesc.h" | |
24 | ||
25 | #define TARGET_BYTE_ORDER BIG_ENDIAN | |
26 | ||
27 | /* This is not a CREATE_INFERIOR_HOOK because it also applies to | |
28 | remote debugging. */ | |
29 | #define START_INFERIOR_HOOK () \ | |
30 | { \ | |
31 | extern int safe_to_init_tdesc_context; \ | |
32 | extern int tdesc_handle; \ | |
33 | \ | |
34 | safe_to_init_tdesc_context = 0; \ | |
35 | if (tdesc_handle) \ | |
36 | { \ | |
37 | dc_terminate (tdesc_handle); \ | |
38 | tdesc_handle = 0; \ | |
39 | } \ | |
40 | } | |
41 | ||
42 | #define EXTRA_FRAME_INFO dc_dcontext_t frame_context; | |
43 | #define INIT_EXTRA_FRAME_INFO(fci) \ | |
44 | { \ | |
45 | if (fci->next_frame != NULL) \ | |
46 | { \ | |
47 | /* The call to get_prev_context */ \ | |
48 | /* will update current_context for us. */ \ | |
49 | int stack_error = 1; \ | |
50 | jmp_buf stack_jmp; \ | |
51 | if (!setjmp (stack_jmp)) \ | |
52 | { \ | |
53 | prev->frame_context \ | |
54 | = get_prev_context (next_frame->frame_context); \ | |
55 | stack_error = 0; \ | |
56 | } \ | |
57 | else \ | |
58 | { \ | |
59 | stack_error = 0; \ | |
60 | next_frame->prev = 0; \ | |
61 | return 0; \ | |
62 | } \ | |
63 | if (!prev->frame_context) \ | |
64 | { \ | |
65 | next_frame->prev = 0; \ | |
66 | return 0; \ | |
67 | } \ | |
68 | } \ | |
69 | else \ | |
70 | { \ | |
71 | /* We are creating an arbitrary frame */ \ | |
72 | /* (i.e. we are in create_new_frame). */ \ | |
73 | extern dc_dcontext_t current_context; \ | |
74 | \ | |
75 | fci->frame_context = current_context; \ | |
76 | } \ | |
77 | } | |
78 | ||
79 | #define INIT_FRAME_PC(fromleaf, prev) \ | |
80 | { \ | |
81 | prev->pc = dc_location (prev->frame_context); \ | |
82 | prev->frame = get_frame_base (prev->pc); \ | |
83 | } | |
84 | ||
85 | #define IEEE_FLOAT | |
86 | ||
87 | /* Text Description (TDESC) is used by m88k to maintain stack & reg info */ | |
88 | ||
89 | #define TDESC | |
90 | ||
91 | /* Define this if the C compiler puts an underscore at the front | |
92 | of external names before giving them to the linker. */ | |
93 | ||
94 | #define NAMES_HAVE_UNDERSCORE | |
95 | ||
96 | /* Hook for read_relative_register_raw_bytes */ | |
97 | ||
98 | #define READ_RELATIVE_REGISTER_RAW_BYTES | |
99 | ||
100 | /* Offset from address of function to start of its code. | |
101 | Zero on most machines. */ | |
102 | ||
103 | #define FUNCTION_START_OFFSET 0 | |
104 | ||
105 | /* Advance PC across any function entry prologue instructions | |
106 | to reach some "real" code. */ | |
107 | ||
108 | #define SKIP_PROLOGUE(frompc) 0 | |
109 | ||
110 | /* The m88k kernel aligns all instructions on 4-byte boundaries. The | |
111 | kernel also uses the least significant two bits for its own hocus | |
112 | pocus. When gdb receives an address from the kernel, it needs to | |
113 | preserve those right-most two bits, but gdb also needs to be careful | |
114 | to realize that those two bits are not really a part of the address | |
115 | of an instruction. Shrug. */ | |
116 | ||
117 | #define ADDR_BITS_REMOVE(addr) ((addr) & ~3) | |
118 | #define ADDR_BITS_SET(addr) (((addr) | 0x00000002) - 4) | |
119 | ||
120 | /* Immediately after a function call, return the saved pc. | |
121 | Can't always go through the frames for this because on some machines | |
122 | the new frame is not set up until the new function executes | |
123 | some instructions. */ | |
124 | ||
125 | #define SAVED_PC_AFTER_CALL(frame) \ | |
126 | (read_register (SRP_REGNUM) & (~3)) | |
127 | ||
128 | /* Address of end of stack space. */ | |
129 | ||
130 | #define STACK_END_ADDR 0xF0000000 | |
131 | ||
132 | /* Stack grows downward. */ | |
133 | ||
134 | #define INNER_THAN < | |
135 | ||
136 | /* Sequence of bytes for breakpoint instruction. */ | |
137 | ||
138 | /* instruction 0xF000D1FF is 'tb0 0,r0,511' | |
139 | If Bit bit 0 of r0 is clear (always true), | |
140 | initiate exception processing (trap). | |
141 | */ | |
142 | #define BREAKPOINT {0xF0, 0x00, 0xD1, 0xFF} | |
143 | ||
144 | /* Address of end of stack space. */ | |
145 | ||
146 | #define STACK_END_ADDR 0xF0000000 | |
147 | ||
148 | /* Stack grows downward. */ | |
149 | ||
150 | #define INNER_THAN < | |
151 | ||
152 | /* Sequence of bytes for breakpoint instruction. */ | |
153 | ||
154 | /* instruction 0xF000D1FF is 'tb0 0,r0,511' | |
155 | If Bit bit 0 of r0 is clear (always true), | |
156 | initiate exception processing (trap). | |
157 | */ | |
158 | #define BREAKPOINT {0xF0, 0x00, 0xD1, 0xFF} | |
159 | ||
160 | /* Amount PC must be decremented by after a breakpoint. | |
161 | This is often the number of bytes in BREAKPOINT | |
162 | but not always. */ | |
163 | ||
164 | #define DECR_PC_AFTER_BREAK 0 | |
165 | ||
166 | /* Nonzero if instruction at PC is a return instruction. */ | |
167 | /* 'jmp r1' or 'jmp.n r1' is used to return from a subroutine. */ | |
168 | ||
169 | #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 2) == 0xF800) | |
170 | ||
171 | /* Return 1 if P points to an invalid floating point value. | |
172 | LEN is the length in bytes -- not relevant on the 386. */ | |
173 | ||
174 | #define INVALID_FLOAT(p, len) IEEE_isNAN(p,len) | |
175 | ||
176 | /* Say how long (ordinary) registers are. */ | |
177 | ||
178 | #define REGISTER_TYPE long | |
179 | ||
180 | /* Number of machine registers */ | |
181 | ||
182 | #define NUM_REGS 38 | |
183 | ||
184 | /* Initializer for an array of names of registers. | |
185 | There should be NUM_REGS strings in this initializer. */ | |
186 | ||
187 | #define REGISTER_NAMES {\ | |
188 | "r0",\ | |
189 | "r1",\ | |
190 | "r2",\ | |
191 | "r3",\ | |
192 | "r4",\ | |
193 | "r5",\ | |
194 | "r6",\ | |
195 | "r7",\ | |
196 | "r8",\ | |
197 | "r9",\ | |
198 | "r10",\ | |
199 | "r11",\ | |
200 | "r12",\ | |
201 | "r13",\ | |
202 | "r14",\ | |
203 | "r15",\ | |
204 | "r16",\ | |
205 | "r17",\ | |
206 | "r18",\ | |
207 | "r19",\ | |
208 | "r20",\ | |
209 | "r21",\ | |
210 | "r22",\ | |
211 | "r23",\ | |
212 | "r24",\ | |
213 | "r25",\ | |
214 | "r26",\ | |
215 | "r27",\ | |
216 | "r28",\ | |
217 | "r29",\ | |
218 | "r30",\ | |
219 | "r31",\ | |
220 | "psr",\ | |
221 | "fpsr",\ | |
222 | "fpcr",\ | |
223 | "sxip",\ | |
224 | "snip",\ | |
225 | "sfip",\ | |
226 | "vbr",\ | |
227 | "dmt0",\ | |
228 | "dmd0",\ | |
229 | "dma0",\ | |
230 | "dmt1",\ | |
231 | "dmd1",\ | |
232 | "dma1",\ | |
233 | "dmt2",\ | |
234 | "dmd2",\ | |
235 | "dma2",\ | |
236 | "sr0",\ | |
237 | "sr1",\ | |
238 | "sr2",\ | |
239 | "sr3",\ | |
240 | "fpecr",\ | |
241 | "fphs1",\ | |
242 | "fpls1",\ | |
243 | "fphs2",\ | |
244 | "fpls2",\ | |
245 | "fppt",\ | |
246 | "fprh",\ | |
247 | "fprl",\ | |
248 | "fpit",\ | |
249 | "fpsr",\ | |
250 | "fpcr",\ | |
251 | }; | |
252 | ||
253 | ||
254 | /* Register numbers of various important registers. | |
255 | Note that some of these values are "real" register numbers, | |
256 | and correspond to the general registers of the machine, | |
257 | and some are "phony" register numbers which are too large | |
258 | to be actual register numbers as far as the user is concerned | |
259 | but do serve to get the desired values when passed to read_register. */ | |
260 | ||
261 | #define SRP_REGNUM 1 /* Contains subroutine return pointer */ | |
262 | #define RV_REGNUM 2 /* Contains simple return values */ | |
263 | #define SRA_REGNUM 12 /* Contains address of struct return values */ | |
264 | #define FP_REGNUM 30 /* Contains address of executing stack frame */ | |
265 | #define SP_REGNUM 31 /* Contains address of top of stack */ | |
266 | #define SXIP_REGNUM 35 /* Contains Shadow Execute Instruction Pointer */ | |
267 | #define SNIP_REGNUM 36 /* Contains Shadow Next Instruction Pointer */ | |
268 | #define PC_REGNUM SXIP_REGNUM /* Program Counter */ | |
269 | #define NPC_REGNUM SNIP_REGNUM /* Next Program Counter */ | |
270 | #define PSR_REGNUM 32 /* Processor Status Register */ | |
271 | #define FPSR_REGNUM 33 /* Floating Point Status Register */ | |
272 | #define FPCR_REGNUM 34 /* Floating Point Control Register */ | |
273 | #define SFIP_REGNUM 37 /* Contains Shadow Fetched Intruction pointer */ | |
274 | #define NNPC_REGNUM SFIP_REGNUM /* Next Next Program Counter */ | |
275 | ||
276 | /* PSR status bit definitions. */ | |
277 | ||
278 | #define PSR_MODE 0x80000000 | |
279 | #define PSR_BYTE_ORDER 0x40000000 | |
280 | #define PSR_SERIAL_MODE 0x20000000 | |
281 | #define PSR_CARRY 0x10000000 | |
282 | #define PSR_SFU_DISABLE 0x000003f0 | |
283 | #define PSR_SFU1_DISABLE 0x00000008 | |
284 | #define PSR_MXM 0x00000004 | |
285 | #define PSR_IND 0x00000002 | |
286 | #define PSR_SFRZ 0x00000001 | |
287 | ||
288 | /* BCS requires that the SXIP_REGNUM (or PC_REGNUM) contain the address | |
289 | of the next instr to be executed when a breakpoint occurs. Because | |
290 | the kernel gets the next instr (SNIP_REGNUM), the instr in SNIP needs | |
291 | to be put back into SFIP, and the instr in SXIP should be shifted | |
292 | to SNIP */ | |
293 | ||
294 | /* Are you sitting down? It turns out that the 88K BCS (binary compatibility | |
295 | standard) folks originally felt that the debugger should be responsible | |
296 | for backing up the IPs, not the kernel (as is usually done). Well, they | |
297 | have reversed their decision, and in future releases our kernel will be | |
298 | handling the backing up of the IPs. So, eventually, we won't need to | |
299 | do the SHIFT_INST_REGS stuff. But, for now, since there are 88K systems out | |
300 | there that do need the debugger to do the IP shifting, and since there | |
301 | will be systems where the kernel does the shifting, the code is a little | |
302 | more complex than perhaps it needs to be (we still go inside SHIFT_INST_REGS, | |
303 | and if the shifting hasn't occurred then gdb goes ahead and shifts). */ | |
304 | ||
305 | #define SHIFT_INST_REGS | |
306 | ||
307 | /* Total amount of space needed to store our copies of the machine's | |
308 | register state, the array `registers'. */ | |
309 | ||
310 | #define REGISTER_BYTES (NUM_REGS * sizeof(REGISTER_TYPE)) | |
311 | ||
312 | /* Index within `registers' of the first byte of the space for | |
313 | register N. */ | |
314 | ||
315 | #define REGISTER_BYTE(N) ((N)*sizeof(REGISTER_TYPE)) | |
316 | ||
317 | /* Number of bytes of storage in the actual machine representation | |
318 | for register N. */ | |
319 | ||
320 | #define REGISTER_RAW_SIZE(N) (sizeof(REGISTER_TYPE)) | |
321 | ||
322 | /* Number of bytes of storage in the program's representation | |
323 | for register N. */ | |
324 | ||
325 | #define REGISTER_VIRTUAL_SIZE(N) (sizeof(REGISTER_TYPE)) | |
326 | ||
327 | /* Largest value REGISTER_RAW_SIZE can have. */ | |
328 | ||
329 | #define MAX_REGISTER_RAW_SIZE (sizeof(REGISTER_TYPE)) | |
330 | ||
331 | /* Largest value REGISTER_VIRTUAL_SIZE can have. | |
332 | /* Are FPS1, FPS2, FPR "virtual" regisers? */ | |
333 | ||
334 | #define MAX_REGISTER_VIRTUAL_SIZE (sizeof(REGISTER_TYPE)) | |
335 | ||
336 | /* Nonzero if register N requires conversion | |
337 | from raw format to virtual format. */ | |
338 | ||
339 | #define REGISTER_CONVERTIBLE(N) (0) | |
340 | ||
341 | /* Convert data from raw format for register REGNUM | |
342 | to virtual format for register REGNUM. */ | |
343 | ||
344 | #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) {bcopy ((FROM), (TO), (sizeof(REGISTER_TYPE)));} | |
345 | ||
346 | /* Convert data from virtual format for register REGNUM | |
347 | to raw format for register REGNUM. */ | |
348 | ||
349 | #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) {bcopy ((FROM), (TO), (sizeof(REGISTER_TYPE)));} | |
350 | ||
351 | /* Return the GDB type object for the "standard" data type | |
352 | of data in register N. */ | |
353 | ||
354 | #define REGISTER_VIRTUAL_TYPE(N) (builtin_type_int) | |
355 | ||
356 | /* The 88k call/return conventions call for "small" values to be returned | |
357 | into consecutive registers starting from r2. */ | |
358 | ||
359 | #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ | |
360 | bcopy (&(((void *)REGBUF)[REGISTER_BYTE(RV_REGNUM)]), (VALBUF), TYPE_LENGTH (TYPE)) | |
361 | ||
362 | #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) | |
363 | ||
364 | /* Write into appropriate registers a function return value | |
365 | of type TYPE, given in virtual format. */ | |
366 | ||
367 | #define STORE_RETURN_VALUE(TYPE,VALBUF) \ | |
368 | write_register_bytes (2*sizeof(void*), (VALBUF), TYPE_LENGTH (TYPE)) | |
369 | ||
370 | /* In COFF, if PCC says a parameter is a short or a char, do not | |
371 | change it to int (it seems the convention is to change it). */ | |
372 | ||
373 | #define BELIEVE_PCC_PROMOTION 1 | |
374 | ||
375 | /* Describe the pointer in each stack frame to the previous stack frame | |
376 | (its caller). */ | |
377 | ||
378 | /* FRAME_CHAIN takes a frame's nominal address | |
379 | and produces the frame's chain-pointer. | |
380 | ||
381 | FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address | |
382 | and produces the nominal address of the caller frame. | |
383 | ||
384 | However, if FRAME_CHAIN_VALID returns zero, | |
385 | it means the given frame is the outermost one and has no caller. | |
386 | In that case, FRAME_CHAIN_COMBINE is not used. */ | |
387 | ||
388 | /* These are just dummies for the 88k because INIT_FRAME_PC sets prev->frame | |
389 | instead. */ | |
390 | ||
391 | #define FRAME_CHAIN(thisframe) (0) | |
392 | ||
393 | #define FRAME_CHAIN_VALID(chain, thisframe) (1) | |
394 | ||
395 | #define FRAME_CHAIN_COMBINE(chain, thisframe) (0) | |
396 | ||
397 | /* Define other aspects of the stack frame. */ | |
398 | ||
399 | #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame+4, 4)) | |
400 | ||
401 | #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) | |
402 | ||
403 | #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) | |
404 | ||
405 | /* Return number of args passed to a frame. | |
406 | Can return -1, meaning no way to tell. */ | |
407 | ||
408 | #define FRAME_NUM_ARGS(numargs, fi) ((numargs) = -1) | |
409 | ||
410 | /* Return number of bytes at start of arglist that are not really args. */ | |
411 | ||
412 | #define FRAME_ARGS_SKIP 0 | |
413 | ||
414 | /* Put here the code to store, into a struct frame_saved_regs, | |
415 | the addresses of the saved registers of frame described by FRAME_INFO. | |
416 | This includes special registers such as pc and fp saved in special | |
417 | ways in the stack frame. sp is even more special: | |
418 | the address we return for it IS the sp for the next frame. */ | |
419 | ||
420 | /* On the 88k, parameter registers get stored into the so called "homing" | |
421 | area. This *always* happens when you compiled with GCC and use -g. | |
422 | Also, (with GCC and -g) the saving of the parameter register values | |
423 | always happens right within the function prologue code, so these register | |
424 | values can generally be relied upon to be already copied into their | |
425 | respective homing slots by the time you will normally try to look at | |
426 | them (we hope). | |
427 | ||
428 | Note that homing area stack slots are always at *positive* offsets from | |
429 | the frame pointer. Thus, the homing area stack slots for the parameter | |
430 | registers (passed values) for a given function are actually part of the | |
431 | frame area of the caller. This is unusual, but it should not present | |
432 | any special problems for GDB. | |
433 | ||
434 | Note also that on the 88k, we are only interested in finding the | |
435 | registers that might have been saved in memory. This is a subset of | |
436 | the whole set of registers because the standard calling sequence allows | |
437 | the called routine to clobber many registers. | |
438 | ||
439 | We could manage to locate values for all of the so called "preserved" | |
440 | registers (some of which may get saved within any particular frame) but | |
441 | that would require decoding all of the tdesc information. Tht would be | |
442 | nice information for GDB to have, but it is not strictly manditory if we | |
443 | can live without the ability to look at values within (or backup to) | |
444 | previous frames. | |
445 | */ | |
446 | ||
447 | #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ | |
448 | frame_find_saved_regs (frame_info, &frame_saved_regs) | |
449 | ||
450 | \f | |
451 | /* When popping a frame on the 88k (say when doing a return command), the | |
452 | calling function only expects to have the "preserved" registers restored. | |
453 | Thus, those are the only ones that we even try to restore here. */ | |
454 | ||
455 | extern void pop_frame (); | |
456 | ||
457 | #define POP_FRAME pop_frame () | |
458 | ||
459 | /* BCS is a standard for binary compatibility. This machine uses it. */ | |
460 | #define BCS |