]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/rs6000-aix-tdep.c
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / rs6000-aix-tdep.c
CommitLineData
1f82754b
JB
1/* Native support code for PPC AIX, for GDB the GNU debugger.
2
213516ef 3 Copyright (C) 2006-2023 Free Software Foundation, Inc.
1f82754b
JB
4
5 Free Software Foundation, Inc.
6
7 This file is part of GDB.
8
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
a9762ec7 11 the Free Software Foundation; either version 3 of the License, or
1f82754b
JB
12 (at your option) any later version.
13
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.
18
19 You should have received a copy of the GNU General Public License
a9762ec7 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
1f82754b
JB
21
22#include "defs.h"
23#include "osabi.h"
7a61a01c
UW
24#include "regcache.h"
25#include "regset.h"
4a7622d1
UW
26#include "gdbtypes.h"
27#include "gdbcore.h"
28#include "target.h"
29#include "value.h"
30#include "infcall.h"
31#include "objfiles.h"
32#include "breakpoint.h"
6f7f3f0d 33#include "ppc-tdep.h"
356a5233 34#include "rs6000-aix-tdep.h"
d5367fe1 35#include "xcoffread.h"
4d1eb6b4
JB
36#include "solib.h"
37#include "solib-aix.h"
3b2ca824 38#include "target-float.h"
268a13a5 39#include "gdbsupport/xml-utils.h"
cdcda965
SM
40#include "trad-frame.h"
41#include "frame-unwind.h"
4a7622d1
UW
42
43/* If the kernel has to deliver a signal, it pushes a sigcontext
44 structure on the stack and then calls the signal handler, passing
0df8b418 45 the address of the sigcontext in an argument register. Usually
4a7622d1
UW
46 the signal handler doesn't save this register, so we have to
47 access the sigcontext structure via an offset from the signal handler
48 frame.
cdcda965
SM
49 The following constants were determined by experimentation on AIX 3.2.
50
51 sigcontext structure have the mstsave saved under the
52 sc_jmpbuf.jmp_context. STKMIN(minimum stack size) is 56 for 32-bit
53 processes, and iar offset under sc_jmpbuf.jmp_context is 40.
54 ie offsetof(struct sigcontext, sc_jmpbuf.jmp_context.iar).
55 so PC offset in this case is STKMIN+iar offset, which is 96. */
56
4a7622d1
UW
57#define SIG_FRAME_PC_OFFSET 96
58#define SIG_FRAME_LR_OFFSET 108
cdcda965 59/* STKMIN+grp1 offset, which is 56+228=284 */
4a7622d1
UW
60#define SIG_FRAME_FP_OFFSET 284
61
cdcda965
SM
62/* 64 bit process.
63 STKMIN64 is 112 and iar offset is 312. So 112+312=424 */
64#define SIG_FRAME_LR_OFFSET64 424
65/* STKMIN64+grp1 offset. 112+56=168 */
66#define SIG_FRAME_FP_OFFSET64 168
67
629f88f8
SM
68/* Minimum possible text address in AIX. */
69#define AIX_TEXT_SEGMENT_BASE 0x10000000
70
cdcda965 71static struct trad_frame_cache *
bd2b40ac 72aix_sighandle_frame_cache (frame_info_ptr this_frame,
cdcda965
SM
73 void **this_cache)
74{
75 LONGEST backchain;
76 CORE_ADDR base, base_orig, func;
77 struct gdbarch *gdbarch = get_frame_arch (this_frame);
08106042 78 ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
cdcda965
SM
79 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
80 struct trad_frame_cache *this_trad_cache;
81
82 if ((*this_cache) != NULL)
83 return (struct trad_frame_cache *) (*this_cache);
84
85 this_trad_cache = trad_frame_cache_zalloc (this_frame);
86 (*this_cache) = this_trad_cache;
87
88 base = get_frame_register_unsigned (this_frame,
dda83cd7 89 gdbarch_sp_regnum (gdbarch));
cdcda965
SM
90 base_orig = base;
91
92 if (tdep->wordsize == 4)
93 {
94 func = read_memory_unsigned_integer (base_orig +
95 SIG_FRAME_PC_OFFSET + 8,
96 tdep->wordsize, byte_order);
97 safe_read_memory_integer (base_orig + SIG_FRAME_FP_OFFSET + 8,
98 tdep->wordsize, byte_order, &backchain);
99 base = (CORE_ADDR)backchain;
100 }
101 else
102 {
103 func = read_memory_unsigned_integer (base_orig +
104 SIG_FRAME_LR_OFFSET64,
105 tdep->wordsize, byte_order);
106 safe_read_memory_integer (base_orig + SIG_FRAME_FP_OFFSET64,
107 tdep->wordsize, byte_order, &backchain);
108 base = (CORE_ADDR)backchain;
109 }
110
111 trad_frame_set_reg_value (this_trad_cache, gdbarch_pc_regnum (gdbarch), func);
112 trad_frame_set_reg_value (this_trad_cache, gdbarch_sp_regnum (gdbarch), base);
113
114 if (tdep->wordsize == 4)
115 trad_frame_set_reg_addr (this_trad_cache, tdep->ppc_lr_regnum,
dda83cd7 116 base_orig + 0x38 + 52 + 8);
cdcda965
SM
117 else
118 trad_frame_set_reg_addr (this_trad_cache, tdep->ppc_lr_regnum,
dda83cd7 119 base_orig + 0x70 + 320);
cdcda965
SM
120
121 trad_frame_set_id (this_trad_cache, frame_id_build (base, func));
122 trad_frame_set_this_base (this_trad_cache, base);
123
124 return this_trad_cache;
125}
126
127static void
bd2b40ac 128aix_sighandle_frame_this_id (frame_info_ptr this_frame,
cdcda965
SM
129 void **this_prologue_cache,
130 struct frame_id *this_id)
131{
132 struct trad_frame_cache *this_trad_cache
133 = aix_sighandle_frame_cache (this_frame, this_prologue_cache);
134 trad_frame_get_id (this_trad_cache, this_id);
135}
136
137static struct value *
bd2b40ac 138aix_sighandle_frame_prev_register (frame_info_ptr this_frame,
cdcda965
SM
139 void **this_prologue_cache, int regnum)
140{
141 struct trad_frame_cache *this_trad_cache
142 = aix_sighandle_frame_cache (this_frame, this_prologue_cache);
143 return trad_frame_get_register (this_trad_cache, this_frame, regnum);
144}
145
cb8c24b6 146static int
cdcda965 147aix_sighandle_frame_sniffer (const struct frame_unwind *self,
bd2b40ac 148 frame_info_ptr this_frame,
cdcda965
SM
149 void **this_prologue_cache)
150{
151 CORE_ADDR pc = get_frame_pc (this_frame);
152 if (pc && pc < AIX_TEXT_SEGMENT_BASE)
153 return 1;
154
155 return 0;
156}
157
158/* AIX signal handler frame unwinder */
159
160static const struct frame_unwind aix_sighandle_frame_unwind = {
a154d838 161 "rs6000 aix sighandle",
cdcda965
SM
162 SIGTRAMP_FRAME,
163 default_frame_unwind_stop_reason,
164 aix_sighandle_frame_this_id,
165 aix_sighandle_frame_prev_register,
166 NULL,
167 aix_sighandle_frame_sniffer
168};
7a61a01c
UW
169
170/* Core file support. */
171
172static struct ppc_reg_offsets rs6000_aix32_reg_offsets =
173{
174 /* General-purpose registers. */
175 208, /* r0_offset */
f2db237a
AM
176 4, /* gpr_size */
177 4, /* xr_size */
7a61a01c
UW
178 24, /* pc_offset */
179 28, /* ps_offset */
180 32, /* cr_offset */
181 36, /* lr_offset */
182 40, /* ctr_offset */
183 44, /* xer_offset */
184 48, /* mq_offset */
185
186 /* Floating-point registers. */
187 336, /* f0_offset */
188 56, /* fpscr_offset */
1d75a658 189 4 /* fpscr_size */
7a61a01c
UW
190};
191
192static struct ppc_reg_offsets rs6000_aix64_reg_offsets =
193{
194 /* General-purpose registers. */
195 0, /* r0_offset */
f2db237a
AM
196 8, /* gpr_size */
197 4, /* xr_size */
7a61a01c
UW
198 264, /* pc_offset */
199 256, /* ps_offset */
200 288, /* cr_offset */
201 272, /* lr_offset */
202 280, /* ctr_offset */
203 292, /* xer_offset */
204 -1, /* mq_offset */
205
206 /* Floating-point registers. */
207 312, /* f0_offset */
208 296, /* fpscr_offset */
1d75a658 209 4 /* fpscr_size */
7a61a01c
UW
210};
211
212
213/* Supply register REGNUM in the general-purpose register set REGSET
214 from the buffer specified by GREGS and LEN to register cache
215 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
216
217static void
218rs6000_aix_supply_regset (const struct regset *regset,
219 struct regcache *regcache, int regnum,
220 const void *gregs, size_t len)
221{
222 ppc_supply_gregset (regset, regcache, regnum, gregs, len);
f2db237a 223 ppc_supply_fpregset (regset, regcache, regnum, gregs, len);
7a61a01c
UW
224}
225
226/* Collect register REGNUM in the general-purpose register set
0df8b418 227 REGSET, from register cache REGCACHE into the buffer specified by
7a61a01c
UW
228 GREGS and LEN. If REGNUM is -1, do this for all registers in
229 REGSET. */
230
231static void
232rs6000_aix_collect_regset (const struct regset *regset,
233 const struct regcache *regcache, int regnum,
234 void *gregs, size_t len)
235{
236 ppc_collect_gregset (regset, regcache, regnum, gregs, len);
f2db237a 237 ppc_collect_fpregset (regset, regcache, regnum, gregs, len);
7a61a01c
UW
238}
239
240/* AIX register set. */
241
3ca7dae4 242static const struct regset rs6000_aix32_regset =
7a61a01c
UW
243{
244 &rs6000_aix32_reg_offsets,
245 rs6000_aix_supply_regset,
246 rs6000_aix_collect_regset,
247};
248
3ca7dae4 249static const struct regset rs6000_aix64_regset =
7a61a01c
UW
250{
251 &rs6000_aix64_reg_offsets,
252 rs6000_aix_supply_regset,
253 rs6000_aix_collect_regset,
254};
255
23ea9aeb 256/* Iterate over core file register note sections. */
7a61a01c 257
23ea9aeb
AA
258static void
259rs6000_aix_iterate_over_regset_sections (struct gdbarch *gdbarch,
260 iterate_over_regset_sections_cb *cb,
261 void *cb_data,
262 const struct regcache *regcache)
7a61a01c 263{
08106042 264 ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
345bd07c 265 if (tdep->wordsize == 4)
a616bb94 266 cb (".reg", 592, 592, &rs6000_aix32_regset, NULL, cb_data);
7a61a01c 267 else
a616bb94 268 cb (".reg", 576, 576, &rs6000_aix64_regset, NULL, cb_data);
7a61a01c
UW
269}
270
271
0df8b418 272/* Pass the arguments in either registers, or in the stack. In RS/6000,
4a7622d1
UW
273 the first eight words of the argument list (that might be less than
274 eight parameters if some parameters occupy more than one word) are
0df8b418 275 passed in r3..r10 registers. Float and double parameters are
4a7622d1
UW
276 passed in fpr's, in addition to that. Rest of the parameters if any
277 are passed in user stack. There might be cases in which half of the
278 parameter is copied into registers, the other half is pushed into
279 stack.
280
281 Stack must be aligned on 64-bit boundaries when synthesizing
282 function calls.
283
284 If the function is returning a structure, then the return address is passed
285 in r3, then the first 7 words of the parameters can be passed in registers,
286 starting from r4. */
287
288static CORE_ADDR
289rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
290 struct regcache *regcache, CORE_ADDR bp_addr,
291 int nargs, struct value **args, CORE_ADDR sp,
cf84fa6b
AH
292 function_call_return_method return_method,
293 CORE_ADDR struct_addr)
4a7622d1 294{
08106042 295 ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
e17a4113 296 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
4a7622d1
UW
297 int ii;
298 int len = 0;
299 int argno; /* current argument number */
300 int argbytes; /* current argument byte */
301 gdb_byte tmp_buffer[50];
302 int f_argno = 0; /* current floating point argno */
345bd07c 303 int wordsize = tdep->wordsize;
4a7622d1
UW
304 CORE_ADDR func_addr = find_function_addr (function, NULL);
305
306 struct value *arg = 0;
307 struct type *type;
308
309 ULONGEST saved_sp;
310
311 /* The calling convention this function implements assumes the
312 processor has floating-point registers. We shouldn't be using it
313 on PPC variants that lack them. */
314 gdb_assert (ppc_floating_point_unit_p (gdbarch));
315
316 /* The first eight words of ther arguments are passed in registers.
317 Copy them appropriately. */
318 ii = 0;
319
320 /* If the function is returning a `struct', then the first word
321 (which will be passed in r3) is used for struct return address.
322 In that case we should advance one word and start from r4
323 register to copy parameters. */
cf84fa6b 324 if (return_method == return_method_struct)
4a7622d1
UW
325 {
326 regcache_raw_write_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
327 struct_addr);
328 ii++;
329 }
330
0df8b418 331/* effectively indirect call... gcc does...
4a7622d1
UW
332
333 return_val example( float, int);
334
335 eabi:
336 float in fp0, int in r3
337 offset of stack on overflow 8/16
338 for varargs, must go by type.
339 power open:
340 float in r3&r4, int in r5
341 offset of stack on overflow different
342 both:
343 return in r3 or f0. If no float, must study how gcc emulates floats;
0df8b418 344 pay attention to arg promotion.
4a7622d1 345 User may have to cast\args to handle promotion correctly
0df8b418 346 since gdb won't know if prototype supplied or not. */
4a7622d1
UW
347
348 for (argno = 0, argbytes = 0; argno < nargs && ii < 8; ++ii)
349 {
350 int reg_size = register_size (gdbarch, ii + 3);
351
352 arg = args[argno];
353 type = check_typedef (value_type (arg));
df86565b 354 len = type->length ();
4a7622d1 355
78134374 356 if (type->code () == TYPE_CODE_FLT)
4a7622d1 357 {
4a7622d1 358 /* Floating point arguments are passed in fpr's, as well as gpr's.
0df8b418 359 There are 13 fpr's reserved for passing parameters. At this point
36d1c68c
JB
360 there is no way we would run out of them.
361
362 Always store the floating point value using the register's
363 floating-point format. */
364 const int fp_regnum = tdep->ppc_fp0_regnum + 1 + f_argno;
0f068fb5 365 gdb_byte reg_val[PPC_MAX_REGISTER_SIZE];
36d1c68c 366 struct type *reg_type = register_type (gdbarch, fp_regnum);
4a7622d1
UW
367
368 gdb_assert (len <= 8);
369
50888e42
SM
370 target_float_convert (value_contents (arg).data (), type, reg_val,
371 reg_type);
b66f5587 372 regcache->cooked_write (fp_regnum, reg_val);
4a7622d1
UW
373 ++f_argno;
374 }
375
376 if (len > reg_size)
377 {
378
379 /* Argument takes more than one register. */
380 while (argbytes < len)
381 {
0f068fb5 382 gdb_byte word[PPC_MAX_REGISTER_SIZE];
4a7622d1
UW
383 memset (word, 0, reg_size);
384 memcpy (word,
50888e42 385 ((char *) value_contents (arg).data ()) + argbytes,
4a7622d1 386 (len - argbytes) > reg_size
dda83cd7 387 ? reg_size : len - argbytes);
b66f5587 388 regcache->cooked_write (tdep->ppc_gp0_regnum + 3 + ii, word);
4a7622d1
UW
389 ++ii, argbytes += reg_size;
390
391 if (ii >= 8)
392 goto ran_out_of_registers_for_arguments;
393 }
394 argbytes = 0;
395 --ii;
396 }
397 else
398 {
399 /* Argument can fit in one register. No problem. */
0f068fb5 400 gdb_byte word[PPC_MAX_REGISTER_SIZE];
4a7622d1
UW
401
402 memset (word, 0, reg_size);
7aae1a86
AVK
403 if (type->code () == TYPE_CODE_INT
404 || type->code () == TYPE_CODE_ENUM
405 || type->code () == TYPE_CODE_BOOL
406 || type->code () == TYPE_CODE_CHAR)
407 /* Sign or zero extend the "int" into a "word". */
408 store_unsigned_integer (word, reg_size, byte_order,
409 unpack_long (type, value_contents (arg).data ()));
410 else
411 memcpy (word, value_contents (arg).data (), len);
b66f5587 412 regcache->cooked_write (tdep->ppc_gp0_regnum + 3 +ii, word);
4a7622d1
UW
413 }
414 ++argno;
415 }
416
417ran_out_of_registers_for_arguments:
418
419 regcache_cooked_read_unsigned (regcache,
420 gdbarch_sp_regnum (gdbarch),
421 &saved_sp);
422
423 /* Location for 8 parameters are always reserved. */
424 sp -= wordsize * 8;
425
426 /* Another six words for back chain, TOC register, link register, etc. */
427 sp -= wordsize * 6;
428
429 /* Stack pointer must be quadword aligned. */
430 sp &= -16;
431
432 /* If there are more arguments, allocate space for them in
433 the stack, then push them starting from the ninth one. */
434
435 if ((argno < nargs) || argbytes)
436 {
437 int space = 0, jj;
438
439 if (argbytes)
440 {
441 space += ((len - argbytes + 3) & -4);
442 jj = argno + 1;
443 }
444 else
445 jj = argno;
446
447 for (; jj < nargs; ++jj)
448 {
449 struct value *val = args[jj];
df86565b 450 space += ((value_type (val)->length ()) + 3) & -4;
4a7622d1
UW
451 }
452
453 /* Add location required for the rest of the parameters. */
454 space = (space + 15) & -16;
455 sp -= space;
456
457 /* This is another instance we need to be concerned about
dda83cd7
SM
458 securing our stack space. If we write anything underneath %sp
459 (r1), we might conflict with the kernel who thinks he is free
460 to use this area. So, update %sp first before doing anything
461 else. */
4a7622d1
UW
462
463 regcache_raw_write_signed (regcache,
464 gdbarch_sp_regnum (gdbarch), sp);
465
466 /* If the last argument copied into the registers didn't fit there
dda83cd7 467 completely, push the rest of it into stack. */
4a7622d1
UW
468
469 if (argbytes)
470 {
471 write_memory (sp + 24 + (ii * 4),
50888e42 472 value_contents (arg).data () + argbytes,
4a7622d1
UW
473 len - argbytes);
474 ++argno;
475 ii += ((len - argbytes + 3) & -4) / 4;
476 }
477
478 /* Push the rest of the arguments into stack. */
479 for (; argno < nargs; ++argno)
480 {
481
482 arg = args[argno];
483 type = check_typedef (value_type (arg));
df86565b 484 len = type->length ();
4a7622d1
UW
485
486
487 /* Float types should be passed in fpr's, as well as in the
dda83cd7 488 stack. */
78134374 489 if (type->code () == TYPE_CODE_FLT && f_argno < 13)
4a7622d1
UW
490 {
491
492 gdb_assert (len <= 8);
493
b66f5587 494 regcache->cooked_write (tdep->ppc_fp0_regnum + 1 + f_argno,
50888e42 495 value_contents (arg).data ());
4a7622d1
UW
496 ++f_argno;
497 }
498
50888e42 499 write_memory (sp + 24 + (ii * 4), value_contents (arg).data (), len);
4a7622d1
UW
500 ii += ((len + 3) & -4) / 4;
501 }
502 }
503
504 /* Set the stack pointer. According to the ABI, the SP is meant to
505 be set _before_ the corresponding stack space is used. On AIX,
506 this even applies when the target has been completely stopped!
507 Not doing this can lead to conflicts with the kernel which thinks
508 that it still has control over this not-yet-allocated stack
509 region. */
510 regcache_raw_write_signed (regcache, gdbarch_sp_regnum (gdbarch), sp);
511
512 /* Set back chain properly. */
e17a4113 513 store_unsigned_integer (tmp_buffer, wordsize, byte_order, saved_sp);
4a7622d1
UW
514 write_memory (sp, tmp_buffer, wordsize);
515
516 /* Point the inferior function call's return address at the dummy's
517 breakpoint. */
518 regcache_raw_write_signed (regcache, tdep->ppc_lr_regnum, bp_addr);
519
4d1eb6b4
JB
520 /* Set the TOC register value. */
521 regcache_raw_write_signed (regcache, tdep->ppc_toc_regnum,
522 solib_aix_get_toc_value (func_addr));
4a7622d1
UW
523
524 target_store_registers (regcache, -1);
525 return sp;
526}
527
528static enum return_value_convention
6a3a010b 529rs6000_return_value (struct gdbarch *gdbarch, struct value *function,
4a7622d1
UW
530 struct type *valtype, struct regcache *regcache,
531 gdb_byte *readbuf, const gdb_byte *writebuf)
532{
08106042 533 ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
e17a4113 534 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
4a7622d1
UW
535
536 /* The calling convention this function implements assumes the
537 processor has floating-point registers. We shouldn't be using it
538 on PowerPC variants that lack them. */
539 gdb_assert (ppc_floating_point_unit_p (gdbarch));
540
541 /* AltiVec extension: Functions that declare a vector data type as a
542 return value place that return value in VR2. */
bd63c870 543 if (valtype->code () == TYPE_CODE_ARRAY && valtype->is_vector ()
df86565b 544 && valtype->length () == 16)
4a7622d1
UW
545 {
546 if (readbuf)
dca08e1f 547 regcache->cooked_read (tdep->ppc_vr0_regnum + 2, readbuf);
4a7622d1 548 if (writebuf)
b66f5587 549 regcache->cooked_write (tdep->ppc_vr0_regnum + 2, writebuf);
4a7622d1
UW
550
551 return RETURN_VALUE_REGISTER_CONVENTION;
552 }
553
554 /* If the called subprogram returns an aggregate, there exists an
555 implicit first argument, whose value is the address of a caller-
556 allocated buffer into which the callee is assumed to store its
0df8b418 557 return value. All explicit parameters are appropriately
4a7622d1 558 relabeled. */
78134374
SM
559 if (valtype->code () == TYPE_CODE_STRUCT
560 || valtype->code () == TYPE_CODE_UNION
561 || valtype->code () == TYPE_CODE_ARRAY)
4a7622d1
UW
562 return RETURN_VALUE_STRUCT_CONVENTION;
563
564 /* Scalar floating-point values are returned in FPR1 for float or
565 double, and in FPR1:FPR2 for quadword precision. Fortran
566 complex*8 and complex*16 are returned in FPR1:FPR2, and
567 complex*32 is returned in FPR1:FPR4. */
78134374 568 if (valtype->code () == TYPE_CODE_FLT
df86565b 569 && (valtype->length () == 4 || valtype->length () == 8))
4a7622d1
UW
570 {
571 struct type *regtype = register_type (gdbarch, tdep->ppc_fp0_regnum);
572 gdb_byte regval[8];
573
574 /* FIXME: kettenis/2007-01-01: Add support for quadword
575 precision and complex. */
576
577 if (readbuf)
578 {
dca08e1f 579 regcache->cooked_read (tdep->ppc_fp0_regnum + 1, regval);
3b2ca824 580 target_float_convert (regval, regtype, readbuf, valtype);
4a7622d1
UW
581 }
582 if (writebuf)
583 {
3b2ca824 584 target_float_convert (writebuf, valtype, regval, regtype);
b66f5587 585 regcache->cooked_write (tdep->ppc_fp0_regnum + 1, regval);
4a7622d1
UW
586 }
587
588 return RETURN_VALUE_REGISTER_CONVENTION;
589 }
590
591 /* Values of the types int, long, short, pointer, and char (length
592 is less than or equal to four bytes), as well as bit values of
593 lengths less than or equal to 32 bits, must be returned right
594 justified in GPR3 with signed values sign extended and unsigned
595 values zero extended, as necessary. */
df86565b 596 if (valtype->length () <= tdep->wordsize)
4a7622d1
UW
597 {
598 if (readbuf)
599 {
600 ULONGEST regval;
601
602 /* For reading we don't have to worry about sign extension. */
603 regcache_cooked_read_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
604 &regval);
df86565b 605 store_unsigned_integer (readbuf, valtype->length (), byte_order,
e17a4113 606 regval);
4a7622d1
UW
607 }
608 if (writebuf)
609 {
610 /* For writing, use unpack_long since that should handle any
611 required sign extension. */
612 regcache_cooked_write_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
613 unpack_long (valtype, writebuf));
614 }
615
616 return RETURN_VALUE_REGISTER_CONVENTION;
617 }
618
619 /* Eight-byte non-floating-point scalar values must be returned in
620 GPR3:GPR4. */
621
df86565b 622 if (valtype->length () == 8)
4a7622d1 623 {
78134374 624 gdb_assert (valtype->code () != TYPE_CODE_FLT);
4a7622d1
UW
625 gdb_assert (tdep->wordsize == 4);
626
627 if (readbuf)
628 {
629 gdb_byte regval[8];
630
dca08e1f
SM
631 regcache->cooked_read (tdep->ppc_gp0_regnum + 3, regval);
632 regcache->cooked_read (tdep->ppc_gp0_regnum + 4, regval + 4);
4a7622d1
UW
633 memcpy (readbuf, regval, 8);
634 }
635 if (writebuf)
636 {
b66f5587
SM
637 regcache->cooked_write (tdep->ppc_gp0_regnum + 3, writebuf);
638 regcache->cooked_write (tdep->ppc_gp0_regnum + 4, writebuf + 4);
4a7622d1
UW
639 }
640
641 return RETURN_VALUE_REGISTER_CONVENTION;
642 }
643
644 return RETURN_VALUE_STRUCT_CONVENTION;
645}
646
647/* Support for CONVERT_FROM_FUNC_PTR_ADDR (ARCH, ADDR, TARG).
648
649 Usually a function pointer's representation is simply the address
0df8b418
MS
650 of the function. On the RS/6000 however, a function pointer is
651 represented by a pointer to an OPD entry. This OPD entry contains
4a7622d1
UW
652 three words, the first word is the address of the function, the
653 second word is the TOC pointer (r2), and the third word is the
654 static chain value. Throughout GDB it is currently assumed that a
655 function pointer contains the address of the function, which is not
656 easy to fix. In addition, the conversion of a function address to
657 a function pointer would require allocation of an OPD entry in the
658 inferior's memory space, with all its drawbacks. To be able to
659 call C++ virtual methods in the inferior (which are called via
660 function pointers), find_function_addr uses this function to get the
661 function address from a function pointer. */
662
663/* Return real function address if ADDR (a function pointer) is in the data
664 space and is therefore a special function pointer. */
665
666static CORE_ADDR
667rs6000_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
668 CORE_ADDR addr,
669 struct target_ops *targ)
670{
08106042 671 ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
e17a4113 672 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
4a7622d1
UW
673 struct obj_section *s;
674
675 s = find_pc_section (addr);
4a7622d1 676
40adab56
JB
677 /* Normally, functions live inside a section that is executable.
678 So, if ADDR points to a non-executable section, then treat it
679 as a function descriptor and return the target address iff
680 the target address itself points to a section that is executable. */
681 if (s && (s->the_bfd_section->flags & SEC_CODE) == 0)
682 {
57174f31 683 CORE_ADDR pc = 0;
2971b56b 684 struct obj_section *pc_section;
2971b56b 685
a70b8144 686 try
dda83cd7
SM
687 {
688 pc = read_memory_unsigned_integer (addr, tdep->wordsize, byte_order);
689 }
230d2906 690 catch (const gdb_exception_error &e)
dda83cd7
SM
691 {
692 /* An error occured during reading. Probably a memory error
693 due to the section not being loaded yet. This address
694 cannot be a function descriptor. */
695 return addr;
696 }
492d29ea 697
2971b56b 698 pc_section = find_pc_section (pc);
40adab56
JB
699
700 if (pc_section && (pc_section->the_bfd_section->flags & SEC_CODE))
dda83cd7 701 return pc;
40adab56
JB
702 }
703
704 return addr;
4a7622d1
UW
705}
706
707
708/* Calculate the destination of a branch/jump. Return -1 if not a branch. */
709
710static CORE_ADDR
41e26ad3 711branch_dest (struct regcache *regcache, int opcode, int instr,
4a7622d1
UW
712 CORE_ADDR pc, CORE_ADDR safety)
713{
ac7936df 714 struct gdbarch *gdbarch = regcache->arch ();
08106042 715 ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
e17a4113 716 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
4a7622d1
UW
717 CORE_ADDR dest;
718 int immediate;
719 int absolute;
720 int ext_op;
721
722 absolute = (int) ((instr >> 1) & 1);
723
724 switch (opcode)
725 {
726 case 18:
727 immediate = ((instr & ~3) << 6) >> 6; /* br unconditional */
728 if (absolute)
729 dest = immediate;
730 else
731 dest = pc + immediate;
732 break;
733
734 case 16:
735 immediate = ((instr & ~3) << 16) >> 16; /* br conditional */
736 if (absolute)
737 dest = immediate;
738 else
739 dest = pc + immediate;
740 break;
741
742 case 19:
743 ext_op = (instr >> 1) & 0x3ff;
744
745 if (ext_op == 16) /* br conditional register */
746 {
dda83cd7 747 dest = regcache_raw_get_unsigned (regcache, tdep->ppc_lr_regnum) & ~3;
4a7622d1
UW
748
749 /* If we are about to return from a signal handler, dest is
750 something like 0x3c90. The current frame is a signal handler
751 caller frame, upon completion of the sigreturn system call
752 execution will return to the saved PC in the frame. */
753 if (dest < AIX_TEXT_SEGMENT_BASE)
41e26ad3 754 {
bd2b40ac 755 frame_info_ptr frame = get_current_frame ();
41e26ad3
YQ
756
757 dest = read_memory_unsigned_integer
758 (get_frame_base (frame) + SIG_FRAME_PC_OFFSET,
759 tdep->wordsize, byte_order);
760 }
4a7622d1
UW
761 }
762
763 else if (ext_op == 528) /* br cond to count reg */
764 {
dda83cd7 765 dest = regcache_raw_get_unsigned (regcache,
41e26ad3 766 tdep->ppc_ctr_regnum) & ~3;
4a7622d1
UW
767
768 /* If we are about to execute a system call, dest is something
769 like 0x22fc or 0x3b00. Upon completion the system call
770 will return to the address in the link register. */
771 if (dest < AIX_TEXT_SEGMENT_BASE)
dda83cd7 772 dest = regcache_raw_get_unsigned (regcache,
41e26ad3 773 tdep->ppc_lr_regnum) & ~3;
4a7622d1
UW
774 }
775 else
776 return -1;
777 break;
778
779 default:
780 return -1;
781 }
782 return (dest < AIX_TEXT_SEGMENT_BASE) ? safety : dest;
783}
784
785/* AIX does not support PT_STEP. Simulate it. */
786
a0ff9e1a 787static std::vector<CORE_ADDR>
f5ea389a 788rs6000_software_single_step (struct regcache *regcache)
4a7622d1 789{
ac7936df 790 struct gdbarch *gdbarch = regcache->arch ();
e17a4113 791 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
4a7622d1
UW
792 int ii, insn;
793 CORE_ADDR loc;
794 CORE_ADDR breaks[2];
795 int opcode;
796
41e26ad3 797 loc = regcache_read_pc (regcache);
4a7622d1 798
e17a4113 799 insn = read_memory_integer (loc, 4, byte_order);
4a7622d1 800
a0ff9e1a
SM
801 std::vector<CORE_ADDR> next_pcs = ppc_deal_with_atomic_sequence (regcache);
802 if (!next_pcs.empty ())
93f9a11f 803 return next_pcs;
4a7622d1
UW
804
805 breaks[0] = loc + PPC_INSN_SIZE;
806 opcode = insn >> 26;
41e26ad3 807 breaks[1] = branch_dest (regcache, opcode, insn, loc, breaks[0]);
4a7622d1 808
0df8b418 809 /* Don't put two breakpoints on the same address. */
4a7622d1
UW
810 if (breaks[1] == breaks[0])
811 breaks[1] = -1;
812
813 for (ii = 0; ii < 2; ++ii)
814 {
0df8b418 815 /* ignore invalid breakpoint. */
4a7622d1
UW
816 if (breaks[ii] == -1)
817 continue;
a0ff9e1a
SM
818
819 next_pcs.push_back (breaks[ii]);
4a7622d1
UW
820 }
821
0df8b418 822 errno = 0; /* FIXME, don't ignore errors! */
4a7622d1 823 /* What errors? {read,write}_memory call error(). */
93f9a11f 824 return next_pcs;
4a7622d1
UW
825}
826
38a69d0a
JB
827/* Implement the "auto_wide_charset" gdbarch method for this platform. */
828
829static const char *
830rs6000_aix_auto_wide_charset (void)
831{
832 return "UTF-16";
833}
834
beb4b03c
JB
835/* Implement an osabi sniffer for RS6000/AIX.
836
837 This function assumes that ABFD's flavour is XCOFF. In other words,
838 it should be registered as a sniffer for bfd_target_xcoff_flavour
839 objfiles only. A failed assertion will be raised if this condition
840 is not met. */
841
1f82754b
JB
842static enum gdb_osabi
843rs6000_aix_osabi_sniffer (bfd *abfd)
844{
beb4b03c 845 gdb_assert (bfd_get_flavour (abfd) == bfd_target_xcoff_flavour);
1f82754b 846
d5367fe1
JB
847 /* The only noticeable difference between Lynx178 XCOFF files and
848 AIX XCOFF files comes from the fact that there are no shared
849 libraries on Lynx178. On AIX, we are betting that an executable
850 linked with no shared library will never exist. */
851 if (xcoff_get_n_import_files (abfd) <= 0)
852 return GDB_OSABI_UNKNOWN;
853
beb4b03c 854 return GDB_OSABI_AIX;
1f82754b
JB
855}
856
356a5233
JB
857/* A structure encoding the offset and size of a field within
858 a struct. */
859
c01e2836 860struct ldinfo_field
356a5233
JB
861{
862 int offset;
863 int size;
864};
865
866/* A structure describing the layout of all the fields of interest
867 in AIX's struct ld_info. Each field in this struct corresponds
868 to the field of the same name in struct ld_info. */
869
870struct ld_info_desc
871{
c01e2836
TT
872 struct ldinfo_field ldinfo_next;
873 struct ldinfo_field ldinfo_fd;
874 struct ldinfo_field ldinfo_textorg;
875 struct ldinfo_field ldinfo_textsize;
876 struct ldinfo_field ldinfo_dataorg;
877 struct ldinfo_field ldinfo_datasize;
878 struct ldinfo_field ldinfo_filename;
356a5233
JB
879};
880
881/* The following data has been generated by compiling and running
882 the following program on AIX 5.3. */
883
884#if 0
1c432e72
JB
885#include <stddef.h>
886#include <stdio.h>
887#define __LDINFO_PTRACE32__
888#define __LDINFO_PTRACE64__
889#include <sys/ldr.h>
890
891#define pinfo(type,member) \
892 { \
893 struct type ldi = {0}; \
dda83cd7 894 \
1c432e72 895 printf (" {%d, %d},\t/* %s */\n", \
dda83cd7
SM
896 offsetof (struct type, member), \
897 sizeof (ldi.member), \
898 #member); \
1c432e72
JB
899 } \
900 while (0)
901
902int
903main (void)
904{
905 printf ("static const struct ld_info_desc ld_info32_desc =\n{\n");
906 pinfo (__ld_info32, ldinfo_next);
907 pinfo (__ld_info32, ldinfo_fd);
908 pinfo (__ld_info32, ldinfo_textorg);
909 pinfo (__ld_info32, ldinfo_textsize);
910 pinfo (__ld_info32, ldinfo_dataorg);
911 pinfo (__ld_info32, ldinfo_datasize);
912 pinfo (__ld_info32, ldinfo_filename);
913 printf ("};\n");
914
915 printf ("\n");
916
917 printf ("static const struct ld_info_desc ld_info64_desc =\n{\n");
918 pinfo (__ld_info64, ldinfo_next);
919 pinfo (__ld_info64, ldinfo_fd);
920 pinfo (__ld_info64, ldinfo_textorg);
921 pinfo (__ld_info64, ldinfo_textsize);
922 pinfo (__ld_info64, ldinfo_dataorg);
923 pinfo (__ld_info64, ldinfo_datasize);
924 pinfo (__ld_info64, ldinfo_filename);
925 printf ("};\n");
926
927 return 0;
928}
356a5233
JB
929#endif /* 0 */
930
931/* Layout of the 32bit version of struct ld_info. */
932
933static const struct ld_info_desc ld_info32_desc =
934{
935 {0, 4}, /* ldinfo_next */
936 {4, 4}, /* ldinfo_fd */
937 {8, 4}, /* ldinfo_textorg */
938 {12, 4}, /* ldinfo_textsize */
939 {16, 4}, /* ldinfo_dataorg */
940 {20, 4}, /* ldinfo_datasize */
941 {24, 2}, /* ldinfo_filename */
942};
943
944/* Layout of the 64bit version of struct ld_info. */
945
946static const struct ld_info_desc ld_info64_desc =
947{
948 {0, 4}, /* ldinfo_next */
949 {8, 4}, /* ldinfo_fd */
950 {16, 8}, /* ldinfo_textorg */
951 {24, 8}, /* ldinfo_textsize */
952 {32, 8}, /* ldinfo_dataorg */
953 {40, 8}, /* ldinfo_datasize */
954 {48, 2}, /* ldinfo_filename */
955};
956
957/* A structured representation of one entry read from the ld_info
958 binary data provided by the AIX loader. */
959
960struct ld_info
961{
962 ULONGEST next;
963 int fd;
964 CORE_ADDR textorg;
965 ULONGEST textsize;
966 CORE_ADDR dataorg;
967 ULONGEST datasize;
968 char *filename;
969 char *member_name;
970};
971
972/* Return a struct ld_info object corresponding to the entry at
973 LDI_BUF.
974
975 Note that the filename and member_name strings still point
976 to the data in LDI_BUF. So LDI_BUF must not be deallocated
977 while the struct ld_info object returned is in use. */
978
979static struct ld_info
980rs6000_aix_extract_ld_info (struct gdbarch *gdbarch,
981 const gdb_byte *ldi_buf)
982{
08106042 983 ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
356a5233
JB
984 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
985 struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
986 const struct ld_info_desc desc
987 = tdep->wordsize == 8 ? ld_info64_desc : ld_info32_desc;
988 struct ld_info info;
989
990 info.next = extract_unsigned_integer (ldi_buf + desc.ldinfo_next.offset,
991 desc.ldinfo_next.size,
992 byte_order);
993 info.fd = extract_signed_integer (ldi_buf + desc.ldinfo_fd.offset,
994 desc.ldinfo_fd.size,
995 byte_order);
996 info.textorg = extract_typed_address (ldi_buf + desc.ldinfo_textorg.offset,
997 ptr_type);
998 info.textsize
999 = extract_unsigned_integer (ldi_buf + desc.ldinfo_textsize.offset,
1000 desc.ldinfo_textsize.size,
1001 byte_order);
1002 info.dataorg = extract_typed_address (ldi_buf + desc.ldinfo_dataorg.offset,
1003 ptr_type);
1004 info.datasize
1005 = extract_unsigned_integer (ldi_buf + desc.ldinfo_datasize.offset,
1006 desc.ldinfo_datasize.size,
1007 byte_order);
1008 info.filename = (char *) ldi_buf + desc.ldinfo_filename.offset;
1009 info.member_name = info.filename + strlen (info.filename) + 1;
1010
1011 return info;
1012}
1013
1014/* Append to OBJSTACK an XML string description of the shared library
1015 corresponding to LDI, following the TARGET_OBJECT_LIBRARIES_AIX
1016 format. */
1017
1018static void
1019rs6000_aix_shared_library_to_xml (struct ld_info *ldi,
1020 struct obstack *obstack)
1021{
356a5233 1022 obstack_grow_str (obstack, "<library name=\"");
5e187554
SM
1023 std::string p = xml_escape_text (ldi->filename);
1024 obstack_grow_str (obstack, p.c_str ());
356a5233
JB
1025 obstack_grow_str (obstack, "\"");
1026
1027 if (ldi->member_name[0] != '\0')
1028 {
1029 obstack_grow_str (obstack, " member=\"");
1030 p = xml_escape_text (ldi->member_name);
5e187554 1031 obstack_grow_str (obstack, p.c_str ());
356a5233
JB
1032 obstack_grow_str (obstack, "\"");
1033 }
1034
1035 obstack_grow_str (obstack, " text_addr=\"");
1036 obstack_grow_str (obstack, core_addr_to_string (ldi->textorg));
1037 obstack_grow_str (obstack, "\"");
1038
1039 obstack_grow_str (obstack, " text_size=\"");
1040 obstack_grow_str (obstack, pulongest (ldi->textsize));
1041 obstack_grow_str (obstack, "\"");
1042
1043 obstack_grow_str (obstack, " data_addr=\"");
1044 obstack_grow_str (obstack, core_addr_to_string (ldi->dataorg));
1045 obstack_grow_str (obstack, "\"");
1046
1047 obstack_grow_str (obstack, " data_size=\"");
1048 obstack_grow_str (obstack, pulongest (ldi->datasize));
1049 obstack_grow_str (obstack, "\"");
1050
1051 obstack_grow_str (obstack, "></library>");
1052}
1053
1054/* Convert the ld_info binary data provided by the AIX loader into
1055 an XML representation following the TARGET_OBJECT_LIBRARIES_AIX
1056 format.
1057
1058 LDI_BUF is a buffer containing the ld_info data.
1059 READBUF, OFFSET and LEN follow the same semantics as target_ops'
1060 to_xfer_partial target_ops method.
1061
1062 If CLOSE_LDINFO_FD is nonzero, then this routine also closes
1063 the ldinfo_fd file descriptor. This is useful when the ldinfo
1064 data is obtained via ptrace, as ptrace opens a file descriptor
1065 for each and every entry; but we cannot use this descriptor
1066 as the consumer of the XML library list might live in a different
1067 process. */
1068
c09f20e4 1069ULONGEST
356a5233 1070rs6000_aix_ld_info_to_xml (struct gdbarch *gdbarch, const gdb_byte *ldi_buf,
b55e14c7 1071 gdb_byte *readbuf, ULONGEST offset, ULONGEST len,
356a5233
JB
1072 int close_ldinfo_fd)
1073{
1074 struct obstack obstack;
1075 const char *buf;
c09f20e4 1076 ULONGEST len_avail;
356a5233
JB
1077
1078 obstack_init (&obstack);
1079 obstack_grow_str (&obstack, "<library-list-aix version=\"1.0\">\n");
1080
1081 while (1)
1082 {
1083 struct ld_info ldi = rs6000_aix_extract_ld_info (gdbarch, ldi_buf);
1084
1085 rs6000_aix_shared_library_to_xml (&ldi, &obstack);
1086 if (close_ldinfo_fd)
1087 close (ldi.fd);
1088
1089 if (!ldi.next)
1090 break;
1091 ldi_buf = ldi_buf + ldi.next;
1092 }
1093
1094 obstack_grow_str0 (&obstack, "</library-list-aix>\n");
1095
224c3ddb 1096 buf = (const char *) obstack_finish (&obstack);
356a5233
JB
1097 len_avail = strlen (buf);
1098 if (offset >= len_avail)
1099 len= 0;
1100 else
1101 {
1102 if (len > len_avail - offset)
dda83cd7 1103 len = len_avail - offset;
356a5233
JB
1104 memcpy (readbuf, buf + offset, len);
1105 }
1106
1107 obstack_free (&obstack, NULL);
1108 return len;
1109}
1110
1111/* Implement the core_xfer_shared_libraries_aix gdbarch method. */
1112
c09f20e4 1113static ULONGEST
356a5233
JB
1114rs6000_aix_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch,
1115 gdb_byte *readbuf,
1116 ULONGEST offset,
7ec1862d 1117 ULONGEST len)
356a5233
JB
1118{
1119 struct bfd_section *ldinfo_sec;
1120 int ldinfo_size;
356a5233
JB
1121
1122 ldinfo_sec = bfd_get_section_by_name (core_bfd, ".ldinfo");
1123 if (ldinfo_sec == NULL)
1124 error (_("cannot find .ldinfo section from core file: %s"),
1125 bfd_errmsg (bfd_get_error ()));
fd361982 1126 ldinfo_size = bfd_section_size (ldinfo_sec);
356a5233 1127
984c7238 1128 gdb::byte_vector ldinfo_buf (ldinfo_size);
356a5233
JB
1129
1130 if (! bfd_get_section_contents (core_bfd, ldinfo_sec,
984c7238 1131 ldinfo_buf.data (), 0, ldinfo_size))
356a5233
JB
1132 error (_("unable to read .ldinfo section from core file: %s"),
1133 bfd_errmsg (bfd_get_error ()));
1134
984c7238
TT
1135 return rs6000_aix_ld_info_to_xml (gdbarch, ldinfo_buf.data (), readbuf,
1136 offset, len, 0);
356a5233
JB
1137}
1138
1f82754b
JB
1139static void
1140rs6000_aix_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)
1141{
08106042 1142 ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
4a7622d1 1143
1f82754b
JB
1144 /* RS6000/AIX does not support PT_STEP. Has to be simulated. */
1145 set_gdbarch_software_single_step (gdbarch, rs6000_software_single_step);
6f7f3f0d 1146
2454a024 1147 /* Displaced stepping is currently not supported in combination with
187b041e
SM
1148 software single-stepping. These override the values set by
1149 rs6000_gdbarch_init. */
2454a024
UW
1150 set_gdbarch_displaced_step_copy_insn (gdbarch, NULL);
1151 set_gdbarch_displaced_step_fixup (gdbarch, NULL);
187b041e
SM
1152 set_gdbarch_displaced_step_prepare (gdbarch, NULL);
1153 set_gdbarch_displaced_step_finish (gdbarch, NULL);
2454a024 1154
4a7622d1
UW
1155 set_gdbarch_push_dummy_call (gdbarch, rs6000_push_dummy_call);
1156 set_gdbarch_return_value (gdbarch, rs6000_return_value);
1157 set_gdbarch_long_double_bit (gdbarch, 8 * TARGET_CHAR_BIT);
1158
1159 /* Handle RS/6000 function pointers (which are really function
1160 descriptors). */
1161 set_gdbarch_convert_from_func_ptr_addr
1162 (gdbarch, rs6000_convert_from_func_ptr_addr);
1163
7a61a01c 1164 /* Core file support. */
23ea9aeb
AA
1165 set_gdbarch_iterate_over_regset_sections
1166 (gdbarch, rs6000_aix_iterate_over_regset_sections);
356a5233
JB
1167 set_gdbarch_core_xfer_shared_libraries_aix
1168 (gdbarch, rs6000_aix_core_xfer_shared_libraries_aix);
7a61a01c 1169
4a7622d1
UW
1170 if (tdep->wordsize == 8)
1171 tdep->lr_frame_offset = 16;
1172 else
1173 tdep->lr_frame_offset = 8;
1174
1175 if (tdep->wordsize == 4)
1176 /* PowerOpen / AIX 32 bit. The saved area or red zone consists of
1177 19 4 byte GPRS + 18 8 byte FPRs giving a total of 220 bytes.
1178 Problem is, 220 isn't frame (16 byte) aligned. Round it up to
1179 224. */
1180 set_gdbarch_frame_red_zone_size (gdbarch, 224);
1181 else
1182 set_gdbarch_frame_red_zone_size (gdbarch, 0);
38a69d0a 1183
53375380
PA
1184 if (tdep->wordsize == 8)
1185 set_gdbarch_wchar_bit (gdbarch, 32);
1186 else
1187 set_gdbarch_wchar_bit (gdbarch, 16);
1188 set_gdbarch_wchar_signed (gdbarch, 0);
38a69d0a 1189 set_gdbarch_auto_wide_charset (gdbarch, rs6000_aix_auto_wide_charset);
4d1eb6b4 1190
9e468e95 1191 set_gdbarch_so_ops (gdbarch, &solib_aix_so_ops);
cdcda965 1192 frame_unwind_append_unwinder (gdbarch, &aix_sighandle_frame_unwind);
1f82754b
JB
1193}
1194
6c265988 1195void _initialize_rs6000_aix_tdep ();
1f82754b 1196void
6c265988 1197_initialize_rs6000_aix_tdep ()
1f82754b
JB
1198{
1199 gdbarch_register_osabi_sniffer (bfd_arch_rs6000,
dda83cd7
SM
1200 bfd_target_xcoff_flavour,
1201 rs6000_aix_osabi_sniffer);
7a61a01c 1202 gdbarch_register_osabi_sniffer (bfd_arch_powerpc,
dda83cd7
SM
1203 bfd_target_xcoff_flavour,
1204 rs6000_aix_osabi_sniffer);
1f82754b
JB
1205
1206 gdbarch_register_osabi (bfd_arch_rs6000, 0, GDB_OSABI_AIX,
dda83cd7 1207 rs6000_aix_init_osabi);
7a61a01c 1208 gdbarch_register_osabi (bfd_arch_powerpc, 0, GDB_OSABI_AIX,
dda83cd7 1209 rs6000_aix_init_osabi);
1f82754b
JB
1210}
1211