From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25159 invoked by alias); 12 Apr 2012 15:38:10 -0000 Received: (qmail 24917 invoked by uid 22791); 12 Apr 2012 15:38:07 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-qc0-f169.google.com (HELO mail-qc0-f169.google.com) (209.85.216.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 12 Apr 2012 15:37:54 +0000 Received: by qcsd16 with SMTP id d16so1530319qcs.0 for ; Thu, 12 Apr 2012 08:37:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.134.210 with SMTP id k18mr1167015qct.115.1334245073469; Thu, 12 Apr 2012 08:37:53 -0700 (PDT) Received: by 10.229.136.69 with HTTP; Thu, 12 Apr 2012 08:37:53 -0700 (PDT) In-Reply-To: <4F86D411.4000100@redhat.com> References: <20120411191609.GA466@intel.com> <4F86D411.4000100@redhat.com> Date: Thu, 12 Apr 2012 15:58:00 -0000 Message-ID: Subject: Re: PATCH: PR gdb/13969: GDBserver doesn't check unsupported binary From: "H.J. Lu" To: Pedro Alves Cc: GDB Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-04/txt/msg00306.txt.bz2 On Thu, Apr 12, 2012 at 6:09 AM, Pedro Alves wrote: > On 04/11/2012 08:16 PM, H.J. Lu wrote: > >> 2012-04-11 =A0H.J. Lu =A0 >> >> =A0 =A0 =A0 PR gdb/13969 >> =A0 =A0 =A0 * linux-low.c (linux_pid_exe_is_elf_64_file): Also return the >> =A0 =A0 =A0 e_machine field. >> =A0 =A0 =A0 (linux_qxfer_libraries_svr4): Update call to elf_64_file_p. >> >> =A0 =A0 =A0 * linux-low.h (linux_pid_exe_is_elf_64_file): Updated. >> >> =A0 =A0 =A0 * linux-x86-low.c (linux_is_64bit): New. > > > I don't see a new linux_is_64bit symbol in the patch. Removed. >> =A0 =A0 =A0 (x86_arch_setup): Check if GDBserver is compatible with >> =A0 =A0 =A0 process. > > > These all all logically related changes. =A0Please drop the empty lines. Done. > >> --- 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) >> =A0static void >> =A0x86_arch_setup (void) >> =A0{ >> -#ifdef __x86_64__ >> =A0 =A0int pid =3D pid_of (get_thread_lwp (current_inferior)); >> - =A0int use_64bit =3D linux_pid_exe_is_elf_64_file (pid); >> + =A0unsigned int machine; >> + =A0int use_64bit =3D linux_pid_exe_is_elf_64_file (pid, &machine); >> >> + =A0if (sizeof (void *) =3D=3D 4) >> + =A0 =A0{ >> + =A0 =A0 =A0if (use_64bit > 0) >> + =A0 =A0 error (_("Can't debug 64-bit process with 32-bit GDBserver")); >> +#ifndef __x86_64__ >> + =A0 =A0 =A0else if (machine =3D=3D EM_X86_64) >> + =A0 =A0 error (_("Can't debug x86-64 process with 32-bit GDBserver")); >> +#endif >> + =A0 =A0} >> + >> +#ifdef __x86_64__ >> =A0 =A0if (use_64bit < 0) > > > Please rename use_64bit to something like is_elf64. =A0The code reads > now a bit confusingly with "use_64bit". =A0Okay with that change, > and the ChangeLog entry fixed. Done. I checked in the updated patch. > I assume there's no kernel limitation that would prevent a x32 > gdbserver from debugging a 64-bit process? > It doesn't work since x32 is a 32-bit process. Although x32 GDBserver can get registers of 64-bit process, it can't handle 64-bit address in 64b-bit process, like setting break points. --=20 H.J.