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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [i386-sol2-tdep.c] - Blame information for rev 421

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

Line No. Rev Author Line
1 227 jeremybenn
/* Target-dependent code for Solaris x86.
2
 
3
   Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010
4
   Free Software Foundation, Inc.
5
 
6
   This file is part of GDB.
7
 
8
   This program is free software; you can redistribute it and/or modify
9
   it under the terms of the GNU General Public License as published by
10
   the Free Software Foundation; either version 3 of the License, or
11
   (at your option) any later version.
12
 
13
   This program is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
 
18
   You should have received a copy of the GNU General Public License
19
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20
 
21
#include "defs.h"
22
#include "value.h"
23
#include "osabi.h"
24
 
25
#include "gdb_string.h"
26
 
27
#include "sol2-tdep.h"
28
#include "i386-tdep.h"
29
#include "solib-svr4.h"
30
 
31
/* From <ia32/sys/reg.h>.  */
32
static int i386_sol2_gregset_reg_offset[] =
33
{
34
  11 * 4,                       /* %eax */
35
  10 * 4,                       /* %ecx */
36
  9 * 4,                        /* %edx */
37
  8 * 4,                        /* %ebx */
38
  17 * 4,                       /* %esp */
39
  6 * 4,                        /* %ebp */
40
  5 * 4,                        /* %esi */
41
  4 * 4,                        /* %edi */
42
  14 * 4,                       /* %eip */
43
  16 * 4,                       /* %eflags */
44
  15 * 4,                       /* %cs */
45
  18 * 4,                       /* %ss */
46
  3 * 4,                        /* %ds */
47
  2 * 4,                        /* %es */
48
  1 * 4,                        /* %fs */
49
 
50
};
51
 
52
/* Return whether THIS_FRAME corresponds to a Solaris sigtramp
53
   routine.  */
54
 
55
static int
56
i386_sol2_sigtramp_p (struct frame_info *this_frame)
57
{
58
  CORE_ADDR pc = get_frame_pc (this_frame);
59
  char *name;
60
 
61
  find_pc_partial_function (pc, &name, NULL, NULL);
62
  return (name && (strcmp ("sigacthandler", name) == 0
63
                   || strcmp (name, "ucbsigvechandler") == 0));
64
}
65
 
66
/* Solaris doesn't have a `struct sigcontext', but it does have a
67
   `mcontext_t' that contains the saved set of machine registers.  */
68
 
69
static CORE_ADDR
70
i386_sol2_mcontext_addr (struct frame_info *this_frame)
71
{
72
  CORE_ADDR sp, ucontext_addr;
73
 
74
  sp = get_frame_register_unsigned (this_frame, I386_ESP_REGNUM);
75
  ucontext_addr = get_frame_memory_unsigned (this_frame, sp + 8, 4);
76
 
77
  return ucontext_addr + 36;
78
}
79
 
80
/* SunPRO encodes the static variables.  This is not related to C++
81
   mangling, it is done for C too.  */
82
 
83
static char *
84
i386_sol2_static_transform_name (char *name)
85
{
86
  char *p;
87
  if (name[0] == '.')
88
    {
89
      /* For file-local statics there will be a period, a bunch of
90
         junk (the contents of which match a string given in the
91
         N_OPT), a period and the name.  For function-local statics
92
         there will be a bunch of junk (which seems to change the
93
         second character from 'A' to 'B'), a period, the name of the
94
         function, and the name.  So just skip everything before the
95
         last period.  */
96
      p = strrchr (name, '.');
97
      if (p != NULL)
98
        name = p + 1;
99
    }
100
  return name;
101
}
102
 
103
/* Solaris 2.  */
104
 
105
static void
106
i386_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
107
{
108
  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
109
 
110
  /* Solaris is SVR4-based.  */
111
  i386_svr4_init_abi (info, gdbarch);
112
 
113
  /* The SunPRO compiler puts out 0 instead of the address in N_SO symbols,
114
     and for SunPRO 3.0, N_FUN symbols too.  */
115
  set_gdbarch_sofun_address_maybe_missing (gdbarch, 1);
116
 
117
  /* Handle SunPRO encoding of static symbols.  */
118
  set_gdbarch_static_transform_name (gdbarch, i386_sol2_static_transform_name);
119
 
120
  /* Solaris reserves space for its FPU emulator in `fpregset_t'.
121
     There is also some space reserved for the registers of a Weitek
122
     math coprocessor.  */
123
  tdep->gregset_reg_offset = i386_sol2_gregset_reg_offset;
124
  tdep->gregset_num_regs = ARRAY_SIZE (i386_sol2_gregset_reg_offset);
125
  tdep->sizeof_gregset = 19 * 4;
126
  tdep->sizeof_fpregset = 380;
127
 
128
  /* Signal trampolines are slightly different from SVR4.  */
129
  tdep->sigtramp_p = i386_sol2_sigtramp_p;
130
  tdep->sigcontext_addr = i386_sol2_mcontext_addr;
131
  tdep->sc_reg_offset = tdep->gregset_reg_offset;
132
  tdep->sc_num_regs = tdep->gregset_num_regs;
133
 
134
  /* Solaris has SVR4-style shared libraries.  */
135
  set_gdbarch_skip_solib_resolver (gdbarch, sol2_skip_solib_resolver);
136
  set_solib_svr4_fetch_link_map_offsets
137
    (gdbarch, svr4_ilp32_fetch_link_map_offsets);
138
 
139
  /* Solaris encodes the pid of the inferior in regset section
140
     names.  */
141
  set_gdbarch_core_reg_section_encodes_pid (gdbarch, 1);
142
 
143
  /* How to print LWP PTIDs from core files.  */
144
  set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);
145
}
146
 
147
 
148
static enum gdb_osabi
149
i386_sol2_osabi_sniffer (bfd *abfd)
150
{
151
  /* If we have a section named .SUNW_version, then it is almost
152
     certainly Solaris 2.  */
153
  if (bfd_get_section_by_name (abfd, ".SUNW_version"))
154
    return GDB_OSABI_SOLARIS;
155
 
156
  return GDB_OSABI_UNKNOWN;
157
}
158
 
159
/* Provide a prototype to silence -Wmissing-prototypes.  */
160
void _initialize_i386_sol2_tdep (void);
161
 
162
void
163
_initialize_i386_sol2_tdep (void)
164
{
165
  /* Register an ELF OS ABI sniffer for Solaris 2 binaries.  */
166
  gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour,
167
                                  i386_sol2_osabi_sniffer);
168
 
169
  gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_SOLARIS,
170
                          i386_sol2_init_abi);
171
}

powered by: WebSVN 2.1.0

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