1 /* Native support code for PPC AIX, for GDB the GNU debugger.
3 Copyright (C) 2006, 2007 Free Software Foundation, Inc.
5 Free Software Foundation, Inc.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
25 #include "gdb_string.h"
29 #include "rs6000-tdep.h"
33 /* Core file support. */
35 static struct ppc_reg_offsets rs6000_aix32_reg_offsets =
37 /* General-purpose registers. */
47 /* Floating-point registers. */
49 56, /* fpscr_offset */
51 /* AltiVec registers. */
54 -1 /* vrsave_offset */
57 static struct ppc_reg_offsets rs6000_aix64_reg_offsets =
59 /* General-purpose registers. */
69 /* Floating-point registers. */
71 296, /* fpscr_offset */
73 /* AltiVec registers. */
76 -1 /* vrsave_offset */
80 /* Supply register REGNUM in the general-purpose register set REGSET
81 from the buffer specified by GREGS and LEN to register cache
82 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
85 rs6000_aix_supply_regset (const struct regset *regset,
86 struct regcache *regcache, int regnum,
87 const void *gregs, size_t len)
89 ppc_supply_gregset (regset, regcache, regnum, gregs, len);
91 if (ppc_floating_point_unit_p (get_regcache_arch (regcache)))
92 ppc_supply_fpregset (regset, regcache, regnum, gregs, len);
95 /* Collect register REGNUM in the general-purpose register set
96 REGSET. from register cache REGCACHE into the buffer specified by
97 GREGS and LEN. If REGNUM is -1, do this for all registers in
101 rs6000_aix_collect_regset (const struct regset *regset,
102 const struct regcache *regcache, int regnum,
103 void *gregs, size_t len)
105 ppc_collect_gregset (regset, regcache, regnum, gregs, len);
107 if (ppc_floating_point_unit_p (get_regcache_arch (regcache)))
108 ppc_collect_fpregset (regset, regcache, regnum, gregs, len);
111 /* AIX register set. */
113 static struct regset rs6000_aix32_regset =
115 &rs6000_aix32_reg_offsets,
116 rs6000_aix_supply_regset,
117 rs6000_aix_collect_regset,
120 static struct regset rs6000_aix64_regset =
122 &rs6000_aix64_reg_offsets,
123 rs6000_aix_supply_regset,
124 rs6000_aix_collect_regset,
127 /* Return the appropriate register set for the core section identified
128 by SECT_NAME and SECT_SIZE. */
130 static const struct regset *
131 rs6000_aix_regset_from_core_section (struct gdbarch *gdbarch,
132 const char *sect_name, size_t sect_size)
134 if (gdbarch_tdep (gdbarch)->wordsize == 4)
136 if (strcmp (sect_name, ".reg") == 0 && sect_size >= 592)
137 return &rs6000_aix32_regset;
141 if (strcmp (sect_name, ".reg") == 0 && sect_size >= 576)
142 return &rs6000_aix64_regset;
149 static enum gdb_osabi
150 rs6000_aix_osabi_sniffer (bfd *abfd)
153 if (bfd_get_flavour (abfd) == bfd_target_xcoff_flavour);
154 return GDB_OSABI_AIX;
156 return GDB_OSABI_UNKNOWN;
160 rs6000_aix_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)
162 /* RS6000/AIX does not support PT_STEP. Has to be simulated. */
163 set_gdbarch_software_single_step (gdbarch, rs6000_software_single_step);
165 /* Core file support. */
166 set_gdbarch_regset_from_core_section
167 (gdbarch, rs6000_aix_regset_from_core_section);
169 /* Minimum possible text address in AIX. */
170 gdbarch_tdep (gdbarch)->text_segment_base = 0x10000000;
174 _initialize_rs6000_aix_tdep (void)
176 gdbarch_register_osabi_sniffer (bfd_arch_rs6000,
177 bfd_target_xcoff_flavour,
178 rs6000_aix_osabi_sniffer);
179 gdbarch_register_osabi_sniffer (bfd_arch_powerpc,
180 bfd_target_xcoff_flavour,
181 rs6000_aix_osabi_sniffer);
183 gdbarch_register_osabi (bfd_arch_rs6000, 0, GDB_OSABI_AIX,
184 rs6000_aix_init_osabi);
185 gdbarch_register_osabi (bfd_arch_powerpc, 0, GDB_OSABI_AIX,
186 rs6000_aix_init_osabi);