1 /* Machine independent support for Solaris 2 core files for GDB.
2 Copyright 1994 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 /* Solaris comes with two flavours of core files, cores generated by
22 an ELF executable and cores generated by programs that were
23 run under BCP (the part of Solaris which allows it to run SunOS4
25 This file combines the core register fetching from core-regset.c
26 and sparc-nat.c to be able to read both flavours. */
33 #include <sys/types.h>
34 #include <sys/regset.h>
35 #include <sys/procfs.h>
38 #include "gdb_string.h"
45 static void fetch_core_registers
PARAMS ((char *, unsigned, int, CORE_ADDR
));
48 fetch_core_registers (core_reg_sect
, core_reg_size
, which
, reg_addr
)
50 unsigned core_reg_size
;
52 CORE_ADDR reg_addr
; /* Unused in this version */
54 prgregset_t prgregset
;
55 prfpregset_t prfpregset
;
59 if (core_reg_size
== sizeof (prgregset
))
61 memcpy ((char *) &prgregset
, core_reg_sect
, sizeof (prgregset
));
62 supply_gregset (&prgregset
);
64 else if (core_reg_size
== sizeof (struct regs
))
66 #define gregs ((struct regs *)core_reg_sect)
67 /* G0 *always* holds 0. */
68 *(int *)®isters
[REGISTER_BYTE (0)] = 0;
70 /* The globals and output registers. */
71 memcpy (®isters
[REGISTER_BYTE (G1_REGNUM
)], &gregs
->r_g1
,
72 15 * REGISTER_RAW_SIZE (G1_REGNUM
));
73 *(int *)®isters
[REGISTER_BYTE (PS_REGNUM
)] = gregs
->r_ps
;
74 *(int *)®isters
[REGISTER_BYTE (PC_REGNUM
)] = gregs
->r_pc
;
75 *(int *)®isters
[REGISTER_BYTE (NPC_REGNUM
)] = gregs
->r_npc
;
76 *(int *)®isters
[REGISTER_BYTE (Y_REGNUM
)] = gregs
->r_y
;
78 /* My best guess at where to get the locals and input
79 registers is exactly where they usually are, right above
80 the stack pointer. If the core dump was caused by a bus error
81 from blowing away the stack pointer (as is possible) then this
82 won't work, but it's worth the try. */
86 sp
= *(int *)®isters
[REGISTER_BYTE (SP_REGNUM
)];
87 if (0 != target_read_memory (sp
,
88 ®isters
[REGISTER_BYTE (L0_REGNUM
)],
89 16 * REGISTER_RAW_SIZE (L0_REGNUM
)))
91 warning ("couldn't read input and local registers from core file\n");
97 warning ("wrong size gregset struct in core file");
102 if (core_reg_size
== sizeof (prfpregset
))
104 memcpy ((char *) &prfpregset
, core_reg_sect
, sizeof (prfpregset
));
105 supply_fpregset (&prfpregset
);
107 else if (core_reg_size
>= sizeof (struct fpu
))
109 #define fpuregs ((struct fpu *) core_reg_sect)
110 memcpy (®isters
[REGISTER_BYTE (FP0_REGNUM
)], &fpuregs
->fpu_fr
,
111 sizeof (fpuregs
->fpu_fr
));
112 memcpy (®isters
[REGISTER_BYTE (FPS_REGNUM
)], &fpuregs
->fpu_fsr
,
113 sizeof (FPU_FSR_TYPE
));
117 warning ("wrong size fpregset struct in core file");
123 /* Register that we are able to handle solaris core file formats. */
125 static struct core_fns solaris_core_fns
=
127 bfd_target_elf_flavour
,
128 fetch_core_registers
,
133 _initialize_core_solaris ()
135 add_core_fns (&solaris_core_fns
);