aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/linux-x86-low.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2012-04-12 15:35:32 +0000
committerH.J. Lu <hjl.tools@gmail.com>2012-04-12 15:35:32 +0000
commit214d508ee1d179d6c9e0e993d68628a0bc477124 (patch)
treea246980ee017a23fc7bcff794619709f9852ce7e /gdb/gdbserver/linux-x86-low.c
parentb38cadfb70dbcbe3f1b31f53e96f0ab9a72e394b (diff)
downloadgdb-214d508ee1d179d6c9e0e993d68628a0bc477124.zip
gdb-214d508ee1d179d6c9e0e993d68628a0bc477124.tar.gz
gdb-214d508ee1d179d6c9e0e993d68628a0bc477124.tar.bz2
Check if GDBserver is compatible with process
PR gdb/13969 * linux-low.c (linux_pid_exe_is_elf_64_file): Also return the e_machine field. (linux_qxfer_libraries_svr4): Update call to elf_64_file_p. * linux-low.h (linux_pid_exe_is_elf_64_file): Updated. * linux-x86-low.c (x86_arch_setup): Check if GDBserver is compatible with process.
Diffstat (limited to 'gdb/gdbserver/linux-x86-low.c')
-rw-r--r--gdb/gdbserver/linux-x86-low.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index 7feb721..3dcae00 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -1106,17 +1106,28 @@ x86_linux_process_qsupported (const char *query)
static void
x86_arch_setup (void)
{
-#ifdef __x86_64__
int pid = pid_of (get_thread_lwp (current_inferior));
- int use_64bit = linux_pid_exe_is_elf_64_file (pid);
+ unsigned int machine;
+ int is_elf64 = linux_pid_exe_is_elf_64_file (pid, &machine);
- if (use_64bit < 0)
+ if (sizeof (void *) == 4)
+ {
+ if (is_elf64 > 0)
+ error (_("Can't debug 64-bit process with 32-bit GDBserver"));
+#ifndef __x86_64__
+ else if (machine == EM_X86_64)
+ error (_("Can't debug x86-64 process with 32-bit GDBserver"));
+#endif
+ }
+
+#ifdef __x86_64__
+ if (is_elf64 < 0)
{
/* This can only happen if /proc/<pid>/exe is unreadable,
but "that can't happen" if we've gotten this far.
Fall through and assume this is a 32-bit program. */
}
- else if (use_64bit)
+ else if (machine == EM_X86_64)
{
/* Amd64 doesn't have HAVE_LINUX_USRREGS. */
the_low_target.num_regs = -1;