+2018-05-22 Pedro Franco de Carvalho <pedromfc@linux.vnet.ibm.com>
+
+ * configure.nat <linux powerpc>: Add ppc-linux.o to NATDEPFILES.
+ * ppc-linux-nat.c (ppc_linux_target_wordsize): Move to
+ nat/ppc-linux.c.
+ (ppc_linux_nat_target::auxv_parse): Get thread id tid. Call
+ ppc_linux_target_wordsize with tid.
+ (ppc_linux_nat_target::read_description): Call ppc_linux_target
+ wordsize with tid.
+ * nat/ppc-linux.c: Include nat/gdb_ptrace.h.
+ (ppc64_64bit_inferior_p): Add static and inline specifiers.
+ (ppc_linux_target_wordsize): Move here from ppc-linux-nat.c. Add
+ tid parameter. Remove static specifier.
+ * nat/ppc-linux.h (ppc64_64bit_inferior_p): Remove declaration.
+ (ppc_linux_target_wordsize): New declaration.
+
2018-05-22 Pedro Franco de Carvalho <pedromfc@linux.vnet.ibm.com>
* arch/ppc-linux-common.c: New file.
;;
powerpc)
# Host: PowerPC, running Linux
- NATDEPFILES="${NATDEPFILES} ppc-linux-nat.o"
+ NATDEPFILES="${NATDEPFILES} ppc-linux-nat.o ppc-linux.o"
;;
s390)
# Host: S390, running Linux
+2018-05-22 Pedro Franco de Carvalho <pedromfc@linux.vnet.ibm.com>
+
+ * linux-ppc-low.c (ppc_arch_setup): Remove code for getting the
+ wordsize of the inferior. Call ppc_linux_target_wordsize.
+
2018-05-22 Pedro Franco de Carvalho <pedromfc@linux.vnet.ibm.com>
* configure.srv (srv_tgtobj): Add arch/ppc-linux-common.o.
{
const struct target_desc *tdesc;
struct ppc_linux_features features = ppc_linux_no_features;
+ int tid = lwpid_of (current_thread);
- features.wordsize = 4;
-
-#ifdef __powerpc64__
- long msr;
- struct regcache *regcache;
-
- /* On a 64-bit host, assume 64-bit inferior process with no
- AltiVec registers. Reset ppc_hwcap to ensure that the
- collect_register call below does not fail. */
- tdesc = tdesc_powerpc_64l;
- current_process ()->tdesc = tdesc;
- ppc_hwcap = 0;
-
- regcache = new_register_cache (tdesc);
- fetch_inferior_registers (regcache, find_regno (tdesc, "msr"));
- collect_register_by_name (regcache, "msr", &msr);
- free_register_cache (regcache);
- if (ppc64_64bit_inferior_p (msr))
- {
- features.wordsize = 8;
- }
-#endif
+ features.wordsize = ppc_linux_target_wordsize (tid);
if (features.wordsize == 4)
- {
- /* OK, we have a 32-bit inferior. */
tdesc = tdesc_powerpc_32l;
- current_process ()->tdesc = tdesc;
- }
+ else
+ tdesc = tdesc_powerpc_64l;
+
+ current_process ()->tdesc = tdesc;
/* The value of current_process ()->tdesc needs to be set for this
call. */
#include "common-defs.h"
#include "ppc-linux.h"
+#include "nat/gdb_ptrace.h"
#include <elf.h>
#ifdef HAVE_GETAUXVAL
#endif /* HAVE_GETAUXVAL */
}
-int
+static inline int
ppc64_64bit_inferior_p (long msr)
{
unsigned long ppc_host_hwcap = 0;
}
#endif
+
+int
+ppc_linux_target_wordsize (int tid)
+{
+ int wordsize = 4;
+
+ /* Check for 64-bit inferior process. This is the case when the host is
+ 64-bit, and in addition the top bit of the MSR register is set. */
+#ifdef __powerpc64__
+ long msr;
+
+ errno = 0;
+ msr = (long) ptrace (PTRACE_PEEKUSER, tid, PT_MSR * 8, 0);
+ if (errno == 0 && ppc64_64bit_inferior_p (msr))
+ wordsize = 8;
+#endif
+
+ return wordsize;
+}
#define PTRACE_SETEVRREGS 21
#endif
-#ifdef __powerpc64__
-/* Return whether the inferior is 64bit or not by checking certain bit
- in MSR. */
-int ppc64_64bit_inferior_p (long msr);
-#endif
+/* Return the wordsize of the target, either 4 or 8 bytes. */
+int ppc_linux_target_wordsize (int tid);
#endif
fpregsetp, sizeof (*fpregsetp));
}
-static int
-ppc_linux_target_wordsize (void)
+int
+ppc_linux_nat_target::auxv_parse (gdb_byte **readptr,
+ gdb_byte *endptr, CORE_ADDR *typep,
+ CORE_ADDR *valp)
{
- int wordsize = 4;
-
- /* Check for 64-bit inferior process. This is the case when the host is
- 64-bit, and in addition the top bit of the MSR register is set. */
-#ifdef __powerpc64__
- long msr;
-
int tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
tid = ptid_get_pid (inferior_ptid);
- errno = 0;
- msr = (long) ptrace (PTRACE_PEEKUSER, tid, PT_MSR * 8, 0);
- if (errno == 0 && ppc64_64bit_inferior_p (msr))
- wordsize = 8;
-#endif
-
- return wordsize;
-}
+ int sizeof_auxv_field = ppc_linux_target_wordsize (tid);
-int
-ppc_linux_nat_target::auxv_parse (gdb_byte **readptr,
- gdb_byte *endptr, CORE_ADDR *typep,
- CORE_ADDR *valp)
-{
- int sizeof_auxv_field = ppc_linux_target_wordsize ();
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
gdb_byte *ptr = *readptr;
struct ppc_linux_features features = ppc_linux_no_features;
- features.wordsize = ppc_linux_target_wordsize ();
+ features.wordsize = ppc_linux_target_wordsize (tid);
unsigned long hwcap = ppc_linux_get_hwcap ();