OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [core-sol2.c] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 104 markom
/* Machine independent support for Solaris 2 core files for GDB.
2
   Copyright 1994 Free Software Foundation, Inc.
3
 
4
   This file is part of GDB.
5
 
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.
10
 
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.
15
 
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,
19
   Boston, MA 02111-1307, USA.  */
20
 
21
 
22
/* Solaris comes with two flavours of core files, cores generated by
23
   an ELF executable and cores generated by programs that were
24
   run under BCP (the part of Solaris which allows it to run SunOS4
25
   a.out files).
26
   This file combines the core register fetching from core-regset.c
27
   and sparc-nat.c to be able to read both flavours.  */
28
 
29
#include "defs.h"
30
#include <time.h>
31
#include <sys/types.h>
32
#include <sys/regset.h>
33
#include <sys/procfs.h>
34
#include <fcntl.h>
35
#include <errno.h>
36
#include "gdb_string.h"
37
 
38
#include "inferior.h"
39
#include "target.h"
40
#include "command.h"
41
#include "gdbcore.h"
42
 
43
static void fetch_core_registers PARAMS ((char *, unsigned, int, CORE_ADDR));
44
 
45
static void
46
fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
47
     char *core_reg_sect;
48
     unsigned core_reg_size;
49
     int which;
50
     CORE_ADDR reg_addr;        /* Unused in this version */
51
{
52
  prgregset_t prgregset;
53
  prfpregset_t prfpregset;
54
 
55
  if (which == 0)
56
    {
57
      if (core_reg_size == sizeof (prgregset))
58
        {
59
          memcpy ((char *) &prgregset, core_reg_sect, sizeof (prgregset));
60
          supply_gregset (&prgregset);
61
        }
62
      else if (core_reg_size == sizeof (struct regs))
63
        {
64
#define gregs ((struct regs *)core_reg_sect)
65
          /* G0 *always* holds 0.  */
66
          *(int *) &registers[REGISTER_BYTE (0)] = 0;
67
 
68
          /* The globals and output registers.  */
69
          memcpy (&registers[REGISTER_BYTE (G1_REGNUM)], &gregs->r_g1,
70
                  15 * REGISTER_RAW_SIZE (G1_REGNUM));
71
          *(int *) &registers[REGISTER_BYTE (PS_REGNUM)] = gregs->r_ps;
72
          *(int *) &registers[REGISTER_BYTE (PC_REGNUM)] = gregs->r_pc;
73
          *(int *) &registers[REGISTER_BYTE (NPC_REGNUM)] = gregs->r_npc;
74
          *(int *) &registers[REGISTER_BYTE (Y_REGNUM)] = gregs->r_y;
75
 
76
          /* My best guess at where to get the locals and input
77
             registers is exactly where they usually are, right above
78
             the stack pointer.  If the core dump was caused by a bus error
79
             from blowing away the stack pointer (as is possible) then this
80
             won't work, but it's worth the try. */
81
          {
82
            int sp;
83
 
84
            sp = *(int *) &registers[REGISTER_BYTE (SP_REGNUM)];
85
            if (0 != target_read_memory (sp,
86
                                      &registers[REGISTER_BYTE (L0_REGNUM)],
87
                                         16 * REGISTER_RAW_SIZE (L0_REGNUM)))
88
              {
89
                warning ("couldn't read input and local registers from core file\n");
90
              }
91
          }
92
        }
93
      else
94
        {
95
          warning ("wrong size gregset struct in core file");
96
        }
97
    }
98
  else if (which == 2)
99
    {
100
      if (core_reg_size == sizeof (prfpregset))
101
        {
102
          memcpy ((char *) &prfpregset, core_reg_sect, sizeof (prfpregset));
103
          supply_fpregset (&prfpregset);
104
        }
105
      else if (core_reg_size >= sizeof (struct fpu))
106
        {
107
#define fpuregs  ((struct fpu *) core_reg_sect)
108
          memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], &fpuregs->fpu_fr,
109
                  sizeof (fpuregs->fpu_fr));
110
          memcpy (&registers[REGISTER_BYTE (FPS_REGNUM)], &fpuregs->fpu_fsr,
111
                  sizeof (FPU_FSR_TYPE));
112
        }
113
      else
114
        {
115
          warning ("wrong size fpregset struct in core file");
116
        }
117
    }
118
}
119
 
120
 
121
/* Register that we are able to handle solaris core file formats. */
122
 
123
static struct core_fns solaris_core_fns =
124
{
125
  bfd_target_elf_flavour,               /* core_flavour */
126
  default_check_format,                 /* check_format */
127
  default_core_sniffer,                 /* core_sniffer */
128
  fetch_core_registers,                 /* core_read_registers */
129
  NULL                                  /* next */
130
};
131
 
132
void
133
_initialize_core_solaris ()
134
{
135
  add_core_fns (&solaris_core_fns);
136
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.