]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/m-hp9k320.h
372547611fa29b8e7307b2cb11d8257fb1956370
1 /* Parameters for execution on an HP 9000 model 320, for GDB, the GNU debugger.
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 /* Define the bit, byte, and word ordering of the machine. */
21 #define BITS_BIG_ENDIAN
22 #define BYTES_BIG_ENDIAN
23 #define WORDS_BIG_ENDIAN
29 /* Define this to indicate problems with traps after continuing. */
32 /* Set flag to indicate whether HP's assembler is in use. */
41 /* Define this for versions of hp-ux older than 6.0 */
42 /* #define HPUX_VERSION_5 */
44 /* define USG if you are using sys5 /usr/include's */
49 /* Get rid of any system-imposed stack limit if possible. */
50 /* The hp9k320.h doesn't seem to have this feature. */
51 /* #define SET_STACK_LIMIT_HUGE */
52 /* So we'll just have to avoid big alloca's. */
53 #define BROKEN_LARGE_ALLOCA
55 /* Define this if the C compiler puts an underscore at the front
56 of external names before giving them to the linker. */
58 #define NAMES_HAVE_UNDERSCORE
60 /* Debugger information will be in DBX format. */
62 #define READ_DBX_FORMAT
64 /* Offset from address of function to start of its code.
65 Zero on most machines. */
67 #define FUNCTION_START_OFFSET 0
69 /* Advance PC across any function entry prologue instructions
70 to reach some "real" code. */
72 #define SKIP_PROLOGUE(pc) \
73 { register int op = read_memory_integer (pc, 2); \
75 pc += 4; /* Skip link #word */ \
76 else if (op == 0044016) \
77 pc += 6; /* Skip link #long */ \
80 /* Immediately after a function call, return the saved pc.
81 Can't go through the frames for this because on some machines
82 the new frame is not set up until the new function executes
85 #define SAVED_PC_AFTER_CALL(frame) \
86 read_memory_integer (read_register (SP_REGNUM), 4)
88 /* This is the amount to subtract from u.u_ar0
89 to get the offset in the core file of the register values. */
92 #define KERNEL_U_ADDR 0x00979000
94 #define KERNEL_U_ADDR 0x00C01000
97 /* Address of end of stack space. */
99 #define STACK_END_ADDR 0xFFF00000
101 /* Stack grows downward. */
105 /* Sequence of bytes for breakpoint instruction. */
107 #define BREAKPOINT {0x4e, 0x41}
109 /* Amount PC must be decremented by after a breakpoint.
110 This is often the number of bytes in BREAKPOINT
113 #define DECR_PC_AFTER_BREAK 2
115 /* Nonzero if instruction at PC is a return instruction. */
117 #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 2) == 0x4e75)
119 /* Return 1 if P points to an invalid floating point value. */
121 #define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */
123 /* Largest integer type */
126 /* Name of the builtin type for the LONGEST type above. */
127 #define BUILTIN_TYPE_LONGEST builtin_type_long
129 /* Say how long (ordinary) registers are. */
131 #define REGISTER_TYPE long
133 /* Number of machine registers */
137 /* Initializer for an array of names of registers.
138 There should be NUM_REGS strings in this initializer. */
140 #define REGISTER_NAMES \
141 {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \
142 "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp", \
144 "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7", \
145 "fpcontrol", "fpstatus", "fpiaddr" }
147 /* Register numbers of various important registers.
148 Note that some of these values are "real" register numbers,
149 and correspond to the general registers of the machine,
150 and some are "phony" register numbers which are too large
151 to be actual register numbers as far as the user is concerned
152 but do serve to get the desired values when passed to read_register. */
154 #define FP_REGNUM 14 /* Contains address of executing stack frame */
155 #define SP_REGNUM 15 /* Contains address of top of stack */
156 #define PS_REGNUM 16 /* Contains processor status */
157 #define PC_REGNUM 17 /* Contains program counter */
158 #define FP0_REGNUM 18 /* Floating point register 0 */
159 #define FPC_REGNUM 26 /* 68881 control register */
161 /* Total amount of space needed to store our copies of the machine's
162 register state, the array `registers'. */
163 #define REGISTER_BYTES (16*4+8*12+8+12)
165 /* Index within `registers' of the first byte of the space for
168 #define REGISTER_BYTE(N) \
169 ((N) >= FPC_REGNUM ? (((N) - FPC_REGNUM) * 4) + 168 \
170 : (N) >= FP0_REGNUM ? (((N) - FP0_REGNUM) * 12) + 72 \
173 /* Number of bytes of storage in the actual machine representation
174 for register N. On the 68000, all regs are 4 bytes
175 except the floating point regs which are 12 bytes. */
177 #define REGISTER_RAW_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 12 : 4)
179 /* Number of bytes of storage in the program's representation
180 for register N. On the 68000, all regs are 4 bytes
181 except the floating point regs which are 8-byte doubles. */
183 #define REGISTER_VIRTUAL_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 8 : 4)
185 /* Largest value REGISTER_RAW_SIZE can have. */
187 #define MAX_REGISTER_RAW_SIZE 12
189 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
191 #define MAX_REGISTER_VIRTUAL_SIZE 8
193 /* Nonzero if register N requires conversion
194 from raw format to virtual format. */
196 #define REGISTER_CONVERTIBLE(N) (((unsigned)(N) - FP0_REGNUM) < 8)
198 /* Convert data from raw format for register REGNUM
199 to virtual format for register REGNUM. */
201 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
202 { if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
203 convert_from_68881 ((FROM), (TO)); \
205 bcopy ((FROM), (TO), 4); }
207 /* Convert data from virtual format for register REGNUM
208 to raw format for register REGNUM. */
210 #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
211 { if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
212 convert_to_68881 ((FROM), (TO)); \
214 bcopy ((FROM), (TO), 4); }
216 /* Return the GDB type object for the "standard" data type
217 of data in register N. */
219 #define REGISTER_VIRTUAL_TYPE(N) \
220 (((unsigned)(N) - FP0_REGNUM) < 8 ? builtin_type_double : builtin_type_int)
222 /* Store the address of the place in which to copy the structure the
223 subroutine will return. This is called from call_function. */
225 #define STORE_STRUCT_RETURN(ADDR, SP) \
226 { write_register (9, (ADDR)); }
228 /* Extract from an array REGBUF containing the (raw) register state
229 a function return value of type TYPE, and copy that, in virtual format,
232 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
233 bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE))
235 /* Write into appropriate registers a function return value
236 of type TYPE, given in virtual format. */
238 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
239 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
241 /* Extract from an array REGBUF containing the (raw) register state
242 the address in which a function should return its structure value,
243 as a CORE_ADDR (or an expression that can be used as one). */
245 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
247 #define REGISTER_ADDR(u_ar0, regno) \
248 (((regno) < PS_REGNUM) \
249 ? (&((struct exception_stack *) (u_ar0))->e_regs[(regno + R0)]) \
250 : (((regno) == PS_REGNUM) \
251 ? ((int *) (&((struct exception_stack *) (u_ar0))->e_PS)) \
252 : (&((struct exception_stack *) (u_ar0))->e_PC)))
254 #define FP_REGISTER_ADDR(u, regno) \
256 (((regno) < FPC_REGNUM) \
257 ? (&u.u_pcb.pcb_mc68881[FMC68881_R0 + (((regno) - FP0_REGNUM) * 3)]) \
258 : (&u.u_pcb.pcb_mc68881[FMC68881_C + ((regno) - FPC_REGNUM)]))) \
261 /* Describe the pointer in each stack frame to the previous stack frame
264 /* FRAME_CHAIN takes a frame's nominal address
265 and produces the frame's chain-pointer.
267 FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
268 and produces the nominal address of the caller frame.
270 However, if FRAME_CHAIN_VALID returns zero,
271 it means the given frame is the outermost one and has no caller.
272 In that case, FRAME_CHAIN_COMBINE is not used. */
274 /* In the case of the Sun, the frame's nominal address
275 is the address of a 4-byte word containing the calling frame's address. */
277 #define FRAME_CHAIN(thisframe) \
278 (outside_startup_file ((thisframe)->pc) ? \
279 read_memory_integer ((thisframe)->frame, 4) : \
282 #define FRAME_CHAIN_VALID(chain, thisframe) \
283 (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe))))
285 #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
287 /* Define other aspects of the stack frame. */
289 /* A macro that tells us whether the function invocation represented
290 by FI does not have a frame on the stack associated with it. If it
291 does not, FRAMELESS is set to 1, else 0. */
292 #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
293 FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS)
295 #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
297 #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
299 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
301 /* Set VAL to the number of args passed to frame described by FI.
302 Can set VAL to -1, meaning no way to tell. */
304 /* We can't tell how many args there are
305 now that the C compiler delays popping them. */
306 #define FRAME_NUM_ARGS(val,fi) (val = -1)
309 #define FRAME_NUM_ARGS(val, fi) \
310 { register CORE_ADDR pc = FRAME_SAVED_PC (fi); \
311 register int insn = 0177777 & read_memory_integer (pc, 2); \
313 if (insn == 0047757 || insn == 0157374) /* lea W(sp),sp or addaw #W,sp */ \
314 val = read_memory_integer (pc + 2, 2); \
315 else if ((insn & 0170777) == 0050217 /* addql #N, sp */ \
316 || (insn & 0170777) == 0050117) /* addqw */ \
317 { val = (insn >> 9) & 7; if (val == 0) val = 8; } \
318 else if (insn == 0157774) /* addal #WW, sp */ \
319 val = read_memory_integer (pc + 2, 4); \
323 /* Return number of bytes at start of arglist that are not really args. */
325 #define FRAME_ARGS_SKIP 8
327 /* Put here the code to store, into a struct frame_saved_regs,
328 the addresses of the saved registers of frame described by FRAME_INFO.
329 This includes special registers such as pc and fp saved in special
330 ways in the stack frame. sp is even more special:
331 the address we return for it IS the sp for the next frame. */
333 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
334 { register int regnum; \
335 register int regmask; \
336 register CORE_ADDR next_addr; \
337 register CORE_ADDR pc; \
339 bzero (&frame_saved_regs, sizeof frame_saved_regs); \
340 if ((frame_info)->pc >= (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 8*12 - 4 \
341 && (frame_info)->pc <= (frame_info)->frame) \
342 { next_addr = (frame_info)->frame; \
343 pc = (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 8*12 - 4; }\
345 { pc = get_pc_function_start ((frame_info)->pc); \
346 /* Verify we have a link a6 instruction next; \
347 if not we lose. If we win, find the address above the saved \
348 regs using the amount of storage from the link instruction. */\
349 if (044016 == read_memory_integer (pc, 2)) \
350 next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 4), pc+=4; \
351 else if (047126 == read_memory_integer (pc, 2)) \
352 next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 2), pc+=2; \
354 /* If have an addal #-n, sp next, adjust next_addr. */ \
355 if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \
356 next_addr += read_memory_integer (pc += 2, 4), pc += 4; \
358 /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \
359 regmask = read_memory_integer (pc + 2, 2); \
360 /* But before that can come an fmovem. Check for it. */ \
361 nextinsn = 0xffff & read_memory_integer (pc, 2); \
362 if (0xf227 == nextinsn \
363 && (regmask & 0xff00) == 0xe000) \
364 { pc += 4; /* Regmask's low bit is for register fp7, the first pushed */ \
365 for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \
367 (frame_saved_regs).regs[regnum] = (next_addr -= 12); \
368 regmask = read_memory_integer (pc + 2, 2); } \
369 if (0044327 == read_memory_integer (pc, 2)) \
370 { pc += 4; /* Regmask's low bit is for register 0, the first written */ \
371 for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \
373 (frame_saved_regs).regs[regnum] = (next_addr += 4) - 4; } \
374 else if (0044347 == read_memory_integer (pc, 2)) \
375 { pc += 4; /* Regmask's low bit is for register 15, the first pushed */ \
376 for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \
378 (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \
379 else if (0x2f00 == 0xfff0 & read_memory_integer (pc, 2)) \
380 { regnum = 0xf & read_memory_integer (pc, 2); pc += 2; \
381 (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \
382 /* fmovemx to index of sp may follow. */ \
383 regmask = read_memory_integer (pc + 2, 2); \
384 nextinsn = 0xffff & read_memory_integer (pc, 2); \
385 if (0xf236 == nextinsn \
386 && (regmask & 0xff00) == 0xf000) \
387 { pc += 10; /* Regmask's low bit is for register fp0, the first written */ \
388 for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \
390 (frame_saved_regs).regs[regnum] = (next_addr += 12) - 12; \
391 regmask = read_memory_integer (pc + 2, 2); } \
392 /* clrw -(sp); movw ccr,-(sp) may follow. */ \
393 if (0x426742e7 == read_memory_integer (pc, 4)) \
394 (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \
396 (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 8; \
397 (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \
398 (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \
401 /* Things needed for making the inferior call functions. */
403 /* Push an empty stack frame, to record the current PC, etc. */
405 #define PUSH_DUMMY_FRAME \
406 { register CORE_ADDR sp = read_register (SP_REGNUM); \
407 register int regnum; \
408 char raw_buffer[12]; \
409 sp = push_word (sp, read_register (PC_REGNUM)); \
410 sp = push_word (sp, read_register (FP_REGNUM)); \
411 write_register (FP_REGNUM, sp); \
412 for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \
413 { read_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); \
414 sp = push_bytes (sp, raw_buffer, 12); } \
415 for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \
416 sp = push_word (sp, read_register (regnum)); \
417 sp = push_word (sp, read_register (PS_REGNUM)); \
418 write_register (SP_REGNUM, sp); }
420 /* Discard from the stack the innermost frame,
421 restoring all saved registers. */
424 { register FRAME frame = get_current_frame (); \
425 register CORE_ADDR fp; \
426 register int regnum; \
427 struct frame_saved_regs fsr; \
428 struct frame_info *fi; \
429 char raw_buffer[12]; \
430 fi = get_frame_info (frame); \
432 get_frame_saved_regs (fi, &fsr); \
433 for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \
434 if (fsr.regs[regnum]) \
435 { read_memory (fsr.regs[regnum], raw_buffer, 12); \
436 write_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); }\
437 for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \
438 if (fsr.regs[regnum]) \
439 write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
440 if (fsr.regs[PS_REGNUM]) \
441 write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \
442 write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
443 write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
444 write_register (SP_REGNUM, fp + 8); \
445 flush_cached_frames (); \
446 set_current_frame (create_new_frame (read_register (FP_REGNUM),\
449 /* This sequence of words is the instructions
454 /..* The arguments are pushed at this point by GDB;
455 no code is needed in the dummy for this.
456 The CALL_DUMMY_START_OFFSET gives the position of
457 the following jsr instruction. *../
462 Note this is 28 bytes.
463 We actually start executing at the jsr, since the pushing of the
464 registers is done by PUSH_DUMMY_FRAME. If this were real code,
465 the arguments for the function called by the jsr would be pushed
466 between the moveml and the jsr, and we could allow it to execute through.
467 But the arguments have to be pushed by GDB after the PUSH_DUMMY_FRAME is done,
468 and we cannot allow the moveml to push the registers again lest they be
469 taken for the arguments. */
471 #define CALL_DUMMY {0xf227e0ff, 0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, 0x4e414e71}
473 #define CALL_DUMMY_LENGTH 28
475 #define CALL_DUMMY_START_OFFSET 12
477 /* Insert the specified number of args and function address
478 into a call sequence of the above form stored at DUMMYNAME. */
480 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \
481 { *(int *)((char *) dummyname + 20) = nargs * 4; \
482 *(int *)((char *) dummyname + 14) = fun; }
484 /* Interface definitions for kernel debugger KDB. */
486 /* Map machine fault codes into signal numbers.
487 First subtract 0, divide by 4, then index in a table.
488 Faults for which the entry in this table is 0
489 are not handled by KDB; the program's own trap handler
490 gets to handle then. */
492 #define FAULT_CODE_ORIGIN 0
493 #define FAULT_CODE_UNITS 4
494 #define FAULT_TABLE \
495 { 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \
496 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \
497 0, 0, 0, 0, 0, 0, 0, 0, \
502 /* Start running with a stack stretching from BEG to END.
503 BEG and END should be symbols meaningful to the assembler.
504 This is used only for kdb. */
506 #define INIT_STACK(beg, end) \
507 { asm (".globl end"); \
508 asm ("movel $ end, sp"); \
511 /* Push the frame pointer register on the stack. */
512 #define PUSH_FRAME_PTR \
513 asm ("movel fp, -(sp)");
515 /* Copy the top-of-stack to the frame pointer register. */
516 #define POP_FRAME_PTR \
517 asm ("movl (sp), fp");
519 /* After KDB is entered by a fault, push all registers
520 that GDB thinks about (all NUM_REGS of them),
521 so that they appear in order of ascending GDB register number.
522 The fault code will be on the stack beyond the last register. */
524 #define PUSH_REGISTERS \
525 { asm ("clrw -(sp)"); \
526 asm ("pea 10(sp)"); \
527 asm ("movem $ 0xfffe,-(sp)"); }
529 /* Assuming the registers (including processor status) have been
530 pushed on the stack in order of ascending GDB register number,
531 restore them and return to the address in the saved PC register. */
533 #define POP_REGISTERS \
534 { asm ("subil $8,28(sp)"); \
535 asm ("movem (sp),$ 0xffff"); \
540 /* Start running with a stack stretching from BEG to END.
541 BEG and END should be symbols meaningful to the assembler.
542 This is used only for kdb. */
544 #define INIT_STACK(beg, end) \
545 { asm ("global end"); \
546 asm ("mov.l &end,%sp"); \
549 /* Push the frame pointer register on the stack. */
550 #define PUSH_FRAME_PTR \
551 asm ("mov.l %fp,-(%sp)");
553 /* Copy the top-of-stack to the frame pointer register. */
554 #define POP_FRAME_PTR \
555 asm ("mov.l (%sp),%fp");
557 /* After KDB is entered by a fault, push all registers
558 that GDB thinks about (all NUM_REGS of them),
559 so that they appear in order of ascending GDB register number.
560 The fault code will be on the stack beyond the last register. */
562 #define PUSH_REGISTERS \
563 { asm ("clr.w -(%sp)"); \
564 asm ("pea 10(%sp)"); \
565 asm ("movm.l &0xfffe,-(%sp)"); }
567 /* Assuming the registers (including processor status) have been
568 pushed on the stack in order of ascending GDB register number,
569 restore them and return to the address in the saved PC register. */
571 #define POP_REGISTERS \
572 { asm ("subi.l &8,28(%sp)"); \
573 asm ("mov.m (%sp),&0xffff"); \
576 #endif /* HPUX_ASM */