38#include <sys/ptrace.h>
52#define __LDINFO_PTRACE32__
53#define __LDINFO_PTRACE64__
55#include <sys/systemcfg.h>
62#include <sys/context.h>
71#if defined (__ld_info32) || defined (__ld_info64)
80# define ARCH64() (register_size (target_gdbarch (), 0) == 8)
92 const gdb_byte *writebuf,
93 ULONGEST offset, ULONGEST len,
94 ULONGEST *xfered_len)
override;
97 char **,
int)
override;
114 const char *annex, gdb_byte *readbuf,
115 const gdb_byte *writebuf,
116 ULONGEST offset, ULONGEST len,
117 ULONGEST *xfered_len);
150 struct procsinfo ProcessBuffer1;
152 if (getprocs (&ProcessBuffer1,
sizeof (ProcessBuffer1),
153 NULL, 0, &child_pid, 1) != 1)
156 return ProcessBuffer1.pi_ppid;
169 [=] (pid_t child_pid)
171 return find_my_aix_parent (child_pid) == parent_pid;
248 int ret = ptrace64 (req,
id, (uintptr_t) addr, data, buf);
250 int ret =
ptrace (req,
id, (
int *)addr, data, buf);
253 printf (
"rs6000_ptrace32 (%d, %d, 0x%x, %08x, 0x%x) = 0x%x\n",
254 req,
id, (
unsigned int)addr, data, (
unsigned int)buf, ret);
266 int ret = ptrace64 (req,
id, addr, data, (PTRACE_TYPE_ARG5) buf);
268 int ret = ptracex (req,
id, addr, data, (PTRACE_TYPE_ARG5) buf);
274 printf (
"rs6000_ptrace64 (%d, %d, %s, %08x, 0x%x) = 0x%x\n",
275 req,
id, hex_string (addr), data, (
unsigned int)buf, ret);
288 struct thrdentry64 thrdentry;
293 if (getthrds64(
pid, &thrdentry,
sizeof(
struct thrdentry64),
295 thrd_i = thrdentry.ti_tid;
297 memset(&vsx, 0,
sizeof(__vsx_context_t));
298 if (__power_vsx() && thrd_i > 0)
316 perror_with_name (_(
"Unable to write VSX registers after reading it"));
328 struct thrdentry64 thrdentry;
333 if (getthrds64(
pid, &thrdentry,
sizeof(
struct thrdentry64),
335 thrd_i = thrdentry.ti_tid;
337 memset(&vmx, 0,
sizeof(__vmx_context_t));
338 if (__power_vmx() && thrd_i > 0)
355 perror_with_name (_(
"Unable to store AltiVec register after reading it"));
369 for (i = 0; i < num_of_vrregs; i++)
381 struct thrdentry64 thrdentry;
386 if (getthrds64(
pid, &thrdentry,
sizeof(
struct thrdentry64),
388 thrd_i = thrdentry.ti_tid;
390 memset(&vmx, 0,
sizeof(__vmx_context_t));
391 if (__power_vmx() && thrd_i > 0)
412 &(vsx->__vsr_dw1[i]));
419 struct thrdentry64 thrdentry;
424 if (getthrds64(
pid, &thrdentry,
sizeof(
struct thrdentry64),
426 thrd_i = thrdentry.ti_tid;
428 memset(&vsx, 0,
sizeof(__vsx_context_t));
429 if (__power_vsx() && thrd_i > 0)
518 "gdb error: register no %d not implemented.\n",
535 memcpy (addr, &buf, 8);
547 perror (_(
"ptrace read"));
592 "gdb error: register no %d not implemented.\n",
610 memcpy (&buf, addr, 8);
619 perror (_(
"ptrace write"));
678 else if (__power_vmx ())
685 else if (__power_vmx ())
737 const char *annex, gdb_byte *readbuf,
738 const gdb_byte *writebuf,
739 ULONGEST offset, ULONGEST len,
740 ULONGEST *xfered_len)
750 offset, len, xfered_len);
758 ULONGEST rounded_offset;
771 if (partial_len > len)
779 if (rounded_offset < offset
780 || (offset + partial_len
786 rounded_offset, 0, NULL);
796 memcpy (buffer.byte + (offset - rounded_offset),
797 writebuf, partial_len);
802 rounded_offset, buffer.word, NULL);
805 (
int *) (uintptr_t) rounded_offset,
816 rounded_offset, 0, NULL);
819 (
int *)(uintptr_t)rounded_offset,
825 memcpy (readbuf, buffer.byte + (offset - rounded_offset),
829 *xfered_len = (ULONGEST) partial_len;
844 target_wait_flags options)
858 while (
pid == -1 && errno == EINTR);
865 _(
"Child process unexpectedly missing: %s.\n"),
866 safe_strerror (save_errno));
869 return minus_one_ptid;
877 if ((
status & 0xff) == W_SFWTED)
891 return ptid_t (parent_pid);
940 const std::string &allargs,
941 char **env,
int from_tty)
943 enum bfd_architecture arch;
951 arch = bfd_arch_rs6000;
952 mach = bfd_mach_rs6k;
956 arch = bfd_arch_powerpc;
970 const struct bfd_arch_info *exec_bfd_arch_info;
974 if (arch == exec_bfd_arch_info->arch)
978 bfd_default_set_arch_mach (&abfd, arch, mach);
981 info.bfd_arch_info = bfd_get_arch_info (&abfd);
985 internal_error (_(
"rs6000_create_inferior: failed "
986 "to select architecture"));
995static gdb::byte_vector
998 const int pid = ptid.pid ();
999 gdb::byte_vector ldi (1024);
1014 if (errno != ENOMEM)
1015 perror_with_name (_(
"ptrace ldinfo"));
1018 ldi.resize (ldi.size () * 2);
1030 const char *annex, gdb_byte *readbuf,
const gdb_byte *writebuf,
1031 ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
1044 readbuf, offset, len, 1);
1050 *xfered_len = result;
int gdbarch_update_p(struct gdbarch_info info)
struct gdbarch * target_gdbarch(void)
const target_info & info() const override
void follow_fork(inferior *child_inf, ptid_t child_ptid, target_waitkind fork_kind, bool follow_child, bool detach_on_fork) override
void raw_collect(int regnum, void *buf) const override
void raw_supply(int regnum, const void *buf) override
ptid_t wait(ptid_t, struct target_waitstatus *, target_wait_flags) override
void post_startup_inferior(ptid_t ptid) override
void store_registers(struct regcache *, int) override
enum target_xfer_status xfer_partial(enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) override
const struct target_desc * read_description() override
void create_inferior(const char *, const std::string &, char **, int) override
void fetch_registers(struct regcache *, int) override
void follow_fork(inferior *, ptid_t, target_waitkind, bool, bool) override
enum target_xfer_status xfer_shared_libraries(enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
#define ptrace(request, pid, addr, data)
int gdbarch_pc_regnum(struct gdbarch *gdbarch)
int gdbarch_num_regs(struct gdbarch *gdbarch)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
target_waitstatus host_status_to_waitstatus(int hoststatus)
void add_inf_child_target(inf_child_target *target)
struct inferior * find_inferior_pid(process_stratum_target *targ, int pid)
struct inferior * current_inferior(void)
void set_sigint_trap(void)
void clear_sigint_trap(void)
static bool follow_fork()
const struct target_desc * tdesc_powerpc_altivec32
const struct target_desc * tdesc_powerpc_altivec64
const struct target_desc * tdesc_powerpc_vsx32
const struct target_desc * tdesc_powerpc_vsx64
int altivec_register_p(struct gdbarch *gdbarch, int regno)
#define PPC_MAX_REGISTER_SIZE
int vsx_register_p(struct gdbarch *gdbarch, int regno)
struct program_space * current_program_space
int register_size(struct gdbarch *gdbarch, int regnum)
static void fetch_vsx_registers_aix(struct regcache *regcache)
static std::list< pid_t > aix_pending_children
static void store_register(struct regcache *regcache, int regno)
void _initialize_rs6000_nat()
static void fetch_register(struct regcache *regcache, int regno)
static void supply_vsxregset_aix(struct regcache *regcache, __vsx_context_t *vsx)
static void fetch_altivec_registers_aix(struct regcache *regcache)
static gdb::byte_vector rs6000_ptrace_ldinfo(ptid_t ptid)
static void supply_vrregset_aix(struct regcache *regcache, __vmx_context_t *vmx)
static rs6000_nat_target the_rs6000_nat_target
static pid_t has_my_aix_child_reported(pid_t parent_pid)
static void store_vsx_register_aix(struct regcache *regcache, int regno)
static pid_t find_my_aix_parent(pid_t child_pid)
static void store_altivec_register_aix(struct regcache *regcache, int regno)
static void aix_remember_parent(pid_t pid)
static int rs6000_ptrace32(int req, int id, int *addr, int data, int *buf)
static std::list< pid_t > aix_pending_parent
static int rs6000_ptrace64(int req, int id, long long addr, int data, void *buf)
static void aix_remember_child(pid_t pid)
static pid_t has_my_aix_parent_reported(pid_t child_pid)
ULONGEST rs6000_aix_ld_info_to_xml(struct gdbarch *gdbarch, const gdb_byte *ldi_buf, gdb_byte *readbuf, ULONGEST offset, ULONGEST len, int close_ldinfo_fd)
void create_inferior(const char *, const std::string &, char **, int) override
int ppc_vsr0_upper_regnum
target_waitstatus & set_spurious()
target_waitstatus & set_forked(ptid_t child_ptid)
target_waitstatus & set_loaded()
target_waitstatus & set_ignore()
bool target_has_execution(inferior *inf)
@ TARGET_OBJECT_LIBRARIES_AIX
void gdb_printf(struct ui_file *stream, const char *format,...)