+2015-03-03 Markus Metzger <markus.t.metzger@intel.com>
+
+ * nat/linux-btrace.c: Include sys/utsname.h.
+ (linux_determine_kernel_ptr_bits): New.
+ (linux_enable_bts): Call linux_determine_kernel_ptr_bits.
+ * x86-linux-nat.c (x86_linux_enable_btrace): Do not overwrite non-zero
+ ptr_bits.
+
2015-03-03 Markus Metzger <markus.t.metzger@intel.com>
* btrace.c (ftrace_update_function): Treat return as tailcall for
+2015-03-03 Markus Metzger <markus.t.metzger@intel.com>
+
+ * linux-low.c (linux_low_enable_btrace): Do not overwrite non-zero
+ ptr_bits.
+
2015-03-02 Andreas Arnez <arnez@linux.vnet.ibm.com>
* Makefile.in (s390-vx-linux64.c, s390-tevx-linux64.c)
tinfo = linux_enable_btrace (ptid, conf);
- if (tinfo != NULL)
+ if (tinfo != NULL && tinfo->ptr_bits == 0)
{
struct thread_info *thread = find_thread_ptid (ptid);
struct regcache *regcache = get_thread_regcache (thread, 0);
#include <sys/ptrace.h>
#include <sys/types.h>
#include <signal.h>
+#include <sys/utsname.h>
/* A branch trace record in perf_event. */
struct perf_event_bts
return *pev->data_head != pev->last_head;
}
+/* Try to determine the size of a pointer in bits for the OS.
+
+ This is the same as the size of a pointer for the inferior process
+ except when a 32-bit inferior is running on a 64-bit OS. */
+
+static int
+linux_determine_kernel_ptr_bits (void)
+{
+ struct utsname utsn;
+ int errcode;
+
+ memset (&utsn, 0, sizeof (utsn));
+
+ errcode = uname (&utsn);
+ if (errcode < 0)
+ return 0;
+
+ /* We only need to handle the 64-bit host case, here. For 32-bit host,
+ the pointer size can be filled in later based on the inferior. */
+ if (strcmp (utsn.machine, "x86_64") == 0)
+ return 64;
+
+ return 0;
+}
+
/* Check whether an address is in the kernel. */
static inline int
tinfo = xzalloc (sizeof (*tinfo));
tinfo->ptid = ptid;
- tinfo->ptr_bits = 0;
+ tinfo->ptr_bits = linux_determine_kernel_ptr_bits ();
tinfo->conf.format = BTRACE_FORMAT_BTS;
bts = &tinfo->variant.bts;
target_pid_to_str (ptid), safe_strerror (errno));
/* Fill in the size of a pointer in bits. */
- gdbarch = target_thread_architecture (ptid);
- tinfo->ptr_bits = gdbarch_ptr_bit (gdbarch);
-
+ if (tinfo->ptr_bits == 0)
+ {
+ gdbarch = target_thread_architecture (ptid);
+ tinfo->ptr_bits = gdbarch_ptr_bit (gdbarch);
+ }
return tinfo;
}