* arm-tdep.c (arm_gdbarch_init): Get default floating-point model
[deliverable/binutils-gdb.git] / gdb / alphaobsd-tdep.c
CommitLineData
8a112c90
MK
1/* Target-dependent code for OpenBSD/alpha.
2
3 Copyright (C) 2006 Free Software Foundation, Inc.
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
27#include "alpha-tdep.h"
28#include "alphabsd-tdep.h"
29#include "solib-svr4.h"
30
31/* Signal trampolines. */
32
33/* The OpenBSD kernel maps the signal trampoline at some random
34 location in user space, which means that the traditional BSD way of
35 detecting it won't work.
36
37 The signal trampoline will be mapped at an address that is page
38 aligned. We recognize the signal trampoline by looking for the
39 sigreturn system call. */
40
41static const int alphaobsd_page_size = 8192;
42
43static LONGEST
44alphaobsd_sigtramp_offset (CORE_ADDR pc)
45{
46 return (pc & (alphaobsd_page_size - 1));
47}
48
49static int
50alphaobsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
51{
52 CORE_ADDR start_pc = (pc & ~(alphaobsd_page_size - 1));
53 unsigned insn;
54
55 if (name)
56 return 0;
57
58 /* Check for "". */
59 insn = alpha_read_insn (start_pc + 5 * ALPHA_INSN_SIZE);
60 if (insn != 0x201f0067)
61 return 0;
62
63 /* Check for "". */
64 insn = alpha_read_insn (start_pc + 6 * ALPHA_INSN_SIZE);
65 if (insn != 0x00000083)
66 return 0;
67
68 return 1;
69}
70
71static CORE_ADDR
72alphaobsd_sigcontext_addr (struct frame_info *next_frame)
73{
74 CORE_ADDR pc = frame_pc_unwind (next_frame);
75
76 if (alphaobsd_sigtramp_offset (pc) < 3 * ALPHA_INSN_SIZE)
77 {
78 /* On entry, a pointer the `struct sigcontext' is passed in %a2. */
79 return frame_unwind_register_unsigned (next_frame, ALPHA_A0_REGNUM + 2);
80 }
81 else if (alphaobsd_sigtramp_offset (pc) < 4 * ALPHA_INSN_SIZE)
82 {
83 /* It is stored on the stack Before calling the signal handler. */
84 CORE_ADDR sp;
85 sp = frame_unwind_register_unsigned (next_frame, ALPHA_SP_REGNUM);
86 return get_frame_memory_unsigned (next_frame, sp, 8);
87 }
88 else
89 {
90 /* It is reloaded into %a0 for the sigreturn(2) call. */
91 return frame_unwind_register_unsigned (next_frame, ALPHA_A0_REGNUM);
92 }
93}
94\f
95
96static void
97alphaobsd_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
98{
99 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
100
101 /* Hook into the DWARF CFI frame unwinder. */
102 alpha_dwarf2_init_abi (info, gdbarch);
103
104 /* Hook into the MDEBUG frame unwinder. */
105 alpha_mdebug_init_abi (info, gdbarch);
106
107 /* OpenBSD/alpha 3.0 and earlier does not provide single step
108 support via ptrace(2); use software single-stepping for now. */
109 set_gdbarch_software_single_step (gdbarch, alpha_software_single_step);
110
111 /* OpenBSD/alpha has SVR4-style shared libraries. */
112 set_solib_svr4_fetch_link_map_offsets
113 (gdbarch, svr4_lp64_fetch_link_map_offsets);
114
115 tdep->dynamic_sigtramp_offset = alphaobsd_sigtramp_offset;
116 tdep->pc_in_sigtramp = alphaobsd_pc_in_sigtramp;
117 tdep->sigcontext_addr = alphaobsd_sigcontext_addr;
118
119 tdep->jb_pc = 2;
120 tdep->jb_elt_size = 8;
121
122 set_gdbarch_regset_from_core_section
123 (gdbarch, alphanbsd_regset_from_core_section);
124}
125\f
126
127/* Provide a prototype to silence -Wmissing-prototypes. */
128void _initialize_alphaobsd_tdep (void);
129
130void
131_initialize_alphaobsd_tdep (void)
132{
133 gdbarch_register_osabi (bfd_arch_alpha, 0, GDB_OSABI_OPENBSD_ELF,
134 alphaobsd_init_abi);
135}
This page took 0.028573 seconds and 4 git commands to generate.