Commit | Line | Data |
---|---|---|
6b16acab MK |
1 | /* Native-dependent code for Solaris x86. |
2 | ||
7b6bb8da JB |
3 | Copyright (C) 2004, 2007, 2008, 2009, 2010, 2011 |
4 | Free Software Foundation, Inc. | |
6b16acab MK |
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 | |
a9762ec7 | 10 | the Free Software Foundation; either version 3 of the License, or |
6b16acab MK |
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 | |
a9762ec7 | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
6b16acab MK |
20 | |
21 | #include "defs.h" | |
22 | #include "regcache.h" | |
23 | ||
24 | #include <sys/procfs.h> | |
25 | #include "gregset.h" | |
d1a7880c PA |
26 | #include "target.h" |
27 | #include "procfs.h" | |
6b16acab MK |
28 | |
29 | /* This file provids the (temporary) glue between the Solaris x86 | |
30 | target dependent code and the machine independent SVR4 /proc | |
31 | support. */ | |
32 | ||
33 | /* Solaris 10 (Solaris 2.10, SunOS 5.10) and up support two process | |
34 | data models, the traditional 32-bit data model (ILP32) and the | |
35 | 64-bit data model (LP64). The format of /proc depends on the data | |
36 | model of the observer (the controlling process, GDB in our case). | |
37 | The Solaris header files conveniently define PR_MODEL_NATIVE to the | |
38 | data model of the controlling process. If its value is | |
39 | PR_MODEL_LP64, we know that GDB is being compiled as a 64-bit | |
40 | program. | |
41 | ||
42 | Note that a 32-bit GDB won't be able to debug a 64-bit target | |
43 | process using /proc on Solaris. */ | |
44 | ||
45 | #if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64) | |
46 | ||
47 | #include "amd64-nat.h" | |
48 | #include "amd64-tdep.h" | |
49 | ||
0bbc026e JM |
50 | /* Mapping between the general-purpose registers in gregset_t format |
51 | and GDB's register cache layout. */ | |
52 | ||
53 | /* From <sys/regset.h>. */ | |
54 | static int amd64_sol2_gregset64_reg_offset[] = { | |
55 | 14 * 8, /* %rax */ | |
56 | 11 * 8, /* %rbx */ | |
57 | 13 * 8, /* %rcx */ | |
58 | 12 * 8, /* %rdx */ | |
59 | 9 * 8, /* %rsi */ | |
60 | 8 * 8, /* %rdi */ | |
61 | 10 * 8, /* %rbp */ | |
62 | 20 * 8, /* %rsp */ | |
63 | 7 * 8, /* %r8 ... */ | |
64 | 6 * 8, | |
65 | 5 * 8, | |
66 | 4 * 8, | |
67 | 3 * 8, | |
68 | 2 * 8, | |
69 | 1 * 8, | |
70 | 0 * 8, /* ... %r15 */ | |
71 | 17 * 8, /* %rip */ | |
72 | 16 * 8, /* %eflags */ | |
73 | 18 * 8, /* %cs */ | |
74 | 21 * 8, /* %ss */ | |
75 | 25 * 8, /* %ds */ | |
76 | 24 * 8, /* %es */ | |
77 | 22 * 8, /* %fs */ | |
78 | 23 * 8 /* %gs */ | |
79 | }; | |
80 | ||
81 | /* 32-bit registers are provided by Solaris in 64-bit format, so just | |
82 | give a subset of the list above. */ | |
83 | static int amd64_sol2_gregset32_reg_offset[] = { | |
84 | 14 * 8, /* %eax */ | |
85 | 13 * 8, /* %ecx */ | |
86 | 12 * 8, /* %edx */ | |
87 | 11 * 8, /* %ebx */ | |
88 | 20 * 8, /* %esp */ | |
89 | 10 * 8, /* %ebp */ | |
90 | 9 * 8, /* %esi */ | |
91 | 8 * 8, /* %edi */ | |
92 | 17 * 8, /* %eip */ | |
93 | 16 * 8, /* %eflags */ | |
94 | 18 * 8, /* %cs */ | |
95 | 21 * 8, /* %ss */ | |
96 | 25 * 8, /* %ds */ | |
97 | 24 * 8, /* %es */ | |
98 | 22 * 8, /* %fs */ | |
99 | 23 * 8 /* %gs */ | |
100 | }; | |
101 | ||
6b16acab | 102 | void |
7f7fe91e | 103 | supply_gregset (struct regcache *regcache, const prgregset_t *gregs) |
6b16acab | 104 | { |
7f7fe91e | 105 | amd64_supply_native_gregset (regcache, gregs, -1); |
6b16acab MK |
106 | } |
107 | ||
108 | void | |
7f7fe91e | 109 | supply_fpregset (struct regcache *regcache, const prfpregset_t *fpregs) |
6b16acab | 110 | { |
7f7fe91e | 111 | amd64_supply_fxsave (regcache, -1, fpregs); |
6b16acab MK |
112 | } |
113 | ||
114 | void | |
7f7fe91e UW |
115 | fill_gregset (const struct regcache *regcache, |
116 | prgregset_t *gregs, int regnum) | |
6b16acab | 117 | { |
7f7fe91e | 118 | amd64_collect_native_gregset (regcache, gregs, regnum); |
6b16acab MK |
119 | } |
120 | ||
121 | void | |
7f7fe91e UW |
122 | fill_fpregset (const struct regcache *regcache, |
123 | prfpregset_t *fpregs, int regnum) | |
6b16acab | 124 | { |
7f7fe91e | 125 | amd64_collect_fxsave (regcache, regnum, fpregs); |
6b16acab MK |
126 | } |
127 | ||
128 | #else | |
129 | ||
f69c55b2 | 130 | /* For 32-bit Solaris x86, we use the Unix SVR4 code in i386v4-nat.c. */ |
6b16acab MK |
131 | |
132 | #endif | |
0bbc026e JM |
133 | |
134 | /* Provide a prototype to silence -Wmissing-prototypes. */ | |
135 | extern void _initialize_amd64_sol2_nat (void); | |
136 | ||
137 | void | |
138 | _initialize_amd64_sol2_nat (void) | |
139 | { | |
d1a7880c PA |
140 | struct target_ops *t; |
141 | ||
142 | /* Fill in the generic procfs methods. */ | |
143 | t = procfs_target (); | |
144 | ||
145 | #ifdef NEW_PROC_API /* Solaris 6 and above can do HW watchpoints */ | |
146 | procfs_use_watchpoints (t); | |
147 | #endif | |
148 | ||
0bbc026e JM |
149 | #if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64) |
150 | amd64_native_gregset32_reg_offset = amd64_sol2_gregset32_reg_offset; | |
151 | amd64_native_gregset32_num_regs = | |
152 | ARRAY_SIZE (amd64_sol2_gregset32_reg_offset); | |
153 | amd64_native_gregset64_reg_offset = amd64_sol2_gregset64_reg_offset; | |
154 | amd64_native_gregset64_num_regs = | |
155 | ARRAY_SIZE (amd64_sol2_gregset64_reg_offset); | |
156 | #endif | |
d1a7880c PA |
157 | |
158 | add_target (t); | |
0bbc026e | 159 | } |