X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fnat%2Fppc-linux.c;h=aa0a8df02155d340c9f1951a1ea5ad9cf51c51d2;hb=1ee1a363454d88a87ad2ade7530b2a7fb670021e;hp=3cb8f13d96c194671d26eb6b1c4540530b34a5e8;hpb=61baf725eca99af2569262d10aca03dcde2698f6;p=deliverable%2Fbinutils-gdb.git
diff --git a/gdb/nat/ppc-linux.c b/gdb/nat/ppc-linux.c
index 3cb8f13d96..aa0a8df021 100644
--- a/gdb/nat/ppc-linux.c
+++ b/gdb/nat/ppc-linux.c
@@ -1,4 +1,4 @@
-/*Copyright (C) 2015-2017 Free Software Foundation, Inc.
+/*Copyright (C) 2015-2020 Free Software Foundation, Inc.
This file is part of GDB.
@@ -15,8 +15,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
-#include "common-defs.h"
+#include "gdbsupport/common-defs.h"
#include "ppc-linux.h"
+#include "nat/gdb_ptrace.h"
#include
#ifdef HAVE_GETAUXVAL
@@ -53,7 +54,7 @@ ppc64_host_hwcap (unsigned long *valp)
#endif /* HAVE_GETAUXVAL */
}
-int
+static inline int
ppc64_64bit_inferior_p (long msr)
{
unsigned long ppc_host_hwcap = 0;
@@ -73,3 +74,22 @@ ppc64_64bit_inferior_p (long msr)
}
#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;
+}