1 /* Target-dependent code for HP-UX on PA-RISC.
3 Copyright (C) 2002-2015 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include "arch-utils.h"
25 #include "frame-unwind.h"
26 #include "trad-frame.h"
32 #include "hppa-tdep.h"
33 #include "solib-som.h"
34 #include "solib-pa64.h"
38 #define IS_32BIT_TARGET(_gdbarch) \
39 ((gdbarch_tdep (_gdbarch))->bytes_per_address == 4)
41 /* Bit in the `ss_flag' member of `struct save_state' that indicates
42 that the 64-bit register values are live. From
43 <machine/save_state.h>. */
44 #define HPPA_HPUX_SS_WIDEREGS 0x40
46 /* Offsets of various parts of `struct save_state'. From
47 <machine/save_state.h>. */
48 #define HPPA_HPUX_SS_FLAGS_OFFSET 0
49 #define HPPA_HPUX_SS_NARROW_OFFSET 4
50 #define HPPA_HPUX_SS_FPBLOCK_OFFSET 256
51 #define HPPA_HPUX_SS_WIDE_OFFSET 640
53 /* The size of `struct save_state. */
54 #define HPPA_HPUX_SAVE_STATE_SIZE 1152
56 /* The size of `struct pa89_save_state', which corresponds to PA-RISC
57 1.1, the lowest common denominator that we support. */
58 #define HPPA_HPUX_PA89_SAVE_STATE_SIZE 512
61 /* Forward declarations. */
62 extern void _initialize_hppa_hpux_tdep (void);
63 extern initialize_file_ftype _initialize_hppa_hpux_tdep
;
65 /* Return one if PC is in the call path of a trampoline, else return zero.
67 Note we return one for *any* call trampoline (long-call, arg-reloc), not
68 just shared library trampolines (import, export). */
71 hppa32_hpux_in_solib_call_trampoline (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
73 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
74 struct bound_minimal_symbol minsym
;
75 struct unwind_table_entry
*u
;
77 /* First see if PC is in one of the two C-library trampolines. */
78 if (pc
== hppa_symbol_address("$$dyncall")
79 || pc
== hppa_symbol_address("_sr4export"))
82 minsym
= lookup_minimal_symbol_by_pc (pc
);
84 && strcmp (MSYMBOL_LINKAGE_NAME (minsym
.minsym
), ".stub") == 0)
87 /* Get the unwind descriptor corresponding to PC, return zero
88 if no unwind was found. */
89 u
= find_unwind_entry (pc
);
93 /* If this isn't a linker stub, then return now. */
94 if (u
->stub_unwind
.stub_type
== 0)
97 /* By definition a long-branch stub is a call stub. */
98 if (u
->stub_unwind
.stub_type
== LONG_BRANCH
)
101 /* The call and return path execute the same instructions within
102 an IMPORT stub! So an IMPORT stub is both a call and return
104 if (u
->stub_unwind
.stub_type
== IMPORT
)
107 /* Parameter relocation stubs always have a call path and may have a
109 if (u
->stub_unwind
.stub_type
== PARAMETER_RELOCATION
110 || u
->stub_unwind
.stub_type
== EXPORT
)
114 /* Search forward from the current PC until we hit a branch
115 or the end of the stub. */
116 for (addr
= pc
; addr
<= u
->region_end
; addr
+= 4)
120 insn
= read_memory_integer (addr
, 4, byte_order
);
122 /* Does it look like a bl? If so then it's the call path, if
123 we find a bv or be first, then we're on the return path. */
124 if ((insn
& 0xfc00e000) == 0xe8000000)
126 else if ((insn
& 0xfc00e001) == 0xe800c000
127 || (insn
& 0xfc000000) == 0xe0000000)
131 /* Should never happen. */
132 warning (_("Unable to find branch in parameter relocation stub."));
136 /* Unknown stub type. For now, just return zero. */
141 hppa64_hpux_in_solib_call_trampoline (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
143 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
145 /* PA64 has a completely different stub/trampoline scheme. Is it
146 better? Maybe. It's certainly harder to determine with any
147 certainty that we are in a stub because we can not refer to the
150 The heuristic is simple. Try to lookup the current PC value in th
151 minimal symbol table. If that fails, then assume we are not in a
154 Then see if the PC value falls within the section bounds for the
155 section containing the minimal symbol we found in the first
156 step. If it does, then assume we are not in a stub and return.
158 Finally peek at the instructions to see if they look like a stub. */
159 struct bound_minimal_symbol minsym
;
164 minsym
= lookup_minimal_symbol_by_pc (pc
);
168 sec
= MSYMBOL_OBJ_SECTION (minsym
.objfile
, minsym
.minsym
)->the_bfd_section
;
170 if (bfd_get_section_vma (sec
->owner
, sec
) <= pc
171 && pc
< (bfd_get_section_vma (sec
->owner
, sec
)
172 + bfd_section_size (sec
->owner
, sec
)))
175 /* We might be in a stub. Peek at the instructions. Stubs are 3
176 instructions long. */
177 insn
= read_memory_integer (pc
, 4, byte_order
);
179 /* Find out where we think we are within the stub. */
180 if ((insn
& 0xffffc00e) == 0x53610000)
182 else if ((insn
& 0xffffffff) == 0xe820d000)
184 else if ((insn
& 0xffffc00e) == 0x537b0000)
189 /* Now verify each insn in the range looks like a stub instruction. */
190 insn
= read_memory_integer (addr
, 4, byte_order
);
191 if ((insn
& 0xffffc00e) != 0x53610000)
194 /* Now verify each insn in the range looks like a stub instruction. */
195 insn
= read_memory_integer (addr
+ 4, 4, byte_order
);
196 if ((insn
& 0xffffffff) != 0xe820d000)
199 /* Now verify each insn in the range looks like a stub instruction. */
200 insn
= read_memory_integer (addr
+ 8, 4, byte_order
);
201 if ((insn
& 0xffffc00e) != 0x537b0000)
204 /* Looks like a stub. */
208 /* Return one if PC is in the return path of a trampoline, else return zero.
210 Note we return one for *any* call trampoline (long-call, arg-reloc), not
211 just shared library trampolines (import, export). */
214 hppa_hpux_in_solib_return_trampoline (struct gdbarch
*gdbarch
,
215 CORE_ADDR pc
, const char *name
)
217 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
218 struct unwind_table_entry
*u
;
220 /* Get the unwind descriptor corresponding to PC, return zero
221 if no unwind was found. */
222 u
= find_unwind_entry (pc
);
226 /* If this isn't a linker stub or it's just a long branch stub, then
228 if (u
->stub_unwind
.stub_type
== 0 || u
->stub_unwind
.stub_type
== LONG_BRANCH
)
231 /* The call and return path execute the same instructions within
232 an IMPORT stub! So an IMPORT stub is both a call and return
234 if (u
->stub_unwind
.stub_type
== IMPORT
)
237 /* Parameter relocation stubs always have a call path and may have a
239 if (u
->stub_unwind
.stub_type
== PARAMETER_RELOCATION
240 || u
->stub_unwind
.stub_type
== EXPORT
)
244 /* Search forward from the current PC until we hit a branch
245 or the end of the stub. */
246 for (addr
= pc
; addr
<= u
->region_end
; addr
+= 4)
250 insn
= read_memory_integer (addr
, 4, byte_order
);
252 /* Does it look like a bl? If so then it's the call path, if
253 we find a bv or be first, then we're on the return path. */
254 if ((insn
& 0xfc00e000) == 0xe8000000)
256 else if ((insn
& 0xfc00e001) == 0xe800c000
257 || (insn
& 0xfc000000) == 0xe0000000)
261 /* Should never happen. */
262 warning (_("Unable to find branch in parameter relocation stub."));
266 /* Unknown stub type. For now, just return zero. */
271 /* Figure out if PC is in a trampoline, and if so find out where
272 the trampoline will jump to. If not in a trampoline, return zero.
274 Simple code examination probably is not a good idea since the code
275 sequences in trampolines can also appear in user code.
277 We use unwinds and information from the minimal symbol table to
278 determine when we're in a trampoline. This won't work for ELF
279 (yet) since it doesn't create stub unwind entries. Whether or
280 not ELF will create stub unwinds or normal unwinds for linker
281 stubs is still being debated.
283 This should handle simple calls through dyncall or sr4export,
284 long calls, argument relocation stubs, and dyncall/sr4export
285 calling an argument relocation stub. It even handles some stubs
286 used in dynamic executables. */
289 hppa_hpux_skip_trampoline_code (struct frame_info
*frame
, CORE_ADDR pc
)
291 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
292 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
293 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
295 long prev_inst
, curr_inst
, loc
;
296 struct bound_minimal_symbol msym
;
297 struct unwind_table_entry
*u
;
299 /* Addresses passed to dyncall may *NOT* be the actual address
300 of the function. So we may have to do something special. */
301 if (pc
== hppa_symbol_address("$$dyncall"))
303 pc
= (CORE_ADDR
) get_frame_register_unsigned (frame
, 22);
305 /* If bit 30 (counting from the left) is on, then pc is the address of
306 the PLT entry for this function, not the address of the function
307 itself. Bit 31 has meaning too, but only for MPE. */
309 pc
= (CORE_ADDR
) read_memory_integer (pc
& ~0x3, word_size
,
312 if (pc
== hppa_symbol_address("$$dyncall_external"))
314 pc
= (CORE_ADDR
) get_frame_register_unsigned (frame
, 22);
315 pc
= (CORE_ADDR
) read_memory_integer (pc
& ~0x3, word_size
, byte_order
);
317 else if (pc
== hppa_symbol_address("_sr4export"))
318 pc
= (CORE_ADDR
) get_frame_register_unsigned (frame
, 22);
320 /* Get the unwind descriptor corresponding to PC, return zero
321 if no unwind was found. */
322 u
= find_unwind_entry (pc
);
326 /* If this isn't a linker stub, then return now. */
327 /* elz: attention here! (FIXME) because of a compiler/linker
328 error, some stubs which should have a non zero stub_unwind.stub_type
329 have unfortunately a value of zero. So this function would return here
330 as if we were not in a trampoline. To fix this, we go look at the partial
331 symbol information, which reports this guy as a stub.
332 (FIXME): Unfortunately, we are not that lucky: it turns out that the
333 partial symbol information is also wrong sometimes. This is because
334 when it is entered (somread.c::som_symtab_read()) it can happen that
335 if the type of the symbol (from the som) is Entry, and the symbol is
336 in a shared library, then it can also be a trampoline. This would be OK,
337 except that I believe the way they decide if we are ina shared library
338 does not work. SOOOO..., even if we have a regular function w/o
339 trampolines its minimal symbol can be assigned type mst_solib_trampoline.
340 Also, if we find that the symbol is a real stub, then we fix the unwind
341 descriptor, and define the stub type to be EXPORT.
342 Hopefully this is correct most of the times. */
343 if (u
->stub_unwind
.stub_type
== 0)
346 /* elz: NOTE (FIXME!) once the problem with the unwind information is fixed
347 we can delete all the code which appears between the lines. */
348 /*--------------------------------------------------------------------------*/
349 msym
= lookup_minimal_symbol_by_pc (pc
);
351 if (msym
.minsym
== NULL
352 || MSYMBOL_TYPE (msym
.minsym
) != mst_solib_trampoline
)
353 return orig_pc
== pc
? 0 : pc
& ~0x3;
355 else if (msym
.minsym
!= NULL
356 && MSYMBOL_TYPE (msym
.minsym
) == mst_solib_trampoline
)
358 struct objfile
*objfile
;
359 struct minimal_symbol
*msymbol
;
360 int function_found
= 0;
362 /* Go look if there is another minimal symbol with the same name as
363 this one, but with type mst_text. This would happen if the msym
364 is an actual trampoline, in which case there would be another
365 symbol with the same name corresponding to the real function. */
367 ALL_MSYMBOLS (objfile
, msymbol
)
369 if (MSYMBOL_TYPE (msymbol
) == mst_text
370 && strcmp (MSYMBOL_LINKAGE_NAME (msymbol
),
371 MSYMBOL_LINKAGE_NAME (msym
.minsym
)) == 0)
379 /* The type of msym is correct (mst_solib_trampoline), but
380 the unwind info is wrong, so set it to the correct value. */
381 u
->stub_unwind
.stub_type
= EXPORT
;
383 /* The stub type info in the unwind is correct (this is not a
384 trampoline), but the msym type information is wrong, it
385 should be mst_text. So we need to fix the msym, and also
386 get out of this function. */
388 MSYMBOL_TYPE (msym
.minsym
) = mst_text
;
389 return orig_pc
== pc
? 0 : pc
& ~0x3;
393 /*--------------------------------------------------------------------------*/
396 /* It's a stub. Search for a branch and figure out where it goes.
397 Note we have to handle multi insn branch sequences like ldil;ble.
398 Most (all?) other branches can be determined by examining the contents
399 of certain registers and the stack. */
406 /* Make sure we haven't walked outside the range of this stub. */
407 if (u
!= find_unwind_entry (loc
))
409 warning (_("Unable to find branch in linker stub"));
410 return orig_pc
== pc
? 0 : pc
& ~0x3;
413 prev_inst
= curr_inst
;
414 curr_inst
= read_memory_integer (loc
, 4, byte_order
);
416 /* Does it look like a branch external using %r1? Then it's the
417 branch from the stub to the actual function. */
418 if ((curr_inst
& 0xffe0e000) == 0xe0202000)
420 /* Yup. See if the previous instruction loaded
421 a value into %r1. If so compute and return the jump address. */
422 if ((prev_inst
& 0xffe00000) == 0x20200000)
423 return (hppa_extract_21 (prev_inst
)
424 + hppa_extract_17 (curr_inst
)) & ~0x3;
427 warning (_("Unable to find ldil X,%%r1 "
428 "before ble Y(%%sr4,%%r1)."));
429 return orig_pc
== pc
? 0 : pc
& ~0x3;
433 /* Does it look like a be 0(sr0,%r21)? OR
434 Does it look like a be, n 0(sr0,%r21)? OR
435 Does it look like a bve (r21)? (this is on PA2.0)
436 Does it look like a bve, n(r21)? (this is also on PA2.0)
437 That's the branch from an
438 import stub to an export stub.
440 It is impossible to determine the target of the branch via
441 simple examination of instructions and/or data (consider
442 that the address in the plabel may be the address of the
443 bind-on-reference routine in the dynamic loader).
445 So we have try an alternative approach.
447 Get the name of the symbol at our current location; it should
448 be a stub symbol with the same name as the symbol in the
451 Then lookup a minimal symbol with the same name; we should
452 get the minimal symbol for the target routine in the shared
453 library as those take precedence of import/export stubs. */
454 if ((curr_inst
== 0xe2a00000) ||
455 (curr_inst
== 0xe2a00002) ||
456 (curr_inst
== 0xeaa0d000) ||
457 (curr_inst
== 0xeaa0d002))
459 struct bound_minimal_symbol stubsym
;
460 struct bound_minimal_symbol libsym
;
462 stubsym
= lookup_minimal_symbol_by_pc (loc
);
463 if (stubsym
.minsym
== NULL
)
465 warning (_("Unable to find symbol for 0x%lx"), loc
);
466 return orig_pc
== pc
? 0 : pc
& ~0x3;
469 libsym
= lookup_minimal_symbol (MSYMBOL_LINKAGE_NAME (stubsym
.minsym
),
471 if (libsym
.minsym
== NULL
)
473 warning (_("Unable to find library symbol for %s."),
474 MSYMBOL_PRINT_NAME (stubsym
.minsym
));
475 return orig_pc
== pc
? 0 : pc
& ~0x3;
478 return MSYMBOL_VALUE (libsym
.minsym
);
481 /* Does it look like bl X,%rp or bl X,%r0? Another way to do a
482 branch from the stub to the actual function. */
484 else if ((curr_inst
& 0xffe0e000) == 0xe8400000
485 || (curr_inst
& 0xffe0e000) == 0xe8000000
486 || (curr_inst
& 0xffe0e000) == 0xe800A000)
487 return (loc
+ hppa_extract_17 (curr_inst
) + 8) & ~0x3;
489 /* Does it look like bv (rp)? Note this depends on the
490 current stack pointer being the same as the stack
491 pointer in the stub itself! This is a branch on from the
492 stub back to the original caller. */
493 /*else if ((curr_inst & 0xffe0e000) == 0xe840c000) */
494 else if ((curr_inst
& 0xffe0f000) == 0xe840c000)
496 /* Yup. See if the previous instruction loaded
498 if (prev_inst
== 0x4bc23ff1)
501 sp
= get_frame_register_unsigned (frame
, HPPA_SP_REGNUM
);
502 return read_memory_integer (sp
- 8, 4, byte_order
) & ~0x3;
506 warning (_("Unable to find restore of %%rp before bv (%%rp)."));
507 return orig_pc
== pc
? 0 : pc
& ~0x3;
511 /* elz: added this case to capture the new instruction
512 at the end of the return part of an export stub used by
513 the PA2.0: BVE, n (rp) */
514 else if ((curr_inst
& 0xffe0f000) == 0xe840d000)
516 return (read_memory_integer
517 (get_frame_register_unsigned (frame
, HPPA_SP_REGNUM
) - 24,
518 word_size
, byte_order
)) & ~0x3;
521 /* What about be,n 0(sr0,%rp)? It's just another way we return to
522 the original caller from the stub. Used in dynamic executables. */
523 else if (curr_inst
== 0xe0400002)
525 /* The value we jump to is sitting in sp - 24. But that's
526 loaded several instructions before the be instruction.
527 I guess we could check for the previous instruction being
528 mtsp %r1,%sr0 if we want to do sanity checking. */
529 return (read_memory_integer
530 (get_frame_register_unsigned (frame
, HPPA_SP_REGNUM
) - 24,
531 word_size
, byte_order
)) & ~0x3;
534 /* Haven't found the branch yet, but we're still in the stub.
541 hppa_skip_permanent_breakpoint (struct regcache
*regcache
)
543 /* To step over a breakpoint instruction on the PA takes some
544 fiddling with the instruction address queue.
546 When we stop at a breakpoint, the IA queue front (the instruction
547 we're executing now) points at the breakpoint instruction, and
548 the IA queue back (the next instruction to execute) points to
549 whatever instruction we would execute after the breakpoint, if it
550 were an ordinary instruction. This is the case even if the
551 breakpoint is in the delay slot of a branch instruction.
553 Clearly, to step past the breakpoint, we need to set the queue
554 front to the back. But what do we put in the back? What
555 instruction comes after that one? Because of the branch delay
556 slot, the next insn is always at the back + 4. */
558 ULONGEST pcoq_tail
, pcsq_tail
;
559 regcache_cooked_read_unsigned (regcache
, HPPA_PCOQ_TAIL_REGNUM
, &pcoq_tail
);
560 regcache_cooked_read_unsigned (regcache
, HPPA_PCSQ_TAIL_REGNUM
, &pcsq_tail
);
562 regcache_cooked_write_unsigned (regcache
, HPPA_PCOQ_HEAD_REGNUM
, pcoq_tail
);
563 regcache_cooked_write_unsigned (regcache
, HPPA_PCSQ_HEAD_REGNUM
, pcsq_tail
);
565 regcache_cooked_write_unsigned (regcache
,
566 HPPA_PCOQ_TAIL_REGNUM
, pcoq_tail
+ 4);
567 /* We can leave the tail's space the same, since there's no jump. */
572 struct hppa_hpux_sigtramp_unwind_cache
575 struct trad_frame_saved_reg
*saved_regs
;
578 static int hppa_hpux_tramp_reg
[] = {
580 HPPA_PCOQ_HEAD_REGNUM
,
581 HPPA_PCSQ_HEAD_REGNUM
,
582 HPPA_PCOQ_TAIL_REGNUM
,
583 HPPA_PCSQ_TAIL_REGNUM
,
610 static struct hppa_hpux_sigtramp_unwind_cache
*
611 hppa_hpux_sigtramp_frame_unwind_cache (struct frame_info
*this_frame
,
615 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
616 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
617 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
618 struct hppa_hpux_sigtramp_unwind_cache
*info
;
620 CORE_ADDR sp
, scptr
, off
;
626 info
= FRAME_OBSTACK_ZALLOC (struct hppa_hpux_sigtramp_unwind_cache
);
628 info
->saved_regs
= trad_frame_alloc_saved_regs (this_frame
);
630 sp
= get_frame_register_unsigned (this_frame
, HPPA_SP_REGNUM
);
632 if (IS_32BIT_TARGET (gdbarch
))
639 /* See /usr/include/machine/save_state.h for the structure of the
640 save_state_t structure. */
642 flag
= read_memory_unsigned_integer (scptr
+ HPPA_HPUX_SS_FLAGS_OFFSET
,
645 if (!(flag
& HPPA_HPUX_SS_WIDEREGS
))
647 /* Narrow registers. */
648 off
= scptr
+ HPPA_HPUX_SS_NARROW_OFFSET
;
654 /* Wide registers. */
655 off
= scptr
+ HPPA_HPUX_SS_WIDE_OFFSET
+ 8;
657 szoff
= (tdep
->bytes_per_address
== 4 ? 4 : 0);
660 for (i
= 1; i
< 32; i
++)
662 info
->saved_regs
[HPPA_R0_REGNUM
+ i
].addr
= off
+ szoff
;
666 for (i
= 0; i
< ARRAY_SIZE (hppa_hpux_tramp_reg
); i
++)
668 if (hppa_hpux_tramp_reg
[i
] > 0)
669 info
->saved_regs
[hppa_hpux_tramp_reg
[i
]].addr
= off
+ szoff
;
676 info
->base
= get_frame_register_unsigned (this_frame
, HPPA_SP_REGNUM
);
682 hppa_hpux_sigtramp_frame_this_id (struct frame_info
*this_frame
,
683 void **this_prologue_cache
,
684 struct frame_id
*this_id
)
686 struct hppa_hpux_sigtramp_unwind_cache
*info
687 = hppa_hpux_sigtramp_frame_unwind_cache (this_frame
, this_prologue_cache
);
689 *this_id
= frame_id_build (info
->base
, get_frame_pc (this_frame
));
692 static struct value
*
693 hppa_hpux_sigtramp_frame_prev_register (struct frame_info
*this_frame
,
694 void **this_prologue_cache
,
697 struct hppa_hpux_sigtramp_unwind_cache
*info
698 = hppa_hpux_sigtramp_frame_unwind_cache (this_frame
, this_prologue_cache
);
700 return hppa_frame_prev_register_helper (this_frame
,
701 info
->saved_regs
, regnum
);
705 hppa_hpux_sigtramp_unwind_sniffer (const struct frame_unwind
*self
,
706 struct frame_info
*this_frame
,
709 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
710 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
711 struct unwind_table_entry
*u
;
712 CORE_ADDR pc
= get_frame_pc (this_frame
);
714 u
= find_unwind_entry (pc
);
716 /* If this is an export stub, try to get the unwind descriptor for
717 the actual function itself. */
718 if (u
&& u
->stub_unwind
.stub_type
== EXPORT
)
720 gdb_byte buf
[HPPA_INSN_SIZE
];
723 if (!safe_frame_unwind_memory (this_frame
, u
->region_start
,
727 insn
= extract_unsigned_integer (buf
, sizeof buf
, byte_order
);
728 if ((insn
& 0xffe0e000) == 0xe8400000)
729 u
= find_unwind_entry(u
->region_start
+ hppa_extract_17 (insn
) + 8);
732 if (u
&& u
->HP_UX_interrupt_marker
)
738 static const struct frame_unwind hppa_hpux_sigtramp_frame_unwind
= {
740 default_frame_unwind_stop_reason
,
741 hppa_hpux_sigtramp_frame_this_id
,
742 hppa_hpux_sigtramp_frame_prev_register
,
744 hppa_hpux_sigtramp_unwind_sniffer
748 hppa32_hpux_find_global_pointer (struct gdbarch
*gdbarch
,
749 struct value
*function
)
751 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
754 faddr
= value_as_address (function
);
756 /* Is this a plabel? If so, dereference it to get the gp value. */
764 status
= target_read_memory (faddr
+ 4, buf
, sizeof (buf
));
766 return extract_unsigned_integer (buf
, sizeof (buf
), byte_order
);
769 return gdbarch_tdep (gdbarch
)->solib_get_got_by_pc (faddr
);
773 hppa64_hpux_find_global_pointer (struct gdbarch
*gdbarch
,
774 struct value
*function
)
776 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
780 faddr
= value_as_address (function
);
782 if (pc_in_section (faddr
, ".opd"))
784 target_read_memory (faddr
, buf
, sizeof (buf
));
785 return extract_unsigned_integer (&buf
[24], 8, byte_order
);
789 return gdbarch_tdep (gdbarch
)->solib_get_got_by_pc (faddr
);
793 static unsigned int ldsid_pattern
[] = {
794 0x000010a0, /* ldsid (rX),rY */
795 0x00001820, /* mtsp rY,sr0 */
796 0xe0000000 /* be,n (sr0,rX) */
800 hppa_hpux_search_pattern (struct gdbarch
*gdbarch
,
801 CORE_ADDR start
, CORE_ADDR end
,
802 unsigned int *patterns
, int count
)
804 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
805 int num_insns
= (end
- start
+ HPPA_INSN_SIZE
) / HPPA_INSN_SIZE
;
810 buf
= alloca (num_insns
* HPPA_INSN_SIZE
);
811 insns
= alloca (num_insns
* sizeof (unsigned int));
813 read_memory (start
, buf
, num_insns
* HPPA_INSN_SIZE
);
814 for (i
= 0; i
< num_insns
; i
++, buf
+= HPPA_INSN_SIZE
)
815 insns
[i
] = extract_unsigned_integer (buf
, HPPA_INSN_SIZE
, byte_order
);
817 for (offset
= 0; offset
<= num_insns
- count
; offset
++)
819 for (i
= 0; i
< count
; i
++)
821 if ((insns
[offset
+ i
] & patterns
[i
]) != patterns
[i
])
828 if (offset
<= num_insns
- count
)
829 return start
+ offset
* HPPA_INSN_SIZE
;
835 hppa32_hpux_search_dummy_call_sequence (struct gdbarch
*gdbarch
, CORE_ADDR pc
,
838 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
840 struct obj_section
*sec
;
841 struct hppa_objfile_private
*priv
;
842 struct frame_info
*frame
;
843 struct unwind_table_entry
*u
;
848 sec
= find_pc_section (pc
);
850 priv
= objfile_data (obj
, hppa_objfile_priv_data
);
853 priv
= hppa_init_objfile_priv_data (obj
);
855 error (_("Internal error creating objfile private data."));
857 /* Use the cached value if we have one. */
858 if (priv
->dummy_call_sequence_addr
!= 0)
860 *argreg
= priv
->dummy_call_sequence_reg
;
861 return priv
->dummy_call_sequence_addr
;
864 /* First try a heuristic; if we are in a shared library call, our return
865 pointer is likely to point at an export stub. */
866 frame
= get_current_frame ();
867 rp
= frame_unwind_register_unsigned (frame
, 2);
868 u
= find_unwind_entry (rp
);
869 if (u
&& u
->stub_unwind
.stub_type
== EXPORT
)
871 addr
= hppa_hpux_search_pattern (gdbarch
,
872 u
->region_start
, u
->region_end
,
874 ARRAY_SIZE (ldsid_pattern
));
879 /* Next thing to try is to look for an export stub. */
880 if (priv
->unwind_info
)
884 for (i
= 0; i
< priv
->unwind_info
->last
; i
++)
886 struct unwind_table_entry
*u
;
887 u
= &priv
->unwind_info
->table
[i
];
888 if (u
->stub_unwind
.stub_type
== EXPORT
)
890 addr
= hppa_hpux_search_pattern (gdbarch
,
891 u
->region_start
, u
->region_end
,
893 ARRAY_SIZE (ldsid_pattern
));
902 /* Finally, if this is the main executable, try to locate a sequence
904 addr
= hppa_symbol_address ("noshlibs");
905 sec
= find_pc_section (addr
);
907 if (sec
&& sec
->objfile
== obj
)
909 CORE_ADDR start
, end
;
911 find_pc_partial_function (addr
, NULL
, &start
, &end
);
912 if (start
!= 0 && end
!= 0)
914 addr
= hppa_hpux_search_pattern (gdbarch
, start
, end
, ldsid_pattern
,
915 ARRAY_SIZE (ldsid_pattern
));
921 /* Can't find a suitable sequence. */
925 target_read_memory (addr
, buf
, sizeof (buf
));
926 insn
= extract_unsigned_integer (buf
, sizeof (buf
), byte_order
);
927 priv
->dummy_call_sequence_addr
= addr
;
928 priv
->dummy_call_sequence_reg
= (insn
>> 21) & 0x1f;
930 *argreg
= priv
->dummy_call_sequence_reg
;
931 return priv
->dummy_call_sequence_addr
;
935 hppa64_hpux_search_dummy_call_sequence (struct gdbarch
*gdbarch
, CORE_ADDR pc
,
938 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
940 struct obj_section
*sec
;
941 struct hppa_objfile_private
*priv
;
943 struct minimal_symbol
*msym
;
945 sec
= find_pc_section (pc
);
947 priv
= objfile_data (obj
, hppa_objfile_priv_data
);
950 priv
= hppa_init_objfile_priv_data (obj
);
952 error (_("Internal error creating objfile private data."));
954 /* Use the cached value if we have one. */
955 if (priv
->dummy_call_sequence_addr
!= 0)
957 *argreg
= priv
->dummy_call_sequence_reg
;
958 return priv
->dummy_call_sequence_addr
;
961 /* FIXME: Without stub unwind information, locating a suitable sequence is
962 fairly difficult. For now, we implement a very naive and inefficient
963 scheme; try to read in blocks of code, and look for a "bve,n (rp)"
964 instruction. These are likely to occur at the end of functions, so
965 we only look at the last two instructions of each function. */
966 ALL_OBJFILE_MSYMBOLS (obj
, msym
)
968 CORE_ADDR begin
, end
;
970 gdb_byte buf
[2 * HPPA_INSN_SIZE
];
973 find_pc_partial_function (MSYMBOL_VALUE_ADDRESS (obj
, msym
), &name
,
976 if (name
== NULL
|| begin
== 0 || end
== 0)
979 if (target_read_memory (end
- sizeof (buf
), buf
, sizeof (buf
)) == 0)
981 for (offset
= 0; offset
< sizeof (buf
); offset
++)
985 insn
= extract_unsigned_integer (buf
+ offset
,
986 HPPA_INSN_SIZE
, byte_order
);
987 if (insn
== 0xe840d002) /* bve,n (rp) */
989 addr
= (end
- sizeof (buf
)) + offset
;
996 /* Can't find a suitable sequence. */
1000 priv
->dummy_call_sequence_addr
= addr
;
1001 /* Right now we only look for a "bve,l (rp)" sequence, so the register is
1002 always HPPA_RP_REGNUM. */
1003 priv
->dummy_call_sequence_reg
= HPPA_RP_REGNUM
;
1005 *argreg
= priv
->dummy_call_sequence_reg
;
1006 return priv
->dummy_call_sequence_addr
;
1010 hppa_hpux_find_import_stub_for_addr (CORE_ADDR funcaddr
)
1012 struct objfile
*objfile
;
1013 struct bound_minimal_symbol funsym
;
1014 struct bound_minimal_symbol stubsym
;
1017 funsym
= lookup_minimal_symbol_by_pc (funcaddr
);
1020 ALL_OBJFILES (objfile
)
1022 stubsym
= lookup_minimal_symbol_solib_trampoline
1023 (MSYMBOL_LINKAGE_NAME (funsym
.minsym
), objfile
);
1027 struct unwind_table_entry
*u
;
1029 u
= find_unwind_entry (MSYMBOL_VALUE (stubsym
.minsym
));
1031 || (u
->stub_unwind
.stub_type
!= IMPORT
1032 && u
->stub_unwind
.stub_type
!= IMPORT_SHLIB
))
1035 stubaddr
= MSYMBOL_VALUE (stubsym
.minsym
);
1037 /* If we found an IMPORT stub, then we can stop searching;
1038 if we found an IMPORT_SHLIB, we want to continue the search
1039 in the hopes that we will find an IMPORT stub. */
1040 if (u
->stub_unwind
.stub_type
== IMPORT
)
1049 hppa_hpux_sr_for_addr (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
1052 /* The space register to use is encoded in the top 2 bits of the address. */
1053 sr
= addr
>> (gdbarch_tdep (gdbarch
)->bytes_per_address
* 8 - 2);
1058 hppa_hpux_find_dummy_bpaddr (CORE_ADDR addr
)
1060 /* In order for us to restore the space register to its starting state,
1061 we need the dummy trampoline to return to an instruction address in
1062 the same space as where we started the call. We used to place the
1063 breakpoint near the current pc, however, this breaks nested dummy calls
1064 as the nested call will hit the breakpoint address and terminate
1065 prematurely. Instead, we try to look for an address in the same space to
1068 This is similar in spirit to putting the breakpoint at the "entry point"
1069 of an executable. */
1071 struct obj_section
*sec
;
1072 struct unwind_table_entry
*u
;
1073 struct minimal_symbol
*msym
;
1076 sec
= find_pc_section (addr
);
1079 /* First try the lowest address in the section; we can use it as long
1080 as it is "regular" code (i.e. not a stub). */
1081 u
= find_unwind_entry (obj_section_addr (sec
));
1082 if (!u
|| u
->stub_unwind
.stub_type
== 0)
1083 return obj_section_addr (sec
);
1085 /* Otherwise, we need to find a symbol for a regular function. We
1086 do this by walking the list of msymbols in the objfile. The symbol
1087 we find should not be the same as the function that was passed in. */
1089 /* FIXME: this is broken, because we can find a function that will be
1090 called by the dummy call target function, which will still not
1093 find_pc_partial_function (addr
, NULL
, &func
, NULL
);
1094 ALL_OBJFILE_MSYMBOLS (sec
->objfile
, msym
)
1096 u
= find_unwind_entry (MSYMBOL_VALUE_ADDRESS (sec
->objfile
, msym
));
1097 if (func
!= MSYMBOL_VALUE_ADDRESS (sec
->objfile
, msym
)
1098 && (!u
|| u
->stub_unwind
.stub_type
== 0))
1099 return MSYMBOL_VALUE_ADDRESS (sec
->objfile
, msym
);
1103 warning (_("Cannot find suitable address to place dummy breakpoint; nested "
1104 "calls may fail."));
1109 hppa_hpux_push_dummy_code (struct gdbarch
*gdbarch
, CORE_ADDR sp
,
1111 struct value
**args
, int nargs
,
1112 struct type
*value_type
,
1113 CORE_ADDR
*real_pc
, CORE_ADDR
*bp_addr
,
1114 struct regcache
*regcache
)
1116 CORE_ADDR pc
, stubaddr
;
1119 pc
= regcache_read_pc (regcache
);
1121 /* Note: we don't want to pass a function descriptor here; push_dummy_call
1122 fills in the PIC register for us. */
1123 funcaddr
= gdbarch_convert_from_func_ptr_addr (gdbarch
, funcaddr
, NULL
);
1125 /* The simple case is where we call a function in the same space that we are
1126 currently in; in that case we don't really need to do anything. */
1127 if (hppa_hpux_sr_for_addr (gdbarch
, pc
)
1128 == hppa_hpux_sr_for_addr (gdbarch
, funcaddr
))
1130 /* Intraspace call. */
1131 *bp_addr
= hppa_hpux_find_dummy_bpaddr (pc
);
1132 *real_pc
= funcaddr
;
1133 regcache_cooked_write_unsigned (regcache
, HPPA_RP_REGNUM
, *bp_addr
);
1138 /* In order to make an interspace call, we need to go through a stub.
1139 gcc supplies an appropriate stub called "__gcc_plt_call", however, if
1140 an application is compiled with HP compilers then this stub is not
1141 available. We used to fallback to "__d_plt_call", however that stub
1142 is not entirely useful for us because it doesn't do an interspace
1143 return back to the caller. Also, on hppa64-hpux, there is no
1144 __gcc_plt_call available. In order to keep the code uniform, we
1145 instead don't use either of these stubs, but instead write our own
1148 A problem arises since the stack is located in a different space than
1149 code, so in order to branch to a stack stub, we will need to do an
1150 interspace branch. Previous versions of gdb did this by modifying code
1151 at the current pc and doing single-stepping to set the pcsq. Since this
1152 is highly undesirable, we use a different scheme:
1154 All we really need to do the branch to the stub is a short instruction
1165 Instead of writing these sequences ourselves, we can find it in
1166 the instruction stream that belongs to the current space. While this
1167 seems difficult at first, we are actually guaranteed to find the sequences
1171 - in export stubs for shared libraries
1172 - in the "noshlibs" routine in the main module
1175 - at the end of each "regular" function
1177 We cache the address of these sequences in the objfile's private data
1178 since these operations can potentially be quite expensive.
1181 - write a stack trampoline
1182 - look for a suitable instruction sequence in the current space
1183 - point the sequence at the trampoline
1184 - set the return address of the trampoline to the current space
1185 (see hppa_hpux_find_dummy_call_bpaddr)
1186 - set the continuing address of the "dummy code" as the sequence. */
1188 if (IS_32BIT_TARGET (gdbarch
))
1190 #define INSN(I1, I2, I3, I4) 0x ## I1, 0x ## I2, 0x ## I3, 0x ## I4
1191 static const gdb_byte hppa32_tramp
[] = {
1192 INSN(0f
,df
,12,91), /* stw r31,-8(,sp) */
1193 INSN(02,c0
,10,a1
), /* ldsid (,r22),r1 */
1194 INSN(00,01,18,20), /* mtsp r1,sr0 */
1195 INSN(e6
,c0
,00,00), /* be,l 0(sr0,r22),%sr0,%r31 */
1196 INSN(08,1f
,02,42), /* copy r31,rp */
1197 INSN(0f
,d1
,10,82), /* ldw -8(,sp),rp */
1198 INSN(00,40,10,a1
), /* ldsid (,rp),r1 */
1199 INSN(00,01,18,20), /* mtsp r1,sr0 */
1200 INSN(e0
,40,00,00), /* be 0(sr0,rp) */
1201 INSN(08,00,02,40) /* nop */
1204 /* for hppa32, we must call the function through a stub so that on
1205 return it can return to the space of our trampoline. */
1206 stubaddr
= hppa_hpux_find_import_stub_for_addr (funcaddr
);
1208 error (_("Cannot call external function not referenced by application "
1209 "(no import stub).\n"));
1210 regcache_cooked_write_unsigned (regcache
, 22, stubaddr
);
1212 write_memory (sp
, hppa32_tramp
, sizeof (hppa32_tramp
));
1214 *bp_addr
= hppa_hpux_find_dummy_bpaddr (pc
);
1215 regcache_cooked_write_unsigned (regcache
, 31, *bp_addr
);
1217 *real_pc
= hppa32_hpux_search_dummy_call_sequence (gdbarch
, pc
, &argreg
);
1219 error (_("Cannot make interspace call from here."));
1221 regcache_cooked_write_unsigned (regcache
, argreg
, sp
);
1223 sp
+= sizeof (hppa32_tramp
);
1227 static const gdb_byte hppa64_tramp
[] = {
1228 INSN(ea
,c0
,f0
,00), /* bve,l (r22),%r2 */
1229 INSN(0f
,df
,12,d1
), /* std r31,-8(,sp) */
1230 INSN(0f
,d1
,10,c2
), /* ldd -8(,sp),rp */
1231 INSN(e8
,40,d0
,02), /* bve,n (rp) */
1232 INSN(08,00,02,40) /* nop */
1236 /* for hppa64, we don't need to call through a stub; all functions
1237 return via a bve. */
1238 regcache_cooked_write_unsigned (regcache
, 22, funcaddr
);
1239 write_memory (sp
, hppa64_tramp
, sizeof (hppa64_tramp
));
1242 regcache_cooked_write_unsigned (regcache
, 31, *bp_addr
);
1244 *real_pc
= hppa64_hpux_search_dummy_call_sequence (gdbarch
, pc
, &argreg
);
1246 error (_("Cannot make interspace call from here."));
1248 regcache_cooked_write_unsigned (regcache
, argreg
, sp
);
1250 sp
+= sizeof (hppa64_tramp
);
1253 sp
= gdbarch_frame_align (gdbarch
, sp
);
1261 hppa_hpux_supply_ss_narrow (struct regcache
*regcache
,
1262 int regnum
, const gdb_byte
*save_state
)
1264 const gdb_byte
*ss_narrow
= save_state
+ HPPA_HPUX_SS_NARROW_OFFSET
;
1267 for (i
= HPPA_R1_REGNUM
; i
< HPPA_FP0_REGNUM
; i
++)
1269 if (regnum
== i
|| regnum
== -1)
1270 regcache_raw_supply (regcache
, i
, ss_narrow
+ offset
);
1277 hppa_hpux_supply_ss_fpblock (struct regcache
*regcache
,
1278 int regnum
, const gdb_byte
*save_state
)
1280 const gdb_byte
*ss_fpblock
= save_state
+ HPPA_HPUX_SS_FPBLOCK_OFFSET
;
1283 /* FIXME: We view the floating-point state as 64 single-precision
1284 registers for 32-bit code, and 32 double-precision register for
1285 64-bit code. This distinction is artificial and should be
1286 eliminated. If that ever happens, we should remove the if-clause
1289 if (register_size (get_regcache_arch (regcache
), HPPA_FP0_REGNUM
) == 4)
1291 for (i
= HPPA_FP0_REGNUM
; i
< HPPA_FP0_REGNUM
+ 64; i
++)
1293 if (regnum
== i
|| regnum
== -1)
1294 regcache_raw_supply (regcache
, i
, ss_fpblock
+ offset
);
1301 for (i
= HPPA_FP0_REGNUM
; i
< HPPA_FP0_REGNUM
+ 32; i
++)
1303 if (regnum
== i
|| regnum
== -1)
1304 regcache_raw_supply (regcache
, i
, ss_fpblock
+ offset
);
1312 hppa_hpux_supply_ss_wide (struct regcache
*regcache
,
1313 int regnum
, const gdb_byte
*save_state
)
1315 const gdb_byte
*ss_wide
= save_state
+ HPPA_HPUX_SS_WIDE_OFFSET
;
1318 if (register_size (get_regcache_arch (regcache
), HPPA_R1_REGNUM
) == 4)
1321 for (i
= HPPA_R1_REGNUM
; i
< HPPA_FP0_REGNUM
; i
++)
1323 if (regnum
== i
|| regnum
== -1)
1324 regcache_raw_supply (regcache
, i
, ss_wide
+ offset
);
1331 hppa_hpux_supply_save_state (const struct regset
*regset
,
1332 struct regcache
*regcache
,
1333 int regnum
, const void *regs
, size_t len
)
1335 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
1336 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1337 const gdb_byte
*proc_info
= regs
;
1338 const gdb_byte
*save_state
= proc_info
+ 8;
1341 flags
= extract_unsigned_integer (save_state
+ HPPA_HPUX_SS_FLAGS_OFFSET
,
1343 if (regnum
== -1 || regnum
== HPPA_FLAGS_REGNUM
)
1345 size_t size
= register_size (gdbarch
, HPPA_FLAGS_REGNUM
);
1348 store_unsigned_integer (buf
, size
, byte_order
, flags
);
1349 regcache_raw_supply (regcache
, HPPA_FLAGS_REGNUM
, buf
);
1352 /* If the SS_WIDEREGS flag is set, we really do need the full
1353 `struct save_state'. */
1354 if (flags
& HPPA_HPUX_SS_WIDEREGS
&& len
< HPPA_HPUX_SAVE_STATE_SIZE
)
1355 error (_("Register set contents too small"));
1357 if (flags
& HPPA_HPUX_SS_WIDEREGS
)
1358 hppa_hpux_supply_ss_wide (regcache
, regnum
, save_state
);
1360 hppa_hpux_supply_ss_narrow (regcache
, regnum
, save_state
);
1362 hppa_hpux_supply_ss_fpblock (regcache
, regnum
, save_state
);
1365 /* HP-UX register set. */
1367 static const struct regset hppa_hpux_regset
=
1370 hppa_hpux_supply_save_state
,
1372 REGSET_VARIABLE_SIZE
1376 hppa_hpux_iterate_over_regset_sections (struct gdbarch
*gdbarch
,
1377 iterate_over_regset_sections_cb
*cb
,
1379 const struct regcache
*regcache
)
1381 cb (".reg", HPPA_HPUX_PA89_SAVE_STATE_SIZE
+ 8, &hppa_hpux_regset
,
1386 /* Bit in the `ss_flag' member of `struct save_state' that indicates
1387 the state was saved from a system call. From
1388 <machine/save_state.h>. */
1389 #define HPPA_HPUX_SS_INSYSCALL 0x02
1392 hppa_hpux_read_pc (struct regcache
*regcache
)
1396 /* If we're currently in a system call return the contents of %r31. */
1397 regcache_cooked_read_unsigned (regcache
, HPPA_FLAGS_REGNUM
, &flags
);
1398 if (flags
& HPPA_HPUX_SS_INSYSCALL
)
1401 regcache_cooked_read_unsigned (regcache
, HPPA_R31_REGNUM
, &pc
);
1405 return hppa_read_pc (regcache
);
1409 hppa_hpux_write_pc (struct regcache
*regcache
, CORE_ADDR pc
)
1413 /* If we're currently in a system call also write PC into %r31. */
1414 regcache_cooked_read_unsigned (regcache
, HPPA_FLAGS_REGNUM
, &flags
);
1415 if (flags
& HPPA_HPUX_SS_INSYSCALL
)
1416 regcache_cooked_write_unsigned (regcache
, HPPA_R31_REGNUM
, pc
| 0x3);
1418 hppa_write_pc (regcache
, pc
);
1422 hppa_hpux_unwind_pc (struct gdbarch
*gdbarch
, struct frame_info
*next_frame
)
1426 /* If we're currently in a system call return the contents of %r31. */
1427 flags
= frame_unwind_register_unsigned (next_frame
, HPPA_FLAGS_REGNUM
);
1428 if (flags
& HPPA_HPUX_SS_INSYSCALL
)
1429 return frame_unwind_register_unsigned (next_frame
, HPPA_R31_REGNUM
) & ~0x3;
1431 return hppa_unwind_pc (gdbarch
, next_frame
);
1435 /* Given the current value of the pc, check to see if it is inside a stub, and
1436 if so, change the value of the pc to point to the caller of the stub.
1437 THIS_FRAME is the current frame in the current list of frames.
1438 BASE contains to stack frame base of the current frame.
1439 SAVE_REGS is the register file stored in the frame cache. */
1441 hppa_hpux_unwind_adjust_stub (struct frame_info
*this_frame
, CORE_ADDR base
,
1442 struct trad_frame_saved_reg
*saved_regs
)
1444 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1445 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1446 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
1447 struct value
*pcoq_head_val
;
1450 struct unwind_table_entry
*u
;
1452 pcoq_head_val
= trad_frame_get_prev_register (this_frame
, saved_regs
,
1453 HPPA_PCOQ_HEAD_REGNUM
);
1455 extract_unsigned_integer (value_contents_all (pcoq_head_val
),
1456 register_size (gdbarch
, HPPA_PCOQ_HEAD_REGNUM
),
1459 u
= find_unwind_entry (pcoq_head
);
1460 if (u
&& u
->stub_unwind
.stub_type
== EXPORT
)
1462 stubpc
= read_memory_integer (base
- 24, word_size
, byte_order
);
1463 trad_frame_set_value (saved_regs
, HPPA_PCOQ_HEAD_REGNUM
, stubpc
);
1465 else if (hppa_symbol_address ("__gcc_plt_call")
1466 == get_pc_function_start (pcoq_head
))
1468 stubpc
= read_memory_integer (base
- 8, word_size
, byte_order
);
1469 trad_frame_set_value (saved_regs
, HPPA_PCOQ_HEAD_REGNUM
, stubpc
);
1474 hppa_hpux_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
1476 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1478 if (IS_32BIT_TARGET (gdbarch
))
1479 tdep
->in_solib_call_trampoline
= hppa32_hpux_in_solib_call_trampoline
;
1481 tdep
->in_solib_call_trampoline
= hppa64_hpux_in_solib_call_trampoline
;
1483 tdep
->unwind_adjust_stub
= hppa_hpux_unwind_adjust_stub
;
1485 set_gdbarch_in_solib_return_trampoline
1486 (gdbarch
, hppa_hpux_in_solib_return_trampoline
);
1487 set_gdbarch_skip_trampoline_code (gdbarch
, hppa_hpux_skip_trampoline_code
);
1489 set_gdbarch_push_dummy_code (gdbarch
, hppa_hpux_push_dummy_code
);
1490 set_gdbarch_call_dummy_location (gdbarch
, ON_STACK
);
1492 set_gdbarch_read_pc (gdbarch
, hppa_hpux_read_pc
);
1493 set_gdbarch_write_pc (gdbarch
, hppa_hpux_write_pc
);
1494 set_gdbarch_unwind_pc (gdbarch
, hppa_hpux_unwind_pc
);
1495 set_gdbarch_skip_permanent_breakpoint
1496 (gdbarch
, hppa_skip_permanent_breakpoint
);
1498 set_gdbarch_iterate_over_regset_sections
1499 (gdbarch
, hppa_hpux_iterate_over_regset_sections
);
1501 frame_unwind_append_unwinder (gdbarch
, &hppa_hpux_sigtramp_frame_unwind
);
1505 hppa_hpux_som_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
1507 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1511 tdep
->find_global_pointer
= hppa32_hpux_find_global_pointer
;
1513 hppa_hpux_init_abi (info
, gdbarch
);
1514 som_solib_select (gdbarch
);
1518 hppa_hpux_elf_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
1520 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1523 tdep
->find_global_pointer
= hppa64_hpux_find_global_pointer
;
1525 hppa_hpux_init_abi (info
, gdbarch
);
1526 pa64_solib_select (gdbarch
);
1529 static enum gdb_osabi
1530 hppa_hpux_core_osabi_sniffer (bfd
*abfd
)
1532 if (strcmp (bfd_get_target (abfd
), "hpux-core") == 0)
1533 return GDB_OSABI_HPUX_SOM
;
1534 else if (strcmp (bfd_get_target (abfd
), "elf64-hppa") == 0)
1538 section
= bfd_get_section_by_name (abfd
, ".kernel");
1544 size
= bfd_section_size (abfd
, section
);
1545 contents
= alloca (size
);
1546 if (bfd_get_section_contents (abfd
, section
, contents
,
1548 && strcmp (contents
, "HP-UX") == 0)
1549 return GDB_OSABI_HPUX_ELF
;
1553 return GDB_OSABI_UNKNOWN
;
1557 _initialize_hppa_hpux_tdep (void)
1559 /* BFD doesn't set a flavour for HP-UX style core files. It doesn't
1560 set the architecture either. */
1561 gdbarch_register_osabi_sniffer (bfd_arch_unknown
,
1562 bfd_target_unknown_flavour
,
1563 hppa_hpux_core_osabi_sniffer
);
1564 gdbarch_register_osabi_sniffer (bfd_arch_hppa
,
1565 bfd_target_elf_flavour
,
1566 hppa_hpux_core_osabi_sniffer
);
1568 gdbarch_register_osabi (bfd_arch_hppa
, 0, GDB_OSABI_HPUX_SOM
,
1569 hppa_hpux_som_init_abi
);
1570 gdbarch_register_osabi (bfd_arch_hppa
, bfd_mach_hppa20w
, GDB_OSABI_HPUX_ELF
,
1571 hppa_hpux_elf_init_abi
);