1 /* Parameters for execution on any Hewlett-Packard PA-RISC machine.
2 Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1995, 1999, 2000
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24 /* PA 64-bit specific definitions. Override those which are in
27 /* jimb: this must go. I'm just using it to disable code I haven't
28 gotten working yet. */
29 #define GDB_TARGET_IS_HPPA_20W
31 /* FIXME: brobecker 2003-04-21: Although 32bit hppa is partially multiarched,
32 the conversion for hppa64 hasn't been completed yet. */
33 #define GDB_MULTI_ARCH 0
35 /* FIXME: brobecker 2003-04-21: All the definition from this point until
36 the include of pa/tm-hppah.h are extracted from tm-hppa.h. They have
37 been temporarily moved here, until hppa64 is multiarched too. */
40 extern int hppa_reg_struct_has_addr (int gcc_p
, struct type
*type
);
41 #define REG_STRUCT_HAS_ADDR(gcc_p,type) hppa_reg_struct_has_addr (gcc_p,type)
44 /* Offset from address of function to start of its code.
45 Zero on most machines. */
48 #define FUNCTION_START_OFFSET 0
51 /* Advance PC across any function entry prologue instructions
52 to reach some "real" code. */
55 extern CORE_ADDR
hppa_skip_prologue (CORE_ADDR
);
56 #define SKIP_PROLOGUE(pc) (hppa_skip_prologue (pc))
59 /* If PC is in some function-call trampoline code, return the PC
60 where the function itself actually starts. If not, return NULL. */
63 #define SKIP_TRAMPOLINE_CODE(pc) hppa_skip_trampoline_code (pc)
64 extern CORE_ADDR
hppa_skip_trampoline_code (CORE_ADDR
);
67 /* Return non-zero if we are in an appropriate trampoline. */
70 #define IN_SOLIB_CALL_TRAMPOLINE(pc, name) \
71 hppa_in_solib_call_trampoline (pc, name)
72 extern int hppa_in_solib_call_trampoline (CORE_ADDR
, char *);
76 #define IN_SOLIB_RETURN_TRAMPOLINE(pc, name) \
77 hppa_in_solib_return_trampoline (pc, name)
78 extern int hppa_in_solib_return_trampoline (CORE_ADDR
, char *);
82 #undef DEPRECATED_SAVED_PC_AFTER_CALL
83 #define DEPRECATED_SAVED_PC_AFTER_CALL(frame) hppa_saved_pc_after_call (frame)
84 extern CORE_ADDR
hppa_saved_pc_after_call (struct frame_info
*);
88 extern int hppa_inner_than (CORE_ADDR lhs
, CORE_ADDR rhs
);
89 #define INNER_THAN(lhs,rhs) hppa_inner_than(lhs,rhs)
93 extern CORE_ADDR
hppa_stack_align (CORE_ADDR sp
);
94 #define STACK_ALIGN(sp) hppa_stack_align (sp)
97 /* Amount PC must be decremented by after a breakpoint.
98 This is often the number of bytes in BREAKPOINT
101 Not on the PA-RISC */
104 #define DECR_PC_AFTER_BREAK 0
107 /* Say how long (ordinary) registers are. This is a piece of bogosity
108 used in push_word and a few other places; REGISTER_RAW_SIZE is the
109 real way to know how big a register is. */
112 #define REGISTER_SIZE 4
115 /* Number of machine registers */
122 #define DEPRECATED_FP_REGNUM 3 /* Contains address of executing stack */
126 #define SP_REGNUM 30 /* Contains address of top of stack */
130 #define FP0_REGNUM 64 /* floating point reg. 0 (fspr) */
133 /* compatibility with the rest of gdb. */
135 #define PC_REGNUM PCOQ_HEAD_REGNUM
138 #define NPC_REGNUM PCOQ_TAIL_REGNUM
141 /* Number of bytes of storage in the actual machine representation
142 for register N. On the PA-RISC, all regs are 4 bytes, including
143 the FP registers (they're accessed as two 4 byte halves). */
146 extern int hppa_register_raw_size (int reg_nr
);
147 #define REGISTER_RAW_SIZE(N) hppa_register_raw_size (N)
150 /* Total amount of space needed to store our copies of the machine's
151 register state, the array `registers'. */
153 #define REGISTER_BYTES (NUM_REGS * 4)
157 extern int hppa_register_byte (int reg_nr
);
158 #define REGISTER_BYTE(N) hppa_register_byte (N)
161 /* Number of bytes of storage in the program's representation
165 #define REGISTER_VIRTUAL_SIZE(N) REGISTER_RAW_SIZE(N)
168 /* Largest value REGISTER_RAW_SIZE can have. */
171 #define DEPRECATED_MAX_REGISTER_RAW_SIZE 4
174 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
177 #define DEPRECATED_MAX_REGISTER_VIRTUAL_SIZE 8
181 extern struct type
* hppa_register_virtual_type (int reg_nr
);
182 #define REGISTER_VIRTUAL_TYPE(N) hppa_register_virtual_type (N)
186 extern void hppa_store_struct_return (CORE_ADDR addr
, CORE_ADDR sp
);
187 #define STORE_STRUCT_RETURN(ADDR, SP) hppa_store_struct_return (ADDR, SP)
190 /* Extract from an array REGBUF containing the (raw) register state
191 a function return value of type TYPE, and copy that, in virtual format,
195 void hppa_extract_return_value (struct type
*type
, char *regbuf
, char *valbuf
);
196 #define DEPRECATED_EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
197 hppa_extract_return_value (TYPE, REGBUF, VALBUF);
200 /* elz: decide whether the function returning a value of type type
201 will put it on the stack or in the registers.
202 The pa calling convention says that:
203 register 28 (called ret0 by gdb) contains any ASCII char,
204 and any non_floating point value up to 32-bits.
205 reg 28 and 29 contain non-floating point up tp 64 bits and larger
206 than 32 bits. (higer order word in reg 28).
207 fr4: floating point up to 64 bits
208 sr1: space identifier (32-bit)
209 stack: any lager than 64-bit, with the address in r28
212 extern use_struct_convention_fn hppa_use_struct_convention
;
213 #define USE_STRUCT_CONVENTION(gcc_p,type) hppa_use_struct_convention (gcc_p,type)
216 /* Write into appropriate registers a function return value
217 of type TYPE, given in virtual format. */
220 extern void hppa_store_return_value (struct type
*type
, char *valbuf
);
221 #define DEPRECATED_STORE_RETURN_VALUE(TYPE,VALBUF) \
222 hppa_store_return_value (TYPE, VALBUF);
226 extern CORE_ADDR
hppa_extract_struct_value_address (char *regbuf
);
227 #define DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
228 hppa_extract_struct_value_address (REGBUF)
232 extern int hppa_cannot_store_register (int regnum
);
233 #define CANNOT_STORE_REGISTER(regno) hppa_cannot_store_register (regno)
237 #define DEPRECATED_INIT_EXTRA_FRAME_INFO(fromleaf, frame) hppa_init_extra_frame_info (fromleaf, frame)
238 extern void hppa_init_extra_frame_info (int, struct frame_info
*);
241 /* Describe the pointer in each stack frame to the previous stack frame
244 /* DEPRECATED_FRAME_CHAIN takes a frame's nominal address and produces
245 the frame's chain-pointer. */
247 /* In the case of the PA-RISC, the frame's nominal address
248 is the address of a 4-byte word containing the calling frame's
249 address (previous FP). */
252 #define DEPRECATED_FRAME_CHAIN(thisframe) hppa_frame_chain (thisframe)
253 extern CORE_ADDR
hppa_frame_chain (struct frame_info
*);
257 extern int hppa_frame_chain_valid (CORE_ADDR
, struct frame_info
*);
258 #define DEPRECATED_FRAME_CHAIN_VALID(chain, thisframe) hppa_frame_chain_valid (chain, thisframe)
261 /* Define other aspects of the stack frame. */
263 /* A macro that tells us whether the function invocation represented
264 by FI does not have a frame on the stack associated with it. If it
265 does not, FRAMELESS is set to 1, else 0. */
267 #define FRAMELESS_FUNCTION_INVOCATION(FI) \
268 (hppa_frameless_function_invocation (FI))
269 extern int hppa_frameless_function_invocation (struct frame_info
*);
273 extern CORE_ADDR
hppa_frame_saved_pc (struct frame_info
*frame
);
274 #define DEPRECATED_FRAME_SAVED_PC(FRAME) hppa_frame_saved_pc (FRAME)
278 extern CORE_ADDR
hppa_frame_args_address (struct frame_info
*fi
);
279 #define FRAME_ARGS_ADDRESS(fi) hppa_frame_args_address (fi)
283 extern CORE_ADDR
hppa_frame_locals_address (struct frame_info
*fi
);
284 #define FRAME_LOCALS_ADDRESS(fi) hppa_frame_locals_address (fi)
288 extern int hppa_frame_num_args (struct frame_info
*frame
);
289 #define FRAME_NUM_ARGS(fi) hppa_frame_num_args (fi)
293 #define FRAME_ARGS_SKIP 0
296 /* Things needed for making the inferior call functions. */
299 #define DEPRECATED_PUSH_DUMMY_FRAME hppa_push_dummy_frame ()
300 extern void hppa_push_dummy_frame (void);
303 /* Discard from the stack the innermost frame,
304 restoring all saved registers. */
306 #define DEPRECATED_POP_FRAME hppa_pop_frame ()
307 extern void hppa_pop_frame (void);
311 #define CALL_DUMMY_LENGTH (INSTRUCTION_SIZE * 28)
315 #define CALL_DUMMY_START_OFFSET 0
319 #define DEPRECATED_PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
320 (hppa_push_arguments((nargs), (args), (sp), (struct_return), (struct_addr)))
321 extern CORE_ADDR
hppa_push_arguments (int, struct value
**, CORE_ADDR
, int,
326 extern CORE_ADDR
hppa_smash_text_address (CORE_ADDR addr
);
327 #define SMASH_TEXT_ADDRESS(addr) hppa_smash_text_address (addr)
331 #define BELIEVE_PCC_PROMOTION 1
335 #define TARGET_READ_PC(pid) hppa_target_read_pc (pid)
336 extern CORE_ADDR
hppa_target_read_pc (ptid_t
);
340 #define TARGET_WRITE_PC(v,pid) hppa_target_write_pc (v,pid)
341 extern void hppa_target_write_pc (CORE_ADDR
, ptid_t
);
345 #define DEPRECATED_TARGET_READ_FP() hppa_target_read_fp ()
346 extern CORE_ADDR
hppa_target_read_fp (void);
349 #include "pa/tm-hppah.h"
353 /* The low two bits of the IA are the privilege level of the instruction. */
354 #define ADDR_BITS_REMOVE(addr) ((CORE_ADDR)addr & (CORE_ADDR)~3)
356 /* Say how long (ordinary) registers are. This is used in
357 push_word and a few other places, but REGISTER_RAW_SIZE is
358 the real way to know how big a register is. */
361 #define REGISTER_SIZE 8
363 /* Number of bytes of storage in the actual machine representation
364 for register N. On the PA-RISC 2.0, all regs are 8 bytes, including
365 the FP registers (they're accessed as two 4 byte halves). */
367 #undef REGISTER_RAW_SIZE
368 #define REGISTER_RAW_SIZE(N) 8
370 /* Largest value REGISTER_RAW_SIZE can have. */
372 #undef DEPRECATED_MAX_REGISTER_RAW_SIZE
373 #define DEPRECATED_MAX_REGISTER_RAW_SIZE 8
375 /* Total amount of space needed to store our copies of the machine's
376 register state, the array `registers'. */
378 #undef REGISTER_BYTES
379 #define REGISTER_BYTES (NUM_REGS * 8)
381 /* Index within `registers' of the first byte of the space for
385 #define REGISTER_BYTE(N) ((N) * 8)
387 #undef REGISTER_VIRTUAL_TYPE
388 #define REGISTER_VIRTUAL_TYPE(N) \
389 ((N) < FP4_REGNUM ? builtin_type_unsigned_long_long : builtin_type_double)
392 /* Number of machine registers */
396 /* Initializer for an array of names of registers.
397 There should be NUM_REGS strings in this initializer.
398 They are in rows of eight entries */
399 #undef REGISTER_NAMES
400 #define REGISTER_NAMES \
401 {"flags", "r1", "rp", "r3", "r4", "r5", "r6", "r7", \
402 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
403 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
404 "r24", "r25", "r26", "dp", "ret0", "ret1", "sp", "r31", \
405 "sar", "pcoqh", "pcsqh", "pcoqt", "pcsqt", "eiem", "iir", "isr", \
406 "ior", "ipsw", "goto", "sr4", "sr0", "sr1", "sr2", "sr3", \
407 "sr5", "sr6", "sr7", "cr0", "cr8", "cr9", "ccr", "cr12", \
408 "cr13", "cr24", "cr25", "cr26", "mpsfu_high","mpsfu_low","mpsfu_ovflo","pad",\
409 "fpsr", "fpe1", "fpe2", "fpe3", "fr4", "fr5", "fr6", "fr7", \
410 "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15", \
411 "fr16", "fr17", "fr18", "fr19", "fr20", "fr21", "fr22", "fr23", \
412 "fr24", "fr25", "fr26", "fr27", "fr28", "fr29", "fr30", "fr31"}
416 #define FP0_REGNUM 64 /* floating point reg. 0 (fspr)*/
417 #define FP4_REGNUM 68
419 /* Redefine some target bit sizes from the default. */
421 /* Number of bits in a long or unsigned long for the target machine. */
423 #define TARGET_LONG_BIT 64
425 /* Number of bits in a long long or unsigned long long for the
428 #define TARGET_LONG_LONG_BIT 64
430 /* Number of bits in a pointer for the target machine */
432 #define TARGET_PTR_BIT 64
434 /* Argument Pointer Register */
439 #define FP5_REGNUM 70
441 #define SR5_REGNUM 48
443 /* We access locals from SP. This may not work for frames which call
444 alloca; for those, we may need to consult unwind tables.
446 #undef FRAME_LOCALS_ADDRESS
447 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
449 /* For a number of horrible reasons we may have to adjust the location
450 of variables on the stack. Ugh. jimb: why? */
451 #define HPREAD_ADJUST_STACK_ADDRESS(ADDR) hpread_adjust_stack_address(ADDR)
453 extern int hpread_adjust_stack_address (CORE_ADDR
);
456 /* jimb: omitted dynamic linking stuff here */
458 /* This sequence of words is the instructions
460 ; Call stack frame has already been built by gdb. Since we could be calling
461 ; a varargs function, and we do not have the benefit of a stub to put things in
462 ; the right place, we load the first 8 word of arguments into both the general
469 fldd -64(0,%r29),%fr4
470 fldd -56(0,%r29),%fr5
471 fldd -48(0,%r29),%fr6
472 fldd -40(0,%r29),%fr7
473 fldd -32(0,%r29),%fr8
474 fldd -24(0,%r29),%fr9
475 fldd -16(0,%r29),%fr10
476 fldd -8(0,%r29),%fr11
493 /* Call dummys are sized and written out in word sized hunks. So we have
494 to pack the instructions into words. Ugh. */
496 #define CALL_DUMMY {0x08000240349d0000LL, 0x34b6000034db0000LL, \
497 0x53a43f8353a53f93LL, 0x53a63fa353a73fb3LL,\
498 0x53a83fc353a93fd3LL, 0x2fa1100a2fb1100bLL,\
499 0x36c1000053ba3f81LL, 0x53b93f9153b83fa1LL,\
500 0x53b73fb153b63fc1LL, 0x53b53fd10fa110d4LL,\
501 0xe820f0000fb110d3LL, 0x0001000400151820LL,\
502 0xe6c0000008000240LL}
504 #define CALL_DUMMY_BREAKPOINT_OFFSET 22 * 4
506 /* CALL_DUMMY_LENGTH is computed based on the size of a word on the target
507 machine, not the size of an instruction. Since a word on this target
508 holds two instructions we have to divide the instruction size by two to
509 get the word size of the dummy. */
510 #undef CALL_DUMMY_LENGTH
511 #define CALL_DUMMY_LENGTH (INSTRUCTION_SIZE * 26 / 2)
513 /* The PA64 ABI mandates a 16 byte stack alignment. */
515 #define STACK_ALIGN(arg) ( ((arg)%16) ? (((arg)+15)&-16) : (arg))
517 /* The PA64 ABI reserves 64 bytes of stack space for outgoing register
519 #undef REG_PARM_STACK_SPACE
520 #define REG_PARM_STACK_SPACE 64
522 /* Use the 64-bit calling conventions designed for the PA2.0 in wide mode. */
523 #define PA20W_CALLING_CONVENTIONS
525 #undef FUNC_LDIL_OFFSET
526 #undef FUNC_LDO_OFFSET
527 #undef SR4EXPORT_LDIL_OFFSET
528 #undef SR4EXPORT_LDO_OFFSET
530 #undef REG_STRUCT_HAS_ADDR
532 #undef DEPRECATED_EXTRACT_RETURN_VALUE
533 /* RM: floats are returned in FR4R, doubles in FR4
534 * integral values are in r28, padded on the left
535 * aggregates less that 65 bits are in r28, right padded
536 * aggregates upto 128 bits are in r28 and r29, right padded
538 #define DEPRECATED_EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
540 if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \
542 ((char *)(REGBUF)) + REGISTER_BYTE (FP4_REGNUM) + \
543 (REGISTER_SIZE - TYPE_LENGTH (TYPE)), \
544 TYPE_LENGTH (TYPE)); \
545 else if (is_integral_type(TYPE)) \
547 (char *)(REGBUF) + REGISTER_BYTE (28) + \
548 (REGISTER_SIZE - TYPE_LENGTH (TYPE)), \
549 TYPE_LENGTH (TYPE)); \
550 else if (TYPE_LENGTH (TYPE) <= 8) \
552 (char *)(REGBUF) + REGISTER_BYTE (28), \
553 TYPE_LENGTH (TYPE)); \
554 else if (TYPE_LENGTH (TYPE) <= 16) \
557 (char *)(REGBUF) + REGISTER_BYTE (28), \
559 memcpy (((char *) VALBUF + 8), \
560 (char *)(REGBUF) + REGISTER_BYTE (29), \
561 TYPE_LENGTH (TYPE) - 8); \
565 /* RM: struct upto 128 bits are returned in registers */
566 #undef USE_STRUCT_CONVENTION
567 #define USE_STRUCT_CONVENTION(gcc_p, value_type)\
568 (TYPE_LENGTH (value_type) > 16)
570 /* RM: for return command */
571 #undef DEPRECATED_STORE_RETURN_VALUE
572 #define DEPRECATED_STORE_RETURN_VALUE(TYPE,VALBUF) \
574 if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \
575 deprecated_write_register_bytes \
576 (REGISTER_BYTE (FP4_REGNUM) + \
577 (REGISTER_SIZE - TYPE_LENGTH (TYPE)), \
579 TYPE_LENGTH (TYPE)); \
580 else if (is_integral_type(TYPE)) \
581 deprecated_write_register_bytes \
582 (REGISTER_BYTE (28) + \
583 (REGISTER_SIZE - TYPE_LENGTH (TYPE)), \
585 TYPE_LENGTH (TYPE)); \
586 else if (TYPE_LENGTH (TYPE) <= 8) \
587 deprecated_write_register_bytes \
588 ( REGISTER_BYTE (28), \
590 TYPE_LENGTH (TYPE)); \
591 else if (TYPE_LENGTH (TYPE) <= 16) \
593 deprecated_write_register_bytes \
594 (REGISTER_BYTE (28), \
597 deprecated_write_register_bytes \
598 (REGISTER_BYTE (29), \
599 ((char *) VALBUF + 8), \
600 TYPE_LENGTH (TYPE) - 8); \
604 /* RM: these are the PA64 equivalents of the macros in tm-hppah.h --
605 * see comments there. For PA64, the save_state structure is at an
606 * offset of 24 32-bit words from the sigcontext structure. The 64 bit
607 * general registers are at an offset of 640 bytes from the beginning of the
608 * save_state structure, and the floating pointer register are at an offset
609 * of 256 bytes from the beginning of the save_state structure.
611 #undef FRAME_SAVED_PC_IN_SIGTRAMP
612 #define FRAME_SAVED_PC_IN_SIGTRAMP(FRAME, TMP) \
614 *(TMP) = read_memory_integer ((FRAME)->frame + (24 * 4) + 640 + (33 * 8), 8); \
617 #undef FRAME_BASE_BEFORE_SIGTRAMP
618 #define FRAME_BASE_BEFORE_SIGTRAMP(FRAME, TMP) \
620 *(TMP) = read_memory_integer ((FRAME)->frame + (24 * 4) + 640 + (30 * 8), 8); \
623 #undef FRAME_FIND_SAVED_REGS_IN_SIGTRAMP
624 #define FRAME_FIND_SAVED_REGS_IN_SIGTRAMP(FRAME, FSR) \
627 CORE_ADDR TMP1, TMP2; \
628 TMP1 = (FRAME)->frame + (24 * 4) + 640; \
629 TMP2 = (FRAME)->frame + (24 * 4) + 256; \
630 for (i = 0; i < NUM_REGS; i++) \
632 if (i == SP_REGNUM) \
633 (FSR)[SP_REGNUM] = read_memory_integer (TMP1 + SP_REGNUM * 8, 8); \
634 else if (i >= FP0_REGNUM) \
635 (FSR)[i] = TMP2 + (i - FP0_REGNUM) * 8; \
637 (FSR)[i] = TMP1 + i * 8; \
641 /* jimb: omitted purify call support */