GDB (xrefs)

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