Commit | Line | Data |
---|---|---|
273f8429 JB |
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" | |
60e1ff27 | 22 | #include "gdbcore.h" |
273f8429 | 23 | #include "osabi.h" |
65e82032 | 24 | #include "gdb_string.h" |
273f8429 JB |
25 | |
26 | /* Forward declarations. */ | |
27 | extern void _initialize_hppa_hpux_tdep (void); | |
28 | extern initialize_file_ftype _initialize_hppa_hpux_tdep; | |
29 | ||
60e1ff27 JB |
30 | /* FIXME: brobecker 2002-12-25. The following functions will eventually |
31 | become static, after the multiarching conversion is done. */ | |
32 | int hppa_hpux_pc_in_sigtramp (CORE_ADDR pc, char *name); | |
33 | void hppa_hpux_frame_saved_pc_in_sigtramp (struct frame_info *fi, | |
34 | CORE_ADDR *tmp); | |
35 | void hppa_hpux_frame_base_before_sigtramp (struct frame_info *fi, | |
36 | CORE_ADDR *tmp); | |
37 | void hppa_hpux_frame_find_saved_regs_in_sigtramp | |
38 | (struct frame_info *fi, struct frame_saved_regs *fsr); | |
39 | ||
40 | int | |
41 | hppa_hpux_pc_in_sigtramp (CORE_ADDR pc, char *name) | |
42 | { | |
43 | /* Actually, for a PA running HPUX the kernel calls the signal handler | |
44 | without an intermediate trampoline. Luckily the kernel always sets | |
45 | the return pointer for the signal handler to point to _sigreturn. */ | |
46 | return (name && (strcmp ("_sigreturn", name) == 0)); | |
47 | } | |
48 | ||
49 | /* For hppa_hpux_frame_saved_pc_in_sigtramp, | |
50 | hppa_hpux_frame_base_before_sigtramp and | |
51 | hppa_hpux_frame_find_saved_regs_in_sigtramp: | |
52 | ||
53 | The signal context structure pointer is always saved at the base | |
54 | of the frame which "calls" the signal handler. We only want to find | |
55 | the hardware save state structure, which lives 10 32bit words into | |
56 | sigcontext structure. | |
57 | ||
58 | Within the hardware save state structure, registers are found in the | |
59 | same order as the register numbers in GDB. | |
60 | ||
61 | At one time we peeked at %r31 rather than the PC queues to determine | |
62 | what instruction took the fault. This was done on purpose, but I don't | |
63 | remember why. Looking at the PC queues is really the right way, and | |
64 | I don't remember why that didn't work when this code was originally | |
65 | written. */ | |
66 | ||
67 | void | |
68 | hppa_hpux_frame_saved_pc_in_sigtramp (struct frame_info *fi, CORE_ADDR *tmp) | |
69 | { | |
70 | *tmp = read_memory_integer (fi->frame + (43 * 4), 4); | |
71 | } | |
72 | ||
73 | void | |
74 | hppa_hpux_frame_base_before_sigtramp (struct frame_info *fi, | |
75 | CORE_ADDR *tmp) | |
76 | { | |
77 | *tmp = read_memory_integer (fi->frame + (40 * 4), 4); | |
78 | } | |
79 | ||
80 | void | |
81 | hppa_hpux_frame_find_saved_regs_in_sigtramp (struct frame_info *fi, | |
82 | struct frame_saved_regs *fsr) | |
83 | { | |
84 | int i; | |
85 | const CORE_ADDR tmp = (fi)->frame + (10 * 4); | |
86 | ||
87 | for (i = 0; i < NUM_REGS; i++) | |
88 | { | |
89 | if (i == SP_REGNUM) | |
90 | (fsr)->regs[SP_REGNUM] = read_memory_integer (tmp + SP_REGNUM * 4, 4); | |
91 | else | |
92 | (fsr)->regs[i] = tmp + i * 4; | |
93 | } | |
94 | } | |
95 | ||
96 | ||
273f8429 JB |
97 | static void |
98 | hppa_hpux_som_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | |
99 | { | |
100 | } | |
101 | ||
102 | static void | |
103 | hppa_hpux_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | |
104 | { | |
105 | } | |
106 | ||
107 | void | |
108 | _initialize_hppa_hpux_tdep (void) | |
109 | { | |
05816f70 | 110 | gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_HPUX_SOM, |
273f8429 | 111 | hppa_hpux_som_init_abi); |
05816f70 | 112 | gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_HPUX_ELF, |
273f8429 JB |
113 | hppa_hpux_elf_init_abi); |
114 | } |