|
1 --- /dev/null 2013-10-06 14:14:47.000000000 -0700 |
|
2 +++ gdb-7.6/gdb/sol2-core-regset.c 2013-10-06 13:55:51.348498600 -0700 |
|
3 @@ -0,0 +1,147 @@ |
|
4 +/* Machine dependent GDB support for core files on Solaris using "regsets". |
|
5 + |
|
6 + Copyright (C) 2013 Free Software Foundation, Inc. |
|
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 3 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, see <http://www.gnu.org/licenses/>. */ |
|
22 + |
|
23 +/* This file is used by Solaris core dumps. The Solaris /proc filesystem |
|
24 + * will yield different sizes for prgregset_t prfpregset_t depending |
|
25 + * on sizeof(void*). We handle these differences in this Solaris-specific |
|
26 + * core-regset.c file, as opposed to imposing all these Solaris particulars |
|
27 + * on everyone else. |
|
28 + */ |
|
29 + |
|
30 +#include "defs.h" |
|
31 +#include "command.h" |
|
32 +#include "gdbcore.h" |
|
33 +#include "gdbarch.h" |
|
34 +#include "inferior.h" |
|
35 +#include "target.h" |
|
36 +#include "regcache.h" |
|
37 +#include "elf-bfd.h" |
|
38 + |
|
39 +#include <fcntl.h> |
|
40 +#include <errno.h> |
|
41 +#include "gdb_string.h" |
|
42 +#include <time.h> |
|
43 +#ifdef HAVE_SYS_PROCFS_H |
|
44 +#include <sys/procfs.h> |
|
45 +#endif |
|
46 + |
|
47 +/* Prototypes for supply_gregset etc. */ |
|
48 +#include "gregset.h" |
|
49 + |
|
50 +/* Provide registers to GDB from a core file. |
|
51 + |
|
52 + CORE_REG_SECT points to an array of bytes, which are the contents |
|
53 + of a `note' from a core file which BFD thinks might contain |
|
54 + register contents. CORE_REG_SIZE is its size. |
|
55 + |
|
56 + WHICH says which register set corelow suspects this is: |
|
57 + 0 --- the general-purpose register set, in gregset_t format |
|
58 + 2 --- the floating-point register set, in fpregset_t format |
|
59 + |
|
60 + REG_ADDR is ignored. */ |
|
61 + |
|
62 +static void |
|
63 +fetch_core_registers (struct regcache *regcache, |
|
64 + char *core_reg_sect, |
|
65 + unsigned core_reg_size, |
|
66 + int which, |
|
67 + CORE_ADDR reg_addr) |
|
68 +{ |
|
69 + gdb_gregset_t gregset; |
|
70 + gdb_fpregset_t fpregset; |
|
71 + gdb_gregset_t *gregset_p = &gregset; |
|
72 + gdb_fpregset_t *fpregset_p = &fpregset; |
|
73 + /* use default sizes on 64-bit Solaris */ |
|
74 + size_t gregset_size = sizeof (gregset); |
|
75 + size_t fpregset_size = sizeof (fpregset); |
|
76 + int pointer_size; |
|
77 + struct gdbarch *gdbarch = get_regcache_arch (regcache); |
|
78 + enum bfd_endian byte_order; |
|
79 + |
|
80 + if (gdbarch_osabi (gdbarch) == GDB_OSABI_SOLARIS) |
|
81 + { |
|
82 + set_regcache_from_corefile (regcache); |
|
83 + byte_order = gdbarch_byte_order (gdbarch); |
|
84 + pointer_size = gdbarch_ptr_bit (gdbarch); |
|
85 + |
|
86 + if ((byte_order == BFD_ENDIAN_BIG) && (pointer_size == 32)) |
|
87 + { |
|
88 + gregset_size = 152; |
|
89 + fpregset_size = 144; |
|
90 + } |
|
91 + else if ((byte_order == BFD_ENDIAN_LITTLE) && (pointer_size == 32)) |
|
92 + { |
|
93 + gregset_size = 76; |
|
94 + fpregset_size = 380; |
|
95 + } |
|
96 + } |
|
97 + |
|
98 + switch (which) |
|
99 + { |
|
100 + case 0: |
|
101 + if (core_reg_size != gregset_size) |
|
102 + warning (_("Wrong size gregset in core file.")); |
|
103 + else |
|
104 + { |
|
105 + memcpy (&gregset, core_reg_sect, gregset_size); |
|
106 + supply_gregset (regcache, (const gdb_gregset_t *) gregset_p); |
|
107 + } |
|
108 + break; |
|
109 + |
|
110 + case 2: |
|
111 + if (core_reg_size != fpregset_size) |
|
112 + warning (_("Wrong size fpregset in core file.")); |
|
113 + else |
|
114 + { |
|
115 + memcpy (&fpregset, core_reg_sect, fpregset_size); |
|
116 + if (gdbarch_fp0_regnum (get_regcache_arch (regcache)) >= 0) |
|
117 + supply_fpregset (regcache, |
|
118 + (const gdb_fpregset_t *) fpregset_p); |
|
119 + } |
|
120 + break; |
|
121 + |
|
122 + default: |
|
123 + /* We've covered all the kinds of registers we know about here, |
|
124 + so this must be something we wouldn't know what to do with |
|
125 + anyway. Just ignore it. */ |
|
126 + break; |
|
127 + } |
|
128 +} |
|
129 + |
|
130 + |
|
131 +/* Register that we are able to handle ELF core file formats using |
|
132 + standard procfs "regset" structures. */ |
|
133 + |
|
134 +static struct core_fns regset_core_fns = |
|
135 +{ |
|
136 + bfd_target_elf_flavour, /* core_flavour */ |
|
137 + default_check_format, /* check_format */ |
|
138 + default_core_sniffer, /* core_sniffer */ |
|
139 + fetch_core_registers, /* core_read_registers */ |
|
140 + NULL /* next */ |
|
141 +}; |
|
142 + |
|
143 +/* Provide a prototype to silence -Wmissing-prototypes. */ |
|
144 +extern void _initialize_core_regset (void); |
|
145 + |
|
146 +void |
|
147 +_initialize_core_regset (void) |
|
148 +{ |
|
149 + deprecated_add_core_fns (®set_core_fns); |
|
150 +} |