]>
Commit | Line | Data |
---|---|---|
8a112c90 MK |
1 | /* Target-dependent code for OpenBSD/alpha. |
2 | ||
6aba47ca | 3 | Copyright (C) 2006, 2007 Free Software Foundation, Inc. |
8a112c90 MK |
4 | |
5 | This file is part of GDB. | |
6 | ||
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 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
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. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
20 | Boston, MA 02110-1301, USA. */ | |
21 | ||
22 | #include "defs.h" | |
23 | #include "frame.h" | |
24 | #include "gdbcore.h" | |
25 | #include "osabi.h" | |
26 | ||
6ea0ec3f | 27 | #include "obsd-tdep.h" |
8a112c90 MK |
28 | #include "alpha-tdep.h" |
29 | #include "alphabsd-tdep.h" | |
30 | #include "solib-svr4.h" | |
31 | ||
32 | /* Signal trampolines. */ | |
33 | ||
34 | /* The OpenBSD kernel maps the signal trampoline at some random | |
35 | location in user space, which means that the traditional BSD way of | |
36 | detecting it won't work. | |
37 | ||
38 | The signal trampoline will be mapped at an address that is page | |
39 | aligned. We recognize the signal trampoline by looking for the | |
40 | sigreturn system call. */ | |
41 | ||
42 | static const int alphaobsd_page_size = 8192; | |
43 | ||
44 | static LONGEST | |
45 | alphaobsd_sigtramp_offset (CORE_ADDR pc) | |
46 | { | |
47 | return (pc & (alphaobsd_page_size - 1)); | |
48 | } | |
49 | ||
50 | static int | |
51 | alphaobsd_pc_in_sigtramp (CORE_ADDR pc, char *name) | |
52 | { | |
53 | CORE_ADDR start_pc = (pc & ~(alphaobsd_page_size - 1)); | |
54 | unsigned insn; | |
55 | ||
56 | if (name) | |
57 | return 0; | |
58 | ||
59 | /* Check for "". */ | |
60 | insn = alpha_read_insn (start_pc + 5 * ALPHA_INSN_SIZE); | |
61 | if (insn != 0x201f0067) | |
62 | return 0; | |
63 | ||
64 | /* Check for "". */ | |
65 | insn = alpha_read_insn (start_pc + 6 * ALPHA_INSN_SIZE); | |
66 | if (insn != 0x00000083) | |
67 | return 0; | |
68 | ||
69 | return 1; | |
70 | } | |
71 | ||
72 | static CORE_ADDR | |
73 | alphaobsd_sigcontext_addr (struct frame_info *next_frame) | |
74 | { | |
75 | CORE_ADDR pc = frame_pc_unwind (next_frame); | |
76 | ||
77 | if (alphaobsd_sigtramp_offset (pc) < 3 * ALPHA_INSN_SIZE) | |
78 | { | |
79 | /* On entry, a pointer the `struct sigcontext' is passed in %a2. */ | |
80 | return frame_unwind_register_unsigned (next_frame, ALPHA_A0_REGNUM + 2); | |
81 | } | |
82 | else if (alphaobsd_sigtramp_offset (pc) < 4 * ALPHA_INSN_SIZE) | |
83 | { | |
84 | /* It is stored on the stack Before calling the signal handler. */ | |
85 | CORE_ADDR sp; | |
86 | sp = frame_unwind_register_unsigned (next_frame, ALPHA_SP_REGNUM); | |
87 | return get_frame_memory_unsigned (next_frame, sp, 8); | |
88 | } | |
89 | else | |
90 | { | |
91 | /* It is reloaded into %a0 for the sigreturn(2) call. */ | |
92 | return frame_unwind_register_unsigned (next_frame, ALPHA_A0_REGNUM); | |
93 | } | |
94 | } | |
95 | \f | |
96 | ||
97 | static void | |
98 | alphaobsd_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch) | |
99 | { | |
100 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
101 | ||
102 | /* Hook into the DWARF CFI frame unwinder. */ | |
103 | alpha_dwarf2_init_abi (info, gdbarch); | |
104 | ||
105 | /* Hook into the MDEBUG frame unwinder. */ | |
106 | alpha_mdebug_init_abi (info, gdbarch); | |
107 | ||
108 | /* OpenBSD/alpha 3.0 and earlier does not provide single step | |
109 | support via ptrace(2); use software single-stepping for now. */ | |
110 | set_gdbarch_software_single_step (gdbarch, alpha_software_single_step); | |
111 | ||
112 | /* OpenBSD/alpha has SVR4-style shared libraries. */ | |
113 | set_solib_svr4_fetch_link_map_offsets | |
114 | (gdbarch, svr4_lp64_fetch_link_map_offsets); | |
6ea0ec3f | 115 | set_gdbarch_skip_solib_resolver (gdbarch, obsd_skip_solib_resolver); |
8a112c90 MK |
116 | |
117 | tdep->dynamic_sigtramp_offset = alphaobsd_sigtramp_offset; | |
118 | tdep->pc_in_sigtramp = alphaobsd_pc_in_sigtramp; | |
119 | tdep->sigcontext_addr = alphaobsd_sigcontext_addr; | |
120 | ||
121 | tdep->jb_pc = 2; | |
122 | tdep->jb_elt_size = 8; | |
123 | ||
124 | set_gdbarch_regset_from_core_section | |
125 | (gdbarch, alphanbsd_regset_from_core_section); | |
126 | } | |
127 | \f | |
128 | ||
129 | /* Provide a prototype to silence -Wmissing-prototypes. */ | |
130 | void _initialize_alphaobsd_tdep (void); | |
131 | ||
132 | void | |
133 | _initialize_alphaobsd_tdep (void) | |
134 | { | |
135 | gdbarch_register_osabi (bfd_arch_alpha, 0, GDB_OSABI_OPENBSD_ELF, | |
136 | alphaobsd_init_abi); | |
137 | } |