GDB (xrefs)

/tmp/gdb-8.1/gdb/alpha-obsd-tdep.c
Go to the documentation of this file.
1 /* Target-dependent code for OpenBSD/alpha.
2
3 Copyright (C) 2006-2018 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 3 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, see <http://www.gnu.org/licenses/>. */
19
20 #include "defs.h"
21 #include "frame.h"
22 #include "gdbcore.h"
23 #include "osabi.h"
24
25 #include "obsd-tdep.h"
26 #include "alpha-tdep.h"
27 #include "alpha-bsd-tdep.h"
28 #include "solib-svr4.h"
29
30 /* Signal trampolines. */
31
32 /* The OpenBSD kernel maps the signal trampoline at some random
33 location in user space, which means that the traditional BSD way of
34 detecting it won't work.
35
36 The signal trampoline will be mapped at an address that is page
37 aligned. We recognize the signal trampoline by looking for the
38 sigreturn system call. */
39
40 static const int alphaobsd_page_size = 8192;
41
42 static LONGEST
43 alphaobsd_sigtramp_offset (struct gdbarch *gdbarch, CORE_ADDR pc)
44 {
45 return (pc & (alphaobsd_page_size - 1));
46 }
47
48 static int
49 alphaobsd_pc_in_sigtramp (struct gdbarch *gdbarch,
50 CORE_ADDR pc, const 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 (gdbarch, start_pc + 5 * ALPHA_INSN_SIZE);
60 if (insn != 0x201f0067)
61 return 0;
62
63 /* Check for "". */
64 insn = alpha_read_insn (gdbarch, start_pc + 6 * ALPHA_INSN_SIZE);
65 if (insn != 0x00000083)
66 return 0;
67
68 return 1;
69 }
70
71 static CORE_ADDR
72 alphaobsd_sigcontext_addr (struct frame_info *this_frame)
73 {
74 struct gdbarch *gdbarch = get_frame_arch (this_frame);
75 CORE_ADDR pc = get_frame_pc (this_frame);
76
77 if (alphaobsd_sigtramp_offset (gdbarch, pc) < 3 * ALPHA_INSN_SIZE)
78 {
79 /* On entry, a pointer the `struct sigcontext' is passed in %a2. */
80 return get_frame_register_unsigned (this_frame, ALPHA_A0_REGNUM + 2);
81 }
82 else if (alphaobsd_sigtramp_offset (gdbarch, pc) < 4 * ALPHA_INSN_SIZE)
83 {
84 /* It is stored on the stack Before calling the signal handler. */
85 CORE_ADDR sp;
86 sp = get_frame_register_unsigned (this_frame, ALPHA_SP_REGNUM);
87 return get_frame_memory_unsigned (this_frame, sp, 8);
88 }
89 else
90 {
91 /* It is reloaded into %a0 for the sigreturn(2) call. */
92 return get_frame_register_unsigned (this_frame, ALPHA_A0_REGNUM);
93 }
94 }
95
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);
115 set_gdbarch_skip_solib_resolver (gdbarch, obsd_skip_solib_resolver);
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_iterate_over_regset_sections
125 (gdbarch, alphanbsd_iterate_over_regset_sections);
126 }
127
128
129 void
130 _initialize_alphaobsd_tdep (void)
131 {
132 gdbarch_register_osabi (bfd_arch_alpha, 0, GDB_OSABI_OPENBSD,
133 alphaobsd_init_abi);
134 }
gdbarch
Definition: gdbarch.c:127
alpha_mdebug_init_abi
void alpha_mdebug_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: alpha-mdebug-tdep.c:403
obsd-tdep.h
get_frame_pc
CORE_ADDR get_frame_pc(struct frame_info *frame)
Definition: frame.c:2376
CORE_ADDR
bfd_vma CORE_ADDR
Definition: common-types.h:41
svr4_lp64_fetch_link_map_offsets
struct link_map_offsets * svr4_lp64_fetch_link_map_offsets(void)
Definition: solib-svr4.c:3214
gdbarch_tdep::dynamic_sigtramp_offset
LONGEST(* dynamic_sigtramp_offset)(struct gdbarch *, CORE_ADDR)
Definition: alpha-tdep.h:78
alpha_software_single_step
std::vector< CORE_ADDR > alpha_software_single_step(struct regcache *regcache)
Definition: alpha-tdep.c:1722
ALPHA_INSN_SIZE
#define ALPHA_INSN_SIZE
Definition: alpha-tdep.h:54
ALPHA_A0_REGNUM
#define ALPHA_A0_REGNUM
Definition: alpha-tdep.h:40
alpha_dwarf2_init_abi
void alpha_dwarf2_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: alpha-tdep.c:1850
ALPHA_SP_REGNUM
#define ALPHA_SP_REGNUM
Definition: alpha-tdep.h:45
gdbarch_tdep::pc
struct m32c_reg * pc
Definition: m32c-tdep.c:116
gdbarch_tdep
Definition: aarch64-tdep.h:55
alpha_read_insn
unsigned int alpha_read_insn(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition: alpha-tdep.c:679
gdbarch_tdep::sigcontext_addr
CORE_ADDR(* sigcontext_addr)(struct frame_info *)
Definition: alpha-tdep.h:82
frame_info
Definition: frame.c:85
alphaobsd_pc_in_sigtramp
static int alphaobsd_pc_in_sigtramp(struct gdbarch *gdbarch, CORE_ADDR pc, const char *name)
Definition: alpha-obsd-tdep.c:49
get_frame_memory_unsigned
ULONGEST get_frame_memory_unsigned(struct frame_info *this_frame, CORE_ADDR addr, int len)
Definition: frame.c:2671
defs.h
gdbarch_tdep
struct gdbarch_tdep * gdbarch_tdep(struct gdbarch *gdbarch)
Definition: gdbarch.c:1491
name
const char *const name
Definition: aarch64-tdep.c:76
alphanbsd_iterate_over_regset_sections
void alphanbsd_iterate_over_regset_sections(struct gdbarch *gdbarch, iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache)
Definition: alpha-nbsd-tdep.c:159
solib-svr4.h
osabi.h
frame.h
gdbarch_tdep::jb_pc
int jb_pc
Definition: aarch64-tdep.h:62
set_solib_svr4_fetch_link_map_offsets
void set_solib_svr4_fetch_link_map_offsets(struct gdbarch *gdbarch, struct link_map_offsets *(*flmo)(void))
Definition: solib-svr4.c:3137
alpha-bsd-tdep.h
_initialize_alphaobsd_tdep
void _initialize_alphaobsd_tdep(void)
Definition: alpha-obsd-tdep.c:130
alphaobsd_sigcontext_addr
static CORE_ADDR alphaobsd_sigcontext_addr(struct frame_info *this_frame)
Definition: alpha-obsd-tdep.c:72
get_frame_register_unsigned
ULONGEST get_frame_register_unsigned(struct frame_info *frame, int regnum)
Definition: frame.c:1308
gdbarch_register_osabi
void gdbarch_register_osabi(enum bfd_architecture arch, unsigned long machine, enum gdb_osabi osabi, void(*init_osabi)(struct gdbarch_info, struct gdbarch *))
Definition: osabi.c:143
gdbarch_tdep::jb_elt_size
size_t jb_elt_size
Definition: aarch64-tdep.h:65
set_gdbarch_software_single_step
void set_gdbarch_software_single_step(struct gdbarch *gdbarch, gdbarch_software_single_step_ftype software_single_step)
Definition: gdbarch.c:3258
gdbarch_tdep::pc_in_sigtramp
int(* pc_in_sigtramp)(struct gdbarch *gdbarch, CORE_ADDR pc, const char *name)
Definition: alpha-tdep.h:88
gdbcore.h
alphaobsd_page_size
static const int alphaobsd_page_size
Definition: alpha-obsd-tdep.c:40
alphaobsd_init_abi
static void alphaobsd_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: alpha-obsd-tdep.c:98
alphaobsd_sigtramp_offset
static LONGEST alphaobsd_sigtramp_offset(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition: alpha-obsd-tdep.c:43
gdbarch_info
Definition: gdbarch.h:1626
obsd_skip_solib_resolver
CORE_ADDR obsd_skip_solib_resolver(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition: obsd-tdep.c:28
set_gdbarch_iterate_over_regset_sections
void set_gdbarch_iterate_over_regset_sections(struct gdbarch *gdbarch, gdbarch_iterate_over_regset_sections_ftype iterate_over_regset_sections)
Definition: gdbarch.c:3647
GDB_OSABI_OPENBSD
Definition: defs.h:520
set_gdbarch_skip_solib_resolver
void set_gdbarch_skip_solib_resolver(struct gdbarch *gdbarch, gdbarch_skip_solib_resolver_ftype skip_solib_resolver)
Definition: gdbarch.c:3333
alpha-tdep.h
get_frame_arch
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
Definition: frame.c:2691
LONGEST
long long LONGEST
Definition: common-types.h:52