1 /* Parameters for execution on a Hewlett-Packard PA-RISC machine, running
3 Copyright 1986, 1987, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
5 Contributed by the Center for Software Science at the
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
24 /* Target system byte order. */
26 #define TARGET_BYTE_ORDER BIG_ENDIAN
28 /* Get at various relevent fields of an instruction word. */
32 #define MASK_14 0x3fff
33 #define MASK_21 0x1fffff
35 /* This macro gets bit fields using HP's numbering (MSB = 0) */
37 #define GET_FIELD(X, FROM, TO) \
38 ((X) >> 31 - (TO) & (1 << ((TO) - (FROM) + 1)) - 1)
40 /* Watch out for NaNs */
46 #define ARGS_GROW_DOWN
48 /* Define this if the C compiler puts an underscore at the front
49 of external names before giving them to the linker. */
51 /* #define NAMES_HAVE_UNDERSCORE */
53 /* Offset from address of function to start of its code.
54 Zero on most machines. */
56 #define FUNCTION_START_OFFSET 0
58 /* Advance PC across any function entry prologue instructions
59 to reach some "real" code. */
61 /* skip (stw rp, -20(0,sp)); copy 4,1; copy sp, 4; stwm 1,framesize(sp)
62 for gcc, or (stw rp, -20(0,sp); stwm 1, framesize(sp) for hcc */
64 #define SKIP_PROLOGUE(pc) pc = skip_prologue (pc)
66 /* If PC is in some function-call trampoline code, return the PC
67 where the function itself actually starts. If not, return NULL. */
69 #define SKIP_TRAMPOLINE_CODE(pc) skip_trampoline_code (pc, NULL)
71 /* Return non-zero if we are in some sort of a trampoline. */
73 #define IN_SOLIB_TRAMPOLINE(pc, name) skip_trampoline_code (pc, name)
75 /* Immediately after a function call, return the saved pc.
76 Can't go through the frames for this because on some machines
77 the new frame is not set up until the new function executes
80 #define SAVED_PC_AFTER_CALL(frame) (read_register (RP_REGNUM) & ~3)
82 /* Address of end of stack space. Who knows. */
84 #define STACK_END_ADDR 0x80000000
86 /* Stack grows upward */
91 /* Sequence of bytes for breakpoint instruction. */
93 /*#define BREAKPOINT {0x00, 0x00, 0x00, 0x00}*/
94 #ifdef KERNELDEBUG /* XXX */
95 #define BREAKPOINT {0x00, 0x00, 0xa0, 0x00}
97 #define BREAKPOINT {0x00, 0x01, 0x00, 0x04}
100 /* Amount PC must be decremented by after a breakpoint.
101 This is often the number of bytes in BREAKPOINT
104 Not on the PA-RISC */
106 #define DECR_PC_AFTER_BREAK 0
108 /* return instruction is bv r0(rp) */
110 #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 4) == 0xE840C000)
112 /* Return 1 if P points to an invalid floating point value. */
114 #define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */
116 /* Largest integer type */
119 /* Name of the builtin type for the LONGEST type above. */
120 #define BUILTIN_TYPE_LONGEST builtin_type_long
122 /* Say how long (ordinary) registers are. */
124 #define REGISTER_TYPE long
126 /* 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 {"flags", "r1", "rp", "r3", "r4", "r5", "r6", "r7", "r8", "r9", \
135 "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", \
136 "r20", "r21", "r22", "arg3", "arg2", "arg1", "arg0", "dp", "ret0", "ret1", \
137 "sp", "r31", "sar", "pcoqh", "pcsqh", "pcoqt", "pcsqt", \
138 "eiem", "iir", "isr", "ior", "ipsw", "goto", "sr4", "sr0", "sr1", "sr2", \
139 "sr3", "sr5", "sr6", "sr7", "cr0", "cr8", "cr9", "ccr", "cr12", "cr13", \
140 "cr24", "cr25", "cr26", "mpsfu_high", "mpsfu_low", "mpsfu_ovflo", "pad", \
141 "fpsr", "fpe1", "fpe2", "fpe3", "fpe4", "fpe5", "fpe6", "fpe7", \
142 "fp4", "fp5", "fp6", "fp7", "fp8", \
143 "fp9", "fp10", "fp11", "fp12", "fp13", "fp14", "fp15", \
144 "fp16", "fp17", "fp18", "fp19", "fp20", "fp21", "fp22", "fp23", \
145 "fp24", "fp25", "fp26", "fp27", "fp28", "fp29", "fp30", "fp31"}
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 FLAGS_REGNUM 0 /* Various status flags */
155 #define RP_REGNUM 2 /* return pointer */
156 #define FP_REGNUM 4 /* Contains address of executing stack */
158 #define SP_REGNUM 30 /* Contains address of top of stack */
159 #define SAR_REGNUM 32 /* shift amount register */
160 #define IPSW_REGNUM 41 /* processor status word. ? */
161 #define PCOQ_HEAD_REGNUM 33 /* instruction offset queue head */
162 #define PCSQ_HEAD_REGNUM 34 /* instruction space queue head */
163 #define PCOQ_TAIL_REGNUM 35 /* instruction offset queue tail */
164 #define PCSQ_TAIL_REGNUM 36 /* instruction space queue tail */
165 #define FP0_REGNUM 64 /* floating point reg. 0 */
166 #define FP4_REGNUM 72
168 /* compatibility with the rest of gdb. */
169 #define PC_REGNUM PCOQ_HEAD_REGNUM
170 #define NPC_REGNUM PCOQ_TAIL_REGNUM
172 /* When fetching register values from an inferior or a core file,
173 clean them up using this macro. BUF is a char pointer to
174 the raw value of the register in the registers[] array. */
176 #define CLEAN_UP_REGISTER_VALUE(regno, buf) \
178 if ((regno) == PCOQ_HEAD_REGNUM || (regno) == PCOQ_TAIL_REGNUM) \
182 /* Define DO_REGISTERS_INFO() to do machine-specific formatting
183 of register dumps. */
185 #define DO_REGISTERS_INFO(_regnum, fp) pa_do_registers_info (_regnum, fp)
187 /* PA specific macro to see if the current instruction is nullified. */
188 #define INSTRUCTION_NULLIFIED ((int)read_register (IPSW_REGNUM) & 0x00200000)
190 /* Total amount of space needed to store our copies of the machine's
191 register state, the array `registers'. */
192 #define REGISTER_BYTES (32 * 4 + 11 * 4 + 8 * 4 + 12 * 4 + 4 + 32 * 8)
194 /* Index within `registers' of the first byte of the space for
197 #define REGISTER_BYTE(N) \
198 ((N) >= FP4_REGNUM ? ((N) - FP4_REGNUM) * 8 + 288 : (N) * 4)
200 /* Number of bytes of storage in the actual machine representation
201 for register N. On the PA-RISC, all regs are 4 bytes
202 except the floating point regs which are 8 bytes. */
204 #define REGISTER_RAW_SIZE(N) ((N) < FP4_REGNUM ? 4 : 8)
206 /* Number of bytes of storage in the program's representation
209 #define REGISTER_VIRTUAL_SIZE(N) REGISTER_RAW_SIZE(N)
211 /* Largest value REGISTER_RAW_SIZE can have. */
213 #define MAX_REGISTER_RAW_SIZE 8
215 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
217 #define MAX_REGISTER_VIRTUAL_SIZE 8
219 /* Nonzero if register N requires conversion
220 from raw format to virtual format. */
222 #define REGISTER_CONVERTIBLE(N) 0
224 /* Convert data from raw format for register REGNUM
225 to virtual format for register REGNUM. */
227 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM, FROM, TO) \
228 { memcpy ((TO), (FROM), (REGNUM) < FP4_REGNUM ? 4 : 8); }
230 /* Convert data from virtual format for register REGNUM
231 to raw format for register REGNUM. */
233 #define REGISTER_CONVERT_TO_RAW(REGNUM, FROM, TO) \
234 { memcpy ((TO), (FROM), (REGNUM) < FP4_REGNUM ? 4 : 8); }
236 /* Return the GDB type object for the "standard" data type
237 of data in register N. */
239 #define REGISTER_VIRTUAL_TYPE(N) \
240 ((N) < FP4_REGNUM ? builtin_type_int : builtin_type_double)
242 /* Store the address of the place in which to copy the structure the
243 subroutine will return. This is called from call_function. */
245 #define STORE_STRUCT_RETURN(ADDR, SP) {write_register (28, (ADDR)); }
247 /* Extract from an array REGBUF containing the (raw) register state
248 a function return value of type TYPE, and copy that, in virtual format,
251 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
252 bcopy ((REGBUF) + REGISTER_BYTE(TYPE_LENGTH(TYPE) > 4 ? \
253 FP4_REGNUM :28), VALBUF, TYPE_LENGTH (TYPE))
255 /* Write into appropriate registers a function return value
256 of type TYPE, given in virtual format. */
258 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
259 write_register_bytes (TYPE_LENGTH(TYPE) > 4 ? FP4_REGNUM :28, \
260 VALBUF, TYPE_LENGTH (TYPE))
262 /* Extract from an array REGBUF containing the (raw) register state
263 the address in which a function should return its structure value,
264 as a CORE_ADDR (or an expression that can be used as one). */
266 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)((REGBUF) + 28))
269 * This macro defines the register numbers (from REGISTER_NAMES) that
270 * are effectively unavailable to the user through ptrace(). It allows
271 * us to include the whole register set in REGISTER_NAMES (inorder to
272 * better support remote debugging). If it is used in
273 * fetch/store_inferior_registers() gdb will not complain about I/O errors
274 * on fetching these registers. If all registers in REGISTER_NAMES
275 * are available, then return false (0).
278 #define CANNOT_STORE_REGISTER(regno) \
280 ((regno) == PCSQ_HEAD_REGNUM) || \
281 ((regno) >= PCSQ_TAIL_REGNUM && (regno) < IPSW_REGNUM) || \
282 ((regno) > IPSW_REGNUM && (regno) < FP4_REGNUM)
284 #define INIT_EXTRA_FRAME_INFO(fromleaf, frame) init_extra_frame_info (fromleaf, frame)
286 /* Describe the pointer in each stack frame to the previous stack frame
289 /* FRAME_CHAIN takes a frame's nominal address
290 and produces the frame's chain-pointer.
292 FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
293 and produces the nominal address of the caller frame.
295 However, if FRAME_CHAIN_VALID returns zero,
296 it means the given frame is the outermost one and has no caller.
297 In that case, FRAME_CHAIN_COMBINE is not used. */
299 /* In the case of the PA-RISC, the frame's nominal address
300 is the address of a 4-byte word containing the calling frame's
301 address (previous FP). */
303 #define FRAME_CHAIN(thisframe) frame_chain (thisframe)
305 #define FRAME_CHAIN_VALID(chain, thisframe) \
306 frame_chain_valid (chain, thisframe)
308 #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
310 /* Define other aspects of the stack frame. */
312 /* A macro that tells us whether the function invocation represented
313 by FI does not have a frame on the stack associated with it. If it
314 does not, FRAMELESS is set to 1, else 0. */
315 #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
316 (FRAMELESS) = frameless_look_for_prologue(FI)
318 #define FRAME_SAVED_PC(FRAME) frame_saved_pc (FRAME)
320 #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
322 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
323 /* Set VAL to the number of args passed to frame described by FI.
324 Can set VAL to -1, meaning no way to tell. */
326 /* We can't tell how many args there are
327 now that the C compiler delays popping them. */
328 #define FRAME_NUM_ARGS(val,fi) (val = -1)
330 /* Return number of bytes at start of arglist that are not really args. */
332 #define FRAME_ARGS_SKIP 0
334 /* Put here the code to store, into a struct frame_saved_regs,
335 the addresses of the saved registers of frame described by FRAME_INFO.
336 This includes special registers such as pc and fp saved in special
337 ways in the stack frame. sp is even more special:
338 the address we return for it IS the sp for the next frame. */
340 /* Deal with dummy functions later. */
342 #define STW_P(INSN) (((INSN) & 0xfc000000) == 0x68000000)
343 #define ADDIL_P(INSN) (((INSN) & 0xfc000000) == 0x28000000)
344 #define LDO_P(INSN) (((INSN) & 0xfc00c000) == 0x34000000)
346 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
347 { register int regnum; \
348 register CORE_ADDR next_addr; \
349 register CORE_ADDR pc; \
350 unsigned this_insn; \
353 bzero (&frame_saved_regs, sizeof frame_saved_regs); \
354 if ((frame_info->pc >= (frame_info)->frame \
355 && (frame_info)->pc <= ((frame_info)->frame + CALL_DUMMY_LENGTH \
356 + 32 * 4 + (NUM_REGS - FP0_REGNUM) * 8 \
358 find_dummy_frame_regs ((frame_info), &(frame_saved_regs)); \
360 { pc = get_pc_function_start ((frame_info)->pc); \
361 if (read_memory_integer (pc, 4) == 0x6BC23FD9) \
362 { (frame_saved_regs).regs[RP_REGNUM] = (frame_info)->frame - 20;\
365 if (read_memory_integer (pc, 4) != 0x8040241) goto lose; \
366 pc += 8; /* skip "copy 4,1; copy 30, 4" */ \
367 /* skip either "stw 1,0(4);addil L'fsize,30;ldo R'fsize(1),30" \
368 or "stwm 1,fsize(30)" */ \
369 if ((read_memory_integer (pc, 4) & ~MASK_14) == 0x68810000) \
374 { this_insn = read_memory_integer(pc, 4); \
375 if (STW_P (this_insn)) /* stw */ \
376 { regnum = GET_FIELD (this_insn, 11, 15); \
377 if (!regnum) goto lose; \
378 (frame_saved_regs).regs[regnum] = (frame_info)->frame + \
379 extract_14 (this_insn); \
382 else if (ADDIL_P (this_insn)) /* addil */ \
384 next_insn = read_memory_integer(pc + 4, 4); \
385 if (STW_P (next_insn)) /* stw */ \
386 { regnum = GET_FIELD (this_insn, 6, 10); \
387 if (!regnum) goto lose; \
388 (frame_saved_regs).regs[regnum] = (frame_info)->frame +\
389 (extract_21 (this_insn) << 11) + extract_14 (next_insn);\
400 this_insn = read_memory_integer (pc, 4); \
401 if (LDO_P (this_insn)) \
402 { next_addr = (frame_info)->frame + extract_14 (this_insn); \
405 else if (ADDIL_P (this_insn)) \
406 { next_addr = (frame_info)->frame + (extract_21 (this_insn) << 11)\
407 + extract_14 (read_memory_integer (pc + 4, 4)); \
411 { this_insn = read_memory_integer (pc, 4); \
412 if ((this_insn & 0xfc001fe0) == 0x2c001220) /* fstds,ma */ \
413 { regnum = GET_FIELD (this_insn, 27, 31); \
414 (frame_saved_regs).regs[regnum + FP0_REGNUM] = next_addr; \
422 (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \
423 (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame -4; \
426 /* Things needed for making the inferior call functions. */
428 /* Push an empty stack frame, to record the current PC, etc. */
430 #define PUSH_DUMMY_FRAME push_dummy_frame ()
432 /* Discard from the stack the innermost frame,
433 restoring all saved registers. */
434 #define POP_FRAME hp_pop_frame ()
436 /* This sequence of words is the instructions
438 ; Call stack frame has already been built by gdb. Since we could be calling
439 ; a varargs function, and we do not have the benefit of a stub to put things in
440 ; the right place, we load the first 4 word of arguments into both the general
451 fldds -12(0, r1), fr7
452 ldil 0, r22 ; target will be placed here.
455 ldil 0, r1 ; _sr4export will be placed here.
458 combt,=,n r3, r19, text_space ; If target is in data space, do a
459 ble 0(sr5, r22) ; "normal" procedure call
464 text_space ; Otherwise, go through _sr4export,
465 ble (sr4, r1) ; which will return back here.
471 The dummy decides if the target is in text space or data space. If
472 it's in data space, there's no problem because the target can
473 return back to the dummy. However, if the target is in text space,
474 the dummy calls the secret, undocumented routine _sr4export, which
475 calls a function in text space and can return to any space. Instead
476 of including fake instructions to represent saved registers, we
477 know that the frame is associated with the call dummy and treat it
480 #define CALL_DUMMY {0x4BDA3FB9, 0x4BD93FB1, 0x4BD83FA9, 0x4BD73FA1,\
481 0x37C13FB9, 0x24201004, 0x2C391005, 0x24311006,\
482 0x2C291007, 0x22C00000, 0x36D60000, 0x02C010A3,\
483 0x20200000, 0x34210000, 0x002010b3, 0x82632022,\
484 0xe6c06000, 0x081f0242, 0x00010004, 0x00151820,\
485 0xe6c00002, 0xe4202000, 0x6bdf3fd1, 0x00010004,\
486 0x00151820, 0xe6c00002}
488 #define CALL_DUMMY_LENGTH 104
489 #define CALL_DUMMY_START_OFFSET 0
492 * Insert the specified number of args and function address
493 * into a call sequence of the above form stored at DUMMYNAME.
495 * On the hppa we need to call the stack dummy through $$dyncall.
496 * Therefore our version of FIX_CALL_DUMMY takes an extra argument,
497 * real_pc, which is the location where gdb should start up the
498 * inferior to do the function call.
501 #define FIX_CALL_DUMMY(dummyname, pc, real_pc, fun, nargs, args, type, gcc_p) \
503 CORE_ADDR dyncall_addr = 0, sr4export_addr = 0; \
507 struct minimal_symbol *msymbol; \
508 msymbol = lookup_minimal_symbol ("$$dyncall", (struct objfile *) NULL);\
509 if (msymbol == NULL) \
510 error ("Can't find an address for $$dyncall trampoline"); \
512 dyncall_addr = SYMBOL_VALUE_ADDRESS (msymbol); \
513 msymbol = lookup_minimal_symbol ("_sr4export", (struct objfile *) NULL);\
514 if (msymbol == NULL) \
515 error ("Can't find an address for _sr4export trampoline"); \
517 sr4export_addr = SYMBOL_VALUE_ADDRESS (msymbol); \
519 dummyname[9] = deposit_21 (fun >> 11, dummyname[9]); \
520 dummyname[10] = deposit_14 (fun & MASK_11, dummyname[10]); \
521 dummyname[12] = deposit_21 (sr4export_addr >> 11, \
523 dummyname[13] = deposit_14 (sr4export_addr & MASK_11, \
525 write_register (22, pc); \
526 real_pc = dyncall_addr; \
529 #define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
530 sp = hp_push_arguments(nargs, args, sp, struct_return, struct_addr)
532 /* Symbol files have two symbol tables. Rather than do this right,
533 like the ELF symbol reading code, massive hackery was added
534 to dbxread.c and partial-stab.h. This flag turns on that
535 hackery, which should all go away FIXME FIXME FIXME FIXME now. */
537 #define GDB_TARGET_IS_HPPA
539 #define BELIEVE_PCC_PROMOTION 1
542 * Unwind table and descriptor.
545 struct unwind_table_entry {
546 unsigned int region_start;
547 unsigned int region_end;
549 unsigned int Cannot_unwind : 1;
550 unsigned int Millicode : 1;
551 unsigned int Millicode_save_sr0 : 1;
552 unsigned int Region_description : 2;
553 unsigned int reserverd1 : 1;
554 unsigned int Entry_SR : 1;
555 unsigned int Entry_FR : 4; /* number saved */
556 unsigned int Entry_GR : 5; /* number saved */
557 unsigned int Args_stored : 1;
558 unsigned int Variable_Frame : 1;
559 unsigned int Separate_Package_Body : 1;
560 unsigned int Frame_Extension_Millicode:1;
561 unsigned int Stack_Overflow_Check : 1;
562 unsigned int Two_Instruction_SP_Increment:1;
563 unsigned int Ada_Region : 1;
564 unsigned int reserved2 : 4;
565 unsigned int Save_SP : 1;
566 unsigned int Save_RP : 1;
567 unsigned int Save_MRP_in_frame : 1;
568 unsigned int extn_ptr_defined : 1;
569 unsigned int Cleanup_defined : 1;
571 unsigned int MPE_XL_interrupt_marker: 1;
572 unsigned int HP_UX_interrupt_marker: 1;
573 unsigned int Large_frame : 1;
574 unsigned int reserved4 : 2;
575 unsigned int Total_frame_size : 27;