*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / amd64-sol2-tdep.c
1 /* Target-dependent code for AMD64 Solaris.
2
3 Copyright (C) 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
4
5 Contributed by Joseph Myers, CodeSourcery, LLC.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA. */
23
24 #include "defs.h"
25 #include "frame.h"
26 #include "gdbcore.h"
27 #include "regcache.h"
28 #include "osabi.h"
29 #include "symtab.h"
30
31 #include "gdb_string.h"
32
33 #include "sol2-tdep.h"
34 #include "amd64-tdep.h"
35 #include "solib-svr4.h"
36
37 /* Mapping between the general-purpose registers in gregset_t format
38 and GDB's register cache layout. */
39
40 /* From <sys/regset.h>. */
41 static int amd64_sol2_gregset_reg_offset[] = {
42 14 * 8, /* %rax */
43 11 * 8, /* %rbx */
44 13 * 8, /* %rcx */
45 12 * 8, /* %rdx */
46 9 * 8, /* %rsi */
47 8 * 8, /* %rdi */
48 10 * 8, /* %rbp */
49 20 * 8, /* %rsp */
50 7 * 8, /* %r8 ... */
51 6 * 8,
52 5 * 8,
53 4 * 8,
54 3 * 8,
55 2 * 8,
56 1 * 8,
57 0 * 8, /* ... %r15 */
58 17 * 8, /* %rip */
59 16 * 8, /* %eflags */
60 18 * 8, /* %cs */
61 21 * 8, /* %ss */
62 25 * 8, /* %ds */
63 24 * 8, /* %es */
64 22 * 8, /* %fs */
65 23 * 8 /* %gs */
66 };
67 \f
68
69 /* Return whether the frame preceding NEXT_FRAME corresponds to a
70 Solaris sigtramp routine. */
71
72 static int
73 amd64_sol2_sigtramp_p (struct frame_info *next_frame)
74 {
75 CORE_ADDR pc = frame_pc_unwind (next_frame);
76 char *name;
77
78 find_pc_partial_function (pc, &name, NULL, NULL);
79 return (name && (strcmp ("sigacthandler", name) == 0
80 || strcmp (name, "ucbsigvechandler") == 0));
81 }
82
83 /* Solaris doesn't have a 'struct sigcontext', but it does have a
84 'mcontext_t' that contains the saved set of machine registers. */
85
86 static CORE_ADDR
87 amd64_sol2_mcontext_addr (struct frame_info *next_frame)
88 {
89 CORE_ADDR sp, ucontext_addr;
90
91 sp = frame_unwind_register_unsigned (next_frame, AMD64_RSP_REGNUM);
92 ucontext_addr = get_frame_memory_unsigned (next_frame, sp + 8, 8);
93
94 return ucontext_addr + 72;
95 }
96
97 static void
98 amd64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
99 {
100 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
101
102 tdep->gregset_reg_offset = amd64_sol2_gregset_reg_offset;
103 tdep->gregset_num_regs = ARRAY_SIZE (amd64_sol2_gregset_reg_offset);
104 tdep->sizeof_gregset = 28 * 8;
105
106 amd64_init_abi (info, gdbarch);
107
108 tdep->sigtramp_p = amd64_sol2_sigtramp_p;
109 tdep->sigcontext_addr = amd64_sol2_mcontext_addr;
110 tdep->sc_reg_offset = tdep->gregset_reg_offset;
111 tdep->sc_num_regs = tdep->gregset_num_regs;
112
113 /* Solaris uses SVR4-style shared libraries. */
114 set_gdbarch_skip_solib_resolver (gdbarch, sol2_skip_solib_resolver);
115 set_solib_svr4_fetch_link_map_offsets
116 (gdbarch, svr4_lp64_fetch_link_map_offsets);
117 }
118 \f
119
120 /* Provide a prototype to silence -Wmissing-prototypes. */
121 extern void _initialize_amd64_sol2_tdep (void);
122
123 void
124 _initialize_amd64_sol2_tdep (void)
125 {
126 gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
127 GDB_OSABI_SOLARIS, amd64_sol2_init_abi);
128 }
This page took 0.033493 seconds and 4 git commands to generate.