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