GDB (xrefs)
/tmp/gdb-7.10/gdb/amd64-darwin-tdep.c
Go to the documentation of this file.
1 /* Darwin support for GDB, the GNU debugger.
2  Copyright (C) 1997-2015 Free Software Foundation, Inc.
3 
4  Contributed by Apple Computer, Inc.
5 
6  This file is part of GDB.
7 
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 
21 #include "defs.h"
22 #include "frame.h"
23 #include "inferior.h"
24 #include "gdbcore.h"
25 #include "target.h"
26 #include "floatformat.h"
27 #include "symtab.h"
28 #include "regcache.h"
29 #include "libbfd.h"
30 #include "objfiles.h"
31 
32 #include "i387-tdep.h"
33 #include "amd64-tdep.h"
34 #include "osabi.h"
35 #include "ui-out.h"
36 #include "amd64-darwin-tdep.h"
37 #include "i386-darwin-tdep.h"
38 #include "solib.h"
39 #include "solib-darwin.h"
40 #include "dwarf2-frame.h"
41 
42 /* Offsets into the struct x86_thread_state64 where we'll find the saved regs.
43  From <mach/i386/thread_status.h> and amd64-tdep.h. */
45 {
46  0 * 8, /* %rax */
47  1 * 8, /* %rbx */
48  2 * 8, /* %rcx */
49  3 * 8, /* %rdx */
50  5 * 8, /* %rsi */
51  4 * 8, /* %rdi */
52  6 * 8, /* %rbp */
53  7 * 8, /* %rsp */
54  8 * 8, /* %r8 ... */
55  9 * 8,
56  10 * 8,
57  11 * 8,
58  12 * 8,
59  13 * 8,
60  14 * 8,
61  15 * 8, /* ... %r15 */
62  16 * 8, /* %rip */
63  17 * 8, /* %rflags */
64  18 * 8, /* %cs */
65  -1, /* %ss */
66  -1, /* %ds */
67  -1, /* %es */
68  19 * 8, /* %fs */
69  20 * 8 /* %gs */
70 };
71 
74 
75 /* Assuming THIS_FRAME is a Darwin sigtramp routine, return the
76  address of the associated sigcontext structure. */
77 
78 static CORE_ADDR
80 {
81  struct gdbarch *gdbarch = get_frame_arch (this_frame);
82  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
83  CORE_ADDR rbx;
84  gdb_byte buf[8];
85 
86  /* A pointer to the ucontext is passed as the fourth argument
87  to the signal handler, which is saved in rbx. */
88  get_frame_register (this_frame, AMD64_RBX_REGNUM, buf);
89  rbx = extract_unsigned_integer (buf, 8, byte_order);
90 
91  /* The pointer to mcontext is at offset 48. */
92  read_memory (rbx + 48, buf, 8);
93 
94  /* First register (rax) is at offset 16. */
95  return extract_unsigned_integer (buf, 8, byte_order) + 16;
96 }
97 
98 static void
100 {
101  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
102 
103  amd64_init_abi (info, gdbarch);
104 
106 
108 
109  tdep->sigtramp_p = i386_sigtramp_p;
113 
114  tdep->jb_pc_offset = 56;
115 
116  set_solib_ops (gdbarch, &darwin_so_ops);
117 }
118 
119 /* -Wmissing-prototypes */
121 
122 void
124 {
125  gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
127 }
ULONGEST extract_unsigned_integer(const gdb_byte *, int, enum bfd_endian)
Definition: findvar.c:84
int jb_pc_offset
Definition: i386-tdep.h:199
bfd_vma CORE_ADDR
Definition: common-types.h:41
int sc_num_regs
Definition: i386-tdep.h:216
void set_solib_ops(struct gdbarch *gdbarch, const struct target_so_ops *new_ops)
Definition: solib.c:76
initialize_file_ftype _initialize_amd64_darwin_tdep
int i386_sigtramp_p(struct frame_info *this_frame)
Definition: i386-tdep.c:3879
int darwin_dwarf_signal_frame_p(struct gdbarch *gdbarch, struct frame_info *this_frame)
CORE_ADDR(* sigcontext_addr)(struct frame_info *)
Definition: alpha-tdep.h:82
void dwarf2_frame_set_signal_frame_p(struct gdbarch *gdbarch, int(*signal_frame_p)(struct gdbarch *, struct frame_info *))
Definition: dwarf2-frame.c:806
struct gdbarch_tdep * gdbarch_tdep(struct gdbarch *gdbarch)
Definition: gdbarch.c:1402
static void x86_darwin_init_abi_64(struct gdbarch_info info, struct gdbarch *gdbarch)
enum struct_return struct_return
Definition: arm-tdep.h:197
void initialize_file_ftype(void)
Definition: defs.h:281
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition: gdbarch.c:1420
struct target_so_ops darwin_so_ops
Definition: solib-darwin.c:615
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition: corefile.c:244
const int amd64_darwin_thread_state_num_regs
bfd_byte gdb_byte
Definition: common-types.h:38
int(* sigtramp_p)(struct frame_info *)
Definition: i386-tdep.h:209
void amd64_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: amd64-tdep.c:2937
void get_frame_register(struct frame_info *frame, int regnum, gdb_byte *buf)
Definition: frame.c:1085
int amd64_darwin_thread_state_reg_offset[]
static CORE_ADDR amd64_darwin_sigcontext_addr(struct frame_info *this_frame)
int * sc_reg_offset
Definition: i386-tdep.h:215
enum bfd_endian byte_order
Definition: gdbarch.c:128
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
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
Definition: frame.c:2535