1 /* Parameters for execution on any Hewlett-Packard PA-RISC machine.
2 Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993
3 Free Software Foundation, Inc.
5 Contributed by the Center for Software Science at the
6 University of Utah (pa-gdb-bugs@cs.utah.edu).
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 */
44 /* On the PA, any pass-by-value structure > 8 bytes is actually
45 passed via a pointer regardless of its type or the compiler
48 #define REG_STRUCT_HAS_ADDR(gcc_p,type) \
49 (TYPE_LENGTH (type) > 8)
51 /* Offset from address of function to start of its code.
52 Zero on most machines. */
54 #define FUNCTION_START_OFFSET 0
56 /* Advance PC across any function entry prologue instructions
57 to reach some "real" code. */
59 /* skip (stw rp, -20(0,sp)); copy 4,1; copy sp, 4; stwm 1,framesize(sp)
60 for gcc, or (stw rp, -20(0,sp); stwm 1, framesize(sp) for hcc */
62 #define SKIP_PROLOGUE(pc) pc = skip_prologue (pc)
64 /* If PC is in some function-call trampoline code, return the PC
65 where the function itself actually starts. If not, return NULL. */
67 #define SKIP_TRAMPOLINE_CODE(pc) skip_trampoline_code (pc, NULL)
69 /* Return non-zero if we are in some sort of a trampoline. */
71 #define IN_SOLIB_TRAMPOLINE(pc, name) skip_trampoline_code (pc, name)
73 /* Immediately after a function call, return the saved pc.
74 Can't go through the frames for this because on some machines
75 the new frame is not set up until the new function executes
78 #undef SAVED_PC_AFTER_CALL
79 #define SAVED_PC_AFTER_CALL(frame) saved_pc_after_call (frame)
81 /* Stack grows upward */
86 /* Sequence of bytes for breakpoint instruction. */
88 /*#define BREAKPOINT {0x00, 0x00, 0x00, 0x00}*/
89 #ifdef KERNELDEBUG /* XXX */
90 #define BREAKPOINT {0x00, 0x00, 0xa0, 0x00}
92 #define BREAKPOINT {0x00, 0x01, 0x00, 0x04}
95 /* Amount PC must be decremented by after a breakpoint.
96 This is often the number of bytes in BREAKPOINT
101 #define DECR_PC_AFTER_BREAK 0
103 /* return instruction is bv r0(rp) or bv,n r0(rp)*/
105 #define ABOUT_TO_RETURN(pc) ((read_memory_integer (pc, 4) | 0x2) == 0xE840C002)
107 /* Return 1 if P points to an invalid floating point value. */
109 #define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */
111 /* Say how long (ordinary) registers are. This is a piece of bogosity
112 used in push_word and a few other places; REGISTER_RAW_SIZE is the
113 real way to know how big a register is. */
115 #define REGISTER_SIZE 4
117 /* Number of machine registers */
121 /* Initializer for an array of names of registers.
122 There should be NUM_REGS strings in this initializer. */
124 #define REGISTER_NAMES \
125 {"flags", "r1", "rp", "r3", "r4", "r5", "r6", "r7", "r8", "r9", \
126 "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", \
127 "r20", "r21", "r22", "arg3", "arg2", "arg1", "arg0", "dp", "ret0", "ret1", \
128 "sp", "r31", "sar", "pcoqh", "pcsqh", "pcoqt", "pcsqt", \
129 "eiem", "iir", "isr", "ior", "ipsw", "goto", "sr4", "sr0", "sr1", "sr2", \
130 "sr3", "sr5", "sr6", "sr7", "cr0", "cr8", "cr9", "ccr", "cr12", "cr13", \
131 "cr24", "cr25", "cr26", "mpsfu_high", "mpsfu_low", "mpsfu_ovflo", "pad", \
132 "fpsr", "fpe1", "fpe2", "fpe3", "fpe4", "fpe5", "fpe6", "fpe7", \
133 "fr4", "fr4R", "fr5", "fr5R", "fr6", "fr6R", "fr7", "fr7R", \
134 "fr8", "fr8R", "fr9", "fr9R", "fr10", "fr10R", "fr11", "fr11R", \
135 "fr12", "fr12R", "fr13", "fr13R", "fr14", "fr14R", "fr15", "fr15R", \
136 "fr16", "fr16R", "fr17", "fr17R", "fr18", "fr18R", "fr19", "fr19R", \
137 "fr20", "fr20R", "fr21", "fr21R", "fr22", "fr22R", "fr23", "fr23R", \
138 "fr24", "fr24R", "fr25", "fr25R", "fr26", "fr26R", "fr27", "fr27R", \
139 "fr28", "fr28R", "fr29", "fr29R", "fr30", "fr30R", "fr31", "fr31R"}
141 /* Register numbers of various important registers.
142 Note that some of these values are "real" register numbers,
143 and correspond to the general registers of the machine,
144 and some are "phony" register numbers which are too large
145 to be actual register numbers as far as the user is concerned
146 but do serve to get the desired values when passed to read_register. */
148 #define FLAGS_REGNUM 0 /* Various status flags */
149 #define RP_REGNUM 2 /* return pointer */
150 #define FP_REGNUM 3 /* Contains address of executing stack */
152 #define SP_REGNUM 30 /* Contains address of top of stack */
153 #define SAR_REGNUM 32 /* shift amount register */
154 #define IPSW_REGNUM 41 /* processor status word. ? */
155 #define PCOQ_HEAD_REGNUM 33 /* instruction offset queue head */
156 #define PCSQ_HEAD_REGNUM 34 /* instruction space queue head */
157 #define PCOQ_TAIL_REGNUM 35 /* instruction offset queue tail */
158 #define PCSQ_TAIL_REGNUM 36 /* instruction space queue tail */
159 #define FP0_REGNUM 64 /* floating point reg. 0 */
160 #define FP4_REGNUM 72
162 /* compatibility with the rest of gdb. */
163 #define PC_REGNUM PCOQ_HEAD_REGNUM
164 #define NPC_REGNUM PCOQ_TAIL_REGNUM
166 /* When fetching register values from an inferior or a core file,
167 clean them up using this macro. BUF is a char pointer to
168 the raw value of the register in the registers[] array. */
170 #define CLEAN_UP_REGISTER_VALUE(regno, buf) \
172 if ((regno) == PCOQ_HEAD_REGNUM || (regno) == PCOQ_TAIL_REGNUM) \
176 /* Define DO_REGISTERS_INFO() to do machine-specific formatting
177 of register dumps. */
179 #define DO_REGISTERS_INFO(_regnum, fp) pa_do_registers_info (_regnum, fp)
181 /* PA specific macro to see if the current instruction is nullified. */
182 #define INSTRUCTION_NULLIFIED ((int)read_register (IPSW_REGNUM) & 0x00200000)
184 /* Number of bytes of storage in the actual machine representation
185 for register N. On the PA-RISC, all regs are 4 bytes, including
186 the FP registers (they're accessed as two 4 byte halves). */
188 #define REGISTER_RAW_SIZE(N) 4
190 /* Total amount of space needed to store our copies of the machine's
191 register state, the array `registers'. */
192 #define REGISTER_BYTES (NUM_REGS * REGISTER_RAW_SIZE (1))
194 /* Index within `registers' of the first byte of the space for
197 #define REGISTER_BYTE(N) (N) * 4
199 /* Number of bytes of storage in the program's representation
202 #define REGISTER_VIRTUAL_SIZE(N) REGISTER_RAW_SIZE(N)
204 /* Largest value REGISTER_RAW_SIZE can have. */
206 #define MAX_REGISTER_RAW_SIZE 4
208 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
210 #define MAX_REGISTER_VIRTUAL_SIZE 8
212 /* Return the GDB type object for the "standard" data type
213 of data in register N. */
215 #define REGISTER_VIRTUAL_TYPE(N) \
216 ((N) < FP4_REGNUM ? builtin_type_int : builtin_type_float)
218 /* Store the address of the place in which to copy the structure the
219 subroutine will return. This is called from call_function. */
221 #define STORE_STRUCT_RETURN(ADDR, SP) {write_register (28, (ADDR)); }
223 /* Extract from an array REGBUF containing the (raw) register state
224 a function return value of type TYPE, and copy that, in virtual format,
227 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
228 memcpy (VALBUF, (REGBUF) + REGISTER_BYTE(TYPE_LENGTH(TYPE) > 4 ? \
229 FP4_REGNUM :28), TYPE_LENGTH (TYPE))
231 /* Write into appropriate registers a function return value
232 of type TYPE, given in virtual format. */
234 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
235 write_register_bytes ((TYPE_LENGTH(TYPE) > 4 \
236 ? REGISTER_BYTE (FP4_REGNUM) \
237 : REGISTER_BYTE (28)), \
238 (VALBUF), TYPE_LENGTH (TYPE))
240 /* Extract from an array REGBUF containing the (raw) register state
241 the address in which a function should return its structure value,
242 as a CORE_ADDR (or an expression that can be used as one). */
244 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)((REGBUF) + 28))
247 * This macro defines the register numbers (from REGISTER_NAMES) that
248 * are effectively unavailable to the user through ptrace(). It allows
249 * us to include the whole register set in REGISTER_NAMES (inorder to
250 * better support remote debugging). If it is used in
251 * fetch/store_inferior_registers() gdb will not complain about I/O errors
252 * on fetching these registers. If all registers in REGISTER_NAMES
253 * are available, then return false (0).
256 #define CANNOT_STORE_REGISTER(regno) \
258 ((regno) == PCSQ_HEAD_REGNUM) || \
259 ((regno) >= PCSQ_TAIL_REGNUM && (regno) < IPSW_REGNUM) || \
260 ((regno) > IPSW_REGNUM && (regno) < FP4_REGNUM)
262 #define INIT_EXTRA_FRAME_INFO(fromleaf, frame) init_extra_frame_info (fromleaf, frame)
264 /* Describe the pointer in each stack frame to the previous stack frame
267 /* FRAME_CHAIN takes a frame's nominal address
268 and produces the frame's chain-pointer.
270 FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
271 and produces the nominal address of the caller frame.
273 However, if FRAME_CHAIN_VALID returns zero,
274 it means the given frame is the outermost one and has no caller.
275 In that case, FRAME_CHAIN_COMBINE is not used. */
277 /* In the case of the PA-RISC, the frame's nominal address
278 is the address of a 4-byte word containing the calling frame's
279 address (previous FP). */
281 #define FRAME_CHAIN(thisframe) frame_chain (thisframe)
283 #define FRAME_CHAIN_VALID(chain, thisframe) \
284 frame_chain_valid (chain, thisframe)
286 #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
288 /* Define other aspects of the stack frame. */
290 /* A macro that tells us whether the function invocation represented
291 by FI does not have a frame on the stack associated with it. If it
292 does not, FRAMELESS is set to 1, else 0. */
293 #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
294 (FRAMELESS) = frameless_function_invocation(FI)
296 #define FRAME_SAVED_PC(FRAME) frame_saved_pc (FRAME)
298 #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
300 #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)
308 /* Return number of bytes at start of arglist that are not really args. */
310 #define FRAME_ARGS_SKIP 0
312 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
313 hppa_frame_find_saved_regs (frame_info, &frame_saved_regs)
316 /* Things needed for making the inferior call functions. */
318 /* Push an empty stack frame, to record the current PC, etc. */
320 #define PUSH_DUMMY_FRAME push_dummy_frame ()
322 /* Discard from the stack the innermost frame,
323 restoring all saved registers. */
324 #define POP_FRAME hppa_pop_frame ()
326 /* This sequence of words is the instructions
328 ; Call stack frame has already been built by gdb. Since we could be calling
329 ; a varargs function, and we do not have the benefit of a stub to put things in
330 ; the right place, we load the first 4 word of arguments into both the general
341 fldds -12(0, r1), fr7
342 ldil 0, r22 ; target will be placed here.
345 ldil 0, r1 ; _sr4export will be placed here.
348 combt,=,n r3, r19, text_space ; If target is in data space, do a
349 ble 0(sr5, r22) ; "normal" procedure call
354 text_space ; Otherwise, go through _sr4export,
355 ble (sr4, r1) ; which will return back here.
360 nop ; To avoid kernel bugs
361 nop ; and keep the dummy 8 byte aligned
363 The dummy decides if the target is in text space or data space. If
364 it's in data space, there's no problem because the target can
365 return back to the dummy. However, if the target is in text space,
366 the dummy calls the secret, undocumented routine _sr4export, which
367 calls a function in text space and can return to any space. Instead
368 of including fake instructions to represent saved registers, we
369 know that the frame is associated with the call dummy and treat it
372 The trailing NOPs are needed to avoid a bug in HPUX, BSD and OSF1
373 kernels. If the memory at the location pointed to by the PC is
374 0xffffffff then a ptrace step call will fail (even if the instruction
377 The code to pop a dummy frame single steps three instructions
378 starting with the last mtsp. This includes the nullified "instruction"
379 following the ble (which is uninitialized junk). If the
380 "instruction" following the last BLE is 0xffffffff, then the ptrace
381 will fail and the dummy frame is not correctly popped.
383 By placing a NOP in the delay slot of the BLE instruction we can be
384 sure that we never try to execute a 0xffffffff instruction and
385 avoid the kernel bug. The second NOP is needed to keep the call
386 dummy 8 byte aligned. */
388 #define CALL_DUMMY {0x4BDA3FB9, 0x4BD93FB1, 0x4BD83FA9, 0x4BD73FA1,\
389 0x37C13FB9, 0x24201004, 0x2C391005, 0x24311006,\
390 0x2C291007, 0x22C00000, 0x36D60000, 0x02C010A4,\
391 0x20200000, 0x34210000, 0x002010b3, 0x82642022,\
392 0xe6c06000, 0x081f0242, 0x00010004, 0x00151820,\
393 0xe6c00002, 0xe4202000, 0x6bdf3fd1, 0x00010004,\
394 0x00151820, 0xe6c00002, 0x08000240, 0x08000240}
396 #define CALL_DUMMY_LENGTH 112
397 #define CALL_DUMMY_START_OFFSET 0
400 * Insert the specified number of args and function address
401 * into a call sequence of the above form stored at DUMMYNAME.
403 * On the hppa we need to call the stack dummy through $$dyncall.
404 * Therefore our version of FIX_CALL_DUMMY takes an extra argument,
405 * real_pc, which is the location where gdb should start up the
406 * inferior to do the function call.
409 #define FIX_CALL_DUMMY hppa_fix_call_dummy
411 CORE_ADDR
hppa_fix_call_dummy();
413 #define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
414 sp = hppa_push_arguments(nargs, args, sp, struct_return, struct_addr)
416 /* The low two bits of the PC on the PA contain the privilege level. Some
417 genius implementing a (non-GCC) compiler apparently decided this means
418 that "addresses" in a text section therefore include a privilege level,
419 and thus symbol tables should contain these bits. This seems like a
420 bonehead thing to do--anyway, it seems to work for our purposes to just
421 ignore those bits. */
422 #define SMASH_TEXT_ADDRESS(addr) ((addr) &= ~0x3)
424 #define GDB_TARGET_IS_HPPA
426 #define BELIEVE_PCC_PROMOTION 1
429 * Unwind table and descriptor.
432 struct unwind_table_entry
{
433 unsigned int region_start
;
434 unsigned int region_end
;
436 unsigned int Cannot_unwind
: 1;
437 unsigned int Millicode
: 1;
438 unsigned int Millicode_save_sr0
: 1;
439 unsigned int Region_description
: 2;
440 unsigned int reserved1
: 1;
441 unsigned int Entry_SR
: 1;
442 unsigned int Entry_FR
: 4; /* number saved */
443 unsigned int Entry_GR
: 5; /* number saved */
444 unsigned int Args_stored
: 1;
445 unsigned int Variable_Frame
: 1;
446 unsigned int Separate_Package_Body
: 1;
447 unsigned int Frame_Extension_Millicode
:1;
448 unsigned int Stack_Overflow_Check
: 1;
449 unsigned int Two_Instruction_SP_Increment
:1;
450 unsigned int Ada_Region
: 1;
451 /* Use this field to store a stub unwind type. */
452 #define stub_type reserved2
453 unsigned int reserved2
: 4;
454 unsigned int Save_SP
: 1;
455 unsigned int Save_RP
: 1;
456 unsigned int Save_MRP_in_frame
: 1;
457 unsigned int extn_ptr_defined
: 1;
458 unsigned int Cleanup_defined
: 1;
460 unsigned int MPE_XL_interrupt_marker
: 1;
461 unsigned int HP_UX_interrupt_marker
: 1;
462 unsigned int Large_frame
: 1;
463 unsigned int reserved4
: 2;
464 unsigned int Total_frame_size
: 27;
467 /* HP linkers also generate unwinds for various linker-generated stubs.
468 GDB reads in the stubs from the $UNWIND_END$ subspace, then
469 "converts" them into normal unwind entries using some of the reserved
470 fields to store the stub type. */
472 struct stub_unwind_entry
474 /* The offset within the executable for the associated stub. */
475 unsigned stub_offset
;
477 /* The type of stub this unwind entry describes. */
480 /* Unknown. Not needed by GDB at this time. */
483 /* Length (in instructions) of the associated stub. */
487 /* Sizes (in bytes) of the native unwind entries. */
488 #define UNWIND_ENTRY_SIZE 16
489 #define STUB_UNWIND_ENTRY_SIZE 8
491 /* The gaps represent linker stubs used in MPE and space for future
493 enum unwind_stub_types
496 PARAMETER_RELOCATION
= 2,
502 /* Info about the unwind table associated with an object file. This is hung
503 off of the objfile->obj_private pointer, and is allocated in the objfile's
504 psymbol obstack. This allows us to have unique unwind info for each
505 executable and shared library that we are debugging. */
507 struct obj_unwind_info
{
508 struct unwind_table_entry
*table
; /* Pointer to unwind info */
509 struct unwind_table_entry
*cache
; /* Pointer to last entry we found */
510 int last
; /* Index of last entry */
513 #define OBJ_UNWIND_INFO(obj) ((struct obj_unwind_info *)obj->obj_private)
515 extern CORE_ADDR target_read_pc
PARAMS ((void));
516 extern void target_write_pc
PARAMS ((CORE_ADDR
));
518 #define TARGET_READ_PC() target_read_pc ()
519 #define TARGET_WRITE_PC(v) target_write_pc (v)