1 /* Definitions to make GDB run on an ISI Optimum V (3.05) under 4.3bsd.
2 Copyright (C) 1987, 1989 Free Software Foundation, Inc.
4 This file is part of GDB.
6 GDB is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 1, or (at your option)
11 GDB is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GDB; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20 /* This has not been tested on ISI's running BSD 4.2, but it will probably
23 /* Identify this machine */
28 /* Define the bit, byte, and word ordering of the machine. */
29 #define BITS_BIG_ENDIAN
30 #define BYTES_BIG_ENDIAN
31 #define WORDS_BIG_ENDIAN
33 /* Define this if the C compiler puts an underscore at the front
34 of external names before giving them to the linker. */
36 #define NAMES_HAVE_UNDERSCORE
38 /* Debugger information will be in DBX format. */
40 #define READ_DBX_FORMAT
42 /* Offset from address of function to start of its code.
43 Zero on most machines. */
45 #define FUNCTION_START_OFFSET 0
47 /* Advance PC across any function entry prologue instructions
48 to reach some "real" code. */
50 #define SKIP_PROLOGUE(pc) \
51 { register int op = read_memory_integer (pc, 2); \
53 pc += 4; /* Skip link #word */ \
54 else if (op == 0044016) \
55 pc += 6; /* Skip link #long */ \
56 else if (op == 0060000) \
57 pc += 4; /* Skip bra #word */ \
58 else if (op == 00600377) \
59 pc += 6; /* skip bra #long */ \
60 else if ((op & 0177400) == 0060000) \
61 pc += 2; /* skip bra #char */ \
65 /* Immediately after a function call, return the saved pc.
66 Can't always go through the frames for this because on some machines
67 the new frame is not set up until the new function executes
70 #define SAVED_PC_AFTER_CALL(frame) \
71 read_memory_integer (read_register (SP_REGNUM), 4)
73 /* This is the amount to subtract from u.u_ar0
74 to get the offset in the core file of the register values. */
76 /*#define KERNEL_U_ADDR 0x10800000*/
77 #define KERNEL_U_ADDR 0
79 /* Address of end of stack space. */
81 /*#define STACK_END_ADDR 0x10000000*/
82 #define STACK_END_ADDR 0xfffe000
84 /* Stack grows downward. */
88 /* Sequence of bytes for breakpoint instruction. */
90 #define BREAKPOINT {0x4e, 0x4f}
92 /* Data segment starts at etext rounded up to DATAROUND in {N,Z}MAGIC files */
94 #define DATAROUND 0x20000
95 #define N_DATADDR(hdr) (hdr.a_magic != OMAGIC ? \
96 (hdr.a_text + DATAROUND) & ~(DATAROUND-1) : hdr.a_text)
98 /* Text segment starts at sizeof (struct exec) in {N,Z}MAGIC files */
100 #define N_TXTADDR(hdr) (hdr.a_magic != OMAGIC ? sizeof (struct exec) : 0)
102 /* Amount PC must be decremented by after a breakpoint.
103 This is often the number of bytes in BREAKPOINT
105 On the ISI, the kernel resets the pc to the trap instr */
107 #define DECR_PC_AFTER_BREAK 0
109 /* Nonzero if instruction at PC is a return instruction. */
111 #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 2) == 0x4e75)
113 /* Return 1 if P points to an invalid floating point value. */
115 #define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */
117 /* Largest integer type */
120 /* Name of the builtin type for the LONGEST type above. */
121 #define BUILTIN_TYPE_LONGEST builtin_type_long
123 /* Say how long registers are. */
125 #define REGISTER_TYPE long
127 /* Number of machine registers */
130 /* Initializer for an array of names of registers.
131 There should be NUM_REGS strings in this initializer. */
133 #define REGISTER_NAMES \
134 {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \
135 "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp", \
137 "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7", \
138 "fpcontrol", "fpstatus", "fpiaddr" }
140 /* Register numbers of various important registers.
141 Note that some of these values are "real" register numbers,
142 and correspond to the general registers of the machine,
143 and some are "phony" register numbers which are too large
144 to be actual register numbers as far as the user is concerned
145 but do serve to get the desired values when passed to read_register. */
147 #define FP_REGNUM 14 /* Contains address of executing stack frame */
148 #define SP_REGNUM 15 /* Contains address of top of stack */
149 #define PS_REGNUM 16 /* Contains processor status */
150 #define PC_REGNUM 17 /* Contains program counter */
151 #define FP0_REGNUM 18 /* Floating point register 0 */
152 #define FPC_REGNUM 26 /* 68881 control register */
154 /* expects blockend to be u.u_ar0 */
155 extern int rloc
[]; /* Defined in isi-dep.c */
156 #define REGISTER_U_ADDR(addr, blockend, regno) \
157 { blockend &= UPAGES*NBPG - 1; \
158 if (regno < 18) addr = (int)blockend + rloc[regno]*4; \
159 else if (regno < 26) addr = (int) &((struct user *)0)->u_68881_regs \
160 + (regno - 18) * 12; \
161 else if (regno < 29) addr = (int) &((struct user *)0)->u_68881_regs \
162 + 8 * 12 + (regno - 26) * 4; \
165 /* Total amount of space needed to store our copies of the machine's
166 register state, the array `registers'. */
167 #define REGISTER_BYTES (16*4+8*12+8+20)
169 /* Index within `registers' of the first byte of the space for
172 #define REGISTER_BYTE(N) \
173 ((N) >= FPC_REGNUM ? (((N) - FPC_REGNUM) * 4) + 168 \
174 : (N) >= FP0_REGNUM ? (((N) - FP0_REGNUM) * 12) + 72 \
177 /* Number of bytes of storage in the actual machine representation
178 for register N. On the 68000, all regs are 4 bytes
179 except the floating point regs which are 12 bytes. */
181 #define REGISTER_RAW_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 12 : 4)
183 /* Number of bytes of storage in the program's representation
184 for register N. On the 68000, all regs are 4 bytes
185 except the floating point regs which are 8-byte doubles. */
187 #define REGISTER_VIRTUAL_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 8 : 4)
189 /* Largest value REGISTER_RAW_SIZE can have. */
191 #define MAX_REGISTER_RAW_SIZE 12
193 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
195 #define MAX_REGISTER_VIRTUAL_SIZE 8
197 /* Nonzero if register N requires conversion
198 from raw format to virtual format. */
200 #define REGISTER_CONVERTIBLE(N) (((unsigned)(N) - FP0_REGNUM) < 8)
202 /* Convert data from raw format for register REGNUM
203 to virtual format for register REGNUM. */
205 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
206 { if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
207 convert_from_68881 ((FROM), (TO)); \
209 bcopy ((FROM), (TO), 4); }
211 /* Convert data from virtual format for register REGNUM
212 to raw format for register REGNUM. */
214 #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
215 { if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
216 convert_to_68881 ((FROM), (TO)); \
218 bcopy ((FROM), (TO), 4); }
220 /* Return the GDB type object for the "standard" data type
221 of data in register N. */
223 #define REGISTER_VIRTUAL_TYPE(N) \
224 (((unsigned)(N) - FP0_REGNUM) < 8 ? builtin_type_double : builtin_type_int)
226 /* Store the address of the place in which to copy the structure the
227 subroutine will return. This is called from call_function. */
229 #define STORE_STRUCT_RETURN(ADDR, SP) \
230 { write_register (9, (ADDR)); }
232 /* Extract from an array REGBUF containing the (raw) register state
233 a function return value of type TYPE, and copy that, in virtual format,
236 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
237 bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE))
239 /* Write into appropriate registers a function return value
240 of type TYPE, given in virtual format. */
242 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
243 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
245 /* Extract from an array REGBUF containing the (raw) register state
246 the address in which a function should return its structure value,
247 as a CORE_ADDR (or an expression that can be used as one). */
249 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
251 /* Describe the pointer in each stack frame to the previous stack frame
254 /* FRAME_CHAIN takes a frame's nominal address
255 and produces the frame's chain-pointer.
257 FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
258 and produces the nominal address of the caller frame.
260 However, if FRAME_CHAIN_VALID returns zero,
261 it means the given frame is the outermost one and has no caller.
262 In that case, FRAME_CHAIN_COMBINE is not used. */
264 /* In the case of the ISI, the frame's nominal address
265 is the address of a 4-byte word containing the calling frame's address. */
267 #define FRAME_CHAIN(thisframe) \
268 (outside_startup_file ((thisframe)->pc) ? \
269 read_memory_integer ((thisframe)->frame, 4) :\
272 #define FRAME_CHAIN_VALID(chain, thisframe) \
273 (chain != 0 && outside_startup_file (FRAME_SAVED_PC (thisframe)))
275 #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
277 /* Define other aspects of the stack frame. */
279 /* A macro that tells us whether the function invocation represented
280 by FI does not have a frame on the stack associated with it. If it
281 does not, FRAMELESS is set to 1, else 0. */
282 #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
283 FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS)
285 #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
287 #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
289 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
291 /* Return number of args passed to a frame.
292 Can return -1, meaning no way to tell. */
294 #define FRAME_NUM_ARGS(val, fi) \
295 { register CORE_ADDR pc = FRAME_SAVED_PC (fi); \
296 register int insn = 0177777 & read_memory_integer (pc, 2); \
298 if (insn == 0047757 || insn == 0157374) /* lea W(sp),sp or addaw #W,sp */ \
299 val = read_memory_integer (pc + 2, 2); \
300 else if ((insn & 0170777) == 0050217 /* addql #N, sp */ \
301 || (insn & 0170777) == 0050117) /* addqw */ \
302 { val = (insn >> 9) & 7; if (val == 0) val = 8; } \
303 else if (insn == 0157774) /* addal #WW, sp */ \
304 val = read_memory_integer (pc + 2, 4); \
307 /* Return number of bytes at start of arglist that are not really args. */
309 #define FRAME_ARGS_SKIP 8
311 /* Put here the code to store, into a struct frame_saved_regs,
312 the addresses of the saved registers of frame described by FRAME_INFO.
313 This includes special registers such as pc and fp saved in special
314 ways in the stack frame. sp is even more special:
315 the address we return for it IS the sp for the next frame. */
317 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
318 { register int regnum; \
319 register int regmask; \
320 register CORE_ADDR next_addr; \
321 register CORE_ADDR pc; \
323 register int offset; \
324 bzero (&frame_saved_regs, sizeof frame_saved_regs); \
325 if ((frame_info)->pc >= (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 8*12 - 4 \
326 && (frame_info)->pc <= (frame_info)->frame) \
327 { next_addr = (frame_info)->frame; \
328 pc = (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 8*12 - 4; }\
330 { pc = get_pc_function_start ((frame_info)->pc); \
331 /* Verify we have a link a6 instruction next, \
332 or a branch followed by a link a6 instruction; \
333 if not we lose. If we win, find the address above the saved \
334 regs using the amount of storage from the link instruction. */\
336 insn = read_memory_integer (pc, 2); \
337 if (insn == 044016) \
338 next_addr = (frame_info)->frame - read_memory_integer (pc += 2, 4), pc+=4; \
339 else if (insn == 047126) \
340 next_addr = (frame_info)->frame - read_memory_integer (pc += 2, 2), pc+=2; \
341 else if ((insn & 0177400) == 060000) /* bra insn */ \
342 { offset = insn & 0377; \
343 pc += 2; /* advance past bra */ \
344 if (offset == 0) /* bra #word */ \
345 offset = read_memory_integer (pc, 2), pc += 2; \
346 else if (offset == 0377) /* bra #long */ \
347 offset = read_memory_integer (pc, 4), pc += 4; \
351 /* If have an addal #-n, sp next, adjust next_addr. */ \
352 if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \
353 next_addr += read_memory_integer (pc += 2, 4), pc += 4; \
355 /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \
356 insn = read_memory_integer (pc, 2), pc += 2; \
357 regmask = read_memory_integer (pc, 2); \
358 if ((insn & 0177760) == 022700) /* movl rn, (sp) */ \
359 (frame_saved_regs).regs[(insn&7) + ((insn&010)?8:0)] = next_addr; \
360 else if ((insn & 0177760) == 024700) /* movl rn, -(sp) */ \
361 (frame_saved_regs).regs[(insn&7) + ((insn&010)?8:0)] = next_addr-=4; \
362 else if (insn == 0044327) /* moveml mask, (sp) */ \
364 /* Regmask's low bit is for register 0, the first written */ \
366 for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \
368 (frame_saved_regs).regs[regnum] = (next_addr += 4); \
369 } else if (insn == 0044347) /* moveml mask, -(sp) */ \
371 /* Regmask's low bit is for register 15, the first pushed */ \
372 for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \
374 (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \
375 /* clrw -(sp); movw ccr,-(sp) may follow. */ \
376 if (read_memory_integer (pc, 2) == 041147 \
377 && read_memory_integer (pc+2, 2) == 042347) \
378 (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \
380 (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 8; \
381 (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \
382 (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \
385 /* Compensate for lack of `vprintf' function. */
387 #define vprintf(format, ap) _doprnt (format, ap, stdout)
390 /* Things needed for making the inferior call functions. */
392 /* Push an empty stack frame, to record the current PC, etc. */
394 #define PUSH_DUMMY_FRAME \
395 { register CORE_ADDR sp = read_register (SP_REGNUM); \
396 register int regnum; \
397 char raw_buffer[12]; \
398 sp = push_word (sp, read_register (PC_REGNUM)); \
399 sp = push_word (sp, read_register (FP_REGNUM)); \
400 write_register (FP_REGNUM, sp); \
401 for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \
402 { read_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); \
403 sp = push_bytes (sp, raw_buffer, 12); } \
404 for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \
405 sp = push_word (sp, read_register (regnum)); \
406 sp = push_word (sp, read_register (PS_REGNUM)); \
407 write_register (SP_REGNUM, sp); }
409 /* Discard from the stack the innermost frame, restoring all registers. */
412 { register FRAME frame = get_current_frame (); \
413 register CORE_ADDR fp; \
414 register int regnum; \
415 struct frame_saved_regs fsr; \
416 struct frame_info *fi; \
417 char raw_buffer[12]; \
418 fi = get_frame_info (frame); \
420 get_frame_saved_regs (fi, &fsr); \
421 for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \
422 if (fsr.regs[regnum]) \
423 { read_memory (fsr.regs[regnum], raw_buffer, 12); \
424 write_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); }\
425 for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \
426 if (fsr.regs[regnum]) \
427 write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
428 if (fsr.regs[PS_REGNUM]) \
429 write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \
430 write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
431 write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
432 write_register (SP_REGNUM, fp + 8); \
433 flush_cached_frames (); \
434 set_current_frame ( create_new_frame (read_register (FP_REGNUM), \
437 /* This sequence of words is the instructions
438 fmovem #<f0-f7>,-(sp)
442 /..* The arguments are pushed at this point by GDB;
443 no code is needed in the dummy for this.
444 The CALL_DUMMY_START_OFFSET gives the position of
445 the following jsr instruction. *../
450 Note this is 24 bytes.
451 We actually start executing at the jsr, since the pushing of the
452 registers is done by PUSH_DUMMY_FRAME. If this were real code,
453 the arguments for the function called by the jsr would be pushed
454 between the moveml and the jsr, and we could allow it to execute through.
455 But the arguments have to be pushed by GDB after the PUSH_DUMMY_FRAME is done,
456 and we cannot allow the moveml to push the registers again lest they be
457 taken for the arguments. */
459 #define CALL_DUMMY {0xf227e0ff, 0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, 0x4e4f4e71}
461 #define CALL_DUMMY_LENGTH 28
463 #define CALL_DUMMY_START_OFFSET 12
465 /* Insert the specified number of args and function address
466 into a call sequence of the above form stored at DUMMYNAME. */
468 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \
469 { *(int *)((char *) dummyname + 20) = nargs * 4; \
470 *(int *)((char *) dummyname + 14) = fun; }
472 /* Interface definitions for kernel debugger KDB. */
474 /* Map machine fault codes into signal numbers.
475 First subtract 0, divide by 4, then index in a table.
476 Faults for which the entry in this table is 0
477 are not handled by KDB; the program's own trap handler
478 gets to handle then. */
480 #define FAULT_CODE_ORIGIN 0
481 #define FAULT_CODE_UNITS 4
482 #define FAULT_TABLE \
483 { 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \
484 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \
485 0, 0, 0, 0, 0, 0, 0, 0, \
488 /* Start running with a stack stretching from BEG to END.
489 BEG and END should be symbols meaningful to the assembler.
490 This is used only for kdb. */
492 #define INIT_STACK(beg, end) \
493 { asm (".globl end"); \
494 asm ("movl $ end, sp"); \
497 /* Push the frame pointer register on the stack. */
498 #define PUSH_FRAME_PTR \
499 asm ("movel fp, -(sp)");
501 /* Copy the top-of-stack to the frame pointer register. */
502 #define POP_FRAME_PTR \
503 asm ("movl (sp), fp");
505 /* After KDB is entered by a fault, push all registers
506 that GDB thinks about (all NUM_REGS of them),
507 so that they appear in order of ascending GDB register number.
508 The fault code will be on the stack beyond the last register. */
510 #define PUSH_REGISTERS \
511 { asm ("clrw -(sp)"); \
512 asm ("pea 10(sp)"); \
513 asm ("movem $ 0xfffe,-(sp)"); }
515 /* Assuming the registers (including processor status) have been
516 pushed on the stack in order of ascending GDB register number,
517 restore them and return to the address in the saved PC register. */
519 #define POP_REGISTERS \
520 { asm ("subil $8,28(sp)"); \
521 asm ("movem (sp),$ 0xffff"); \
This page took 0.041603 seconds and 4 git commands to generate.