[PowerPC] Consolidate wordsize getter between native and gdbserver

This patch moves the native target wordsize getter for ppc linux to
nat/ so that it can be used to simplify ppc_arch_setup in
gdbserver. The ptrace call used to get MSR for this is ultimately the
same as before, but it is no longer necessary to create a temporary
regcache to call fetch_inferior_registers.

gdb/ChangeLog:
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.

gdb/gdbserver/ChangeLog:
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.
This commit is contained in:
Pedro Franco de Carvalho
2018-05-22 11:09:05 -03:00
parent bd64614eb7
commit 2e077f5e67
7 changed files with 58 additions and 58 deletions

View File

@@ -2368,35 +2368,17 @@ fill_fpregset (const struct regcache *regcache,
fpregsetp, sizeof (*fpregsetp));
}
static int
ppc_linux_target_wordsize (void)
{
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
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 ();
int tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
tid = ptid_get_pid (inferior_ptid);
int sizeof_auxv_field = ppc_linux_target_wordsize (tid);
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
gdb_byte *ptr = *readptr;
@@ -2437,7 +2419,7 @@ ppc_linux_nat_target::read_description ()
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 ();