GDB (xrefs)
/tmp/gdb-7.10/gdb/amd64nbsd-tdep.c
Go to the documentation of this file.
1 /* Target-dependent code for NetBSD/amd64.
2 
3  Copyright (C) 2003-2015 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 "arch-utils.h"
22 #include "frame.h"
23 #include "gdbcore.h"
24 #include "osabi.h"
25 #include "symtab.h"
26 
27 #include "amd64-tdep.h"
28 #include "nbsd-tdep.h"
29 #include "solib-svr4.h"
30 
31 /* Support for signal handlers. */
32 
33 /* Return whether THIS_FRAME corresponds to a NetBSD sigtramp
34  routine. */
35 
36 static int
37 amd64nbsd_sigtramp_p (struct frame_info *this_frame)
38 {
39  CORE_ADDR pc = get_frame_pc (this_frame);
40  const char *name;
41 
42  find_pc_partial_function (pc, &name, NULL, NULL);
43  return nbsd_pc_in_sigtramp (pc, name);
44 }
45 
46 /* Assuming THIS_FRAME corresponds to a NetBSD sigtramp routine,
47  return the address of the associated mcontext structure. */
48 
49 static CORE_ADDR
50 amd64nbsd_mcontext_addr (struct frame_info *this_frame)
51 {
52  CORE_ADDR addr;
53 
54  /* The register %r15 points at `struct ucontext' upon entry of a
55  signal trampoline. */
56  addr = get_frame_register_unsigned (this_frame, AMD64_R15_REGNUM);
57 
58  /* The mcontext structure lives as offset 56 in `struct ucontext'. */
59  return addr + 56;
60 }
61 
62 /* NetBSD 2.0 or later. */
63 
64 /* Mapping between the general-purpose registers in `struct reg'
65  format and GDB's register cache layout. */
66 
67 /* From <machine/reg.h>. */
69 {
70  14 * 8, /* %rax */
71  13 * 8, /* %rbx */
72  3 * 8, /* %rcx */
73  2 * 8, /* %rdx */
74  1 * 8, /* %rsi */
75  0 * 8, /* %rdi */
76  12 * 8, /* %rbp */
77  24 * 8, /* %rsp */
78  4 * 8, /* %r8 .. */
79  5 * 8,
80  6 * 8,
81  7 * 8,
82  8 * 8,
83  9 * 8,
84  10 * 8,
85  11 * 8, /* ... %r15 */
86  21 * 8, /* %rip */
87  23 * 8, /* %eflags */
88  22 * 8, /* %cs */
89  25 * 8, /* %ss */
90  18 * 8, /* %ds */
91  17 * 8, /* %es */
92  16 * 8, /* %fs */
93  15 * 8 /* %gs */
94 };
95 
96 static void
98 {
99  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
100 
101  /* Initialize general-purpose register set details first. */
103  tdep->gregset_num_regs = ARRAY_SIZE (amd64nbsd_r_reg_offset);
104  tdep->sizeof_gregset = 26 * 8;
105 
106  amd64_init_abi (info, gdbarch);
107 
108  tdep->jb_pc_offset = 7 * 8;
109 
110  /* NetBSD has its own convention for signal trampolines. */
114  tdep->sc_num_regs = ARRAY_SIZE (amd64nbsd_r_reg_offset);
115 
116  /* NetBSD uses SVR4-style shared libraries. */
119 }
120 
121 
122 /* Provide a prototype to silence -Wmissing-prototypes. */
123 void _initialize_amd64nbsd_tdep (void);
124 
125 void
127 {
128  /* The NetBSD/amd64 native dependent code makes this assumption. */
130 
131  gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
133 }
int jb_pc_offset
Definition: i386-tdep.h:199
CORE_ADDR get_frame_pc(struct frame_info *frame)
Definition: frame.c:2217
bfd_vma CORE_ADDR
Definition: common-types.h:41
struct link_map_offsets * svr4_lp64_fetch_link_map_offsets(void)
Definition: solib-svr4.c:3180
int sc_num_regs
Definition: i386-tdep.h:216
static void amd64nbsd_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
int nbsd_pc_in_sigtramp(CORE_ADDR pc, const char *func_name)
Definition: nbsd-tdep.c:42
struct m32c_reg * pc
Definition: m32c-tdep.c:111
CORE_ADDR(* sigcontext_addr)(struct frame_info *)
Definition: alpha-tdep.h:82
struct gdbarch_tdep * gdbarch_tdep(struct gdbarch *gdbarch)
Definition: gdbarch.c:1402
const char *const name
Definition: aarch64-tdep.c:68
int amd64nbsd_r_reg_offset[]
#define AMD64_NUM_GREGS
Definition: amd64-tdep.h:83
void set_solib_svr4_fetch_link_map_offsets(struct gdbarch *gdbarch, struct link_map_offsets *(*flmo)(void))
Definition: solib-svr4.c:3108
int find_pc_partial_function(CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr)
Definition: blockframe.c:321
#define gdb_assert(expr)
Definition: gdb_assert.h:33
ULONGEST get_frame_register_unsigned(struct frame_info *frame, int regnum)
Definition: frame.c:1194
int * gregset_reg_offset
Definition: i386-tdep.h:59
static CORE_ADDR amd64nbsd_mcontext_addr(struct frame_info *this_frame)
int(* sigtramp_p)(struct frame_info *)
Definition: i386-tdep.h:209
void _initialize_amd64nbsd_tdep(void)
void amd64_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: amd64-tdep.c:2937
size_t sizeof_gregset
Definition: i386-tdep.h:61
static int amd64nbsd_sigtramp_p(struct frame_info *this_frame)
int * sc_reg_offset
Definition: i386-tdep.h:215
int gregset_num_regs
Definition: i386-tdep.h:60
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:148