1 /* Target-dependent code for the HP PA architecture, for GDB.
3 Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
4 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
7 Contributed by the Center for Software Science at the
8 University of Utah (pa-gdb-bugs@cs.utah.edu).
10 This file is part of GDB.
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. */
33 #include "completer.h"
36 #include "gdb_assert.h"
37 #include "infttrace.h"
38 #include "arch-utils.h"
39 /* For argument passing to the inferior */
43 #include "trad-frame.h"
44 #include "frame-unwind.h"
45 #include "frame-base.h"
48 #include <sys/types.h>
52 #include <sys/param.h>
55 #include <sys/ptrace.h>
56 #include <machine/save_state.h>
58 #ifdef COFF_ENCAPSULATE
59 #include "a.out.encap.h"
63 /*#include <sys/user.h> After a.out.h */
73 #include "hppa-tdep.h"
75 /* Some local constants. */
76 static const int hppa32_num_regs
= 128;
77 static const int hppa64_num_regs
= 96;
79 /* Get at various relevent fields of an instruction word. */
82 #define MASK_14 0x3fff
83 #define MASK_21 0x1fffff
85 /* Define offsets into the call dummy for the _sr4export address.
86 See comments related to CALL_DUMMY for more info. */
87 #define SR4EXPORT_LDIL_OFFSET (INSTRUCTION_SIZE * 12)
88 #define SR4EXPORT_LDO_OFFSET (INSTRUCTION_SIZE * 13)
90 /* To support detection of the pseudo-initial frame
92 #define THREAD_INITIAL_FRAME_SYMBOL "__pthread_exit"
93 #define THREAD_INITIAL_FRAME_SYM_LEN sizeof(THREAD_INITIAL_FRAME_SYMBOL)
95 /* Sizes (in bytes) of the native unwind entries. */
96 #define UNWIND_ENTRY_SIZE 16
97 #define STUB_UNWIND_ENTRY_SIZE 8
99 static int get_field (unsigned word
, int from
, int to
);
101 static int extract_5_load (unsigned int);
103 static unsigned extract_5R_store (unsigned int);
105 static unsigned extract_5r_store (unsigned int);
107 struct unwind_table_entry
*find_unwind_entry (CORE_ADDR
);
109 static int extract_17 (unsigned int);
111 static int extract_21 (unsigned);
113 static int extract_14 (unsigned);
115 static void unwind_command (char *, int);
117 static int low_sign_extend (unsigned int, unsigned int);
119 static int sign_extend (unsigned int, unsigned int);
121 static int hppa_alignof (struct type
*);
123 static int prologue_inst_adjust_sp (unsigned long);
125 static int is_branch (unsigned long);
127 static int inst_saves_gr (unsigned long);
129 static int inst_saves_fr (unsigned long);
131 static int compare_unwind_entries (const void *, const void *);
133 static void read_unwind_info (struct objfile
*);
135 static void internalize_unwinds (struct objfile
*,
136 struct unwind_table_entry
*,
137 asection
*, unsigned int,
138 unsigned int, CORE_ADDR
);
139 static void pa_print_registers (char *, int, int);
140 static void pa_strcat_registers (char *, int, int, struct ui_file
*);
141 static void pa_register_look_aside (char *, int, long *);
142 static void pa_print_fp_reg (int);
143 static void pa_strcat_fp_reg (int, struct ui_file
*, enum precision_type
);
144 static void record_text_segment_lowaddr (bfd
*, asection
*, void *);
145 /* FIXME: brobecker 2002-11-07: We will likely be able to make the
146 following functions static, once we hppa is partially multiarched. */
147 int hppa_reg_struct_has_addr (int gcc_p
, struct type
*type
);
148 CORE_ADDR
hppa_skip_prologue (CORE_ADDR pc
);
149 CORE_ADDR
hppa_skip_trampoline_code (CORE_ADDR pc
);
150 int hppa_in_solib_call_trampoline (CORE_ADDR pc
, char *name
);
151 int hppa_in_solib_return_trampoline (CORE_ADDR pc
, char *name
);
152 int hppa_inner_than (CORE_ADDR lhs
, CORE_ADDR rhs
);
153 int hppa_pc_requires_run_before_use (CORE_ADDR pc
);
154 int hppa_instruction_nullified (void);
155 int hppa_register_raw_size (int reg_nr
);
156 int hppa_register_byte (int reg_nr
);
157 struct type
* hppa32_register_virtual_type (int reg_nr
);
158 struct type
* hppa64_register_virtual_type (int reg_nr
);
159 int hppa_cannot_store_register (int regnum
);
160 CORE_ADDR
hppa_smash_text_address (CORE_ADDR addr
);
161 CORE_ADDR
hppa_target_read_pc (ptid_t ptid
);
162 void hppa_target_write_pc (CORE_ADDR v
, ptid_t ptid
);
163 CORE_ADDR
hppa_target_read_fp (void);
167 struct minimal_symbol
*msym
;
168 CORE_ADDR solib_handle
;
169 CORE_ADDR return_val
;
173 static int cover_find_stub_with_shl_get (void *);
175 static int is_pa_2
= 0; /* False */
177 /* This is declared in symtab.c; set to 1 in hp-symtab-read.c */
178 extern int hp_som_som_object_present
;
180 /* In breakpoint.c */
181 extern int exception_catchpoints_are_fragile
;
183 /* Handle 32/64-bit struct return conventions. */
185 static enum return_value_convention
186 hppa32_return_value (struct gdbarch
*gdbarch
,
187 struct type
*type
, struct regcache
*regcache
,
188 void *readbuf
, const void *writebuf
)
190 if (TYPE_CODE (type
) == TYPE_CODE_FLT
)
193 regcache_cooked_read_part (regcache
, FP4_REGNUM
, 0,
194 TYPE_LENGTH (type
), readbuf
);
195 if (writebuf
!= NULL
)
196 regcache_cooked_write_part (regcache
, FP4_REGNUM
, 0,
197 TYPE_LENGTH (type
), writebuf
);
198 return RETURN_VALUE_REGISTER_CONVENTION
;
200 if (TYPE_LENGTH (type
) <= 2 * 4)
202 /* The value always lives in the right hand end of the register
203 (or register pair)? */
206 int part
= TYPE_LENGTH (type
) % 4;
207 /* The left hand register contains only part of the value,
208 transfer that first so that the rest can be xfered as entire
213 regcache_cooked_read_part (regcache
, reg
, 4 - part
,
215 if (writebuf
!= NULL
)
216 regcache_cooked_write_part (regcache
, reg
, 4 - part
,
220 /* Now transfer the remaining register values. */
221 for (b
= part
; b
< TYPE_LENGTH (type
); b
+= 4)
224 regcache_cooked_read (regcache
, reg
, (char *) readbuf
+ b
);
225 if (writebuf
!= NULL
)
226 regcache_cooked_write (regcache
, reg
, (const char *) writebuf
+ b
);
229 return RETURN_VALUE_REGISTER_CONVENTION
;
232 return RETURN_VALUE_STRUCT_CONVENTION
;
235 static enum return_value_convention
236 hppa64_return_value (struct gdbarch
*gdbarch
,
237 struct type
*type
, struct regcache
*regcache
,
238 void *readbuf
, const void *writebuf
)
240 /* RM: Floats are returned in FR4R, doubles in FR4. Integral values
241 are in r28, padded on the left. Aggregates less that 65 bits are
242 in r28, right padded. Aggregates upto 128 bits are in r28 and
243 r29, right padded. */
244 if (TYPE_CODE (type
) == TYPE_CODE_FLT
245 && TYPE_LENGTH (type
) <= 8)
247 /* Floats are right aligned? */
248 int offset
= register_size (gdbarch
, FP4_REGNUM
) - TYPE_LENGTH (type
);
250 regcache_cooked_read_part (regcache
, FP4_REGNUM
, offset
,
251 TYPE_LENGTH (type
), readbuf
);
252 if (writebuf
!= NULL
)
253 regcache_cooked_write_part (regcache
, FP4_REGNUM
, offset
,
254 TYPE_LENGTH (type
), writebuf
);
255 return RETURN_VALUE_REGISTER_CONVENTION
;
257 else if (TYPE_LENGTH (type
) <= 8 && is_integral_type (type
))
259 /* Integrals are right aligned. */
260 int offset
= register_size (gdbarch
, FP4_REGNUM
) - TYPE_LENGTH (type
);
262 regcache_cooked_read_part (regcache
, 28, offset
,
263 TYPE_LENGTH (type
), readbuf
);
264 if (writebuf
!= NULL
)
265 regcache_cooked_write_part (regcache
, 28, offset
,
266 TYPE_LENGTH (type
), writebuf
);
267 return RETURN_VALUE_REGISTER_CONVENTION
;
269 else if (TYPE_LENGTH (type
) <= 2 * 8)
271 /* Composite values are left aligned. */
273 for (b
= 0; b
< TYPE_LENGTH (type
); b
+= 8)
275 int part
= min (8, TYPE_LENGTH (type
) - b
);
277 regcache_cooked_read_part (regcache
, 28 + b
/ 8, 0, part
,
278 (char *) readbuf
+ b
);
279 if (writebuf
!= NULL
)
280 regcache_cooked_write_part (regcache
, 28 + b
/ 8, 0, part
,
281 (const char *) writebuf
+ b
);
283 return RETURN_VALUE_REGISTER_CONVENTION
;
286 return RETURN_VALUE_STRUCT_CONVENTION
;
289 /* Routines to extract various sized constants out of hppa
292 /* This assumes that no garbage lies outside of the lower bits of
296 sign_extend (unsigned val
, unsigned bits
)
298 return (int) (val
>> (bits
- 1) ? (-1 << bits
) | val
: val
);
301 /* For many immediate values the sign bit is the low bit! */
304 low_sign_extend (unsigned val
, unsigned bits
)
306 return (int) ((val
& 0x1 ? (-1 << (bits
- 1)) : 0) | val
>> 1);
309 /* Extract the bits at positions between FROM and TO, using HP's numbering
313 get_field (unsigned word
, int from
, int to
)
315 return ((word
) >> (31 - (to
)) & ((1 << ((to
) - (from
) + 1)) - 1));
318 /* extract the immediate field from a ld{bhw}s instruction */
321 extract_5_load (unsigned word
)
323 return low_sign_extend (word
>> 16 & MASK_5
, 5);
326 /* extract the immediate field from a break instruction */
329 extract_5r_store (unsigned word
)
331 return (word
& MASK_5
);
334 /* extract the immediate field from a {sr}sm instruction */
337 extract_5R_store (unsigned word
)
339 return (word
>> 16 & MASK_5
);
342 /* extract a 14 bit immediate field */
345 extract_14 (unsigned word
)
347 return low_sign_extend (word
& MASK_14
, 14);
350 /* extract a 21 bit constant */
353 extract_21 (unsigned word
)
359 val
= get_field (word
, 20, 20);
361 val
|= get_field (word
, 9, 19);
363 val
|= get_field (word
, 5, 6);
365 val
|= get_field (word
, 0, 4);
367 val
|= get_field (word
, 7, 8);
368 return sign_extend (val
, 21) << 11;
371 /* extract a 17 bit constant from branch instructions, returning the
372 19 bit signed value. */
375 extract_17 (unsigned word
)
377 return sign_extend (get_field (word
, 19, 28) |
378 get_field (word
, 29, 29) << 10 |
379 get_field (word
, 11, 15) << 11 |
380 (word
& 0x1) << 16, 17) << 2;
384 /* Compare the start address for two unwind entries returning 1 if
385 the first address is larger than the second, -1 if the second is
386 larger than the first, and zero if they are equal. */
389 compare_unwind_entries (const void *arg1
, const void *arg2
)
391 const struct unwind_table_entry
*a
= arg1
;
392 const struct unwind_table_entry
*b
= arg2
;
394 if (a
->region_start
> b
->region_start
)
396 else if (a
->region_start
< b
->region_start
)
402 static CORE_ADDR low_text_segment_address
;
405 record_text_segment_lowaddr (bfd
*abfd
, asection
*section
, void *ignored
)
407 if (((section
->flags
& (SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
))
408 == (SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
))
409 && section
->vma
< low_text_segment_address
)
410 low_text_segment_address
= section
->vma
;
414 internalize_unwinds (struct objfile
*objfile
, struct unwind_table_entry
*table
,
415 asection
*section
, unsigned int entries
, unsigned int size
,
416 CORE_ADDR text_offset
)
418 /* We will read the unwind entries into temporary memory, then
419 fill in the actual unwind table. */
424 char *buf
= alloca (size
);
426 low_text_segment_address
= -1;
428 /* If addresses are 64 bits wide, then unwinds are supposed to
429 be segment relative offsets instead of absolute addresses.
431 Note that when loading a shared library (text_offset != 0) the
432 unwinds are already relative to the text_offset that will be
434 if (TARGET_PTR_BIT
== 64 && text_offset
== 0)
436 bfd_map_over_sections (objfile
->obfd
,
437 record_text_segment_lowaddr
, NULL
);
439 /* ?!? Mask off some low bits. Should this instead subtract
440 out the lowest section's filepos or something like that?
441 This looks very hokey to me. */
442 low_text_segment_address
&= ~0xfff;
443 text_offset
+= low_text_segment_address
;
446 bfd_get_section_contents (objfile
->obfd
, section
, buf
, 0, size
);
448 /* Now internalize the information being careful to handle host/target
450 for (i
= 0; i
< entries
; i
++)
452 table
[i
].region_start
= bfd_get_32 (objfile
->obfd
,
454 table
[i
].region_start
+= text_offset
;
456 table
[i
].region_end
= bfd_get_32 (objfile
->obfd
, (bfd_byte
*) buf
);
457 table
[i
].region_end
+= text_offset
;
459 tmp
= bfd_get_32 (objfile
->obfd
, (bfd_byte
*) buf
);
461 table
[i
].Cannot_unwind
= (tmp
>> 31) & 0x1;
462 table
[i
].Millicode
= (tmp
>> 30) & 0x1;
463 table
[i
].Millicode_save_sr0
= (tmp
>> 29) & 0x1;
464 table
[i
].Region_description
= (tmp
>> 27) & 0x3;
465 table
[i
].reserved1
= (tmp
>> 26) & 0x1;
466 table
[i
].Entry_SR
= (tmp
>> 25) & 0x1;
467 table
[i
].Entry_FR
= (tmp
>> 21) & 0xf;
468 table
[i
].Entry_GR
= (tmp
>> 16) & 0x1f;
469 table
[i
].Args_stored
= (tmp
>> 15) & 0x1;
470 table
[i
].Variable_Frame
= (tmp
>> 14) & 0x1;
471 table
[i
].Separate_Package_Body
= (tmp
>> 13) & 0x1;
472 table
[i
].Frame_Extension_Millicode
= (tmp
>> 12) & 0x1;
473 table
[i
].Stack_Overflow_Check
= (tmp
>> 11) & 0x1;
474 table
[i
].Two_Instruction_SP_Increment
= (tmp
>> 10) & 0x1;
475 table
[i
].Ada_Region
= (tmp
>> 9) & 0x1;
476 table
[i
].cxx_info
= (tmp
>> 8) & 0x1;
477 table
[i
].cxx_try_catch
= (tmp
>> 7) & 0x1;
478 table
[i
].sched_entry_seq
= (tmp
>> 6) & 0x1;
479 table
[i
].reserved2
= (tmp
>> 5) & 0x1;
480 table
[i
].Save_SP
= (tmp
>> 4) & 0x1;
481 table
[i
].Save_RP
= (tmp
>> 3) & 0x1;
482 table
[i
].Save_MRP_in_frame
= (tmp
>> 2) & 0x1;
483 table
[i
].extn_ptr_defined
= (tmp
>> 1) & 0x1;
484 table
[i
].Cleanup_defined
= tmp
& 0x1;
485 tmp
= bfd_get_32 (objfile
->obfd
, (bfd_byte
*) buf
);
487 table
[i
].MPE_XL_interrupt_marker
= (tmp
>> 31) & 0x1;
488 table
[i
].HP_UX_interrupt_marker
= (tmp
>> 30) & 0x1;
489 table
[i
].Large_frame
= (tmp
>> 29) & 0x1;
490 table
[i
].Pseudo_SP_Set
= (tmp
>> 28) & 0x1;
491 table
[i
].reserved4
= (tmp
>> 27) & 0x1;
492 table
[i
].Total_frame_size
= tmp
& 0x7ffffff;
494 /* Stub unwinds are handled elsewhere. */
495 table
[i
].stub_unwind
.stub_type
= 0;
496 table
[i
].stub_unwind
.padding
= 0;
501 /* Read in the backtrace information stored in the `$UNWIND_START$' section of
502 the object file. This info is used mainly by find_unwind_entry() to find
503 out the stack frame size and frame pointer used by procedures. We put
504 everything on the psymbol obstack in the objfile so that it automatically
505 gets freed when the objfile is destroyed. */
508 read_unwind_info (struct objfile
*objfile
)
510 asection
*unwind_sec
, *stub_unwind_sec
;
511 unsigned unwind_size
, stub_unwind_size
, total_size
;
512 unsigned index
, unwind_entries
;
513 unsigned stub_entries
, total_entries
;
514 CORE_ADDR text_offset
;
515 struct obj_unwind_info
*ui
;
516 obj_private_data_t
*obj_private
;
518 text_offset
= ANOFFSET (objfile
->section_offsets
, 0);
519 ui
= (struct obj_unwind_info
*) obstack_alloc (&objfile
->objfile_obstack
,
520 sizeof (struct obj_unwind_info
));
526 /* For reasons unknown the HP PA64 tools generate multiple unwinder
527 sections in a single executable. So we just iterate over every
528 section in the BFD looking for unwinder sections intead of trying
529 to do a lookup with bfd_get_section_by_name.
531 First determine the total size of the unwind tables so that we
532 can allocate memory in a nice big hunk. */
534 for (unwind_sec
= objfile
->obfd
->sections
;
536 unwind_sec
= unwind_sec
->next
)
538 if (strcmp (unwind_sec
->name
, "$UNWIND_START$") == 0
539 || strcmp (unwind_sec
->name
, ".PARISC.unwind") == 0)
541 unwind_size
= bfd_section_size (objfile
->obfd
, unwind_sec
);
542 unwind_entries
= unwind_size
/ UNWIND_ENTRY_SIZE
;
544 total_entries
+= unwind_entries
;
548 /* Now compute the size of the stub unwinds. Note the ELF tools do not
549 use stub unwinds at the curren time. */
550 stub_unwind_sec
= bfd_get_section_by_name (objfile
->obfd
, "$UNWIND_END$");
554 stub_unwind_size
= bfd_section_size (objfile
->obfd
, stub_unwind_sec
);
555 stub_entries
= stub_unwind_size
/ STUB_UNWIND_ENTRY_SIZE
;
559 stub_unwind_size
= 0;
563 /* Compute total number of unwind entries and their total size. */
564 total_entries
+= stub_entries
;
565 total_size
= total_entries
* sizeof (struct unwind_table_entry
);
567 /* Allocate memory for the unwind table. */
568 ui
->table
= (struct unwind_table_entry
*)
569 obstack_alloc (&objfile
->objfile_obstack
, total_size
);
570 ui
->last
= total_entries
- 1;
572 /* Now read in each unwind section and internalize the standard unwind
575 for (unwind_sec
= objfile
->obfd
->sections
;
577 unwind_sec
= unwind_sec
->next
)
579 if (strcmp (unwind_sec
->name
, "$UNWIND_START$") == 0
580 || strcmp (unwind_sec
->name
, ".PARISC.unwind") == 0)
582 unwind_size
= bfd_section_size (objfile
->obfd
, unwind_sec
);
583 unwind_entries
= unwind_size
/ UNWIND_ENTRY_SIZE
;
585 internalize_unwinds (objfile
, &ui
->table
[index
], unwind_sec
,
586 unwind_entries
, unwind_size
, text_offset
);
587 index
+= unwind_entries
;
591 /* Now read in and internalize the stub unwind entries. */
592 if (stub_unwind_size
> 0)
595 char *buf
= alloca (stub_unwind_size
);
597 /* Read in the stub unwind entries. */
598 bfd_get_section_contents (objfile
->obfd
, stub_unwind_sec
, buf
,
599 0, stub_unwind_size
);
601 /* Now convert them into regular unwind entries. */
602 for (i
= 0; i
< stub_entries
; i
++, index
++)
604 /* Clear out the next unwind entry. */
605 memset (&ui
->table
[index
], 0, sizeof (struct unwind_table_entry
));
607 /* Convert offset & size into region_start and region_end.
608 Stuff away the stub type into "reserved" fields. */
609 ui
->table
[index
].region_start
= bfd_get_32 (objfile
->obfd
,
611 ui
->table
[index
].region_start
+= text_offset
;
613 ui
->table
[index
].stub_unwind
.stub_type
= bfd_get_8 (objfile
->obfd
,
616 ui
->table
[index
].region_end
617 = ui
->table
[index
].region_start
+ 4 *
618 (bfd_get_16 (objfile
->obfd
, (bfd_byte
*) buf
) - 1);
624 /* Unwind table needs to be kept sorted. */
625 qsort (ui
->table
, total_entries
, sizeof (struct unwind_table_entry
),
626 compare_unwind_entries
);
628 /* Keep a pointer to the unwind information. */
629 if (objfile
->obj_private
== NULL
)
631 obj_private
= (obj_private_data_t
*)
632 obstack_alloc (&objfile
->objfile_obstack
,
633 sizeof (obj_private_data_t
));
634 obj_private
->unwind_info
= NULL
;
635 obj_private
->so_info
= NULL
;
638 objfile
->obj_private
= obj_private
;
640 obj_private
= (obj_private_data_t
*) objfile
->obj_private
;
641 obj_private
->unwind_info
= ui
;
644 /* Lookup the unwind (stack backtrace) info for the given PC. We search all
645 of the objfiles seeking the unwind table entry for this PC. Each objfile
646 contains a sorted list of struct unwind_table_entry. Since we do a binary
647 search of the unwind tables, we depend upon them to be sorted. */
649 struct unwind_table_entry
*
650 find_unwind_entry (CORE_ADDR pc
)
652 int first
, middle
, last
;
653 struct objfile
*objfile
;
655 /* A function at address 0? Not in HP-UX! */
656 if (pc
== (CORE_ADDR
) 0)
659 ALL_OBJFILES (objfile
)
661 struct obj_unwind_info
*ui
;
663 if (objfile
->obj_private
)
664 ui
= ((obj_private_data_t
*) (objfile
->obj_private
))->unwind_info
;
668 read_unwind_info (objfile
);
669 if (objfile
->obj_private
== NULL
)
670 error ("Internal error reading unwind information.");
671 ui
= ((obj_private_data_t
*) (objfile
->obj_private
))->unwind_info
;
674 /* First, check the cache */
677 && pc
>= ui
->cache
->region_start
678 && pc
<= ui
->cache
->region_end
)
681 /* Not in the cache, do a binary search */
686 while (first
<= last
)
688 middle
= (first
+ last
) / 2;
689 if (pc
>= ui
->table
[middle
].region_start
690 && pc
<= ui
->table
[middle
].region_end
)
692 ui
->cache
= &ui
->table
[middle
];
693 return &ui
->table
[middle
];
696 if (pc
< ui
->table
[middle
].region_start
)
701 } /* ALL_OBJFILES() */
705 const unsigned char *
706 hppa_breakpoint_from_pc (CORE_ADDR
*pc
, int *len
)
708 static const unsigned char breakpoint
[] = {0x00, 0x01, 0x00, 0x04};
709 (*len
) = sizeof (breakpoint
);
713 /* Return the name of a register. */
716 hppa32_register_name (int i
)
718 static char *names
[] = {
719 "flags", "r1", "rp", "r3",
720 "r4", "r5", "r6", "r7",
721 "r8", "r9", "r10", "r11",
722 "r12", "r13", "r14", "r15",
723 "r16", "r17", "r18", "r19",
724 "r20", "r21", "r22", "r23",
725 "r24", "r25", "r26", "dp",
726 "ret0", "ret1", "sp", "r31",
727 "sar", "pcoqh", "pcsqh", "pcoqt",
728 "pcsqt", "eiem", "iir", "isr",
729 "ior", "ipsw", "goto", "sr4",
730 "sr0", "sr1", "sr2", "sr3",
731 "sr5", "sr6", "sr7", "cr0",
732 "cr8", "cr9", "ccr", "cr12",
733 "cr13", "cr24", "cr25", "cr26",
734 "mpsfu_high","mpsfu_low","mpsfu_ovflo","pad",
735 "fpsr", "fpe1", "fpe2", "fpe3",
736 "fpe4", "fpe5", "fpe6", "fpe7",
737 "fr4", "fr4R", "fr5", "fr5R",
738 "fr6", "fr6R", "fr7", "fr7R",
739 "fr8", "fr8R", "fr9", "fr9R",
740 "fr10", "fr10R", "fr11", "fr11R",
741 "fr12", "fr12R", "fr13", "fr13R",
742 "fr14", "fr14R", "fr15", "fr15R",
743 "fr16", "fr16R", "fr17", "fr17R",
744 "fr18", "fr18R", "fr19", "fr19R",
745 "fr20", "fr20R", "fr21", "fr21R",
746 "fr22", "fr22R", "fr23", "fr23R",
747 "fr24", "fr24R", "fr25", "fr25R",
748 "fr26", "fr26R", "fr27", "fr27R",
749 "fr28", "fr28R", "fr29", "fr29R",
750 "fr30", "fr30R", "fr31", "fr31R"
752 if (i
< 0 || i
>= (sizeof (names
) / sizeof (*names
)))
759 hppa64_register_name (int i
)
761 static char *names
[] = {
762 "flags", "r1", "rp", "r3",
763 "r4", "r5", "r6", "r7",
764 "r8", "r9", "r10", "r11",
765 "r12", "r13", "r14", "r15",
766 "r16", "r17", "r18", "r19",
767 "r20", "r21", "r22", "r23",
768 "r24", "r25", "r26", "dp",
769 "ret0", "ret1", "sp", "r31",
770 "sar", "pcoqh", "pcsqh", "pcoqt",
771 "pcsqt", "eiem", "iir", "isr",
772 "ior", "ipsw", "goto", "sr4",
773 "sr0", "sr1", "sr2", "sr3",
774 "sr5", "sr6", "sr7", "cr0",
775 "cr8", "cr9", "ccr", "cr12",
776 "cr13", "cr24", "cr25", "cr26",
777 "mpsfu_high","mpsfu_low","mpsfu_ovflo","pad",
778 "fpsr", "fpe1", "fpe2", "fpe3",
779 "fr4", "fr5", "fr6", "fr7",
780 "fr8", "fr9", "fr10", "fr11",
781 "fr12", "fr13", "fr14", "fr15",
782 "fr16", "fr17", "fr18", "fr19",
783 "fr20", "fr21", "fr22", "fr23",
784 "fr24", "fr25", "fr26", "fr27",
785 "fr28", "fr29", "fr30", "fr31"
787 if (i
< 0 || i
>= (sizeof (names
) / sizeof (*names
)))
795 /* Return the adjustment necessary to make for addresses on the stack
796 as presented by hpread.c.
798 This is necessary because of the stack direction on the PA and the
799 bizarre way in which someone (?) decided they wanted to handle
800 frame pointerless code in GDB. */
802 hpread_adjust_stack_address (CORE_ADDR func_addr
)
804 struct unwind_table_entry
*u
;
806 u
= find_unwind_entry (func_addr
);
810 return u
->Total_frame_size
<< 3;
813 /* This function pushes a stack frame with arguments as part of the
814 inferior function calling mechanism.
816 This is the version of the function for the 32-bit PA machines, in
817 which later arguments appear at lower addresses. (The stack always
818 grows towards higher addresses.)
820 We simply allocate the appropriate amount of stack space and put
821 arguments into their proper slots. */
824 hppa32_push_dummy_call (struct gdbarch
*gdbarch
, CORE_ADDR func_addr
,
825 struct regcache
*regcache
, CORE_ADDR bp_addr
,
826 int nargs
, struct value
**args
, CORE_ADDR sp
,
827 int struct_return
, CORE_ADDR struct_addr
)
829 /* NOTE: cagney/2004-02-27: This is a guess - its implemented by
830 reverse engineering testsuite failures. */
832 /* Stack base address at which any pass-by-reference parameters are
834 CORE_ADDR struct_end
= 0;
835 /* Stack base address at which the first parameter is stored. */
836 CORE_ADDR param_end
= 0;
838 /* The inner most end of the stack after all the parameters have
840 CORE_ADDR new_sp
= 0;
842 /* Two passes. First pass computes the location of everything,
843 second pass writes the bytes out. */
845 for (write_pass
= 0; write_pass
< 2; write_pass
++)
847 CORE_ADDR struct_ptr
= 0;
848 CORE_ADDR param_ptr
= 0;
849 int reg
= 27; /* NOTE: Registers go down. */
851 for (i
= 0; i
< nargs
; i
++)
853 struct value
*arg
= args
[i
];
854 struct type
*type
= check_typedef (VALUE_TYPE (arg
));
855 /* The corresponding parameter that is pushed onto the
856 stack, and [possibly] passed in a register. */
859 memset (param_val
, 0, sizeof param_val
);
860 if (TYPE_LENGTH (type
) > 8)
862 /* Large parameter, pass by reference. Store the value
863 in "struct" area and then pass its address. */
865 struct_ptr
+= align_up (TYPE_LENGTH (type
), 8);
867 write_memory (struct_end
- struct_ptr
, VALUE_CONTENTS (arg
),
869 store_unsigned_integer (param_val
, 4, struct_end
- struct_ptr
);
871 else if (TYPE_CODE (type
) == TYPE_CODE_INT
872 || TYPE_CODE (type
) == TYPE_CODE_ENUM
)
874 /* Integer value store, right aligned. "unpack_long"
875 takes care of any sign-extension problems. */
876 param_len
= align_up (TYPE_LENGTH (type
), 4);
877 store_unsigned_integer (param_val
, param_len
,
879 VALUE_CONTENTS (arg
)));
883 /* Small struct value, store right aligned? */
884 param_len
= align_up (TYPE_LENGTH (type
), 4);
885 memcpy (param_val
+ param_len
- TYPE_LENGTH (type
),
886 VALUE_CONTENTS (arg
), TYPE_LENGTH (type
));
888 param_ptr
+= param_len
;
889 reg
-= param_len
/ 4;
892 write_memory (param_end
- param_ptr
, param_val
, param_len
);
895 regcache_cooked_write (regcache
, reg
, param_val
);
897 regcache_cooked_write (regcache
, reg
+ 1, param_val
+ 4);
902 /* Update the various stack pointers. */
905 struct_end
= sp
+ struct_ptr
;
906 /* PARAM_PTR already accounts for all the arguments passed
907 by the user. However, the ABI mandates minimum stack
908 space allocations for outgoing arguments. The ABI also
909 mandates minimum stack alignments which we must
911 param_end
= struct_end
+ max (align_up (param_ptr
, 8),
912 REG_PARM_STACK_SPACE
);
916 /* If a structure has to be returned, set up register 28 to hold its
919 write_register (28, struct_addr
);
921 /* Set the return address. */
922 regcache_cooked_write_unsigned (regcache
, RP_REGNUM
, bp_addr
);
924 /* The stack will have 32 bytes of additional space for a frame marker. */
925 return param_end
+ 32;
928 /* This function pushes a stack frame with arguments as part of the
929 inferior function calling mechanism.
931 This is the version for the PA64, in which later arguments appear
932 at higher addresses. (The stack always grows towards higher
935 We simply allocate the appropriate amount of stack space and put
936 arguments into their proper slots.
938 This ABI also requires that the caller provide an argument pointer
939 to the callee, so we do that too. */
942 hppa64_push_dummy_call (struct gdbarch
*gdbarch
, CORE_ADDR func_addr
,
943 struct regcache
*regcache
, CORE_ADDR bp_addr
,
944 int nargs
, struct value
**args
, CORE_ADDR sp
,
945 int struct_return
, CORE_ADDR struct_addr
)
947 /* NOTE: cagney/2004-02-27: This is a guess - its implemented by
948 reverse engineering testsuite failures. */
950 /* Stack base address at which any pass-by-reference parameters are
952 CORE_ADDR struct_end
= 0;
953 /* Stack base address at which the first parameter is stored. */
954 CORE_ADDR param_end
= 0;
956 /* The inner most end of the stack after all the parameters have
958 CORE_ADDR new_sp
= 0;
960 /* Two passes. First pass computes the location of everything,
961 second pass writes the bytes out. */
963 for (write_pass
= 0; write_pass
< 2; write_pass
++)
965 CORE_ADDR struct_ptr
= 0;
966 CORE_ADDR param_ptr
= 0;
968 for (i
= 0; i
< nargs
; i
++)
970 struct value
*arg
= args
[i
];
971 struct type
*type
= check_typedef (VALUE_TYPE (arg
));
972 if ((TYPE_CODE (type
) == TYPE_CODE_INT
973 || TYPE_CODE (type
) == TYPE_CODE_ENUM
)
974 && TYPE_LENGTH (type
) <= 8)
976 /* Integer value store, right aligned. "unpack_long"
977 takes care of any sign-extension problems. */
981 ULONGEST val
= unpack_long (type
, VALUE_CONTENTS (arg
));
982 int reg
= 27 - param_ptr
/ 8;
983 write_memory_unsigned_integer (param_end
- param_ptr
,
986 regcache_cooked_write_unsigned (regcache
, reg
, val
);
991 /* Small struct value, store left aligned? */
993 if (TYPE_LENGTH (type
) > 8)
995 param_ptr
= align_up (param_ptr
, 16);
996 reg
= 26 - param_ptr
/ 8;
997 param_ptr
+= align_up (TYPE_LENGTH (type
), 16);
1001 param_ptr
= align_up (param_ptr
, 8);
1002 reg
= 26 - param_ptr
/ 8;
1003 param_ptr
+= align_up (TYPE_LENGTH (type
), 8);
1008 write_memory (param_end
- param_ptr
, VALUE_CONTENTS (arg
),
1009 TYPE_LENGTH (type
));
1010 for (byte
= 0; byte
< TYPE_LENGTH (type
); byte
+= 8)
1014 int len
= min (8, TYPE_LENGTH (type
) - byte
);
1015 regcache_cooked_write_part (regcache
, reg
, 0, len
,
1016 VALUE_CONTENTS (arg
) + byte
);
1023 /* Update the various stack pointers. */
1026 struct_end
= sp
+ struct_ptr
;
1027 /* PARAM_PTR already accounts for all the arguments passed
1028 by the user. However, the ABI mandates minimum stack
1029 space allocations for outgoing arguments. The ABI also
1030 mandates minimum stack alignments which we must
1032 param_end
= struct_end
+ max (align_up (param_ptr
, 16),
1033 REG_PARM_STACK_SPACE
);
1037 /* If a structure has to be returned, set up register 28 to hold its
1040 write_register (28, struct_addr
);
1042 /* Set the return address. */
1043 regcache_cooked_write_unsigned (regcache
, RP_REGNUM
, bp_addr
);
1045 /* The stack will have 32 bytes of additional space for a frame marker. */
1046 return param_end
+ 64;
1050 hppa32_frame_align (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
1052 /* HP frames are 64-byte (or cache line) aligned (yes that's _byte_
1054 return align_up (addr
, 64);
1057 /* Force all frames to 16-byte alignment. Better safe than sorry. */
1060 hppa64_frame_align (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
1062 /* Just always 16-byte align. */
1063 return align_up (addr
, 16);
1067 /* elz: Used to lookup a symbol in the shared libraries.
1068 This function calls shl_findsym, indirectly through a
1069 call to __d_shl_get. __d_shl_get is in end.c, which is always
1070 linked in by the hp compilers/linkers.
1071 The call to shl_findsym cannot be made directly because it needs
1072 to be active in target address space.
1073 inputs: - minimal symbol pointer for the function we want to look up
1074 - address in target space of the descriptor for the library
1075 where we want to look the symbol up.
1076 This address is retrieved using the
1077 som_solib_get_solib_by_pc function (somsolib.c).
1078 output: - real address in the library of the function.
1079 note: the handle can be null, in which case shl_findsym will look for
1080 the symbol in all the loaded shared libraries.
1081 files to look at if you need reference on this stuff:
1082 dld.c, dld_shl_findsym.c
1084 man entry for shl_findsym */
1087 find_stub_with_shl_get (struct minimal_symbol
*function
, CORE_ADDR handle
)
1089 struct symbol
*get_sym
, *symbol2
;
1090 struct minimal_symbol
*buff_minsym
, *msymbol
;
1092 struct value
**args
;
1093 struct value
*funcval
;
1096 int x
, namelen
, err_value
, tmp
= -1;
1097 CORE_ADDR endo_buff_addr
, value_return_addr
, errno_return_addr
;
1098 CORE_ADDR stub_addr
;
1101 args
= alloca (sizeof (struct value
*) * 8); /* 6 for the arguments and one null one??? */
1102 funcval
= find_function_in_inferior ("__d_shl_get");
1103 get_sym
= lookup_symbol ("__d_shl_get", NULL
, VAR_DOMAIN
, NULL
, NULL
);
1104 buff_minsym
= lookup_minimal_symbol ("__buffer", NULL
, NULL
);
1105 msymbol
= lookup_minimal_symbol ("__shldp", NULL
, NULL
);
1106 symbol2
= lookup_symbol ("__shldp", NULL
, VAR_DOMAIN
, NULL
, NULL
);
1107 endo_buff_addr
= SYMBOL_VALUE_ADDRESS (buff_minsym
);
1108 namelen
= strlen (DEPRECATED_SYMBOL_NAME (function
));
1109 value_return_addr
= endo_buff_addr
+ namelen
;
1110 ftype
= check_typedef (SYMBOL_TYPE (get_sym
));
1113 if ((x
= value_return_addr
% 64) != 0)
1114 value_return_addr
= value_return_addr
+ 64 - x
;
1116 errno_return_addr
= value_return_addr
+ 64;
1119 /* set up stuff needed by __d_shl_get in buffer in end.o */
1121 target_write_memory (endo_buff_addr
, DEPRECATED_SYMBOL_NAME (function
), namelen
);
1123 target_write_memory (value_return_addr
, (char *) &tmp
, 4);
1125 target_write_memory (errno_return_addr
, (char *) &tmp
, 4);
1127 target_write_memory (SYMBOL_VALUE_ADDRESS (msymbol
),
1128 (char *) &handle
, 4);
1130 /* now prepare the arguments for the call */
1132 args
[0] = value_from_longest (TYPE_FIELD_TYPE (ftype
, 0), 12);
1133 args
[1] = value_from_pointer (TYPE_FIELD_TYPE (ftype
, 1), SYMBOL_VALUE_ADDRESS (msymbol
));
1134 args
[2] = value_from_pointer (TYPE_FIELD_TYPE (ftype
, 2), endo_buff_addr
);
1135 args
[3] = value_from_longest (TYPE_FIELD_TYPE (ftype
, 3), TYPE_PROCEDURE
);
1136 args
[4] = value_from_pointer (TYPE_FIELD_TYPE (ftype
, 4), value_return_addr
);
1137 args
[5] = value_from_pointer (TYPE_FIELD_TYPE (ftype
, 5), errno_return_addr
);
1139 /* now call the function */
1141 val
= call_function_by_hand (funcval
, 6, args
);
1143 /* now get the results */
1145 target_read_memory (errno_return_addr
, (char *) &err_value
, sizeof (err_value
));
1147 target_read_memory (value_return_addr
, (char *) &stub_addr
, sizeof (stub_addr
));
1149 error ("call to __d_shl_get failed, error code is %d", err_value
);
1154 /* Cover routine for find_stub_with_shl_get to pass to catch_errors */
1156 cover_find_stub_with_shl_get (void *args_untyped
)
1158 args_for_find_stub
*args
= args_untyped
;
1159 args
->return_val
= find_stub_with_shl_get (args
->msym
, args
->solib_handle
);
1163 /* If the pid is in a syscall, then the FP register is not readable.
1164 We'll return zero in that case, rather than attempting to read it
1165 and cause a warning. */
1168 hppa_read_fp (int pid
)
1170 int flags
= read_register (FLAGS_REGNUM
);
1174 return (CORE_ADDR
) 0;
1177 /* This is the only site that may directly read_register () the FP
1178 register. All others must use deprecated_read_fp (). */
1179 return read_register (DEPRECATED_FP_REGNUM
);
1183 hppa_target_read_fp (void)
1185 return hppa_read_fp (PIDGET (inferior_ptid
));
1188 /* Get the PC from %r31 if currently in a syscall. Also mask out privilege
1192 hppa_target_read_pc (ptid_t ptid
)
1194 int flags
= read_register_pid (FLAGS_REGNUM
, ptid
);
1196 /* The following test does not belong here. It is OS-specific, and belongs
1198 /* Test SS_INSYSCALL */
1200 return read_register_pid (31, ptid
) & ~0x3;
1202 return read_register_pid (PCOQ_HEAD_REGNUM
, ptid
) & ~0x3;
1205 /* Write out the PC. If currently in a syscall, then also write the new
1206 PC value into %r31. */
1209 hppa_target_write_pc (CORE_ADDR v
, ptid_t ptid
)
1211 int flags
= read_register_pid (FLAGS_REGNUM
, ptid
);
1213 /* The following test does not belong here. It is OS-specific, and belongs
1215 /* If in a syscall, then set %r31. Also make sure to get the
1216 privilege bits set correctly. */
1217 /* Test SS_INSYSCALL */
1219 write_register_pid (31, v
| 0x3, ptid
);
1221 write_register_pid (PCOQ_HEAD_REGNUM
, v
, ptid
);
1222 write_register_pid (PCOQ_TAIL_REGNUM
, v
+ 4, ptid
);
1225 /* return the alignment of a type in bytes. Structures have the maximum
1226 alignment required by their fields. */
1229 hppa_alignof (struct type
*type
)
1231 int max_align
, align
, i
;
1232 CHECK_TYPEDEF (type
);
1233 switch (TYPE_CODE (type
))
1238 return TYPE_LENGTH (type
);
1239 case TYPE_CODE_ARRAY
:
1240 return hppa_alignof (TYPE_FIELD_TYPE (type
, 0));
1241 case TYPE_CODE_STRUCT
:
1242 case TYPE_CODE_UNION
:
1244 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
1246 /* Bit fields have no real alignment. */
1247 /* if (!TYPE_FIELD_BITPOS (type, i)) */
1248 if (!TYPE_FIELD_BITSIZE (type
, i
)) /* elz: this should be bitsize */
1250 align
= hppa_alignof (TYPE_FIELD_TYPE (type
, i
));
1251 max_align
= max (max_align
, align
);
1260 /* Print the register regnum, or all registers if regnum is -1 */
1263 pa_do_registers_info (int regnum
, int fpregs
)
1265 char *raw_regs
= alloca (DEPRECATED_REGISTER_BYTES
);
1268 /* Make a copy of gdb's save area (may cause actual
1269 reads from the target). */
1270 for (i
= 0; i
< NUM_REGS
; i
++)
1271 frame_register_read (deprecated_selected_frame
, i
,
1272 raw_regs
+ DEPRECATED_REGISTER_BYTE (i
));
1275 pa_print_registers (raw_regs
, regnum
, fpregs
);
1276 else if (regnum
< FP4_REGNUM
)
1280 /* Why is the value not passed through "extract_signed_integer"
1281 as in "pa_print_registers" below? */
1282 pa_register_look_aside (raw_regs
, regnum
, ®_val
[0]);
1286 printf_unfiltered ("%s %lx\n", REGISTER_NAME (regnum
), reg_val
[1]);
1290 /* Fancy % formats to prevent leading zeros. */
1291 if (reg_val
[0] == 0)
1292 printf_unfiltered ("%s %lx\n", REGISTER_NAME (regnum
), reg_val
[1]);
1294 printf_unfiltered ("%s %lx%8.8lx\n", REGISTER_NAME (regnum
),
1295 reg_val
[0], reg_val
[1]);
1299 /* Note that real floating point values only start at
1300 FP4_REGNUM. FP0 and up are just status and error
1301 registers, which have integral (bit) values. */
1302 pa_print_fp_reg (regnum
);
1305 /********** new function ********************/
1307 pa_do_strcat_registers_info (int regnum
, int fpregs
, struct ui_file
*stream
,
1308 enum precision_type precision
)
1310 char *raw_regs
= alloca (DEPRECATED_REGISTER_BYTES
);
1313 /* Make a copy of gdb's save area (may cause actual
1314 reads from the target). */
1315 for (i
= 0; i
< NUM_REGS
; i
++)
1316 frame_register_read (deprecated_selected_frame
, i
,
1317 raw_regs
+ DEPRECATED_REGISTER_BYTE (i
));
1320 pa_strcat_registers (raw_regs
, regnum
, fpregs
, stream
);
1322 else if (regnum
< FP4_REGNUM
)
1326 /* Why is the value not passed through "extract_signed_integer"
1327 as in "pa_print_registers" below? */
1328 pa_register_look_aside (raw_regs
, regnum
, ®_val
[0]);
1332 fprintf_unfiltered (stream
, "%s %lx", REGISTER_NAME (regnum
), reg_val
[1]);
1336 /* Fancy % formats to prevent leading zeros. */
1337 if (reg_val
[0] == 0)
1338 fprintf_unfiltered (stream
, "%s %lx", REGISTER_NAME (regnum
),
1341 fprintf_unfiltered (stream
, "%s %lx%8.8lx", REGISTER_NAME (regnum
),
1342 reg_val
[0], reg_val
[1]);
1346 /* Note that real floating point values only start at
1347 FP4_REGNUM. FP0 and up are just status and error
1348 registers, which have integral (bit) values. */
1349 pa_strcat_fp_reg (regnum
, stream
, precision
);
1352 /* If this is a PA2.0 machine, fetch the real 64-bit register
1353 value. Otherwise use the info from gdb's saved register area.
1355 Note that reg_val is really expected to be an array of longs,
1356 with two elements. */
1358 pa_register_look_aside (char *raw_regs
, int regnum
, long *raw_val
)
1360 static int know_which
= 0; /* False */
1363 unsigned int offset
;
1368 char buf
[MAX_REGISTER_SIZE
];
1373 if (CPU_PA_RISC2_0
== sysconf (_SC_CPU_VERSION
))
1378 know_which
= 1; /* True */
1386 raw_val
[1] = *(long *) (raw_regs
+ DEPRECATED_REGISTER_BYTE (regnum
));
1390 /* Code below copied from hppah-nat.c, with fixes for wide
1391 registers, using different area of save_state, etc. */
1392 if (regnum
== FLAGS_REGNUM
|| regnum
>= FP0_REGNUM
||
1393 !HAVE_STRUCT_SAVE_STATE_T
|| !HAVE_STRUCT_MEMBER_SS_WIDE
)
1395 /* Use narrow regs area of save_state and default macro. */
1396 offset
= U_REGS_OFFSET
;
1397 regaddr
= register_addr (regnum
, offset
);
1402 /* Use wide regs area, and calculate registers as 8 bytes wide.
1404 We'd like to do this, but current version of "C" doesn't
1407 offset = offsetof(save_state_t, ss_wide);
1409 Note that to avoid "C" doing typed pointer arithmetic, we
1410 have to cast away the type in our offset calculation:
1411 otherwise we get an offset of 1! */
1413 /* NB: save_state_t is not available before HPUX 9.
1414 The ss_wide field is not available previous to HPUX 10.20,
1415 so to avoid compile-time warnings, we only compile this for
1416 PA 2.0 processors. This control path should only be followed
1417 if we're debugging a PA 2.0 processor, so this should not cause
1420 /* #if the following code out so that this file can still be
1421 compiled on older HPUX boxes (< 10.20) which don't have
1422 this structure/structure member. */
1423 #if HAVE_STRUCT_SAVE_STATE_T == 1 && HAVE_STRUCT_MEMBER_SS_WIDE == 1
1426 offset
= ((int) &temp
.ss_wide
) - ((int) &temp
);
1427 regaddr
= offset
+ regnum
* 8;
1432 for (i
= start
; i
< 2; i
++)
1435 raw_val
[i
] = call_ptrace (PT_RUREGS
, PIDGET (inferior_ptid
),
1436 (PTRACE_ARG3_TYPE
) regaddr
, 0);
1439 /* Warning, not error, in case we are attached; sometimes the
1440 kernel doesn't let us at the registers. */
1441 char *err
= safe_strerror (errno
);
1442 char *msg
= alloca (strlen (err
) + 128);
1443 sprintf (msg
, "reading register %s: %s", REGISTER_NAME (regnum
), err
);
1448 regaddr
+= sizeof (long);
1451 if (regnum
== PCOQ_HEAD_REGNUM
|| regnum
== PCOQ_TAIL_REGNUM
)
1452 raw_val
[1] &= ~0x3; /* I think we're masking out space bits */
1458 /* "Info all-reg" command */
1461 pa_print_registers (char *raw_regs
, int regnum
, int fpregs
)
1464 /* Alas, we are compiled so that "long long" is 32 bits */
1467 int rows
= 48, columns
= 2;
1469 for (i
= 0; i
< rows
; i
++)
1471 for (j
= 0; j
< columns
; j
++)
1473 /* We display registers in column-major order. */
1474 int regnum
= i
+ j
* rows
;
1476 /* Q: Why is the value passed through "extract_signed_integer",
1477 while above, in "pa_do_registers_info" it isn't?
1479 pa_register_look_aside (raw_regs
, regnum
, &raw_val
[0]);
1481 /* Even fancier % formats to prevent leading zeros
1482 and still maintain the output in columns. */
1485 /* Being big-endian, on this machine the low bits
1486 (the ones we want to look at) are in the second longword. */
1487 long_val
= extract_signed_integer (&raw_val
[1], 4);
1488 printf_filtered ("%10.10s: %8lx ",
1489 REGISTER_NAME (regnum
), long_val
);
1493 /* raw_val = extract_signed_integer(&raw_val, 8); */
1494 if (raw_val
[0] == 0)
1495 printf_filtered ("%10.10s: %8lx ",
1496 REGISTER_NAME (regnum
), raw_val
[1]);
1498 printf_filtered ("%10.10s: %8lx%8.8lx ",
1499 REGISTER_NAME (regnum
),
1500 raw_val
[0], raw_val
[1]);
1503 printf_unfiltered ("\n");
1507 for (i
= FP4_REGNUM
; i
< NUM_REGS
; i
++) /* FP4_REGNUM == 72 */
1508 pa_print_fp_reg (i
);
1511 /************* new function ******************/
1513 pa_strcat_registers (char *raw_regs
, int regnum
, int fpregs
,
1514 struct ui_file
*stream
)
1517 long raw_val
[2]; /* Alas, we are compiled so that "long long" is 32 bits */
1519 enum precision_type precision
;
1521 precision
= unspecified_precision
;
1523 for (i
= 0; i
< 18; i
++)
1525 for (j
= 0; j
< 4; j
++)
1527 /* Q: Why is the value passed through "extract_signed_integer",
1528 while above, in "pa_do_registers_info" it isn't?
1530 pa_register_look_aside (raw_regs
, i
+ (j
* 18), &raw_val
[0]);
1532 /* Even fancier % formats to prevent leading zeros
1533 and still maintain the output in columns. */
1536 /* Being big-endian, on this machine the low bits
1537 (the ones we want to look at) are in the second longword. */
1538 long_val
= extract_signed_integer (&raw_val
[1], 4);
1539 fprintf_filtered (stream
, "%8.8s: %8lx ",
1540 REGISTER_NAME (i
+ (j
* 18)), long_val
);
1544 /* raw_val = extract_signed_integer(&raw_val, 8); */
1545 if (raw_val
[0] == 0)
1546 fprintf_filtered (stream
, "%8.8s: %8lx ",
1547 REGISTER_NAME (i
+ (j
* 18)), raw_val
[1]);
1549 fprintf_filtered (stream
, "%8.8s: %8lx%8.8lx ",
1550 REGISTER_NAME (i
+ (j
* 18)), raw_val
[0],
1554 fprintf_unfiltered (stream
, "\n");
1558 for (i
= FP4_REGNUM
; i
< NUM_REGS
; i
++) /* FP4_REGNUM == 72 */
1559 pa_strcat_fp_reg (i
, stream
, precision
);
1563 pa_print_fp_reg (int i
)
1565 char raw_buffer
[MAX_REGISTER_SIZE
];
1566 char virtual_buffer
[MAX_REGISTER_SIZE
];
1568 /* Get 32bits of data. */
1569 frame_register_read (deprecated_selected_frame
, i
, raw_buffer
);
1571 /* Put it in the buffer. No conversions are ever necessary. */
1572 memcpy (virtual_buffer
, raw_buffer
, DEPRECATED_REGISTER_RAW_SIZE (i
));
1574 fputs_filtered (REGISTER_NAME (i
), gdb_stdout
);
1575 print_spaces_filtered (8 - strlen (REGISTER_NAME (i
)), gdb_stdout
);
1576 fputs_filtered ("(single precision) ", gdb_stdout
);
1578 val_print (DEPRECATED_REGISTER_VIRTUAL_TYPE (i
), virtual_buffer
, 0, 0, gdb_stdout
, 0,
1579 1, 0, Val_pretty_default
);
1580 printf_filtered ("\n");
1582 /* If "i" is even, then this register can also be a double-precision
1583 FP register. Dump it out as such. */
1586 /* Get the data in raw format for the 2nd half. */
1587 frame_register_read (deprecated_selected_frame
, i
+ 1, raw_buffer
);
1589 /* Copy it into the appropriate part of the virtual buffer. */
1590 memcpy (virtual_buffer
+ DEPRECATED_REGISTER_RAW_SIZE (i
), raw_buffer
,
1591 DEPRECATED_REGISTER_RAW_SIZE (i
));
1593 /* Dump it as a double. */
1594 fputs_filtered (REGISTER_NAME (i
), gdb_stdout
);
1595 print_spaces_filtered (8 - strlen (REGISTER_NAME (i
)), gdb_stdout
);
1596 fputs_filtered ("(double precision) ", gdb_stdout
);
1598 val_print (builtin_type_double
, virtual_buffer
, 0, 0, gdb_stdout
, 0,
1599 1, 0, Val_pretty_default
);
1600 printf_filtered ("\n");
1604 /*************** new function ***********************/
1606 pa_strcat_fp_reg (int i
, struct ui_file
*stream
, enum precision_type precision
)
1608 char raw_buffer
[MAX_REGISTER_SIZE
];
1609 char virtual_buffer
[MAX_REGISTER_SIZE
];
1611 fputs_filtered (REGISTER_NAME (i
), stream
);
1612 print_spaces_filtered (8 - strlen (REGISTER_NAME (i
)), stream
);
1614 /* Get 32bits of data. */
1615 frame_register_read (deprecated_selected_frame
, i
, raw_buffer
);
1617 /* Put it in the buffer. No conversions are ever necessary. */
1618 memcpy (virtual_buffer
, raw_buffer
, DEPRECATED_REGISTER_RAW_SIZE (i
));
1620 if (precision
== double_precision
&& (i
% 2) == 0)
1623 char raw_buf
[MAX_REGISTER_SIZE
];
1625 /* Get the data in raw format for the 2nd half. */
1626 frame_register_read (deprecated_selected_frame
, i
+ 1, raw_buf
);
1628 /* Copy it into the appropriate part of the virtual buffer. */
1629 memcpy (virtual_buffer
+ DEPRECATED_REGISTER_RAW_SIZE (i
), raw_buf
,
1630 DEPRECATED_REGISTER_RAW_SIZE (i
));
1632 val_print (builtin_type_double
, virtual_buffer
, 0, 0, stream
, 0,
1633 1, 0, Val_pretty_default
);
1638 val_print (DEPRECATED_REGISTER_VIRTUAL_TYPE (i
), virtual_buffer
, 0, 0, stream
, 0,
1639 1, 0, Val_pretty_default
);
1644 /* Return one if PC is in the call path of a trampoline, else return zero.
1646 Note we return one for *any* call trampoline (long-call, arg-reloc), not
1647 just shared library trampolines (import, export). */
1650 hppa_in_solib_call_trampoline (CORE_ADDR pc
, char *name
)
1652 struct minimal_symbol
*minsym
;
1653 struct unwind_table_entry
*u
;
1654 static CORE_ADDR dyncall
= 0;
1655 static CORE_ADDR sr4export
= 0;
1657 #ifdef GDB_TARGET_IS_HPPA_20W
1658 /* PA64 has a completely different stub/trampoline scheme. Is it
1659 better? Maybe. It's certainly harder to determine with any
1660 certainty that we are in a stub because we can not refer to the
1663 The heuristic is simple. Try to lookup the current PC value in th
1664 minimal symbol table. If that fails, then assume we are not in a
1667 Then see if the PC value falls within the section bounds for the
1668 section containing the minimal symbol we found in the first
1669 step. If it does, then assume we are not in a stub and return.
1671 Finally peek at the instructions to see if they look like a stub. */
1673 struct minimal_symbol
*minsym
;
1678 minsym
= lookup_minimal_symbol_by_pc (pc
);
1682 sec
= SYMBOL_BFD_SECTION (minsym
);
1684 if (bfd_get_section_vma (sec
->owner
, sec
) <= pc
1685 && pc
< (bfd_get_section_vma (sec
->owner
, sec
)
1686 + bfd_section_size (sec
->owner
, sec
)))
1689 /* We might be in a stub. Peek at the instructions. Stubs are 3
1690 instructions long. */
1691 insn
= read_memory_integer (pc
, 4);
1693 /* Find out where we think we are within the stub. */
1694 if ((insn
& 0xffffc00e) == 0x53610000)
1696 else if ((insn
& 0xffffffff) == 0xe820d000)
1698 else if ((insn
& 0xffffc00e) == 0x537b0000)
1703 /* Now verify each insn in the range looks like a stub instruction. */
1704 insn
= read_memory_integer (addr
, 4);
1705 if ((insn
& 0xffffc00e) != 0x53610000)
1708 /* Now verify each insn in the range looks like a stub instruction. */
1709 insn
= read_memory_integer (addr
+ 4, 4);
1710 if ((insn
& 0xffffffff) != 0xe820d000)
1713 /* Now verify each insn in the range looks like a stub instruction. */
1714 insn
= read_memory_integer (addr
+ 8, 4);
1715 if ((insn
& 0xffffc00e) != 0x537b0000)
1718 /* Looks like a stub. */
1723 /* FIXME XXX - dyncall and sr4export must be initialized whenever we get a
1726 /* First see if PC is in one of the two C-library trampolines. */
1729 minsym
= lookup_minimal_symbol ("$$dyncall", NULL
, NULL
);
1731 dyncall
= SYMBOL_VALUE_ADDRESS (minsym
);
1738 minsym
= lookup_minimal_symbol ("_sr4export", NULL
, NULL
);
1740 sr4export
= SYMBOL_VALUE_ADDRESS (minsym
);
1745 if (pc
== dyncall
|| pc
== sr4export
)
1748 minsym
= lookup_minimal_symbol_by_pc (pc
);
1749 if (minsym
&& strcmp (DEPRECATED_SYMBOL_NAME (minsym
), ".stub") == 0)
1752 /* Get the unwind descriptor corresponding to PC, return zero
1753 if no unwind was found. */
1754 u
= find_unwind_entry (pc
);
1758 /* If this isn't a linker stub, then return now. */
1759 if (u
->stub_unwind
.stub_type
== 0)
1762 /* By definition a long-branch stub is a call stub. */
1763 if (u
->stub_unwind
.stub_type
== LONG_BRANCH
)
1766 /* The call and return path execute the same instructions within
1767 an IMPORT stub! So an IMPORT stub is both a call and return
1769 if (u
->stub_unwind
.stub_type
== IMPORT
)
1772 /* Parameter relocation stubs always have a call path and may have a
1774 if (u
->stub_unwind
.stub_type
== PARAMETER_RELOCATION
1775 || u
->stub_unwind
.stub_type
== EXPORT
)
1779 /* Search forward from the current PC until we hit a branch
1780 or the end of the stub. */
1781 for (addr
= pc
; addr
<= u
->region_end
; addr
+= 4)
1785 insn
= read_memory_integer (addr
, 4);
1787 /* Does it look like a bl? If so then it's the call path, if
1788 we find a bv or be first, then we're on the return path. */
1789 if ((insn
& 0xfc00e000) == 0xe8000000)
1791 else if ((insn
& 0xfc00e001) == 0xe800c000
1792 || (insn
& 0xfc000000) == 0xe0000000)
1796 /* Should never happen. */
1797 warning ("Unable to find branch in parameter relocation stub.\n");
1801 /* Unknown stub type. For now, just return zero. */
1805 /* Return one if PC is in the return path of a trampoline, else return zero.
1807 Note we return one for *any* call trampoline (long-call, arg-reloc), not
1808 just shared library trampolines (import, export). */
1811 hppa_in_solib_return_trampoline (CORE_ADDR pc
, char *name
)
1813 struct unwind_table_entry
*u
;
1815 /* Get the unwind descriptor corresponding to PC, return zero
1816 if no unwind was found. */
1817 u
= find_unwind_entry (pc
);
1821 /* If this isn't a linker stub or it's just a long branch stub, then
1823 if (u
->stub_unwind
.stub_type
== 0 || u
->stub_unwind
.stub_type
== LONG_BRANCH
)
1826 /* The call and return path execute the same instructions within
1827 an IMPORT stub! So an IMPORT stub is both a call and return
1829 if (u
->stub_unwind
.stub_type
== IMPORT
)
1832 /* Parameter relocation stubs always have a call path and may have a
1834 if (u
->stub_unwind
.stub_type
== PARAMETER_RELOCATION
1835 || u
->stub_unwind
.stub_type
== EXPORT
)
1839 /* Search forward from the current PC until we hit a branch
1840 or the end of the stub. */
1841 for (addr
= pc
; addr
<= u
->region_end
; addr
+= 4)
1845 insn
= read_memory_integer (addr
, 4);
1847 /* Does it look like a bl? If so then it's the call path, if
1848 we find a bv or be first, then we're on the return path. */
1849 if ((insn
& 0xfc00e000) == 0xe8000000)
1851 else if ((insn
& 0xfc00e001) == 0xe800c000
1852 || (insn
& 0xfc000000) == 0xe0000000)
1856 /* Should never happen. */
1857 warning ("Unable to find branch in parameter relocation stub.\n");
1861 /* Unknown stub type. For now, just return zero. */
1866 /* Figure out if PC is in a trampoline, and if so find out where
1867 the trampoline will jump to. If not in a trampoline, return zero.
1869 Simple code examination probably is not a good idea since the code
1870 sequences in trampolines can also appear in user code.
1872 We use unwinds and information from the minimal symbol table to
1873 determine when we're in a trampoline. This won't work for ELF
1874 (yet) since it doesn't create stub unwind entries. Whether or
1875 not ELF will create stub unwinds or normal unwinds for linker
1876 stubs is still being debated.
1878 This should handle simple calls through dyncall or sr4export,
1879 long calls, argument relocation stubs, and dyncall/sr4export
1880 calling an argument relocation stub. It even handles some stubs
1881 used in dynamic executables. */
1884 hppa_skip_trampoline_code (CORE_ADDR pc
)
1887 long prev_inst
, curr_inst
, loc
;
1888 static CORE_ADDR dyncall
= 0;
1889 static CORE_ADDR dyncall_external
= 0;
1890 static CORE_ADDR sr4export
= 0;
1891 struct minimal_symbol
*msym
;
1892 struct unwind_table_entry
*u
;
1894 /* FIXME XXX - dyncall and sr4export must be initialized whenever we get a
1899 msym
= lookup_minimal_symbol ("$$dyncall", NULL
, NULL
);
1901 dyncall
= SYMBOL_VALUE_ADDRESS (msym
);
1906 if (!dyncall_external
)
1908 msym
= lookup_minimal_symbol ("$$dyncall_external", NULL
, NULL
);
1910 dyncall_external
= SYMBOL_VALUE_ADDRESS (msym
);
1912 dyncall_external
= -1;
1917 msym
= lookup_minimal_symbol ("_sr4export", NULL
, NULL
);
1919 sr4export
= SYMBOL_VALUE_ADDRESS (msym
);
1924 /* Addresses passed to dyncall may *NOT* be the actual address
1925 of the function. So we may have to do something special. */
1928 pc
= (CORE_ADDR
) read_register (22);
1930 /* If bit 30 (counting from the left) is on, then pc is the address of
1931 the PLT entry for this function, not the address of the function
1932 itself. Bit 31 has meaning too, but only for MPE. */
1934 pc
= (CORE_ADDR
) read_memory_integer (pc
& ~0x3, TARGET_PTR_BIT
/ 8);
1936 if (pc
== dyncall_external
)
1938 pc
= (CORE_ADDR
) read_register (22);
1939 pc
= (CORE_ADDR
) read_memory_integer (pc
& ~0x3, TARGET_PTR_BIT
/ 8);
1941 else if (pc
== sr4export
)
1942 pc
= (CORE_ADDR
) (read_register (22));
1944 /* Get the unwind descriptor corresponding to PC, return zero
1945 if no unwind was found. */
1946 u
= find_unwind_entry (pc
);
1950 /* If this isn't a linker stub, then return now. */
1951 /* elz: attention here! (FIXME) because of a compiler/linker
1952 error, some stubs which should have a non zero stub_unwind.stub_type
1953 have unfortunately a value of zero. So this function would return here
1954 as if we were not in a trampoline. To fix this, we go look at the partial
1955 symbol information, which reports this guy as a stub.
1956 (FIXME): Unfortunately, we are not that lucky: it turns out that the
1957 partial symbol information is also wrong sometimes. This is because
1958 when it is entered (somread.c::som_symtab_read()) it can happen that
1959 if the type of the symbol (from the som) is Entry, and the symbol is
1960 in a shared library, then it can also be a trampoline. This would
1961 be OK, except that I believe the way they decide if we are ina shared library
1962 does not work. SOOOO..., even if we have a regular function w/o trampolines
1963 its minimal symbol can be assigned type mst_solib_trampoline.
1964 Also, if we find that the symbol is a real stub, then we fix the unwind
1965 descriptor, and define the stub type to be EXPORT.
1966 Hopefully this is correct most of the times. */
1967 if (u
->stub_unwind
.stub_type
== 0)
1970 /* elz: NOTE (FIXME!) once the problem with the unwind information is fixed
1971 we can delete all the code which appears between the lines */
1972 /*--------------------------------------------------------------------------*/
1973 msym
= lookup_minimal_symbol_by_pc (pc
);
1975 if (msym
== NULL
|| MSYMBOL_TYPE (msym
) != mst_solib_trampoline
)
1976 return orig_pc
== pc
? 0 : pc
& ~0x3;
1978 else if (msym
!= NULL
&& MSYMBOL_TYPE (msym
) == mst_solib_trampoline
)
1980 struct objfile
*objfile
;
1981 struct minimal_symbol
*msymbol
;
1982 int function_found
= 0;
1984 /* go look if there is another minimal symbol with the same name as
1985 this one, but with type mst_text. This would happen if the msym
1986 is an actual trampoline, in which case there would be another
1987 symbol with the same name corresponding to the real function */
1989 ALL_MSYMBOLS (objfile
, msymbol
)
1991 if (MSYMBOL_TYPE (msymbol
) == mst_text
1992 && DEPRECATED_STREQ (DEPRECATED_SYMBOL_NAME (msymbol
), DEPRECATED_SYMBOL_NAME (msym
)))
2000 /* the type of msym is correct (mst_solib_trampoline), but
2001 the unwind info is wrong, so set it to the correct value */
2002 u
->stub_unwind
.stub_type
= EXPORT
;
2004 /* the stub type info in the unwind is correct (this is not a
2005 trampoline), but the msym type information is wrong, it
2006 should be mst_text. So we need to fix the msym, and also
2007 get out of this function */
2009 MSYMBOL_TYPE (msym
) = mst_text
;
2010 return orig_pc
== pc
? 0 : pc
& ~0x3;
2014 /*--------------------------------------------------------------------------*/
2017 /* It's a stub. Search for a branch and figure out where it goes.
2018 Note we have to handle multi insn branch sequences like ldil;ble.
2019 Most (all?) other branches can be determined by examining the contents
2020 of certain registers and the stack. */
2027 /* Make sure we haven't walked outside the range of this stub. */
2028 if (u
!= find_unwind_entry (loc
))
2030 warning ("Unable to find branch in linker stub");
2031 return orig_pc
== pc
? 0 : pc
& ~0x3;
2034 prev_inst
= curr_inst
;
2035 curr_inst
= read_memory_integer (loc
, 4);
2037 /* Does it look like a branch external using %r1? Then it's the
2038 branch from the stub to the actual function. */
2039 if ((curr_inst
& 0xffe0e000) == 0xe0202000)
2041 /* Yup. See if the previous instruction loaded
2042 a value into %r1. If so compute and return the jump address. */
2043 if ((prev_inst
& 0xffe00000) == 0x20200000)
2044 return (extract_21 (prev_inst
) + extract_17 (curr_inst
)) & ~0x3;
2047 warning ("Unable to find ldil X,%%r1 before ble Y(%%sr4,%%r1).");
2048 return orig_pc
== pc
? 0 : pc
& ~0x3;
2052 /* Does it look like a be 0(sr0,%r21)? OR
2053 Does it look like a be, n 0(sr0,%r21)? OR
2054 Does it look like a bve (r21)? (this is on PA2.0)
2055 Does it look like a bve, n(r21)? (this is also on PA2.0)
2056 That's the branch from an
2057 import stub to an export stub.
2059 It is impossible to determine the target of the branch via
2060 simple examination of instructions and/or data (consider
2061 that the address in the plabel may be the address of the
2062 bind-on-reference routine in the dynamic loader).
2064 So we have try an alternative approach.
2066 Get the name of the symbol at our current location; it should
2067 be a stub symbol with the same name as the symbol in the
2070 Then lookup a minimal symbol with the same name; we should
2071 get the minimal symbol for the target routine in the shared
2072 library as those take precedence of import/export stubs. */
2073 if ((curr_inst
== 0xe2a00000) ||
2074 (curr_inst
== 0xe2a00002) ||
2075 (curr_inst
== 0xeaa0d000) ||
2076 (curr_inst
== 0xeaa0d002))
2078 struct minimal_symbol
*stubsym
, *libsym
;
2080 stubsym
= lookup_minimal_symbol_by_pc (loc
);
2081 if (stubsym
== NULL
)
2083 warning ("Unable to find symbol for 0x%lx", loc
);
2084 return orig_pc
== pc
? 0 : pc
& ~0x3;
2087 libsym
= lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (stubsym
), NULL
, NULL
);
2090 warning ("Unable to find library symbol for %s\n",
2091 DEPRECATED_SYMBOL_NAME (stubsym
));
2092 return orig_pc
== pc
? 0 : pc
& ~0x3;
2095 return SYMBOL_VALUE (libsym
);
2098 /* Does it look like bl X,%rp or bl X,%r0? Another way to do a
2099 branch from the stub to the actual function. */
2101 else if ((curr_inst
& 0xffe0e000) == 0xe8400000
2102 || (curr_inst
& 0xffe0e000) == 0xe8000000
2103 || (curr_inst
& 0xffe0e000) == 0xe800A000)
2104 return (loc
+ extract_17 (curr_inst
) + 8) & ~0x3;
2106 /* Does it look like bv (rp)? Note this depends on the
2107 current stack pointer being the same as the stack
2108 pointer in the stub itself! This is a branch on from the
2109 stub back to the original caller. */
2110 /*else if ((curr_inst & 0xffe0e000) == 0xe840c000) */
2111 else if ((curr_inst
& 0xffe0f000) == 0xe840c000)
2113 /* Yup. See if the previous instruction loaded
2115 if (prev_inst
== 0x4bc23ff1)
2116 return (read_memory_integer
2117 (read_register (SP_REGNUM
) - 8, 4)) & ~0x3;
2120 warning ("Unable to find restore of %%rp before bv (%%rp).");
2121 return orig_pc
== pc
? 0 : pc
& ~0x3;
2125 /* elz: added this case to capture the new instruction
2126 at the end of the return part of an export stub used by
2127 the PA2.0: BVE, n (rp) */
2128 else if ((curr_inst
& 0xffe0f000) == 0xe840d000)
2130 return (read_memory_integer
2131 (read_register (SP_REGNUM
) - 24, TARGET_PTR_BIT
/ 8)) & ~0x3;
2134 /* What about be,n 0(sr0,%rp)? It's just another way we return to
2135 the original caller from the stub. Used in dynamic executables. */
2136 else if (curr_inst
== 0xe0400002)
2138 /* The value we jump to is sitting in sp - 24. But that's
2139 loaded several instructions before the be instruction.
2140 I guess we could check for the previous instruction being
2141 mtsp %r1,%sr0 if we want to do sanity checking. */
2142 return (read_memory_integer
2143 (read_register (SP_REGNUM
) - 24, TARGET_PTR_BIT
/ 8)) & ~0x3;
2146 /* Haven't found the branch yet, but we're still in the stub.
2153 /* For the given instruction (INST), return any adjustment it makes
2154 to the stack pointer or zero for no adjustment.
2156 This only handles instructions commonly found in prologues. */
2159 prologue_inst_adjust_sp (unsigned long inst
)
2161 /* This must persist across calls. */
2162 static int save_high21
;
2164 /* The most common way to perform a stack adjustment ldo X(sp),sp */
2165 if ((inst
& 0xffffc000) == 0x37de0000)
2166 return extract_14 (inst
);
2169 if ((inst
& 0xffe00000) == 0x6fc00000)
2170 return extract_14 (inst
);
2172 /* std,ma X,D(sp) */
2173 if ((inst
& 0xffe00008) == 0x73c00008)
2174 return (inst
& 0x1 ? -1 << 13 : 0) | (((inst
>> 4) & 0x3ff) << 3);
2176 /* addil high21,%r1; ldo low11,(%r1),%r30)
2177 save high bits in save_high21 for later use. */
2178 if ((inst
& 0xffe00000) == 0x28200000)
2180 save_high21
= extract_21 (inst
);
2184 if ((inst
& 0xffff0000) == 0x343e0000)
2185 return save_high21
+ extract_14 (inst
);
2187 /* fstws as used by the HP compilers. */
2188 if ((inst
& 0xffffffe0) == 0x2fd01220)
2189 return extract_5_load (inst
);
2191 /* No adjustment. */
2195 /* Return nonzero if INST is a branch of some kind, else return zero. */
2198 is_branch (unsigned long inst
)
2227 /* Return the register number for a GR which is saved by INST or
2228 zero it INST does not save a GR. */
2231 inst_saves_gr (unsigned long inst
)
2233 /* Does it look like a stw? */
2234 if ((inst
>> 26) == 0x1a || (inst
>> 26) == 0x1b
2235 || (inst
>> 26) == 0x1f
2236 || ((inst
>> 26) == 0x1f
2237 && ((inst
>> 6) == 0xa)))
2238 return extract_5R_store (inst
);
2240 /* Does it look like a std? */
2241 if ((inst
>> 26) == 0x1c
2242 || ((inst
>> 26) == 0x03
2243 && ((inst
>> 6) & 0xf) == 0xb))
2244 return extract_5R_store (inst
);
2246 /* Does it look like a stwm? GCC & HPC may use this in prologues. */
2247 if ((inst
>> 26) == 0x1b)
2248 return extract_5R_store (inst
);
2250 /* Does it look like sth or stb? HPC versions 9.0 and later use these
2252 if ((inst
>> 26) == 0x19 || (inst
>> 26) == 0x18
2253 || ((inst
>> 26) == 0x3
2254 && (((inst
>> 6) & 0xf) == 0x8
2255 || (inst
>> 6) & 0xf) == 0x9))
2256 return extract_5R_store (inst
);
2261 /* Return the register number for a FR which is saved by INST or
2262 zero it INST does not save a FR.
2264 Note we only care about full 64bit register stores (that's the only
2265 kind of stores the prologue will use).
2267 FIXME: What about argument stores with the HP compiler in ANSI mode? */
2270 inst_saves_fr (unsigned long inst
)
2272 /* is this an FSTD ? */
2273 if ((inst
& 0xfc00dfc0) == 0x2c001200)
2274 return extract_5r_store (inst
);
2275 if ((inst
& 0xfc000002) == 0x70000002)
2276 return extract_5R_store (inst
);
2277 /* is this an FSTW ? */
2278 if ((inst
& 0xfc00df80) == 0x24001200)
2279 return extract_5r_store (inst
);
2280 if ((inst
& 0xfc000002) == 0x7c000000)
2281 return extract_5R_store (inst
);
2285 /* Advance PC across any function entry prologue instructions
2286 to reach some "real" code.
2288 Use information in the unwind table to determine what exactly should
2289 be in the prologue. */
2293 skip_prologue_hard_way (CORE_ADDR pc
)
2296 CORE_ADDR orig_pc
= pc
;
2297 unsigned long inst
, stack_remaining
, save_gr
, save_fr
, save_rp
, save_sp
;
2298 unsigned long args_stored
, status
, i
, restart_gr
, restart_fr
;
2299 struct unwind_table_entry
*u
;
2305 u
= find_unwind_entry (pc
);
2309 /* If we are not at the beginning of a function, then return now. */
2310 if ((pc
& ~0x3) != u
->region_start
)
2313 /* This is how much of a frame adjustment we need to account for. */
2314 stack_remaining
= u
->Total_frame_size
<< 3;
2316 /* Magic register saves we want to know about. */
2317 save_rp
= u
->Save_RP
;
2318 save_sp
= u
->Save_SP
;
2320 /* An indication that args may be stored into the stack. Unfortunately
2321 the HPUX compilers tend to set this in cases where no args were
2325 /* Turn the Entry_GR field into a bitmask. */
2327 for (i
= 3; i
< u
->Entry_GR
+ 3; i
++)
2329 /* Frame pointer gets saved into a special location. */
2330 if (u
->Save_SP
&& i
== DEPRECATED_FP_REGNUM
)
2333 save_gr
|= (1 << i
);
2335 save_gr
&= ~restart_gr
;
2337 /* Turn the Entry_FR field into a bitmask too. */
2339 for (i
= 12; i
< u
->Entry_FR
+ 12; i
++)
2340 save_fr
|= (1 << i
);
2341 save_fr
&= ~restart_fr
;
2343 /* Loop until we find everything of interest or hit a branch.
2345 For unoptimized GCC code and for any HP CC code this will never ever
2346 examine any user instructions.
2348 For optimzied GCC code we're faced with problems. GCC will schedule
2349 its prologue and make prologue instructions available for delay slot
2350 filling. The end result is user code gets mixed in with the prologue
2351 and a prologue instruction may be in the delay slot of the first branch
2354 Some unexpected things are expected with debugging optimized code, so
2355 we allow this routine to walk past user instructions in optimized
2357 while (save_gr
|| save_fr
|| save_rp
|| save_sp
|| stack_remaining
> 0
2360 unsigned int reg_num
;
2361 unsigned long old_stack_remaining
, old_save_gr
, old_save_fr
;
2362 unsigned long old_save_rp
, old_save_sp
, next_inst
;
2364 /* Save copies of all the triggers so we can compare them later
2366 old_save_gr
= save_gr
;
2367 old_save_fr
= save_fr
;
2368 old_save_rp
= save_rp
;
2369 old_save_sp
= save_sp
;
2370 old_stack_remaining
= stack_remaining
;
2372 status
= target_read_memory (pc
, buf
, 4);
2373 inst
= extract_unsigned_integer (buf
, 4);
2379 /* Note the interesting effects of this instruction. */
2380 stack_remaining
-= prologue_inst_adjust_sp (inst
);
2382 /* There are limited ways to store the return pointer into the
2384 if (inst
== 0x6bc23fd9 || inst
== 0x0fc212c1)
2387 /* These are the only ways we save SP into the stack. At this time
2388 the HP compilers never bother to save SP into the stack. */
2389 if ((inst
& 0xffffc000) == 0x6fc10000
2390 || (inst
& 0xffffc00c) == 0x73c10008)
2393 /* Are we loading some register with an offset from the argument
2395 if ((inst
& 0xffe00000) == 0x37a00000
2396 || (inst
& 0xffffffe0) == 0x081d0240)
2402 /* Account for general and floating-point register saves. */
2403 reg_num
= inst_saves_gr (inst
);
2404 save_gr
&= ~(1 << reg_num
);
2406 /* Ugh. Also account for argument stores into the stack.
2407 Unfortunately args_stored only tells us that some arguments
2408 where stored into the stack. Not how many or what kind!
2410 This is a kludge as on the HP compiler sets this bit and it
2411 never does prologue scheduling. So once we see one, skip past
2412 all of them. We have similar code for the fp arg stores below.
2414 FIXME. Can still die if we have a mix of GR and FR argument
2416 if (reg_num
>= (TARGET_PTR_BIT
== 64 ? 19 : 23) && reg_num
<= 26)
2418 while (reg_num
>= (TARGET_PTR_BIT
== 64 ? 19 : 23) && reg_num
<= 26)
2421 status
= target_read_memory (pc
, buf
, 4);
2422 inst
= extract_unsigned_integer (buf
, 4);
2425 reg_num
= inst_saves_gr (inst
);
2431 reg_num
= inst_saves_fr (inst
);
2432 save_fr
&= ~(1 << reg_num
);
2434 status
= target_read_memory (pc
+ 4, buf
, 4);
2435 next_inst
= extract_unsigned_integer (buf
, 4);
2441 /* We've got to be read to handle the ldo before the fp register
2443 if ((inst
& 0xfc000000) == 0x34000000
2444 && inst_saves_fr (next_inst
) >= 4
2445 && inst_saves_fr (next_inst
) <= (TARGET_PTR_BIT
== 64 ? 11 : 7))
2447 /* So we drop into the code below in a reasonable state. */
2448 reg_num
= inst_saves_fr (next_inst
);
2452 /* Ugh. Also account for argument stores into the stack.
2453 This is a kludge as on the HP compiler sets this bit and it
2454 never does prologue scheduling. So once we see one, skip past
2456 if (reg_num
>= 4 && reg_num
<= (TARGET_PTR_BIT
== 64 ? 11 : 7))
2458 while (reg_num
>= 4 && reg_num
<= (TARGET_PTR_BIT
== 64 ? 11 : 7))
2461 status
= target_read_memory (pc
, buf
, 4);
2462 inst
= extract_unsigned_integer (buf
, 4);
2465 if ((inst
& 0xfc000000) != 0x34000000)
2467 status
= target_read_memory (pc
+ 4, buf
, 4);
2468 next_inst
= extract_unsigned_integer (buf
, 4);
2471 reg_num
= inst_saves_fr (next_inst
);
2477 /* Quit if we hit any kind of branch. This can happen if a prologue
2478 instruction is in the delay slot of the first call/branch. */
2479 if (is_branch (inst
))
2482 /* What a crock. The HP compilers set args_stored even if no
2483 arguments were stored into the stack (boo hiss). This could
2484 cause this code to then skip a bunch of user insns (up to the
2487 To combat this we try to identify when args_stored was bogusly
2488 set and clear it. We only do this when args_stored is nonzero,
2489 all other resources are accounted for, and nothing changed on
2492 && !(save_gr
|| save_fr
|| save_rp
|| save_sp
|| stack_remaining
> 0)
2493 && old_save_gr
== save_gr
&& old_save_fr
== save_fr
2494 && old_save_rp
== save_rp
&& old_save_sp
== save_sp
2495 && old_stack_remaining
== stack_remaining
)
2502 /* We've got a tenative location for the end of the prologue. However
2503 because of limitations in the unwind descriptor mechanism we may
2504 have went too far into user code looking for the save of a register
2505 that does not exist. So, if there registers we expected to be saved
2506 but never were, mask them out and restart.
2508 This should only happen in optimized code, and should be very rare. */
2509 if (save_gr
|| (save_fr
&& !(restart_fr
|| restart_gr
)))
2512 restart_gr
= save_gr
;
2513 restart_fr
= save_fr
;
2521 /* Return the address of the PC after the last prologue instruction if
2522 we can determine it from the debug symbols. Else return zero. */
2525 after_prologue (CORE_ADDR pc
)
2527 struct symtab_and_line sal
;
2528 CORE_ADDR func_addr
, func_end
;
2531 /* If we can not find the symbol in the partial symbol table, then
2532 there is no hope we can determine the function's start address
2534 if (!find_pc_partial_function (pc
, NULL
, &func_addr
, &func_end
))
2537 /* Get the line associated with FUNC_ADDR. */
2538 sal
= find_pc_line (func_addr
, 0);
2540 /* There are only two cases to consider. First, the end of the source line
2541 is within the function bounds. In that case we return the end of the
2542 source line. Second is the end of the source line extends beyond the
2543 bounds of the current function. We need to use the slow code to
2544 examine instructions in that case.
2546 Anything else is simply a bug elsewhere. Fixing it here is absolutely
2547 the wrong thing to do. In fact, it should be entirely possible for this
2548 function to always return zero since the slow instruction scanning code
2549 is supposed to *always* work. If it does not, then it is a bug. */
2550 if (sal
.end
< func_end
)
2556 /* To skip prologues, I use this predicate. Returns either PC itself
2557 if the code at PC does not look like a function prologue; otherwise
2558 returns an address that (if we're lucky) follows the prologue. If
2559 LENIENT, then we must skip everything which is involved in setting
2560 up the frame (it's OK to skip more, just so long as we don't skip
2561 anything which might clobber the registers which are being saved.
2562 Currently we must not skip more on the alpha, but we might the lenient
2566 hppa_skip_prologue (CORE_ADDR pc
)
2570 CORE_ADDR post_prologue_pc
;
2573 /* See if we can determine the end of the prologue via the symbol table.
2574 If so, then return either PC, or the PC after the prologue, whichever
2577 post_prologue_pc
= after_prologue (pc
);
2579 /* If after_prologue returned a useful address, then use it. Else
2580 fall back on the instruction skipping code.
2582 Some folks have claimed this causes problems because the breakpoint
2583 may be the first instruction of the prologue. If that happens, then
2584 the instruction skipping code has a bug that needs to be fixed. */
2585 if (post_prologue_pc
!= 0)
2586 return max (pc
, post_prologue_pc
);
2588 return (skip_prologue_hard_way (pc
));
2591 struct hppa_frame_cache
2594 struct trad_frame_saved_reg
*saved_regs
;
2597 static struct hppa_frame_cache
*
2598 hppa_frame_cache (struct frame_info
*next_frame
, void **this_cache
)
2600 struct hppa_frame_cache
*cache
;
2605 struct unwind_table_entry
*u
;
2608 if ((*this_cache
) != NULL
)
2609 return (*this_cache
);
2610 cache
= FRAME_OBSTACK_ZALLOC (struct hppa_frame_cache
);
2611 (*this_cache
) = cache
;
2612 cache
->saved_regs
= trad_frame_alloc_saved_regs (next_frame
);
2615 u
= find_unwind_entry (frame_func_unwind (next_frame
));
2617 return (*this_cache
);
2619 /* Turn the Entry_GR field into a bitmask. */
2621 for (i
= 3; i
< u
->Entry_GR
+ 3; i
++)
2623 /* Frame pointer gets saved into a special location. */
2624 if (u
->Save_SP
&& i
== DEPRECATED_FP_REGNUM
)
2627 saved_gr_mask
|= (1 << i
);
2630 /* Turn the Entry_FR field into a bitmask too. */
2632 for (i
= 12; i
< u
->Entry_FR
+ 12; i
++)
2633 saved_fr_mask
|= (1 << i
);
2635 /* Loop until we find everything of interest or hit a branch.
2637 For unoptimized GCC code and for any HP CC code this will never ever
2638 examine any user instructions.
2640 For optimized GCC code we're faced with problems. GCC will schedule
2641 its prologue and make prologue instructions available for delay slot
2642 filling. The end result is user code gets mixed in with the prologue
2643 and a prologue instruction may be in the delay slot of the first branch
2646 Some unexpected things are expected with debugging optimized code, so
2647 we allow this routine to walk past user instructions in optimized
2650 int final_iteration
= 0;
2652 CORE_ADDR end_pc
= skip_prologue_using_sal (pc
);
2653 int looking_for_sp
= u
->Save_SP
;
2654 int looking_for_rp
= u
->Save_RP
;
2657 end_pc
= frame_pc_unwind (next_frame
);
2659 for (pc
= frame_func_unwind (next_frame
);
2660 ((saved_gr_mask
|| saved_fr_mask
2661 || looking_for_sp
|| looking_for_rp
2662 || frame_size
< (u
->Total_frame_size
<< 3))
2668 long status
= target_read_memory (pc
, buf4
, sizeof buf4
);
2669 long inst
= extract_unsigned_integer (buf4
, sizeof buf4
);
2671 /* Note the interesting effects of this instruction. */
2672 frame_size
+= prologue_inst_adjust_sp (inst
);
2674 /* There are limited ways to store the return pointer into the
2676 if (inst
== 0x6bc23fd9) /* stw rp,-0x14(sr0,sp) */
2679 cache
->saved_regs
[RP_REGNUM
].addr
= -20;
2681 else if (inst
== 0x0fc212c1) /* std rp,-0x10(sr0,sp) */
2684 cache
->saved_regs
[RP_REGNUM
].addr
= -16;
2687 /* Check to see if we saved SP into the stack. This also
2688 happens to indicate the location of the saved frame
2690 if ((inst
& 0xffffc000) == 0x6fc10000 /* stw,ma r1,N(sr0,sp) */
2691 || (inst
& 0xffffc00c) == 0x73c10008) /* std,ma r1,N(sr0,sp) */
2694 cache
->saved_regs
[DEPRECATED_FP_REGNUM
].addr
= 0;
2697 /* Account for general and floating-point register saves. */
2698 reg
= inst_saves_gr (inst
);
2699 if (reg
>= 3 && reg
<= 18
2700 && (!u
->Save_SP
|| reg
!= DEPRECATED_FP_REGNUM
))
2702 saved_gr_mask
&= ~(1 << reg
);
2703 if ((inst
>> 26) == 0x1b && extract_14 (inst
) >= 0)
2704 /* stwm with a positive displacement is a _post_
2706 cache
->saved_regs
[reg
].addr
= 0;
2707 else if ((inst
& 0xfc00000c) == 0x70000008)
2708 /* A std has explicit post_modify forms. */
2709 cache
->saved_regs
[reg
].addr
= 0;
2714 if ((inst
>> 26) == 0x1c)
2715 offset
= (inst
& 0x1 ? -1 << 13 : 0) | (((inst
>> 4) & 0x3ff) << 3);
2716 else if ((inst
>> 26) == 0x03)
2717 offset
= low_sign_extend (inst
& 0x1f, 5);
2719 offset
= extract_14 (inst
);
2721 /* Handle code with and without frame pointers. */
2723 cache
->saved_regs
[reg
].addr
= offset
;
2725 cache
->saved_regs
[reg
].addr
= (u
->Total_frame_size
<< 3) + offset
;
2729 /* GCC handles callee saved FP regs a little differently.
2731 It emits an instruction to put the value of the start of
2732 the FP store area into %r1. It then uses fstds,ma with a
2733 basereg of %r1 for the stores.
2735 HP CC emits them at the current stack pointer modifying the
2736 stack pointer as it stores each register. */
2738 /* ldo X(%r3),%r1 or ldo X(%r30),%r1. */
2739 if ((inst
& 0xffffc000) == 0x34610000
2740 || (inst
& 0xffffc000) == 0x37c10000)
2741 fp_loc
= extract_14 (inst
);
2743 reg
= inst_saves_fr (inst
);
2744 if (reg
>= 12 && reg
<= 21)
2746 /* Note +4 braindamage below is necessary because the FP
2747 status registers are internally 8 registers rather than
2748 the expected 4 registers. */
2749 saved_fr_mask
&= ~(1 << reg
);
2752 /* 1st HP CC FP register store. After this
2753 instruction we've set enough state that the GCC and
2754 HPCC code are both handled in the same manner. */
2755 cache
->saved_regs
[reg
+ FP4_REGNUM
+ 4].addr
= 0;
2760 cache
->saved_regs
[reg
+ FP0_REGNUM
+ 4].addr
= fp_loc
;
2765 /* Quit if we hit any kind of branch the previous iteration. */
2766 if (final_iteration
)
2768 /* We want to look precisely one instruction beyond the branch
2769 if we have not found everything yet. */
2770 if (is_branch (inst
))
2771 final_iteration
= 1;
2776 /* The frame base always represents the value of %sp at entry to
2777 the current function (and is thus equivalent to the "saved"
2779 CORE_ADDR this_sp
= frame_unwind_register_unsigned (next_frame
, SP_REGNUM
);
2780 /* FIXME: cagney/2004-02-22: This assumes that the frame has been
2781 created. If it hasn't everything will be out-of-wack. */
2782 if (u
->Save_SP
&& trad_frame_addr_p (cache
->saved_regs
, SP_REGNUM
))
2783 /* Both we're expecting the SP to be saved and the SP has been
2784 saved. The entry SP value is saved at this frame's SP
2786 cache
->base
= read_memory_integer (this_sp
, TARGET_PTR_BIT
/ 8);
2788 /* The prologue has been slowly allocating stack space. Adjust
2790 cache
->base
= this_sp
- frame_size
;
2791 trad_frame_set_value (cache
->saved_regs
, SP_REGNUM
, cache
->base
);
2794 /* The PC is found in the "return register", "Millicode" uses "r31"
2795 as the return register while normal code uses "rp". */
2797 cache
->saved_regs
[PCOQ_HEAD_REGNUM
] = cache
->saved_regs
[31];
2799 cache
->saved_regs
[PCOQ_HEAD_REGNUM
] = cache
->saved_regs
[RP_REGNUM
];
2802 /* Convert all the offsets into addresses. */
2804 for (reg
= 0; reg
< NUM_REGS
; reg
++)
2806 if (trad_frame_addr_p (cache
->saved_regs
, reg
))
2807 cache
->saved_regs
[reg
].addr
+= cache
->base
;
2811 return (*this_cache
);
2815 hppa_frame_this_id (struct frame_info
*next_frame
, void **this_cache
,
2816 struct frame_id
*this_id
)
2818 struct hppa_frame_cache
*info
= hppa_frame_cache (next_frame
, this_cache
);
2819 (*this_id
) = frame_id_build (info
->base
, frame_func_unwind (next_frame
));
2823 hppa_frame_prev_register (struct frame_info
*next_frame
,
2825 int regnum
, int *optimizedp
,
2826 enum lval_type
*lvalp
, CORE_ADDR
*addrp
,
2827 int *realnump
, void *valuep
)
2829 struct hppa_frame_cache
*info
= hppa_frame_cache (next_frame
, this_cache
);
2830 struct gdbarch
*gdbarch
= get_frame_arch (next_frame
);
2831 if (regnum
== PCOQ_TAIL_REGNUM
)
2833 /* The PCOQ TAIL, or NPC, needs to be computed from the unwound
2841 int regsize
= register_size (gdbarch
, PCOQ_HEAD_REGNUM
);
2844 enum lval_type lval
;
2847 bfd_byte value
[MAX_REGISTER_SIZE
];
2848 trad_frame_prev_register (next_frame
, info
->saved_regs
,
2849 PCOQ_HEAD_REGNUM
, &optimized
, &lval
, &addr
,
2851 pc
= extract_unsigned_integer (&value
, regsize
);
2852 store_unsigned_integer (valuep
, regsize
, pc
+ 4);
2857 trad_frame_prev_register (next_frame
, info
->saved_regs
, regnum
,
2858 optimizedp
, lvalp
, addrp
, realnump
, valuep
);
2862 static const struct frame_unwind hppa_frame_unwind
=
2866 hppa_frame_prev_register
2869 static const struct frame_unwind
*
2870 hppa_frame_unwind_sniffer (struct frame_info
*next_frame
)
2872 return &hppa_frame_unwind
;
2876 hppa_frame_base_address (struct frame_info
*next_frame
,
2879 struct hppa_frame_cache
*info
= hppa_frame_cache (next_frame
,
2884 static const struct frame_base hppa_frame_base
= {
2886 hppa_frame_base_address
,
2887 hppa_frame_base_address
,
2888 hppa_frame_base_address
2891 static const struct frame_base
*
2892 hppa_frame_base_sniffer (struct frame_info
*next_frame
)
2894 return &hppa_frame_base
;
2897 static struct frame_id
2898 hppa_unwind_dummy_id (struct gdbarch
*gdbarch
, struct frame_info
*next_frame
)
2900 return frame_id_build (frame_unwind_register_unsigned (next_frame
,
2902 frame_pc_unwind (next_frame
));
2906 hppa_unwind_pc (struct gdbarch
*gdbarch
, struct frame_info
*next_frame
)
2908 return frame_unwind_register_signed (next_frame
, PCOQ_HEAD_REGNUM
) & ~3;
2911 /* Exception handling support for the HP-UX ANSI C++ compiler.
2912 The compiler (aCC) provides a callback for exception events;
2913 GDB can set a breakpoint on this callback and find out what
2914 exception event has occurred. */
2916 /* The name of the hook to be set to point to the callback function */
2917 static char HP_ACC_EH_notify_hook
[] = "__eh_notify_hook";
2918 /* The name of the function to be used to set the hook value */
2919 static char HP_ACC_EH_set_hook_value
[] = "__eh_set_hook_value";
2920 /* The name of the callback function in end.o */
2921 static char HP_ACC_EH_notify_callback
[] = "__d_eh_notify_callback";
2922 /* Name of function in end.o on which a break is set (called by above) */
2923 static char HP_ACC_EH_break
[] = "__d_eh_break";
2924 /* Name of flag (in end.o) that enables catching throws */
2925 static char HP_ACC_EH_catch_throw
[] = "__d_eh_catch_throw";
2926 /* Name of flag (in end.o) that enables catching catching */
2927 static char HP_ACC_EH_catch_catch
[] = "__d_eh_catch_catch";
2928 /* The enum used by aCC */
2936 /* Is exception-handling support available with this executable? */
2937 static int hp_cxx_exception_support
= 0;
2938 /* Has the initialize function been run? */
2939 int hp_cxx_exception_support_initialized
= 0;
2940 /* Similar to above, but imported from breakpoint.c -- non-target-specific */
2941 extern int exception_support_initialized
;
2942 /* Address of __eh_notify_hook */
2943 static CORE_ADDR eh_notify_hook_addr
= 0;
2944 /* Address of __d_eh_notify_callback */
2945 static CORE_ADDR eh_notify_callback_addr
= 0;
2946 /* Address of __d_eh_break */
2947 static CORE_ADDR eh_break_addr
= 0;
2948 /* Address of __d_eh_catch_catch */
2949 static CORE_ADDR eh_catch_catch_addr
= 0;
2950 /* Address of __d_eh_catch_throw */
2951 static CORE_ADDR eh_catch_throw_addr
= 0;
2952 /* Sal for __d_eh_break */
2953 static struct symtab_and_line
*break_callback_sal
= 0;
2955 /* Code in end.c expects __d_pid to be set in the inferior,
2956 otherwise __d_eh_notify_callback doesn't bother to call
2957 __d_eh_break! So we poke the pid into this symbol
2962 setup_d_pid_in_inferior (void)
2965 struct minimal_symbol
*msymbol
;
2966 char buf
[4]; /* FIXME 32x64? */
2968 /* Slam the pid of the process into __d_pid; failing is only a warning! */
2969 msymbol
= lookup_minimal_symbol ("__d_pid", NULL
, symfile_objfile
);
2970 if (msymbol
== NULL
)
2972 warning ("Unable to find __d_pid symbol in object file.");
2973 warning ("Suggest linking executable with -g (links in /opt/langtools/lib/end.o).");
2977 anaddr
= SYMBOL_VALUE_ADDRESS (msymbol
);
2978 store_unsigned_integer (buf
, 4, PIDGET (inferior_ptid
)); /* FIXME 32x64? */
2979 if (target_write_memory (anaddr
, buf
, 4)) /* FIXME 32x64? */
2981 warning ("Unable to write __d_pid");
2982 warning ("Suggest linking executable with -g (links in /opt/langtools/lib/end.o).");
2988 /* Initialize exception catchpoint support by looking for the
2989 necessary hooks/callbacks in end.o, etc., and set the hook value to
2990 point to the required debug function
2996 initialize_hp_cxx_exception_support (void)
2998 struct symtabs_and_lines sals
;
2999 struct cleanup
*old_chain
;
3000 struct cleanup
*canonical_strings_chain
= NULL
;
3003 char *addr_end
= NULL
;
3004 char **canonical
= (char **) NULL
;
3006 struct symbol
*sym
= NULL
;
3007 struct minimal_symbol
*msym
= NULL
;
3008 struct objfile
*objfile
;
3009 asection
*shlib_info
;
3011 /* Detect and disallow recursion. On HP-UX with aCC, infinite
3012 recursion is a possibility because finding the hook for exception
3013 callbacks involves making a call in the inferior, which means
3014 re-inserting breakpoints which can re-invoke this code */
3016 static int recurse
= 0;
3019 hp_cxx_exception_support_initialized
= 0;
3020 exception_support_initialized
= 0;
3024 hp_cxx_exception_support
= 0;
3026 /* First check if we have seen any HP compiled objects; if not,
3027 it is very unlikely that HP's idiosyncratic callback mechanism
3028 for exception handling debug support will be available!
3029 This will percolate back up to breakpoint.c, where our callers
3030 will decide to try the g++ exception-handling support instead. */
3031 if (!hp_som_som_object_present
)
3034 /* We have a SOM executable with SOM debug info; find the hooks */
3036 /* First look for the notify hook provided by aCC runtime libs */
3037 /* If we find this symbol, we conclude that the executable must
3038 have HP aCC exception support built in. If this symbol is not
3039 found, even though we're a HP SOM-SOM file, we may have been
3040 built with some other compiler (not aCC). This results percolates
3041 back up to our callers in breakpoint.c which can decide to
3042 try the g++ style of exception support instead.
3043 If this symbol is found but the other symbols we require are
3044 not found, there is something weird going on, and g++ support
3045 should *not* be tried as an alternative.
3047 ASSUMPTION: Only HP aCC code will have __eh_notify_hook defined.
3048 ASSUMPTION: HP aCC and g++ modules cannot be linked together. */
3050 /* libCsup has this hook; it'll usually be non-debuggable */
3051 msym
= lookup_minimal_symbol (HP_ACC_EH_notify_hook
, NULL
, NULL
);
3054 eh_notify_hook_addr
= SYMBOL_VALUE_ADDRESS (msym
);
3055 hp_cxx_exception_support
= 1;
3059 warning ("Unable to find exception callback hook (%s).", HP_ACC_EH_notify_hook
);
3060 warning ("Executable may not have been compiled debuggable with HP aCC.");
3061 warning ("GDB will be unable to intercept exception events.");
3062 eh_notify_hook_addr
= 0;
3063 hp_cxx_exception_support
= 0;
3067 /* Next look for the notify callback routine in end.o */
3068 /* This is always available in the SOM symbol dictionary if end.o is linked in */
3069 msym
= lookup_minimal_symbol (HP_ACC_EH_notify_callback
, NULL
, NULL
);
3072 eh_notify_callback_addr
= SYMBOL_VALUE_ADDRESS (msym
);
3073 hp_cxx_exception_support
= 1;
3077 warning ("Unable to find exception callback routine (%s).", HP_ACC_EH_notify_callback
);
3078 warning ("Suggest linking executable with -g (links in /opt/langtools/lib/end.o).");
3079 warning ("GDB will be unable to intercept exception events.");
3080 eh_notify_callback_addr
= 0;
3084 #ifndef GDB_TARGET_IS_HPPA_20W
3085 /* Check whether the executable is dynamically linked or archive bound */
3086 /* With an archive-bound executable we can use the raw addresses we find
3087 for the callback function, etc. without modification. For an executable
3088 with shared libraries, we have to do more work to find the plabel, which
3089 can be the target of a call through $$dyncall from the aCC runtime support
3090 library (libCsup) which is linked shared by default by aCC. */
3091 /* This test below was copied from somsolib.c/somread.c. It may not be a very
3092 reliable one to test that an executable is linked shared. pai/1997-07-18 */
3093 shlib_info
= bfd_get_section_by_name (symfile_objfile
->obfd
, "$SHLIB_INFO$");
3094 if (shlib_info
&& (bfd_section_size (symfile_objfile
->obfd
, shlib_info
) != 0))
3096 /* The minsym we have has the local code address, but that's not the
3097 plabel that can be used by an inter-load-module call. */
3098 /* Find solib handle for main image (which has end.o), and use that
3099 and the min sym as arguments to __d_shl_get() (which does the equivalent
3100 of shl_findsym()) to find the plabel. */
3102 args_for_find_stub args
;
3103 static char message
[] = "Error while finding exception callback hook:\n";
3105 args
.solib_handle
= som_solib_get_solib_by_pc (eh_notify_callback_addr
);
3107 args
.return_val
= 0;
3110 catch_errors (cover_find_stub_with_shl_get
, &args
, message
,
3112 eh_notify_callback_addr
= args
.return_val
;
3115 exception_catchpoints_are_fragile
= 1;
3117 if (!eh_notify_callback_addr
)
3119 /* We can get here either if there is no plabel in the export list
3120 for the main image, or if something strange happened (?) */
3121 warning ("Couldn't find a plabel (indirect function label) for the exception callback.");
3122 warning ("GDB will not be able to intercept exception events.");
3127 exception_catchpoints_are_fragile
= 0;
3130 /* Now, look for the breakpointable routine in end.o */
3131 /* This should also be available in the SOM symbol dict. if end.o linked in */
3132 msym
= lookup_minimal_symbol (HP_ACC_EH_break
, NULL
, NULL
);
3135 eh_break_addr
= SYMBOL_VALUE_ADDRESS (msym
);
3136 hp_cxx_exception_support
= 1;
3140 warning ("Unable to find exception callback routine to set breakpoint (%s).", HP_ACC_EH_break
);
3141 warning ("Suggest linking executable with -g (link in /opt/langtools/lib/end.o).");
3142 warning ("GDB will be unable to intercept exception events.");
3147 /* Next look for the catch enable flag provided in end.o */
3148 sym
= lookup_symbol (HP_ACC_EH_catch_catch
, (struct block
*) NULL
,
3149 VAR_DOMAIN
, 0, (struct symtab
**) NULL
);
3150 if (sym
) /* sometimes present in debug info */
3152 eh_catch_catch_addr
= SYMBOL_VALUE_ADDRESS (sym
);
3153 hp_cxx_exception_support
= 1;
3156 /* otherwise look in SOM symbol dict. */
3158 msym
= lookup_minimal_symbol (HP_ACC_EH_catch_catch
, NULL
, NULL
);
3161 eh_catch_catch_addr
= SYMBOL_VALUE_ADDRESS (msym
);
3162 hp_cxx_exception_support
= 1;
3166 warning ("Unable to enable interception of exception catches.");
3167 warning ("Executable may not have been compiled debuggable with HP aCC.");
3168 warning ("Suggest linking executable with -g (link in /opt/langtools/lib/end.o).");
3173 /* Next look for the catch enable flag provided end.o */
3174 sym
= lookup_symbol (HP_ACC_EH_catch_catch
, (struct block
*) NULL
,
3175 VAR_DOMAIN
, 0, (struct symtab
**) NULL
);
3176 if (sym
) /* sometimes present in debug info */
3178 eh_catch_throw_addr
= SYMBOL_VALUE_ADDRESS (sym
);
3179 hp_cxx_exception_support
= 1;
3182 /* otherwise look in SOM symbol dict. */
3184 msym
= lookup_minimal_symbol (HP_ACC_EH_catch_throw
, NULL
, NULL
);
3187 eh_catch_throw_addr
= SYMBOL_VALUE_ADDRESS (msym
);
3188 hp_cxx_exception_support
= 1;
3192 warning ("Unable to enable interception of exception throws.");
3193 warning ("Executable may not have been compiled debuggable with HP aCC.");
3194 warning ("Suggest linking executable with -g (link in /opt/langtools/lib/end.o).");
3200 hp_cxx_exception_support
= 2; /* everything worked so far */
3201 hp_cxx_exception_support_initialized
= 1;
3202 exception_support_initialized
= 1;
3207 /* Target operation for enabling or disabling interception of
3209 KIND is either EX_EVENT_THROW or EX_EVENT_CATCH
3210 ENABLE is either 0 (disable) or 1 (enable).
3211 Return value is NULL if no support found;
3212 -1 if something went wrong,
3213 or a pointer to a symtab/line struct if the breakpointable
3214 address was found. */
3216 struct symtab_and_line
*
3217 child_enable_exception_callback (enum exception_event_kind kind
, int enable
)
3221 if (!exception_support_initialized
|| !hp_cxx_exception_support_initialized
)
3222 if (!initialize_hp_cxx_exception_support ())
3225 switch (hp_cxx_exception_support
)
3228 /* Assuming no HP support at all */
3231 /* HP support should be present, but something went wrong */
3232 return (struct symtab_and_line
*) -1; /* yuck! */
3233 /* there may be other cases in the future */
3236 /* Set the EH hook to point to the callback routine */
3237 store_unsigned_integer (buf
, 4, enable
? eh_notify_callback_addr
: 0); /* FIXME 32x64 problem */
3238 /* pai: (temp) FIXME should there be a pack operation first? */
3239 if (target_write_memory (eh_notify_hook_addr
, buf
, 4)) /* FIXME 32x64 problem */
3241 warning ("Could not write to target memory for exception event callback.");
3242 warning ("Interception of exception events may not work.");
3243 return (struct symtab_and_line
*) -1;
3247 /* Ensure that __d_pid is set up correctly -- end.c code checks this. :-( */
3248 if (PIDGET (inferior_ptid
) > 0)
3250 if (setup_d_pid_in_inferior ())
3251 return (struct symtab_and_line
*) -1;
3255 warning ("Internal error: Invalid inferior pid? Cannot intercept exception events.");
3256 return (struct symtab_and_line
*) -1;
3262 case EX_EVENT_THROW
:
3263 store_unsigned_integer (buf
, 4, enable
? 1 : 0);
3264 if (target_write_memory (eh_catch_throw_addr
, buf
, 4)) /* FIXME 32x64? */
3266 warning ("Couldn't enable exception throw interception.");
3267 return (struct symtab_and_line
*) -1;
3270 case EX_EVENT_CATCH
:
3271 store_unsigned_integer (buf
, 4, enable
? 1 : 0);
3272 if (target_write_memory (eh_catch_catch_addr
, buf
, 4)) /* FIXME 32x64? */
3274 warning ("Couldn't enable exception catch interception.");
3275 return (struct symtab_and_line
*) -1;
3279 error ("Request to enable unknown or unsupported exception event.");
3282 /* Copy break address into new sal struct, malloc'ing if needed. */
3283 if (!break_callback_sal
)
3285 break_callback_sal
= (struct symtab_and_line
*) xmalloc (sizeof (struct symtab_and_line
));
3287 init_sal (break_callback_sal
);
3288 break_callback_sal
->symtab
= NULL
;
3289 break_callback_sal
->pc
= eh_break_addr
;
3290 break_callback_sal
->line
= 0;
3291 break_callback_sal
->end
= eh_break_addr
;
3293 return break_callback_sal
;
3296 /* Record some information about the current exception event */
3297 static struct exception_event_record current_ex_event
;
3298 /* Convenience struct */
3299 static struct symtab_and_line null_symtab_and_line
=
3302 /* Report current exception event. Returns a pointer to a record
3303 that describes the kind of the event, where it was thrown from,
3304 and where it will be caught. More information may be reported
3306 struct exception_event_record
*
3307 child_get_current_exception_event (void)
3309 CORE_ADDR event_kind
;
3310 CORE_ADDR throw_addr
;
3311 CORE_ADDR catch_addr
;
3312 struct frame_info
*fi
, *curr_frame
;
3315 curr_frame
= get_current_frame ();
3317 return (struct exception_event_record
*) NULL
;
3319 /* Go up one frame to __d_eh_notify_callback, because at the
3320 point when this code is executed, there's garbage in the
3321 arguments of __d_eh_break. */
3322 fi
= find_relative_frame (curr_frame
, &level
);
3324 return (struct exception_event_record
*) NULL
;
3328 /* Read in the arguments */
3329 /* __d_eh_notify_callback() is called with 3 arguments:
3330 1. event kind catch or throw
3331 2. the target address if known
3332 3. a flag -- not sure what this is. pai/1997-07-17 */
3333 event_kind
= read_register (ARG0_REGNUM
);
3334 catch_addr
= read_register (ARG1_REGNUM
);
3336 /* Now go down to a user frame */
3337 /* For a throw, __d_eh_break is called by
3338 __d_eh_notify_callback which is called by
3339 __notify_throw which is called
3341 For a catch, __d_eh_break is called by
3342 __d_eh_notify_callback which is called by
3343 <stackwalking stuff> which is called by
3344 __throw__<stuff> or __rethrow_<stuff> which is called
3346 /* FIXME: Don't use such magic numbers; search for the frames */
3347 level
= (event_kind
== EX_EVENT_THROW
) ? 3 : 4;
3348 fi
= find_relative_frame (curr_frame
, &level
);
3350 return (struct exception_event_record
*) NULL
;
3353 throw_addr
= get_frame_pc (fi
);
3355 /* Go back to original (top) frame */
3356 select_frame (curr_frame
);
3358 current_ex_event
.kind
= (enum exception_event_kind
) event_kind
;
3359 current_ex_event
.throw_sal
= find_pc_line (throw_addr
, 1);
3360 current_ex_event
.catch_sal
= find_pc_line (catch_addr
, 1);
3362 return ¤t_ex_event
;
3365 /* Instead of this nasty cast, add a method pvoid() that prints out a
3366 host VOID data type (remember %p isn't portable). */
3369 hppa_pointer_to_address_hack (void *ptr
)
3371 gdb_assert (sizeof (ptr
) == TYPE_LENGTH (builtin_type_void_data_ptr
));
3372 return POINTER_TO_ADDRESS (builtin_type_void_data_ptr
, &ptr
);
3376 unwind_command (char *exp
, int from_tty
)
3379 struct unwind_table_entry
*u
;
3381 /* If we have an expression, evaluate it and use it as the address. */
3383 if (exp
!= 0 && *exp
!= 0)
3384 address
= parse_and_eval_address (exp
);
3388 u
= find_unwind_entry (address
);
3392 printf_unfiltered ("Can't find unwind table entry for %s\n", exp
);
3396 printf_unfiltered ("unwind_table_entry (0x%s):\n",
3397 paddr_nz (hppa_pointer_to_address_hack (u
)));
3399 printf_unfiltered ("\tregion_start = ");
3400 print_address (u
->region_start
, gdb_stdout
);
3402 printf_unfiltered ("\n\tregion_end = ");
3403 print_address (u
->region_end
, gdb_stdout
);
3405 #define pif(FLD) if (u->FLD) printf_unfiltered (" "#FLD);
3407 printf_unfiltered ("\n\tflags =");
3408 pif (Cannot_unwind
);
3410 pif (Millicode_save_sr0
);
3413 pif (Variable_Frame
);
3414 pif (Separate_Package_Body
);
3415 pif (Frame_Extension_Millicode
);
3416 pif (Stack_Overflow_Check
);
3417 pif (Two_Instruction_SP_Increment
);
3421 pif (Save_MRP_in_frame
);
3422 pif (extn_ptr_defined
);
3423 pif (Cleanup_defined
);
3424 pif (MPE_XL_interrupt_marker
);
3425 pif (HP_UX_interrupt_marker
);
3428 putchar_unfiltered ('\n');
3430 #define pin(FLD) printf_unfiltered ("\t"#FLD" = 0x%x\n", u->FLD);
3432 pin (Region_description
);
3435 pin (Total_frame_size
);
3439 hppa_skip_permanent_breakpoint (void)
3441 /* To step over a breakpoint instruction on the PA takes some
3442 fiddling with the instruction address queue.
3444 When we stop at a breakpoint, the IA queue front (the instruction
3445 we're executing now) points at the breakpoint instruction, and
3446 the IA queue back (the next instruction to execute) points to
3447 whatever instruction we would execute after the breakpoint, if it
3448 were an ordinary instruction. This is the case even if the
3449 breakpoint is in the delay slot of a branch instruction.
3451 Clearly, to step past the breakpoint, we need to set the queue
3452 front to the back. But what do we put in the back? What
3453 instruction comes after that one? Because of the branch delay
3454 slot, the next insn is always at the back + 4. */
3455 write_register (PCOQ_HEAD_REGNUM
, read_register (PCOQ_TAIL_REGNUM
));
3456 write_register (PCSQ_HEAD_REGNUM
, read_register (PCSQ_TAIL_REGNUM
));
3458 write_register (PCOQ_TAIL_REGNUM
, read_register (PCOQ_TAIL_REGNUM
) + 4);
3459 /* We can leave the tail's space the same, since there's no jump. */
3463 hppa_reg_struct_has_addr (int gcc_p
, struct type
*type
)
3465 /* On the PA, any pass-by-value structure > 8 bytes is actually passed
3466 via a pointer regardless of its type or the compiler used. */
3467 return (TYPE_LENGTH (type
) > 8);
3471 hppa_inner_than (CORE_ADDR lhs
, CORE_ADDR rhs
)
3473 /* Stack grows upward */
3478 hppa_pc_requires_run_before_use (CORE_ADDR pc
)
3480 /* Sometimes we may pluck out a minimal symbol that has a negative address.
3482 An example of this occurs when an a.out is linked against a foo.sl.
3483 The foo.sl defines a global bar(), and the a.out declares a signature
3484 for bar(). However, the a.out doesn't directly call bar(), but passes
3485 its address in another call.
3487 If you have this scenario and attempt to "break bar" before running,
3488 gdb will find a minimal symbol for bar() in the a.out. But that
3489 symbol's address will be negative. What this appears to denote is
3490 an index backwards from the base of the procedure linkage table (PLT)
3491 into the data linkage table (DLT), the end of which is contiguous
3492 with the start of the PLT. This is clearly not a valid address for
3493 us to set a breakpoint on.
3495 Note that one must be careful in how one checks for a negative address.
3496 0xc0000000 is a legitimate address of something in a shared text
3497 segment, for example. Since I don't know what the possible range
3498 is of these "really, truly negative" addresses that come from the
3499 minimal symbols, I'm resorting to the gross hack of checking the
3500 top byte of the address for all 1's. Sigh. */
3502 return (!target_has_stack
&& (pc
& 0xFF000000));
3506 hppa_instruction_nullified (void)
3508 /* brobecker 2002/11/07: Couldn't we use a ULONGEST here? It would
3509 avoid the type cast. I'm leaving it as is for now as I'm doing
3510 semi-mechanical multiarching-related changes. */
3511 const int ipsw
= (int) read_register (IPSW_REGNUM
);
3512 const int flags
= (int) read_register (FLAGS_REGNUM
);
3514 return ((ipsw
& 0x00200000) && !(flags
& 0x2));
3518 hppa_register_raw_size (int reg_nr
)
3520 /* All registers have the same size. */
3521 return DEPRECATED_REGISTER_SIZE
;
3524 /* Index within the register vector of the first byte of the space i
3525 used for register REG_NR. */
3528 hppa_register_byte (int reg_nr
)
3530 struct gdbarch_tdep
*tdep
= gdbarch_tdep (current_gdbarch
);
3532 return reg_nr
* tdep
->bytes_per_address
;
3535 /* Return the GDB type object for the "standard" data type of data
3539 hppa32_register_virtual_type (int reg_nr
)
3541 if (reg_nr
< FP4_REGNUM
)
3542 return builtin_type_int
;
3544 return builtin_type_float
;
3547 /* Return the GDB type object for the "standard" data type of data
3548 in register N. hppa64 version. */
3551 hppa64_register_virtual_type (int reg_nr
)
3553 if (reg_nr
< FP4_REGNUM
)
3554 return builtin_type_unsigned_long_long
;
3556 return builtin_type_double
;
3559 /* Return True if REGNUM is not a register available to the user
3560 through ptrace(). */
3563 hppa_cannot_store_register (int regnum
)
3566 || regnum
== PCSQ_HEAD_REGNUM
3567 || (regnum
>= PCSQ_TAIL_REGNUM
&& regnum
< IPSW_REGNUM
)
3568 || (regnum
> IPSW_REGNUM
&& regnum
< FP4_REGNUM
));
3573 hppa_smash_text_address (CORE_ADDR addr
)
3575 /* The low two bits of the PC on the PA contain the privilege level.
3576 Some genius implementing a (non-GCC) compiler apparently decided
3577 this means that "addresses" in a text section therefore include a
3578 privilege level, and thus symbol tables should contain these bits.
3579 This seems like a bonehead thing to do--anyway, it seems to work
3580 for our purposes to just ignore those bits. */
3582 return (addr
&= ~0x3);
3585 /* Get the ith function argument for the current function. */
3587 hppa_fetch_pointer_argument (struct frame_info
*frame
, int argi
,
3591 get_frame_register (frame
, R0_REGNUM
+ 26 - argi
, &addr
);
3595 /* Here is a table of C type sizes on hppa with various compiles
3596 and options. I measured this on PA 9000/800 with HP-UX 11.11
3597 and these compilers:
3599 /usr/ccs/bin/cc HP92453-01 A.11.01.21
3600 /opt/ansic/bin/cc HP92453-01 B.11.11.28706.GP
3601 /opt/aCC/bin/aCC B3910B A.03.45
3602 gcc gcc 3.3.2 native hppa2.0w-hp-hpux11.11
3604 cc : 1 2 4 4 8 : 4 8 -- : 4 4
3605 ansic +DA1.1 : 1 2 4 4 8 : 4 8 16 : 4 4
3606 ansic +DA2.0 : 1 2 4 4 8 : 4 8 16 : 4 4
3607 ansic +DA2.0W : 1 2 4 8 8 : 4 8 16 : 8 8
3608 acc +DA1.1 : 1 2 4 4 8 : 4 8 16 : 4 4
3609 acc +DA2.0 : 1 2 4 4 8 : 4 8 16 : 4 4
3610 acc +DA2.0W : 1 2 4 8 8 : 4 8 16 : 8 8
3611 gcc : 1 2 4 4 8 : 4 8 16 : 4 4
3615 compiler and options
3616 char, short, int, long, long long
3617 float, double, long double
3620 So all these compilers use either ILP32 or LP64 model.
3621 TODO: gcc has more options so it needs more investigation.
3623 For floating point types, see:
3625 http://docs.hp.com/hpux/pdf/B3906-90006.pdf
3626 HP-UX floating-point guide, hpux 11.00
3628 -- chastain 2003-12-18 */
3630 static struct gdbarch
*
3631 hppa_gdbarch_init (struct gdbarch_info info
, struct gdbarch_list
*arches
)
3633 struct gdbarch_tdep
*tdep
;
3634 struct gdbarch
*gdbarch
;
3636 /* Try to determine the ABI of the object we are loading. */
3637 if (info
.abfd
!= NULL
&& info
.osabi
== GDB_OSABI_UNKNOWN
)
3639 /* If it's a SOM file, assume it's HP/UX SOM. */
3640 if (bfd_get_flavour (info
.abfd
) == bfd_target_som_flavour
)
3641 info
.osabi
= GDB_OSABI_HPUX_SOM
;
3644 /* find a candidate among the list of pre-declared architectures. */
3645 arches
= gdbarch_list_lookup_by_info (arches
, &info
);
3647 return (arches
->gdbarch
);
3649 /* If none found, then allocate and initialize one. */
3650 tdep
= XMALLOC (struct gdbarch_tdep
);
3651 gdbarch
= gdbarch_alloc (&info
, tdep
);
3653 /* Determine from the bfd_arch_info structure if we are dealing with
3654 a 32 or 64 bits architecture. If the bfd_arch_info is not available,
3655 then default to a 32bit machine. */
3656 if (info
.bfd_arch_info
!= NULL
)
3657 tdep
->bytes_per_address
=
3658 info
.bfd_arch_info
->bits_per_address
/ info
.bfd_arch_info
->bits_per_byte
;
3660 tdep
->bytes_per_address
= 4;
3662 /* Some parts of the gdbarch vector depend on whether we are running
3663 on a 32 bits or 64 bits target. */
3664 switch (tdep
->bytes_per_address
)
3667 set_gdbarch_num_regs (gdbarch
, hppa32_num_regs
);
3668 set_gdbarch_register_name (gdbarch
, hppa32_register_name
);
3669 set_gdbarch_deprecated_register_virtual_type
3670 (gdbarch
, hppa32_register_virtual_type
);
3673 set_gdbarch_num_regs (gdbarch
, hppa64_num_regs
);
3674 set_gdbarch_register_name (gdbarch
, hppa64_register_name
);
3675 set_gdbarch_deprecated_register_virtual_type
3676 (gdbarch
, hppa64_register_virtual_type
);
3679 internal_error (__FILE__
, __LINE__
, "Unsupported address size: %d",
3680 tdep
->bytes_per_address
);
3683 /* The following gdbarch vector elements depend on other parts of this
3684 vector which have been set above, depending on the ABI. */
3685 set_gdbarch_deprecated_register_bytes
3686 (gdbarch
, gdbarch_num_regs (gdbarch
) * tdep
->bytes_per_address
);
3687 set_gdbarch_long_bit (gdbarch
, tdep
->bytes_per_address
* TARGET_CHAR_BIT
);
3688 set_gdbarch_ptr_bit (gdbarch
, tdep
->bytes_per_address
* TARGET_CHAR_BIT
);
3690 /* The following gdbarch vector elements are the same in both ILP32
3691 and LP64, but might show differences some day. */
3692 set_gdbarch_long_long_bit (gdbarch
, 64);
3693 set_gdbarch_long_double_bit (gdbarch
, 128);
3694 set_gdbarch_long_double_format (gdbarch
, &floatformat_ia64_quad_big
);
3696 /* The following gdbarch vector elements do not depend on the address
3697 size, or in any other gdbarch element previously set. */
3698 set_gdbarch_skip_prologue (gdbarch
, hppa_skip_prologue
);
3699 set_gdbarch_skip_trampoline_code (gdbarch
, hppa_skip_trampoline_code
);
3700 set_gdbarch_in_solib_call_trampoline (gdbarch
, hppa_in_solib_call_trampoline
);
3701 set_gdbarch_in_solib_return_trampoline (gdbarch
,
3702 hppa_in_solib_return_trampoline
);
3703 set_gdbarch_inner_than (gdbarch
, hppa_inner_than
);
3704 set_gdbarch_deprecated_register_size (gdbarch
, tdep
->bytes_per_address
);
3705 set_gdbarch_deprecated_fp_regnum (gdbarch
, 3);
3706 set_gdbarch_sp_regnum (gdbarch
, 30);
3707 set_gdbarch_fp0_regnum (gdbarch
, 64);
3708 set_gdbarch_deprecated_register_raw_size (gdbarch
, hppa_register_raw_size
);
3709 set_gdbarch_deprecated_register_byte (gdbarch
, hppa_register_byte
);
3710 set_gdbarch_deprecated_register_virtual_size (gdbarch
, hppa_register_raw_size
);
3711 set_gdbarch_deprecated_max_register_raw_size (gdbarch
, tdep
->bytes_per_address
);
3712 set_gdbarch_deprecated_max_register_virtual_size (gdbarch
, 8);
3713 set_gdbarch_cannot_store_register (gdbarch
, hppa_cannot_store_register
);
3714 set_gdbarch_addr_bits_remove (gdbarch
, hppa_smash_text_address
);
3715 set_gdbarch_smash_text_address (gdbarch
, hppa_smash_text_address
);
3716 set_gdbarch_believe_pcc_promotion (gdbarch
, 1);
3717 set_gdbarch_read_pc (gdbarch
, hppa_target_read_pc
);
3718 set_gdbarch_write_pc (gdbarch
, hppa_target_write_pc
);
3719 set_gdbarch_deprecated_target_read_fp (gdbarch
, hppa_target_read_fp
);
3721 /* Helper for function argument information. */
3722 set_gdbarch_fetch_pointer_argument (gdbarch
, hppa_fetch_pointer_argument
);
3724 set_gdbarch_print_insn (gdbarch
, print_insn_hppa
);
3726 /* When a hardware watchpoint triggers, we'll move the inferior past
3727 it by removing all eventpoints; stepping past the instruction
3728 that caused the trigger; reinserting eventpoints; and checking
3729 whether any watched location changed. */
3730 set_gdbarch_have_nonsteppable_watchpoint (gdbarch
, 1);
3732 /* Inferior function call methods. */
3733 switch (tdep
->bytes_per_address
)
3736 set_gdbarch_push_dummy_call (gdbarch
, hppa32_push_dummy_call
);
3737 set_gdbarch_frame_align (gdbarch
, hppa32_frame_align
);
3740 set_gdbarch_push_dummy_call (gdbarch
, hppa64_push_dummy_call
);
3741 set_gdbarch_frame_align (gdbarch
, hppa64_frame_align
);
3744 internal_error (__FILE__
, __LINE__
, "bad switch");
3747 /* Struct return methods. */
3748 switch (tdep
->bytes_per_address
)
3751 set_gdbarch_return_value (gdbarch
, hppa32_return_value
);
3754 set_gdbarch_return_value (gdbarch
, hppa64_return_value
);
3756 internal_error (__FILE__
, __LINE__
, "bad switch");
3759 /* Frame unwind methods. */
3760 set_gdbarch_unwind_dummy_id (gdbarch
, hppa_unwind_dummy_id
);
3761 set_gdbarch_unwind_pc (gdbarch
, hppa_unwind_pc
);
3762 frame_unwind_append_sniffer (gdbarch
, hppa_frame_unwind_sniffer
);
3763 frame_base_append_sniffer (gdbarch
, hppa_frame_base_sniffer
);
3765 /* Hook in ABI-specific overrides, if they have been registered. */
3766 gdbarch_init_osabi (info
, gdbarch
);
3772 hppa_dump_tdep (struct gdbarch
*current_gdbarch
, struct ui_file
*file
)
3774 /* Nothing to print for the moment. */
3778 _initialize_hppa_tdep (void)
3780 struct cmd_list_element
*c
;
3781 void break_at_finish_command (char *arg
, int from_tty
);
3782 void tbreak_at_finish_command (char *arg
, int from_tty
);
3783 void break_at_finish_at_depth_command (char *arg
, int from_tty
);
3785 gdbarch_register (bfd_arch_hppa
, hppa_gdbarch_init
, hppa_dump_tdep
);
3787 add_cmd ("unwind", class_maintenance
, unwind_command
,
3788 "Print unwind table entry at given address.",
3789 &maintenanceprintlist
);
3791 deprecate_cmd (add_com ("xbreak", class_breakpoint
,
3792 break_at_finish_command
,
3793 concat ("Set breakpoint at procedure exit. \n\
3794 Argument may be function name, or \"*\" and an address.\n\
3795 If function is specified, break at end of code for that function.\n\
3796 If an address is specified, break at the end of the function that contains \n\
3797 that exact address.\n",
3798 "With no arg, uses current execution address of selected stack frame.\n\
3799 This is useful for breaking on return to a stack frame.\n\
3801 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
3803 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL
)), NULL
);
3804 deprecate_cmd (add_com_alias ("xb", "xbreak", class_breakpoint
, 1), NULL
);
3805 deprecate_cmd (add_com_alias ("xbr", "xbreak", class_breakpoint
, 1), NULL
);
3806 deprecate_cmd (add_com_alias ("xbre", "xbreak", class_breakpoint
, 1), NULL
);
3807 deprecate_cmd (add_com_alias ("xbrea", "xbreak", class_breakpoint
, 1), NULL
);
3809 deprecate_cmd (c
= add_com ("txbreak", class_breakpoint
,
3810 tbreak_at_finish_command
,
3811 "Set temporary breakpoint at procedure exit. Either there should\n\
3812 be no argument or the argument must be a depth.\n"), NULL
);
3813 set_cmd_completer (c
, location_completer
);
3816 deprecate_cmd (add_com ("bx", class_breakpoint
,
3817 break_at_finish_at_depth_command
,
3818 "Set breakpoint at procedure exit. Either there should\n\
3819 be no argument or the argument must be a depth.\n"), NULL
);