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. */
27 /* PA 64-bit specific definitions. Override those which are in
30 /* jimb: this must go. I'm just using it to disable code I haven't
31 gotten working yet. */
32 #define GDB_TARGET_IS_HPPA_20W
34 /* FIXME: brobecker 2003-04-21: Although 32bit hppa is partially multiarched,
35 the conversion for hppa64 hasn't been completed yet. */
36 #define GDB_MULTI_ARCH 0
38 /* FIXME: brobecker 2003-04-21: All the definition from this point until
39 the include of pa/tm-hppah.h are extracted from tm-hppa.h. They have
40 been temporarily moved here, until hppa64 is multiarched too. */
43 extern int hppa_reg_struct_has_addr (int gcc_p
, struct type
*type
);
44 #define REG_STRUCT_HAS_ADDR(gcc_p,type) hppa_reg_struct_has_addr (gcc_p,type)
47 /* Offset from address of function to start of its code.
48 Zero on most machines. */
51 #define FUNCTION_START_OFFSET 0
54 /* Advance PC across any function entry prologue instructions
55 to reach some "real" code. */
58 extern CORE_ADDR
hppa_skip_prologue (CORE_ADDR
);
59 #define SKIP_PROLOGUE(pc) (hppa_skip_prologue (pc))
62 /* If PC is in some function-call trampoline code, return the PC
63 where the function itself actually starts. If not, return NULL. */
66 #define SKIP_TRAMPOLINE_CODE(pc) hppa_skip_trampoline_code (pc)
67 extern CORE_ADDR
hppa_skip_trampoline_code (CORE_ADDR
);
70 /* Return non-zero if we are in an appropriate trampoline. */
73 #define IN_SOLIB_CALL_TRAMPOLINE(pc, name) \
74 hppa_in_solib_call_trampoline (pc, name)
75 extern int hppa_in_solib_call_trampoline (CORE_ADDR
, char *);
79 #define IN_SOLIB_RETURN_TRAMPOLINE(pc, name) \
80 hppa_in_solib_return_trampoline (pc, name)
81 extern int hppa_in_solib_return_trampoline (CORE_ADDR
, char *);
85 #undef DEPRECATED_SAVED_PC_AFTER_CALL
86 #define DEPRECATED_SAVED_PC_AFTER_CALL(frame) hppa_saved_pc_after_call (frame)
87 extern CORE_ADDR
hppa_saved_pc_after_call (struct frame_info
*);
91 extern int hppa_inner_than (CORE_ADDR lhs
, CORE_ADDR rhs
);
92 #define INNER_THAN(lhs,rhs) hppa_inner_than(lhs,rhs)
96 extern CORE_ADDR
hppa_stack_align (CORE_ADDR sp
);
97 #define STACK_ALIGN(sp) hppa_stack_align (sp)
100 /* Amount PC must be decremented by after a breakpoint. This is often
101 the number of bytes returned by BREAKPOINT_FROM_PC but not always.
103 Not on the PA-RISC */
106 #define DECR_PC_AFTER_BREAK 0
109 /* Say how long (ordinary) registers are. This is a piece of bogosity
110 used in push_word and a few other places; REGISTER_RAW_SIZE is the
111 real way to know how big a register is. */
114 #define DEPRECATED_REGISTER_SIZE 4
117 /* Number of machine registers */
124 #define DEPRECATED_FP_REGNUM 3 /* Contains address of executing stack */
128 #define SP_REGNUM 30 /* Contains address of top of stack */
132 #define FP0_REGNUM 64 /* floating point reg. 0 (fspr) */
135 /* compatibility with the rest of gdb. */
137 #define PC_REGNUM PCOQ_HEAD_REGNUM
140 #define NPC_REGNUM PCOQ_TAIL_REGNUM
143 /* Number of bytes of storage in the actual machine representation
144 for register N. On the PA-RISC, all regs are 4 bytes, including
145 the FP registers (they're accessed as two 4 byte halves). */
148 extern int hppa_register_raw_size (int reg_nr
);
149 #define REGISTER_RAW_SIZE(N) hppa_register_raw_size (N)
152 /* Total amount of space needed to store our copies of the machine's
153 register state, the array `registers'. */
155 #define REGISTER_BYTES (NUM_REGS * 4)
159 extern int hppa_register_byte (int reg_nr
);
160 #define REGISTER_BYTE(N) hppa_register_byte (N)
163 /* Number of bytes of storage in the program's representation
167 #define REGISTER_VIRTUAL_SIZE(N) REGISTER_RAW_SIZE(N)
170 /* Largest value REGISTER_RAW_SIZE can have. */
173 #define DEPRECATED_MAX_REGISTER_RAW_SIZE 4
176 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
179 #define DEPRECATED_MAX_REGISTER_VIRTUAL_SIZE 8
183 extern struct type
* hppa_register_virtual_type (int reg_nr
);
184 #define REGISTER_VIRTUAL_TYPE(N) hppa_register_virtual_type (N)
188 extern void hppa_store_struct_return (CORE_ADDR addr
, CORE_ADDR sp
);
189 #define STORE_STRUCT_RETURN(ADDR, SP) hppa_store_struct_return (ADDR, SP)
192 /* Extract from an array REGBUF containing the (raw) register state
193 a function return value of type TYPE, and copy that, in virtual format,
197 void hppa_extract_return_value (struct type
*type
, char *regbuf
, char *valbuf
);
198 #define DEPRECATED_EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
199 hppa_extract_return_value (TYPE, REGBUF, VALBUF);
202 /* elz: decide whether the function returning a value of type type
203 will put it on the stack or in the registers.
204 The pa calling convention says that:
205 register 28 (called ret0 by gdb) contains any ASCII char,
206 and any non_floating point value up to 32-bits.
207 reg 28 and 29 contain non-floating point up tp 64 bits and larger
208 than 32 bits. (higer order word in reg 28).
209 fr4: floating point up to 64 bits
210 sr1: space identifier (32-bit)
211 stack: any lager than 64-bit, with the address in r28
214 extern use_struct_convention_fn hppa_use_struct_convention
;
215 #define USE_STRUCT_CONVENTION(gcc_p,type) hppa_use_struct_convention (gcc_p,type)
218 /* Write into appropriate registers a function return value
219 of type TYPE, given in virtual format. */
222 extern void hppa_store_return_value (struct type
*type
, char *valbuf
);
223 #define DEPRECATED_STORE_RETURN_VALUE(TYPE,VALBUF) \
224 hppa_store_return_value (TYPE, VALBUF);
228 extern CORE_ADDR
hppa_extract_struct_value_address (char *regbuf
);
229 #define DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
230 hppa_extract_struct_value_address (REGBUF)
234 extern int hppa_cannot_store_register (int regnum
);
235 #define CANNOT_STORE_REGISTER(regno) hppa_cannot_store_register (regno)
239 #define DEPRECATED_INIT_EXTRA_FRAME_INFO(fromleaf, frame) hppa_init_extra_frame_info (fromleaf, frame)
240 extern void hppa_init_extra_frame_info (int, struct frame_info
*);
243 /* Describe the pointer in each stack frame to the previous stack frame
246 /* DEPRECATED_FRAME_CHAIN takes a frame's nominal address and produces
247 the frame's chain-pointer. */
249 /* In the case of the PA-RISC, the frame's nominal address
250 is the address of a 4-byte word containing the calling frame's
251 address (previous FP). */
254 #define DEPRECATED_FRAME_CHAIN(thisframe) hppa_frame_chain (thisframe)
255 extern CORE_ADDR
hppa_frame_chain (struct frame_info
*);
259 extern int hppa_frame_chain_valid (CORE_ADDR
, struct frame_info
*);
260 #define DEPRECATED_FRAME_CHAIN_VALID(chain, thisframe) hppa_frame_chain_valid (chain, thisframe)
263 /* Define other aspects of the stack frame. */
265 /* A macro that tells us whether the function invocation represented
266 by FI does not have a frame on the stack associated with it. If it
267 does not, FRAMELESS is set to 1, else 0. */
269 #define FRAMELESS_FUNCTION_INVOCATION(FI) \
270 (hppa_frameless_function_invocation (FI))
271 extern int hppa_frameless_function_invocation (struct frame_info
*);
275 extern CORE_ADDR
hppa_frame_saved_pc (struct frame_info
*frame
);
276 #define DEPRECATED_FRAME_SAVED_PC(FRAME) hppa_frame_saved_pc (FRAME)
280 extern CORE_ADDR
hppa_frame_args_address (struct frame_info
*fi
);
281 #define FRAME_ARGS_ADDRESS(fi) hppa_frame_args_address (fi)
285 extern CORE_ADDR
hppa_frame_locals_address (struct frame_info
*fi
);
286 #define FRAME_LOCALS_ADDRESS(fi) hppa_frame_locals_address (fi)
290 extern int hppa_frame_num_args (struct frame_info
*frame
);
291 #define FRAME_NUM_ARGS(fi) hppa_frame_num_args (fi)
295 #define FRAME_ARGS_SKIP 0
298 /* Things needed for making the inferior call functions. */
301 #define DEPRECATED_PUSH_DUMMY_FRAME hppa_push_dummy_frame ()
302 extern void hppa_push_dummy_frame (void);
305 /* Discard from the stack the innermost frame,
306 restoring all saved registers. */
308 #define DEPRECATED_POP_FRAME hppa_pop_frame ()
309 extern void hppa_pop_frame (void);
313 #define DEPRECATED_CALL_DUMMY_LENGTH (INSTRUCTION_SIZE * 28)
317 #define DEPRECATED_CALL_DUMMY_START_OFFSET 0
321 #define DEPRECATED_PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
322 (hppa_push_arguments((nargs), (args), (sp), (struct_return), (struct_addr)))
323 extern CORE_ADDR
hppa_push_arguments (int, struct value
**, CORE_ADDR
, int,
328 extern CORE_ADDR
hppa_smash_text_address (CORE_ADDR addr
);
329 #define SMASH_TEXT_ADDRESS(addr) hppa_smash_text_address (addr)
333 #define BELIEVE_PCC_PROMOTION 1
337 #define TARGET_READ_PC(pid) hppa_target_read_pc (pid)
338 extern CORE_ADDR
hppa_target_read_pc (ptid_t
);
342 #define TARGET_WRITE_PC(v,pid) hppa_target_write_pc (v,pid)
343 extern void hppa_target_write_pc (CORE_ADDR
, ptid_t
);
347 #define DEPRECATED_TARGET_READ_FP() hppa_target_read_fp ()
348 extern CORE_ADDR
hppa_target_read_fp (void);
351 #include "pa/tm-hppah.h"
355 /* The low two bits of the IA are the privilege level of the instruction. */
356 #define ADDR_BITS_REMOVE(addr) ((CORE_ADDR)addr & (CORE_ADDR)~3)
358 /* Say how long (ordinary) registers are. This is used in
359 push_word and a few other places, but REGISTER_RAW_SIZE is
360 the real way to know how big a register is. */
362 #undef DEPRECATED_REGISTER_SIZE
363 #define DEPRECATED_REGISTER_SIZE 8
365 /* Number of bytes of storage in the actual machine representation
366 for register N. On the PA-RISC 2.0, all regs are 8 bytes, including
367 the FP registers (they're accessed as two 4 byte halves). */
369 #undef REGISTER_RAW_SIZE
370 #define REGISTER_RAW_SIZE(N) 8
372 /* Largest value REGISTER_RAW_SIZE can have. */
374 #undef DEPRECATED_MAX_REGISTER_RAW_SIZE
375 #define DEPRECATED_MAX_REGISTER_RAW_SIZE 8
377 /* Total amount of space needed to store our copies of the machine's
378 register state, the array `registers'. */
380 #undef REGISTER_BYTES
381 #define REGISTER_BYTES (NUM_REGS * 8)
383 /* Index within `registers' of the first byte of the space for
387 #define REGISTER_BYTE(N) ((N) * 8)
389 #undef REGISTER_VIRTUAL_TYPE
390 #define REGISTER_VIRTUAL_TYPE(N) \
391 ((N) < FP4_REGNUM ? builtin_type_unsigned_long_long : builtin_type_double)
394 /* Number of machine registers */
398 /* Initializer for an array of names of registers.
399 There should be NUM_REGS strings in this initializer.
400 They are in rows of eight entries */
401 #undef REGISTER_NAMES
402 #define REGISTER_NAMES \
403 {"flags", "r1", "rp", "r3", "r4", "r5", "r6", "r7", \
404 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
405 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
406 "r24", "r25", "r26", "dp", "ret0", "ret1", "sp", "r31", \
407 "sar", "pcoqh", "pcsqh", "pcoqt", "pcsqt", "eiem", "iir", "isr", \
408 "ior", "ipsw", "goto", "sr4", "sr0", "sr1", "sr2", "sr3", \
409 "sr5", "sr6", "sr7", "cr0", "cr8", "cr9", "ccr", "cr12", \
410 "cr13", "cr24", "cr25", "cr26", "mpsfu_high","mpsfu_low","mpsfu_ovflo","pad",\
411 "fpsr", "fpe1", "fpe2", "fpe3", "fr4", "fr5", "fr6", "fr7", \
412 "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15", \
413 "fr16", "fr17", "fr18", "fr19", "fr20", "fr21", "fr22", "fr23", \
414 "fr24", "fr25", "fr26", "fr27", "fr28", "fr29", "fr30", "fr31"}
418 #define FP0_REGNUM 64 /* floating point reg. 0 (fspr)*/
419 #define FP4_REGNUM 68
421 /* Redefine some target bit sizes from the default. */
423 /* Number of bits in a long or unsigned long for the target machine. */
425 #define TARGET_LONG_BIT 64
427 /* Number of bits in a long long or unsigned long long for the
430 #define TARGET_LONG_LONG_BIT 64
432 /* Number of bits in a pointer for the target machine */
434 #define TARGET_PTR_BIT 64
436 /* Argument Pointer Register */
441 #define FP5_REGNUM 70
443 #define SR5_REGNUM 48
445 /* We access locals from SP. This may not work for frames which call
446 alloca; for those, we may need to consult unwind tables.
448 #undef FRAME_LOCALS_ADDRESS
449 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
451 /* For a number of horrible reasons we may have to adjust the location
452 of variables on the stack. Ugh. jimb: why? */
453 #define HPREAD_ADJUST_STACK_ADDRESS(ADDR) hpread_adjust_stack_address(ADDR)
455 extern int hpread_adjust_stack_address (CORE_ADDR
);
458 /* jimb: omitted dynamic linking stuff here */
460 /* This sequence of words is the instructions
462 ; Call stack frame has already been built by gdb. Since we could be calling
463 ; a varargs function, and we do not have the benefit of a stub to put things in
464 ; the right place, we load the first 8 word of arguments into both the general
471 fldd -64(0,%r29),%fr4
472 fldd -56(0,%r29),%fr5
473 fldd -48(0,%r29),%fr6
474 fldd -40(0,%r29),%fr7
475 fldd -32(0,%r29),%fr8
476 fldd -24(0,%r29),%fr9
477 fldd -16(0,%r29),%fr10
478 fldd -8(0,%r29),%fr11
495 /* Call dummys are sized and written out in word sized hunks. So we have
496 to pack the instructions into words. Ugh. */
498 #define CALL_DUMMY {0x08000240349d0000LL, 0x34b6000034db0000LL, \
499 0x53a43f8353a53f93LL, 0x53a63fa353a73fb3LL,\
500 0x53a83fc353a93fd3LL, 0x2fa1100a2fb1100bLL,\
501 0x36c1000053ba3f81LL, 0x53b93f9153b83fa1LL,\
502 0x53b73fb153b63fc1LL, 0x53b53fd10fa110d4LL,\
503 0xe820f0000fb110d3LL, 0x0001000400151820LL,\
504 0xe6c0000008000240LL}
506 #define DEPRECATED_CALL_DUMMY_BREAKPOINT_OFFSET 22 * 4
508 /* DEPRECATED_CALL_DUMMY_LENGTH is computed based on the size of a
509 word on the target machine, not the size of an instruction. Since
510 a word on this target holds two instructions we have to divide the
511 instruction size by two to get the word size of the dummy. */
512 #undef DEPRECATED_CALL_DUMMY_LENGTH
513 #define DEPRECATED_CALL_DUMMY_LENGTH (INSTRUCTION_SIZE * 26 / 2)
515 /* The PA64 ABI mandates a 16 byte stack alignment. */
517 #define STACK_ALIGN(arg) ( ((arg)%16) ? (((arg)+15)&-16) : (arg))
519 /* The PA64 ABI reserves 64 bytes of stack space for outgoing register
521 #undef REG_PARM_STACK_SPACE
522 #define REG_PARM_STACK_SPACE 64
524 /* Use the 64-bit calling conventions designed for the PA2.0 in wide mode. */
525 #define PA20W_CALLING_CONVENTIONS
527 #undef FUNC_LDIL_OFFSET
528 #undef FUNC_LDO_OFFSET
529 #undef SR4EXPORT_LDIL_OFFSET
530 #undef SR4EXPORT_LDO_OFFSET
532 #undef REG_STRUCT_HAS_ADDR
534 #undef DEPRECATED_EXTRACT_RETURN_VALUE
535 /* RM: floats are returned in FR4R, doubles in FR4
536 * integral values are in r28, padded on the left
537 * aggregates less that 65 bits are in r28, right padded
538 * aggregates upto 128 bits are in r28 and r29, right padded
540 #define DEPRECATED_EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
542 if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \
544 ((char *)(REGBUF)) + REGISTER_BYTE (FP4_REGNUM) + \
545 (DEPRECATED_REGISTER_SIZE - TYPE_LENGTH (TYPE)), \
546 TYPE_LENGTH (TYPE)); \
547 else if (is_integral_type(TYPE)) \
549 (char *)(REGBUF) + REGISTER_BYTE (28) + \
550 (DEPRECATED_REGISTER_SIZE - TYPE_LENGTH (TYPE)), \
551 TYPE_LENGTH (TYPE)); \
552 else if (TYPE_LENGTH (TYPE) <= 8) \
554 (char *)(REGBUF) + REGISTER_BYTE (28), \
555 TYPE_LENGTH (TYPE)); \
556 else if (TYPE_LENGTH (TYPE) <= 16) \
559 (char *)(REGBUF) + REGISTER_BYTE (28), \
561 memcpy (((char *) VALBUF + 8), \
562 (char *)(REGBUF) + REGISTER_BYTE (29), \
563 TYPE_LENGTH (TYPE) - 8); \
567 /* RM: struct upto 128 bits are returned in registers */
568 #undef USE_STRUCT_CONVENTION
569 #define USE_STRUCT_CONVENTION(gcc_p, value_type)\
570 (TYPE_LENGTH (value_type) > 16)
572 /* RM: for return command */
573 #undef DEPRECATED_STORE_RETURN_VALUE
574 #define DEPRECATED_STORE_RETURN_VALUE(TYPE,VALBUF) \
576 if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \
577 deprecated_write_register_bytes \
578 (REGISTER_BYTE (FP4_REGNUM) + \
579 (DEPRECATED_REGISTER_SIZE - TYPE_LENGTH (TYPE)), \
581 TYPE_LENGTH (TYPE)); \
582 else if (is_integral_type(TYPE)) \
583 deprecated_write_register_bytes \
584 (REGISTER_BYTE (28) + \
585 (DEPRECATED_REGISTER_SIZE - TYPE_LENGTH (TYPE)), \
587 TYPE_LENGTH (TYPE)); \
588 else if (TYPE_LENGTH (TYPE) <= 8) \
589 deprecated_write_register_bytes \
590 ( REGISTER_BYTE (28), \
592 TYPE_LENGTH (TYPE)); \
593 else if (TYPE_LENGTH (TYPE) <= 16) \
595 deprecated_write_register_bytes \
596 (REGISTER_BYTE (28), \
599 deprecated_write_register_bytes \
600 (REGISTER_BYTE (29), \
601 ((char *) VALBUF + 8), \
602 TYPE_LENGTH (TYPE) - 8); \
606 /* RM: these are the PA64 equivalents of the macros in tm-hppah.h --
607 * see comments there. For PA64, the save_state structure is at an
608 * offset of 24 32-bit words from the sigcontext structure. The 64 bit
609 * general registers are at an offset of 640 bytes from the beginning of the
610 * save_state structure, and the floating pointer register are at an offset
611 * of 256 bytes from the beginning of the save_state structure.
613 #undef FRAME_SAVED_PC_IN_SIGTRAMP
614 #define FRAME_SAVED_PC_IN_SIGTRAMP(FRAME, TMP) \
616 *(TMP) = read_memory_integer ((FRAME)->frame + (24 * 4) + 640 + (33 * 8), 8); \
619 #undef FRAME_BASE_BEFORE_SIGTRAMP
620 #define FRAME_BASE_BEFORE_SIGTRAMP(FRAME, TMP) \
622 *(TMP) = read_memory_integer ((FRAME)->frame + (24 * 4) + 640 + (30 * 8), 8); \
625 #undef FRAME_FIND_SAVED_REGS_IN_SIGTRAMP
626 #define FRAME_FIND_SAVED_REGS_IN_SIGTRAMP(FRAME, FSR) \
629 CORE_ADDR TMP1, TMP2; \
630 TMP1 = (FRAME)->frame + (24 * 4) + 640; \
631 TMP2 = (FRAME)->frame + (24 * 4) + 256; \
632 for (i = 0; i < NUM_REGS; i++) \
634 if (i == SP_REGNUM) \
635 (FSR)[SP_REGNUM] = read_memory_integer (TMP1 + SP_REGNUM * 8, 8); \
636 else if (i >= FP0_REGNUM) \
637 (FSR)[i] = TMP2 + (i - FP0_REGNUM) * 8; \
639 (FSR)[i] = TMP1 + i * 8; \
643 /* jimb: omitted purify call support */