| 1 | /* Target-dependent code for HPUX running on PA-RISC, for GDB. |
| 2 | Copyright 2002 Free Software Foundation, Inc. |
| 3 | |
| 4 | This file is part of GDB. |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 2 of the License, or |
| 9 | (at your option) any later version. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program; if not, write to the Free Software |
| 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
| 19 | |
| 20 | #include "defs.h" |
| 21 | #include "arch-utils.h" |
| 22 | #include "gdbcore.h" |
| 23 | #include "osabi.h" |
| 24 | |
| 25 | /* Forward declarations. */ |
| 26 | extern void _initialize_hppa_hpux_tdep (void); |
| 27 | extern initialize_file_ftype _initialize_hppa_hpux_tdep; |
| 28 | |
| 29 | /* FIXME: brobecker 2002-12-25. The following functions will eventually |
| 30 | become static, after the multiarching conversion is done. */ |
| 31 | int hppa_hpux_pc_in_sigtramp (CORE_ADDR pc, char *name); |
| 32 | void hppa_hpux_frame_saved_pc_in_sigtramp (struct frame_info *fi, |
| 33 | CORE_ADDR *tmp); |
| 34 | void hppa_hpux_frame_base_before_sigtramp (struct frame_info *fi, |
| 35 | CORE_ADDR *tmp); |
| 36 | void hppa_hpux_frame_find_saved_regs_in_sigtramp |
| 37 | (struct frame_info *fi, struct frame_saved_regs *fsr); |
| 38 | |
| 39 | int |
| 40 | hppa_hpux_pc_in_sigtramp (CORE_ADDR pc, char *name) |
| 41 | { |
| 42 | /* Actually, for a PA running HPUX the kernel calls the signal handler |
| 43 | without an intermediate trampoline. Luckily the kernel always sets |
| 44 | the return pointer for the signal handler to point to _sigreturn. */ |
| 45 | return (name && (strcmp ("_sigreturn", name) == 0)); |
| 46 | } |
| 47 | |
| 48 | /* For hppa_hpux_frame_saved_pc_in_sigtramp, |
| 49 | hppa_hpux_frame_base_before_sigtramp and |
| 50 | hppa_hpux_frame_find_saved_regs_in_sigtramp: |
| 51 | |
| 52 | The signal context structure pointer is always saved at the base |
| 53 | of the frame which "calls" the signal handler. We only want to find |
| 54 | the hardware save state structure, which lives 10 32bit words into |
| 55 | sigcontext structure. |
| 56 | |
| 57 | Within the hardware save state structure, registers are found in the |
| 58 | same order as the register numbers in GDB. |
| 59 | |
| 60 | At one time we peeked at %r31 rather than the PC queues to determine |
| 61 | what instruction took the fault. This was done on purpose, but I don't |
| 62 | remember why. Looking at the PC queues is really the right way, and |
| 63 | I don't remember why that didn't work when this code was originally |
| 64 | written. */ |
| 65 | |
| 66 | void |
| 67 | hppa_hpux_frame_saved_pc_in_sigtramp (struct frame_info *fi, CORE_ADDR *tmp) |
| 68 | { |
| 69 | *tmp = read_memory_integer (fi->frame + (43 * 4), 4); |
| 70 | } |
| 71 | |
| 72 | void |
| 73 | hppa_hpux_frame_base_before_sigtramp (struct frame_info *fi, |
| 74 | CORE_ADDR *tmp) |
| 75 | { |
| 76 | *tmp = read_memory_integer (fi->frame + (40 * 4), 4); |
| 77 | } |
| 78 | |
| 79 | void |
| 80 | hppa_hpux_frame_find_saved_regs_in_sigtramp (struct frame_info *fi, |
| 81 | struct frame_saved_regs *fsr) |
| 82 | { |
| 83 | int i; |
| 84 | const CORE_ADDR tmp = (fi)->frame + (10 * 4); |
| 85 | |
| 86 | for (i = 0; i < NUM_REGS; i++) |
| 87 | { |
| 88 | if (i == SP_REGNUM) |
| 89 | (fsr)->regs[SP_REGNUM] = read_memory_integer (tmp + SP_REGNUM * 4, 4); |
| 90 | else |
| 91 | (fsr)->regs[i] = tmp + i * 4; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | |
| 96 | static void |
| 97 | hppa_hpux_som_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
| 98 | { |
| 99 | } |
| 100 | |
| 101 | static void |
| 102 | hppa_hpux_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
| 103 | { |
| 104 | } |
| 105 | |
| 106 | void |
| 107 | _initialize_hppa_hpux_tdep (void) |
| 108 | { |
| 109 | gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_HPUX_SOM, |
| 110 | hppa_hpux_som_init_abi); |
| 111 | gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_HPUX_ELF, |
| 112 | hppa_hpux_elf_init_abi); |
| 113 | } |