1 /* Parameters for execution on a Hewlett-Packard 9000/300, running bsd.
2 Copyright (C) 1986, 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 /* Describe the endian nature of this machine. */
21 #define BITS_BIG_ENDIAN
22 #define BYTES_BIG_ENDIAN
23 #define WORDS_BIG_ENDIAN
26 * Configuration file for HP9000/300 series machine running
27 * University of Utah's 4.3bsd port. This is NOT for HP-UX.
28 * Problems to hpbsd-bugs@cs.utah.edu
35 /* Watch out for NaNs */
39 /* Get rid of any system-imposed stack limit if possible. */
41 #define SET_STACK_LIMIT_HUGE
43 /* Define this if the C compiler puts an underscore at the front
44 of external names before giving them to the linker. */
46 #define NAMES_HAVE_UNDERSCORE
48 /* Debugger information will be in DBX format. */
50 #define READ_DBX_FORMAT
52 /* Offset from address of function to start of its code.
53 Zero on most machines. */
55 #define FUNCTION_START_OFFSET 0
57 /* Advance PC across any function entry prologue instructions
58 to reach some "real" code. */
60 #define SKIP_PROLOGUE(pc) \
61 { register int op = read_memory_integer (pc, 2); \
63 pc += 4; /* Skip link #word */ \
64 else if (op == 0044016) \
65 pc += 6; /* Skip link #long */ \
68 /* Immediately after a function call, return the saved pc.
69 Can't go through the frames for this because on some machines
70 the new frame is not set up until the new function executes
73 #define SAVED_PC_AFTER_CALL(frame) \
74 read_memory_integer (read_register (SP_REGNUM), 4)
76 /* This is the amount to subtract from u.u_ar0
77 to get the offset in the core file of the register values. */
79 #define KERNEL_U_ADDR kernel_u_addr
81 /* Same as offsetof macro from stddef.h (which 4.3BSD doesn't have). */
82 #define my_offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER)
84 /* On the HP300, sigtramp is in the u area. Gak! User struct is not
85 mapped to the same virtual address in user/kernel address space
86 (hence STACK_END_ADDR as opposed to KERNEL_U_ADDR). */
87 #define IN_SIGTRAMP(pc, name) \
88 ((pc) >= STACK_END_ADDR + my_offsetof (struct user, u_pcb.pcb_sigc[0]) \
89 && (pc) < STACK_END_ADDR + my_offsetof (struct user, u_pcb.pcb_sigc[12]) \
92 /* Address of end of stack space. */
94 #define STACK_END_ADDR 0xfff00000
96 /* Stack grows downward. */
100 /* Sequence of bytes for breakpoint instruction. */
102 #define BREAKPOINT {0x4e, 0x42}
104 /* Amount PC must be decremented by after a breakpoint.
105 This is often the number of bytes in BREAKPOINT
108 #define DECR_PC_AFTER_BREAK 2
110 /* Nonzero if instruction at PC is a return instruction. */
112 #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 2) == 0x4e75)
114 /* Return 1 if P points to an invalid floating point value. */
116 #define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */
118 /* Largest integer type */
121 /* Name of the builtin type for the LONGEST type above. */
122 #define BUILTIN_TYPE_LONGEST builtin_type_long
124 /* Say how long (ordinary) registers are. */
126 #define REGISTER_TYPE long
128 /* Number of machine registers */
132 /* Initializer for an array of names of registers.
133 There should be NUM_REGS strings in this initializer. */
135 #define REGISTER_NAMES \
136 {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \
137 "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp", \
139 "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7", \
140 "fpcontrol", "fpstatus", "fpiaddr" }
142 /* Register numbers of various important registers.
143 Note that some of these values are "real" register numbers,
144 and correspond to the general registers of the machine,
145 and some are "phony" register numbers which are too large
146 to be actual register numbers as far as the user is concerned
147 but do serve to get the desired values when passed to read_register. */
149 #define FP_REGNUM 14 /* Contains address of executing stack frame */
150 #define SP_REGNUM 15 /* Contains address of top of stack */
151 #define PS_REGNUM 16 /* Contains processor status */
152 #define PC_REGNUM 17 /* Contains program counter */
153 #define FP0_REGNUM 18 /* Floating point register 0 */
154 #define FPC_REGNUM 26 /* 68881 control register */
155 #define FPS_REGNUM 27 /* 68881 status register */
157 /* Total amount of space needed to store our copies of the machine's
158 register state, the array `registers'. */
159 #define REGISTER_BYTES (16*4+8*12+8+12)
161 /* Index within `registers' of the first byte of the space for
164 #define REGISTER_BYTE(N) \
165 ((N) >= FPC_REGNUM ? (((N) - FPC_REGNUM) * 4) + 168 \
166 : (N) >= FP0_REGNUM ? (((N) - FP0_REGNUM) * 12) + 72 \
169 /* Number of bytes of storage in the actual machine representation
170 for register N. On the 68000, all regs are 4 bytes
171 except the floating point regs which are 12 bytes. */
172 /* Note that the unsigned cast here forces the result of the
173 subtractiion to very high positive values if N < FP0_REGNUM */
175 #define REGISTER_RAW_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 12 : 4)
177 /* Number of bytes of storage in the program's representation
178 for register N. On the 68000, all regs are 4 bytes
179 except the floating point regs which are 8-byte doubles. */
181 #define REGISTER_VIRTUAL_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 8 : 4)
183 /* Largest value REGISTER_RAW_SIZE can have. */
185 #define MAX_REGISTER_RAW_SIZE 12
187 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
189 #define MAX_REGISTER_VIRTUAL_SIZE 8
191 /* Nonzero if register N requires conversion
192 from raw format to virtual format. */
194 #define REGISTER_CONVERTIBLE(N) (((unsigned)(N) - FP0_REGNUM) < 8)
196 /* Convert data from raw format for register REGNUM
197 to virtual format for register REGNUM. */
199 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
200 { if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
201 convert_from_68881 ((FROM), (TO)); \
203 bcopy ((FROM), (TO), 4); }
205 /* Convert data from virtual format for register REGNUM
206 to raw format for register REGNUM. */
208 #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
209 { if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
210 convert_to_68881 ((FROM), (TO)); \
212 bcopy ((FROM), (TO), 4); }
214 /* Return the GDB type object for the "standard" data type
215 of data in register N. */
217 #define REGISTER_VIRTUAL_TYPE(N) \
218 (((unsigned)(N) - FP0_REGNUM) < 8 ? builtin_type_double : builtin_type_int)
220 /* Store the address of the place in which to copy the structure the
221 subroutine will return. This is called from call_function. */
223 #define STORE_STRUCT_RETURN(ADDR, SP) \
224 { write_register (9, (ADDR)); }
226 /* Extract from an array REGBUF containing the (raw) register state
227 a function return value of type TYPE, and copy that, in virtual format,
230 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
231 bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE))
233 /* Write into appropriate registers a function return value
234 of type TYPE, given in virtual format. */
236 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
237 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
239 /* Extract from an array REGBUF containing the (raw) register state
240 the address in which a function should return its structure value,
241 as a CORE_ADDR (or an expression that can be used as one). */
243 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
245 /* Compensate for lack of `vprintf' function. */
247 #define vprintf(format, ap) _doprnt (format, ap, stdout)
248 #endif /* not HAVE_VPRINTF */
250 /* This is a piece of magic that is given a register number REGNO
251 and as BLOCKEND the address in the system of the end of the user structure
252 and stores in ADDR the address in the kernel or core dump
255 #define REGISTER_U_ADDR(addr, blockend, regno) \
257 if (regno < PS_REGNUM) \
258 addr = (int) &((struct frame *)(blockend))->f_regs[regno]; \
259 else if (regno == PS_REGNUM) \
260 addr = (int) &((struct frame *)(blockend))->f_stackadj; \
261 else if (regno == PC_REGNUM) \
262 addr = (int) &((struct frame *)(blockend))->f_pc; \
263 else if (regno < FPC_REGNUM) \
265 &((struct user *)0)->u_pcb.pcb_fpregs.fpf_regs[((regno)-FP0_REGNUM)*3];\
266 else if (regno == FPC_REGNUM) \
267 addr = (int) &((struct user *)0)->u_pcb.pcb_fpregs.fpf_fpcr; \
268 else if (regno == FPS_REGNUM) \
269 addr = (int) &((struct user *)0)->u_pcb.pcb_fpregs.fpf_fpsr; \
271 addr = (int) &((struct user *)0)->u_pcb.pcb_fpregs.fpf_fpiar; \
274 /* Describe the pointer in each stack frame to the previous stack frame
277 /* FRAME_CHAIN takes a frame's nominal address
278 and produces the frame's chain-pointer.
280 FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
281 and produces the nominal address of the caller frame.
283 However, if FRAME_CHAIN_VALID returns zero,
284 it means the given frame is the outermost one and has no caller.
285 In that case, FRAME_CHAIN_COMBINE is not used. */
287 /* In the case of the Sun, the frame's nominal address
288 is the address of a 4-byte word containing the calling frame's address. */
290 #define FRAME_CHAIN(thisframe) \
291 (outside_startup_file ((thisframe)->pc) ? \
292 read_memory_integer ((thisframe)->frame, 4) :\
295 #define FRAME_CHAIN_VALID(chain, thisframe) \
296 (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe))))
298 #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
300 /* Define other aspects of the stack frame. */
302 /* A macro that tells us whether the function invocation represented
303 by FI does not have a frame on the stack associated with it. If it
304 does not, FRAMELESS is set to 1, else 0. */
305 #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
306 FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS)
308 #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
310 #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
312 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
314 /* Set VAL to the number of args passed to frame described by FI.
315 Can set VAL to -1, meaning no way to tell. */
317 /* We can't tell how many args there are
318 now that the C compiler delays popping them. */
319 #define FRAME_NUM_ARGS(val,fi) (val = -1)
322 #define FRAME_NUM_ARGS(val, fi) \
323 { register CORE_ADDR pc = FRAME_SAVED_PC (fi); \
324 register int insn = 0177777 & read_memory_integer (pc, 2); \
326 if (insn == 0047757 || insn == 0157374) /* lea W(sp),sp or addaw #W,sp */ \
327 val = read_memory_integer (pc + 2, 2); \
328 else if ((insn & 0170777) == 0050217 /* addql #N, sp */ \
329 || (insn & 0170777) == 0050117) /* addqw */ \
330 { val = (insn >> 9) & 7; if (val == 0) val = 8; } \
331 else if (insn == 0157774) /* addal #WW, sp */ \
332 val = read_memory_integer (pc + 2, 4); \
336 /* Return number of bytes at start of arglist that are not really args. */
338 #define FRAME_ARGS_SKIP 8
340 /* Put here the code to store, into a struct frame_saved_regs,
341 the addresses of the saved registers of frame described by FRAME_INFO.
342 This includes special registers such as pc and fp saved in special
343 ways in the stack frame. sp is even more special:
344 the address we return for it IS the sp for the next frame. */
346 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
347 { register int regnum; \
348 register int regmask; \
349 register CORE_ADDR next_addr; \
350 register CORE_ADDR pc; \
352 bzero (&frame_saved_regs, sizeof frame_saved_regs); \
353 if ((frame_info)->pc >= (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 8*12 - 4 \
354 && (frame_info)->pc <= (frame_info)->frame) \
355 { next_addr = (frame_info)->frame; \
356 pc = (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 8*12 - 4; }\
358 { pc = get_pc_function_start ((frame_info)->pc); \
359 /* Verify we have a link a6 instruction next; \
360 if not we lose. If we win, find the address above the saved \
361 regs using the amount of storage from the link instruction. */\
362 if (044016 == read_memory_integer (pc, 2)) \
363 next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 4), pc+=4; \
364 else if (047126 == read_memory_integer (pc, 2)) \
365 next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 2), pc+=2; \
367 /* If have an addal #-n, sp next, adjust next_addr. */ \
368 if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \
369 next_addr += read_memory_integer (pc += 2, 4), pc += 4; \
371 /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \
372 regmask = read_memory_integer (pc + 2, 2); \
373 /* But before that can come an fmovem. Check for it. */ \
374 nextinsn = 0xffff & read_memory_integer (pc, 2); \
375 if (0xf227 == nextinsn \
376 && (regmask & 0xff00) == 0xe000) \
377 { pc += 4; /* Regmask's low bit is for register fp7, the first pushed */ \
378 for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \
380 (frame_saved_regs).regs[regnum] = (next_addr -= 12); \
381 regmask = read_memory_integer (pc + 2, 2); } \
382 if (0044327 == read_memory_integer (pc, 2)) \
383 { pc += 4; /* Regmask's low bit is for register 0, the first written */ \
384 for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \
386 (frame_saved_regs).regs[regnum] = (next_addr += 4) - 4; } \
387 else if (0044347 == read_memory_integer (pc, 2)) \
388 { pc += 4; /* Regmask's low bit is for register 15, the first pushed */ \
389 for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \
391 (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \
392 else if (0x2f00 == (0xfff0 & read_memory_integer (pc, 2))) \
393 { regnum = 0xf & read_memory_integer (pc, 2); pc += 2; \
394 (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \
395 /* fmovemx to index of sp may follow. */ \
396 regmask = read_memory_integer (pc + 2, 2); \
397 nextinsn = 0xffff & read_memory_integer (pc, 2); \
398 if (0xf236 == nextinsn \
399 && (regmask & 0xff00) == 0xf000) \
400 { pc += 10; /* Regmask's low bit is for register fp0, the first written */ \
401 for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \
403 (frame_saved_regs).regs[regnum] = (next_addr += 12) - 12; \
404 regmask = read_memory_integer (pc + 2, 2); } \
405 /* clrw -(sp); movw ccr,-(sp) may follow. */ \
406 if (0x426742e7 == read_memory_integer (pc, 4)) \
407 (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \
409 (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 8; \
410 (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \
411 (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \
414 /* Things needed for making the inferior call functions. */
416 /* Push an empty stack frame, to record the current PC, etc. */
418 #define PUSH_DUMMY_FRAME \
419 { register CORE_ADDR sp = read_register (SP_REGNUM); \
420 register int regnum; \
421 char raw_buffer[12]; \
422 sp = push_word (sp, read_register (PC_REGNUM)); \
423 sp = push_word (sp, read_register (FP_REGNUM)); \
424 write_register (FP_REGNUM, sp); \
425 for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \
426 { read_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); \
427 sp = push_bytes (sp, raw_buffer, 12); } \
428 for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \
429 sp = push_word (sp, read_register (regnum)); \
430 sp = push_word (sp, read_register (PS_REGNUM)); \
431 write_register (SP_REGNUM, sp); }
433 /* Discard from the stack the innermost frame,
434 restoring all saved registers. */
437 { register FRAME frame = get_current_frame (); \
438 register CORE_ADDR fp; \
439 register int regnum; \
440 struct frame_saved_regs fsr; \
441 struct frame_info *fi; \
442 char raw_buffer[12]; \
443 fi = get_frame_info (frame); \
445 get_frame_saved_regs (fi, &fsr); \
446 for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \
447 if (fsr.regs[regnum]) \
448 { read_memory (fsr.regs[regnum], raw_buffer, 12); \
449 write_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); }\
450 for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \
451 if (fsr.regs[regnum]) \
452 write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
453 if (fsr.regs[PS_REGNUM]) \
454 write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \
455 write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
456 write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
457 write_register (SP_REGNUM, fp + 8); \
458 flush_cached_frames (); \
459 set_current_frame (create_new_frame (read_register (FP_REGNUM),\
462 /* This sequence of words is the instructions
467 /..* The arguments are pushed at this point by GDB;
468 no code is needed in the dummy for this.
469 The CALL_DUMMY_START_OFFSET gives the position of
470 the following jsr instruction. *../
475 Note this is 28 bytes.
476 We actually start executing at the jsr, since the pushing of the
477 registers is done by PUSH_DUMMY_FRAME. If this were real code,
478 the arguments for the function called by the jsr would be pushed
479 between the moveml and the jsr, and we could allow it to execute through.
480 But the arguments have to be pushed by GDB after the PUSH_DUMMY_FRAME is done,
481 and we cannot allow the moveml to push the registers again lest they be
482 taken for the arguments. */
484 #define CALL_DUMMY {0xf227e0ff, 0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, 0x4e424e71}
486 #define CALL_DUMMY_LENGTH 28
488 #define CALL_DUMMY_START_OFFSET 12
490 /* Insert the specified number of args and function address
491 into a call sequence of the above form stored at DUMMYNAME. */
493 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \
494 { *(int *)((char *) dummyname + 20) = nargs * 4; \
495 *(int *)((char *) dummyname + 14) = fun; }
497 /* Interface definitions for kernel debugger KDB. */
499 /* Map machine fault codes into signal numbers.
500 First subtract 0, divide by 4, then index in a table.
501 Faults for which the entry in this table is 0
502 are not handled by KDB; the program's own trap handler
503 gets to handle then. */
505 #define FAULT_CODE_ORIGIN 0
506 #define FAULT_CODE_UNITS 4
507 #define FAULT_TABLE \
508 { 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \
509 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \
510 0, 0, 0, 0, 0, 0, 0, 0, \
513 /* Start running with a stack stretching from BEG to END.
514 BEG and END should be symbols meaningful to the assembler.
515 This is used only for kdb. */
517 #define INIT_STACK(beg, end) \
518 { asm (".globl end"); \
519 asm ("movel #end, sp"); \
520 asm ("movel #0,a6"); }
522 /* Push the frame pointer register on the stack. */
523 #define PUSH_FRAME_PTR \
524 asm ("movel a6,sp@-");
526 /* Copy the top-of-stack to the frame pointer register. */
527 #define POP_FRAME_PTR \
530 /* After KDB is entered by a fault, push all registers
531 that GDB thinks about (all NUM_REGS of them),
532 so that they appear in order of ascending GDB register number.
533 The fault code will be on the stack beyond the last register. */
535 #define PUSH_REGISTERS \
536 { asm ("clrw -(sp)"); \
537 asm ("pea sp@(10)"); \
538 asm ("movem #0xfffe,sp@-"); }
540 /* Assuming the registers (including processor status) have been
541 pushed on the stack in order of ascending GDB register number,
542 restore them and return to the address in the saved PC register. */
544 #define POP_REGISTERS \
545 { asm ("subil #8,sp@(28)"); \
546 asm ("movem sp@,#0xffff"); \
This page took 0.040797 seconds and 4 git commands to generate.