New test - verify sdl insn.
[deliverable/binutils-gdb.git] / gdb / core-sol2.c
CommitLineData
256533df
PS
1/* Machine independent support for Solaris 2 core files for GDB.
2 Copyright 1994 Free Software Foundation, Inc.
3
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
6c9638b4 18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
256533df
PS
19
20
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
24 a.out files).
a1df8e78 25 This file combines the core register fetching from core-regset.c
256533df
PS
26 and sparc-nat.c to be able to read both flavours. */
27
28#include "defs.h"
29#undef gregset_t
30#undef fpregset_t
31
32#include <time.h>
33#include <sys/regset.h>
34#include <sys/procfs.h>
35#include <fcntl.h>
36#include <errno.h>
2b576293 37#include "gdb_string.h"
256533df
PS
38
39#include "inferior.h"
40#include "target.h"
41#include "command.h"
42#include "gdbcore.h"
43
948a9d92
FF
44static void fetch_core_registers PARAMS ((char *, unsigned, int, CORE_ADDR));
45
a1df8e78 46static void
256533df
PS
47fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
48 char *core_reg_sect;
49 unsigned core_reg_size;
50 int which;
948a9d92 51 CORE_ADDR reg_addr; /* Unused in this version */
256533df
PS
52{
53 prgregset_t prgregset;
54 prfpregset_t prfpregset;
55
56 if (which == 0)
57 {
58 if (core_reg_size == sizeof (prgregset))
59 {
60 memcpy ((char *) &prgregset, core_reg_sect, sizeof (prgregset));
61 supply_gregset (&prgregset);
62 }
63 else if (core_reg_size == sizeof (struct regs))
64 {
65#define gregs ((struct regs *)core_reg_sect)
66 /* G0 *always* holds 0. */
67 *(int *)&registers[REGISTER_BYTE (0)] = 0;
68
69 /* The globals and output registers. */
70 memcpy (&registers[REGISTER_BYTE (G1_REGNUM)], &gregs->r_g1,
71 15 * REGISTER_RAW_SIZE (G1_REGNUM));
72 *(int *)&registers[REGISTER_BYTE (PS_REGNUM)] = gregs->r_ps;
73 *(int *)&registers[REGISTER_BYTE (PC_REGNUM)] = gregs->r_pc;
74 *(int *)&registers[REGISTER_BYTE (NPC_REGNUM)] = gregs->r_npc;
75 *(int *)&registers[REGISTER_BYTE (Y_REGNUM)] = gregs->r_y;
76
77 /* My best guess at where to get the locals and input
78 registers is exactly where they usually are, right above
79 the stack pointer. If the core dump was caused by a bus error
80 from blowing away the stack pointer (as is possible) then this
81 won't work, but it's worth the try. */
82 {
83 int sp;
84
85 sp = *(int *)&registers[REGISTER_BYTE (SP_REGNUM)];
86 if (0 != target_read_memory (sp,
87 &registers[REGISTER_BYTE (L0_REGNUM)],
88 16 * REGISTER_RAW_SIZE (L0_REGNUM)))
89 {
90 warning ("couldn't read input and local registers from core file\n");
91 }
92 }
93 }
94 else
95 {
96 warning ("wrong size gregset struct in core file");
97 }
98 }
99 else if (which == 2)
100 {
101 if (core_reg_size == sizeof (prfpregset))
102 {
103 memcpy ((char *) &prfpregset, core_reg_sect, sizeof (prfpregset));
104 supply_fpregset (&prfpregset);
105 }
106 else if (core_reg_size >= sizeof (struct fpu))
107 {
108#define fpuregs ((struct fpu *) core_reg_sect)
109 memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], &fpuregs->fpu_fr,
110 sizeof (fpuregs->fpu_fr));
111 memcpy (&registers[REGISTER_BYTE (FPS_REGNUM)], &fpuregs->fpu_fsr,
112 sizeof (FPU_FSR_TYPE));
113 }
114 else
115 {
116 warning ("wrong size fpregset struct in core file");
117 }
118 }
119}
a1df8e78
FF
120
121\f
122/* Register that we are able to handle solaris core file formats. */
123
124static struct core_fns solaris_core_fns =
125{
126 bfd_target_elf_flavour,
127 fetch_core_registers,
128 NULL
129};
130
131void
132_initialize_core_solaris ()
133{
134 add_core_fns (&solaris_core_fns);
135}
This page took 0.489509 seconds and 4 git commands to generate.