1 /* IBM RS/6000 native-dependent code for GDB, the GNU debugger.
3 Copyright (C) 1986-2013 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
26 #include "libbfd.h" /* For bfd_default_set_arch_mach (FIXME) */
28 #include "exceptions.h"
29 #include "gdb-stabs.h"
31 #include "arch-utils.h"
32 #include "inf-child.h"
33 #include "inf-ptrace.h"
35 #include "rs6000-tdep.h"
38 #include "xcoffread.h"
40 #include <sys/ptrace.h>
43 #include <sys/param.h>
47 #include <sys/ioctl.h>
56 #define __LDINFO_PTRACE32__ /* for __ld_info32 */
57 #define __LDINFO_PTRACE64__ /* for __ld_info64 */
59 #include <sys/systemcfg.h>
60 #include "xml-utils.h"
62 /* On AIX4.3+, sys/ldr.h provides different versions of struct ld_info for
63 debugging 32-bit and 64-bit processes. Define a typedef and macros for
64 accessing fields in the appropriate structures. */
66 /* In 32-bit compilation mode (which is the only mode from which ptrace()
67 works on 4.3), __ld_info32 is #defined as equivalent to ld_info. */
73 /* Return whether the current architecture is 64-bit. */
78 # define ARCH64() (register_size (target_gdbarch (), 0) == 8)
81 /* Union of 32-bit and 64-bit versions of ld_info. */
88 struct __ld_info32 l32;
89 struct __ld_info64 l64;
93 /* If compiling with 32-bit and 64-bit debugging capability (e.g. AIX 4.x),
94 declare and initialize a variable named VAR suitable for use as the arch64
95 parameter to the various LDI_*() macros. */
98 # define ARCH64_DECL(var)
100 # define ARCH64_DECL(var) int var = ARCH64 ()
103 /* Return LDI's FIELD for a 64-bit process if ARCH64 and for a 32-bit process
104 otherwise. This technique only works for FIELDs with the same data type in
105 32-bit and 64-bit versions of ld_info. */
108 # define LDI_FIELD(ldi, arch64, field) (ldi)->l32.ldinfo_##field
110 # define LDI_FIELD(ldi, arch64, field) \
111 (arch64 ? (ldi)->l64.ldinfo_##field : (ldi)->l32.ldinfo_##field)
114 /* Return various LDI fields for a 64-bit process if ARCH64 and for a 32-bit
115 process otherwise. */
117 #define LDI_NEXT(ldi, arch64) LDI_FIELD(ldi, arch64, next)
118 #define LDI_FD(ldi, arch64) LDI_FIELD(ldi, arch64, fd)
119 #define LDI_FILENAME(ldi, arch64) LDI_FIELD(ldi, arch64, filename)
121 static void exec_one_dummy_insn (struct regcache *);
123 static LONGEST rs6000_xfer_shared_libraries
124 (struct target_ops *ops, enum target_object object,
125 const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf,
126 ULONGEST offset, LONGEST len);
128 /* Given REGNO, a gdb register number, return the corresponding
129 number suitable for use as a ptrace() parameter. Return -1 if
130 there's no suitable mapping. Also, set the int pointed to by
131 ISFLOAT to indicate whether REGNO is a floating point register. */
134 regmap (struct gdbarch *gdbarch, int regno, int *isfloat)
136 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
139 if (tdep->ppc_gp0_regnum <= regno
140 && regno < tdep->ppc_gp0_regnum + ppc_num_gprs)
142 else if (tdep->ppc_fp0_regnum >= 0
143 && tdep->ppc_fp0_regnum <= regno
144 && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)
147 return regno - tdep->ppc_fp0_regnum + FPR0;
149 else if (regno == gdbarch_pc_regnum (gdbarch))
151 else if (regno == tdep->ppc_ps_regnum)
153 else if (regno == tdep->ppc_cr_regnum)
155 else if (regno == tdep->ppc_lr_regnum)
157 else if (regno == tdep->ppc_ctr_regnum)
159 else if (regno == tdep->ppc_xer_regnum)
161 else if (tdep->ppc_fpscr_regnum >= 0
162 && regno == tdep->ppc_fpscr_regnum)
164 else if (tdep->ppc_mq_regnum >= 0 && regno == tdep->ppc_mq_regnum)
170 /* Call ptrace(REQ, ID, ADDR, DATA, BUF). */
173 rs6000_ptrace32 (int req, int id, int *addr, int data, int *buf)
175 int ret = ptrace (req, id, (int *)addr, data, buf);
177 printf ("rs6000_ptrace32 (%d, %d, 0x%x, %08x, 0x%x) = 0x%x\n",
178 req, id, (unsigned int)addr, data, (unsigned int)buf, ret);
183 /* Call ptracex(REQ, ID, ADDR, DATA, BUF). */
186 rs6000_ptrace64 (int req, int id, long long addr, int data, void *buf)
189 int ret = ptracex (req, id, addr, data, buf);
194 printf ("rs6000_ptrace64 (%d, %d, %s, %08x, 0x%x) = 0x%x\n",
195 req, id, hex_string (addr), data, (unsigned int)buf, ret);
200 /* Fetch register REGNO from the inferior. */
203 fetch_register (struct regcache *regcache, int regno)
205 struct gdbarch *gdbarch = get_regcache_arch (regcache);
206 int addr[MAX_REGISTER_SIZE];
209 /* Retrieved values may be -1, so infer errors from errno. */
212 nr = regmap (gdbarch, regno, &isfloat);
214 /* Floating-point registers. */
216 rs6000_ptrace32 (PT_READ_FPR, PIDGET (inferior_ptid), addr, nr, 0);
218 /* Bogus register number. */
221 if (regno >= gdbarch_num_regs (gdbarch))
222 fprintf_unfiltered (gdb_stderr,
223 "gdb error: register no %d not implemented.\n",
228 /* Fixed-point registers. */
232 *addr = rs6000_ptrace32 (PT_READ_GPR, PIDGET (inferior_ptid),
236 /* PT_READ_GPR requires the buffer parameter to point to long long,
237 even if the register is really only 32 bits. */
239 rs6000_ptrace64 (PT_READ_GPR, PIDGET (inferior_ptid), nr, 0, &buf);
240 if (register_size (gdbarch, regno) == 8)
241 memcpy (addr, &buf, 8);
248 regcache_raw_supply (regcache, regno, (char *) addr);
252 /* FIXME: this happens 3 times at the start of each 64-bit program. */
253 perror (_("ptrace read"));
259 /* Store register REGNO back into the inferior. */
262 store_register (struct regcache *regcache, int regno)
264 struct gdbarch *gdbarch = get_regcache_arch (regcache);
265 int addr[MAX_REGISTER_SIZE];
268 /* Fetch the register's value from the register cache. */
269 regcache_raw_collect (regcache, regno, addr);
271 /* -1 can be a successful return value, so infer errors from errno. */
274 nr = regmap (gdbarch, regno, &isfloat);
276 /* Floating-point registers. */
278 rs6000_ptrace32 (PT_WRITE_FPR, PIDGET (inferior_ptid), addr, nr, 0);
280 /* Bogus register number. */
283 if (regno >= gdbarch_num_regs (gdbarch))
284 fprintf_unfiltered (gdb_stderr,
285 "gdb error: register no %d not implemented.\n",
289 /* Fixed-point registers. */
292 if (regno == gdbarch_sp_regnum (gdbarch))
293 /* Execute one dummy instruction (which is a breakpoint) in inferior
294 process to give kernel a chance to do internal housekeeping.
295 Otherwise the following ptrace(2) calls will mess up user stack
296 since kernel will get confused about the bottom of the stack
298 exec_one_dummy_insn (regcache);
300 /* The PT_WRITE_GPR operation is rather odd. For 32-bit inferiors,
301 the register's value is passed by value, but for 64-bit inferiors,
302 the address of a buffer containing the value is passed. */
304 rs6000_ptrace32 (PT_WRITE_GPR, PIDGET (inferior_ptid),
305 (int *) nr, *addr, 0);
308 /* PT_WRITE_GPR requires the buffer parameter to point to an 8-byte
309 area, even if the register is really only 32 bits. */
311 if (register_size (gdbarch, regno) == 8)
312 memcpy (&buf, addr, 8);
315 rs6000_ptrace64 (PT_WRITE_GPR, PIDGET (inferior_ptid), nr, 0, &buf);
321 perror (_("ptrace write"));
326 /* Read from the inferior all registers if REGNO == -1 and just register
330 rs6000_fetch_inferior_registers (struct target_ops *ops,
331 struct regcache *regcache, int regno)
333 struct gdbarch *gdbarch = get_regcache_arch (regcache);
335 fetch_register (regcache, regno);
339 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
341 /* Read 32 general purpose registers. */
342 for (regno = tdep->ppc_gp0_regnum;
343 regno < tdep->ppc_gp0_regnum + ppc_num_gprs;
346 fetch_register (regcache, regno);
349 /* Read general purpose floating point registers. */
350 if (tdep->ppc_fp0_regnum >= 0)
351 for (regno = 0; regno < ppc_num_fprs; regno++)
352 fetch_register (regcache, tdep->ppc_fp0_regnum + regno);
354 /* Read special registers. */
355 fetch_register (regcache, gdbarch_pc_regnum (gdbarch));
356 fetch_register (regcache, tdep->ppc_ps_regnum);
357 fetch_register (regcache, tdep->ppc_cr_regnum);
358 fetch_register (regcache, tdep->ppc_lr_regnum);
359 fetch_register (regcache, tdep->ppc_ctr_regnum);
360 fetch_register (regcache, tdep->ppc_xer_regnum);
361 if (tdep->ppc_fpscr_regnum >= 0)
362 fetch_register (regcache, tdep->ppc_fpscr_regnum);
363 if (tdep->ppc_mq_regnum >= 0)
364 fetch_register (regcache, tdep->ppc_mq_regnum);
368 /* Store our register values back into the inferior.
369 If REGNO is -1, do this for all registers.
370 Otherwise, REGNO specifies which register (so we can save time). */
373 rs6000_store_inferior_registers (struct target_ops *ops,
374 struct regcache *regcache, int regno)
376 struct gdbarch *gdbarch = get_regcache_arch (regcache);
378 store_register (regcache, regno);
382 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
384 /* Write general purpose registers first. */
385 for (regno = tdep->ppc_gp0_regnum;
386 regno < tdep->ppc_gp0_regnum + ppc_num_gprs;
389 store_register (regcache, regno);
392 /* Write floating point registers. */
393 if (tdep->ppc_fp0_regnum >= 0)
394 for (regno = 0; regno < ppc_num_fprs; regno++)
395 store_register (regcache, tdep->ppc_fp0_regnum + regno);
397 /* Write special registers. */
398 store_register (regcache, gdbarch_pc_regnum (gdbarch));
399 store_register (regcache, tdep->ppc_ps_regnum);
400 store_register (regcache, tdep->ppc_cr_regnum);
401 store_register (regcache, tdep->ppc_lr_regnum);
402 store_register (regcache, tdep->ppc_ctr_regnum);
403 store_register (regcache, tdep->ppc_xer_regnum);
404 if (tdep->ppc_fpscr_regnum >= 0)
405 store_register (regcache, tdep->ppc_fpscr_regnum);
406 if (tdep->ppc_mq_regnum >= 0)
407 store_register (regcache, tdep->ppc_mq_regnum);
412 /* Attempt a transfer all LEN bytes starting at OFFSET between the
413 inferior's OBJECT:ANNEX space and GDB's READBUF/WRITEBUF buffer.
414 Return the number of bytes actually transferred. */
417 rs6000_xfer_partial (struct target_ops *ops, enum target_object object,
418 const char *annex, gdb_byte *readbuf,
419 const gdb_byte *writebuf,
420 ULONGEST offset, LONGEST len)
422 pid_t pid = ptid_get_pid (inferior_ptid);
423 int arch64 = ARCH64 ();
427 case TARGET_OBJECT_LIBRARIES_AIX:
428 return rs6000_xfer_shared_libraries (ops, object, annex,
431 case TARGET_OBJECT_MEMORY:
435 PTRACE_TYPE_RET word;
436 gdb_byte byte[sizeof (PTRACE_TYPE_RET)];
438 ULONGEST rounded_offset;
441 /* Round the start offset down to the next long word
443 rounded_offset = offset & -(ULONGEST) sizeof (PTRACE_TYPE_RET);
445 /* Since ptrace will transfer a single word starting at that
446 rounded_offset the partial_len needs to be adjusted down to
447 that (remember this function only does a single transfer).
448 Should the required length be even less, adjust it down
450 partial_len = (rounded_offset + sizeof (PTRACE_TYPE_RET)) - offset;
451 if (partial_len > len)
456 /* If OFFSET:PARTIAL_LEN is smaller than
457 ROUNDED_OFFSET:WORDSIZE then a read/modify write will
458 be needed. Read in the entire word. */
459 if (rounded_offset < offset
460 || (offset + partial_len
461 < rounded_offset + sizeof (PTRACE_TYPE_RET)))
463 /* Need part of initial word -- fetch it. */
465 buffer.word = rs6000_ptrace64 (PT_READ_I, pid,
466 rounded_offset, 0, NULL);
468 buffer.word = rs6000_ptrace32 (PT_READ_I, pid,
474 /* Copy data to be written over corresponding part of
476 memcpy (buffer.byte + (offset - rounded_offset),
477 writebuf, partial_len);
481 rs6000_ptrace64 (PT_WRITE_D, pid,
482 rounded_offset, buffer.word, NULL);
484 rs6000_ptrace32 (PT_WRITE_D, pid,
485 (int *) (uintptr_t) rounded_offset,
495 buffer.word = rs6000_ptrace64 (PT_READ_I, pid,
496 rounded_offset, 0, NULL);
498 buffer.word = rs6000_ptrace32 (PT_READ_I, pid,
499 (int *)(uintptr_t)rounded_offset,
504 /* Copy appropriate bytes out of the buffer. */
505 memcpy (readbuf, buffer.byte + (offset - rounded_offset),
517 /* Wait for the child specified by PTID to do something. Return the
518 process ID of the child, or MINUS_ONE_PTID in case of error; store
519 the status in *OURSTATUS. */
522 rs6000_wait (struct target_ops *ops,
523 ptid_t ptid, struct target_waitstatus *ourstatus, int options)
526 int status, save_errno;
534 pid = waitpid (ptid_get_pid (ptid), &status, 0);
537 while (pid == -1 && errno == EINTR);
539 clear_sigint_trap ();
543 fprintf_unfiltered (gdb_stderr,
544 _("Child process unexpectedly missing: %s.\n"),
545 safe_strerror (save_errno));
547 /* Claim it exited with unknown signal. */
548 ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
549 ourstatus->value.sig = GDB_SIGNAL_UNKNOWN;
550 return inferior_ptid;
553 /* Ignore terminated detached child processes. */
554 if (!WIFSTOPPED (status) && pid != ptid_get_pid (inferior_ptid))
559 /* AIX has a couple of strange returns from wait(). */
561 /* stop after load" status. */
563 ourstatus->kind = TARGET_WAITKIND_LOADED;
564 /* signal 0. I have no idea why wait(2) returns with this status word. */
565 else if (status == 0x7f)
566 ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
567 /* A normal waitstatus. Let the usual macros deal with it. */
569 store_waitstatus (ourstatus, status);
571 return pid_to_ptid (pid);
574 /* Execute one dummy breakpoint instruction. This way we give the kernel
575 a chance to do some housekeeping and update inferior's internal data,
579 exec_one_dummy_insn (struct regcache *regcache)
581 #define DUMMY_INSN_ADDR AIX_TEXT_SEGMENT_BASE+0x200
583 struct gdbarch *gdbarch = get_regcache_arch (regcache);
584 int ret, status, pid;
588 /* We plant one dummy breakpoint into DUMMY_INSN_ADDR address. We
589 assume that this address will never be executed again by the real
592 bp = deprecated_insert_raw_breakpoint (gdbarch, NULL, DUMMY_INSN_ADDR);
594 /* You might think this could be done with a single ptrace call, and
595 you'd be correct for just about every platform I've ever worked
596 on. However, rs6000-ibm-aix4.1.3 seems to have screwed this up --
597 the inferior never hits the breakpoint (it's also worth noting
598 powerpc-ibm-aix4.1.3 works correctly). */
599 prev_pc = regcache_read_pc (regcache);
600 regcache_write_pc (regcache, DUMMY_INSN_ADDR);
602 ret = rs6000_ptrace64 (PT_CONTINUE, PIDGET (inferior_ptid), 1, 0, NULL);
604 ret = rs6000_ptrace32 (PT_CONTINUE, PIDGET (inferior_ptid),
608 perror (_("pt_continue"));
612 pid = waitpid (PIDGET (inferior_ptid), &status, 0);
614 while (pid != PIDGET (inferior_ptid));
616 regcache_write_pc (regcache, prev_pc);
617 deprecated_remove_raw_breakpoint (gdbarch, bp);
621 /* Set the current architecture from the host running GDB. Called when
622 starting a child process. */
624 static void (*super_create_inferior) (struct target_ops *,char *exec_file,
625 char *allargs, char **env, int from_tty);
627 rs6000_create_inferior (struct target_ops * ops, char *exec_file,
628 char *allargs, char **env, int from_tty)
630 enum bfd_architecture arch;
633 struct gdbarch_info info;
635 super_create_inferior (ops, exec_file, allargs, env, from_tty);
639 arch = bfd_arch_rs6000;
640 mach = bfd_mach_rs6k;
644 arch = bfd_arch_powerpc;
648 /* FIXME: schauer/2002-02-25:
649 We don't know if we are executing a 32 or 64 bit executable,
650 and have no way to pass the proper word size to rs6000_gdbarch_init.
651 So we have to avoid switching to a new architecture, if the architecture
653 Blindly calling rs6000_gdbarch_init used to work in older versions of
654 GDB, as rs6000_gdbarch_init incorrectly used the previous tdep to
655 determine the wordsize. */
658 const struct bfd_arch_info *exec_bfd_arch_info;
660 exec_bfd_arch_info = bfd_get_arch_info (exec_bfd);
661 if (arch == exec_bfd_arch_info->arch)
665 bfd_default_set_arch_mach (&abfd, arch, mach);
667 gdbarch_info_init (&info);
668 info.bfd_arch_info = bfd_get_arch_info (&abfd);
669 info.abfd = exec_bfd;
671 if (!gdbarch_update_p (info))
672 internal_error (__FILE__, __LINE__,
673 _("rs6000_create_inferior: failed "
674 "to select architecture"));
678 /* Shared Object support. */
680 /* Return the LdInfo data for the given process. Raises an error
681 if the data could not be obtained.
683 The returned value must be deallocated after use. */
686 rs6000_ptrace_ldinfo (ptid_t ptid)
688 const int pid = ptid_get_pid (ptid);
690 LdInfo *ldi = xmalloc (ldi_size);
696 rc = rs6000_ptrace64 (PT_LDINFO, pid, (unsigned long) ldi, ldi_size,
699 rc = rs6000_ptrace32 (PT_LDINFO, pid, (int *) ldi, ldi_size, NULL);
702 break; /* Success, we got the entire ld_info data. */
705 perror_with_name (_("ptrace ldinfo"));
707 /* ldi is not big enough. Double it and try again. */
709 ldi = xrealloc (ldi, ldi_size);
715 /* Assuming ABFD refers to a core file, return the LdInfo data
716 stored in that core file. Raises an error if the data could
717 not be read or extracted.
719 The returned value much be deallocated after use. */
722 rs6000_core_ldinfo (bfd *abfd)
724 struct bfd_section *ldinfo_sec;
726 gdb_byte *ldinfo_buf;
727 struct cleanup *cleanup;
729 ldinfo_sec = bfd_get_section_by_name (abfd, ".ldinfo");
730 if (ldinfo_sec == NULL)
731 error (_("cannot find .ldinfo section from core file: %s\n"),
732 bfd_errmsg (bfd_get_error ()));
733 ldinfo_size = bfd_get_section_size (ldinfo_sec);
735 ldinfo_buf = xmalloc (ldinfo_size);
736 cleanup = make_cleanup (xfree, ldinfo_buf);
738 if (! bfd_get_section_contents (abfd, ldinfo_sec,
739 ldinfo_buf, 0, ldinfo_size))
740 error (_("unable to read .ldinfo section from core file: %s\n"),
741 bfd_errmsg (bfd_get_error ()));
743 discard_cleanups (cleanup);
744 return (LdInfo *) ldinfo_buf;
747 /* Append to OBJSTACK an XML string description of the shared library
748 corresponding to LDI, following the TARGET_OBJECT_LIBRARIES_AIX
752 rs6000_xfer_shared_library (LdInfo *ldi, struct obstack *obstack)
754 const int arch64 = ARCH64 ();
755 const char *archive_name = LDI_FILENAME (ldi, arch64);
756 const char *member_name = archive_name + strlen (archive_name) + 1;
757 CORE_ADDR text_addr, data_addr;
758 ULONGEST text_size, data_size;
763 text_addr = ldi->l64.ldinfo_textorg;
764 text_size = ldi->l64.ldinfo_textsize;
765 data_addr = ldi->l64.ldinfo_dataorg;
766 data_size = ldi->l64.ldinfo_datasize;
770 /* The text and data addresses are defined as pointers.
771 To avoid sign-extending their value in the assignments
772 below, we cast their value to unsigned long first. */
773 text_addr = (unsigned long) ldi->l32.ldinfo_textorg;
774 text_size = ldi->l32.ldinfo_textsize;
775 data_addr = (unsigned long) ldi->l32.ldinfo_dataorg;
776 data_size = ldi->l32.ldinfo_datasize;
779 obstack_grow_str (obstack, "<library name=\"");
780 p = xml_escape_text (archive_name);
781 obstack_grow_str (obstack, p);
783 obstack_grow_str (obstack, "\"");
785 if (member_name[0] != '\0')
787 obstack_grow_str (obstack, " member=\"");
788 p = xml_escape_text (member_name);
789 obstack_grow_str (obstack, p);
791 obstack_grow_str (obstack, "\"");
794 obstack_grow_str (obstack, " text_addr=\"");
795 obstack_grow_str (obstack, core_addr_to_string (text_addr));
796 obstack_grow_str (obstack, "\"");
798 obstack_grow_str (obstack, " text_size=\"");
799 obstack_grow_str (obstack, pulongest (text_size));
800 obstack_grow_str (obstack, "\"");
802 obstack_grow_str (obstack, " data_addr=\"");
803 obstack_grow_str (obstack, core_addr_to_string (data_addr));
804 obstack_grow_str (obstack, "\"");
806 obstack_grow_str (obstack, " data_size=\"");
807 obstack_grow_str (obstack, pulongest (data_size));
808 obstack_grow_str (obstack, "\"");
810 obstack_grow_str (obstack, "></library>");
813 /* Implement the to_xfer_partial target_ops method for
814 TARGET_OBJECT_LIBRARIES_AIX objects. */
817 rs6000_xfer_shared_libraries
818 (struct target_ops *ops, enum target_object object,
819 const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf,
820 ULONGEST offset, LONGEST len)
822 const int arch64 = ARCH64 ();
825 struct obstack obstack;
832 /* Get the ldinfo raw data: If debugging a live process, we get it
833 using ptrace. Otherwise, the info is stored in the .ldinfo
834 section of the core file. */
836 if (target_has_execution)
837 ldi_data = rs6000_ptrace_ldinfo (inferior_ptid);
839 ldi_data = rs6000_core_ldinfo (core_bfd);
841 /* Convert the raw data into an XML representation. */
843 obstack_init (&obstack);
844 obstack_grow_str (&obstack, "<library-list version=\"1.0\">\n");
849 /* Close the fd. We cannot use it, because we cannot assume
850 that the user of this descriptor will be in the same
852 close (LDI_FD (ldi, arch64));
854 rs6000_xfer_shared_library (ldi, &obstack);
856 if (!LDI_NEXT (ldi, arch64))
858 ldi = (LdInfo *) ((char *) ldi + LDI_NEXT (ldi, arch64));
863 obstack_grow_str0 (&obstack, "</library-list>\n");
865 buf = obstack_finish (&obstack);
866 len_avail = strlen (buf);
867 if (offset >= len_avail)
871 if (len > len_avail - offset)
872 len = len_avail - offset;
873 memcpy (readbuf, buf + offset, len);
876 obstack_free (&obstack, NULL);
880 void _initialize_rs6000_nat (void);
883 _initialize_rs6000_nat (void)
885 struct target_ops *t;
887 t = inf_ptrace_target ();
888 t->to_fetch_registers = rs6000_fetch_inferior_registers;
889 t->to_store_registers = rs6000_store_inferior_registers;
890 t->to_xfer_partial = rs6000_xfer_partial;
892 super_create_inferior = t->to_create_inferior;
893 t->to_create_inferior = rs6000_create_inferior;
895 t->to_wait = rs6000_wait;