From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24514 invoked by alias); 22 Feb 2010 16:58:28 -0000 Received: (qmail 24494 invoked by uid 22791); 22 Feb 2010 16:58:27 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO glazunov.sibelius.xs4all.nl) (83.163.83.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 22 Feb 2010 16:58:23 +0000 Received: from glazunov.sibelius.xs4all.nl (kettenis@localhost [127.0.0.1]) by glazunov.sibelius.xs4all.nl (8.14.3/8.14.3) with ESMTP id o1MGv0Yt023862; Mon, 22 Feb 2010 17:57:00 +0100 (CET) Received: (from kettenis@localhost) by glazunov.sibelius.xs4all.nl (8.14.3/8.14.3/Submit) id o1MGuw5q009795; Mon, 22 Feb 2010 17:56:58 +0100 (CET) Date: Mon, 22 Feb 2010 16:58:00 -0000 Message-Id: <201002221656.o1MGuw5q009795@glazunov.sibelius.xs4all.nl> From: Mark Kettenis To: dan@codesourcery.com CC: hjl.tools@gmail.com, gdb-patches@sourceware.org In-reply-to: <20100222161040.GD30100@caradoc.them.org> (message from Daniel Jacobowitz on Mon, 22 Feb 2010 11:10:40 -0500) Subject: Re: PATCH: Enable x86 XML target descriptions References: <20100210200303.GA19632@lucon.org> <20100218054312.GA9022@lucon.org> <20100218153402.GA27929@lucon.org> <20100218230135.GA17916@intel.com> <201002221342.o1MDgSZA029705@glazunov.sibelius.xs4all.nl> <20100222144141.GA30100@caradoc.them.org> <6dc9ffc81002220734i15bd1279mb54cb0b64a37f3dc@mail.gmail.com> <20100222155243.GC30100@caradoc.them.org> <6dc9ffc81002220757v5e9b48bdnba56a260f0f3c0a8@mail.gmail.com> <20100222161040.GD30100@caradoc.them.org> 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: 2010-02/txt/msg00543.txt.bz2 > Date: Mon, 22 Feb 2010 11:10:40 -0500 > From: Daniel Jacobowitz > > On Mon, Feb 22, 2010 at 07:57:52AM -0800, H.J. Lu wrote: > > On Mon, Feb 22, 2010 at 7:52 AM, Daniel Jacobowitz wrote: > > > On Mon, Feb 22, 2010 at 07:34:01AM -0800, H.J. Lu wrote: > > >> I just need to know if the inferior is 32bit or 64bit. Why shouldn't > > >> target_gdbarch be used? At this point, target_gdbarch should have > > >> the correct bfd cpu info. Is that correct? > > > > > > Not if, for instance, we did not find the executable. > > > > How do you debug if you can't find executable? I am not sure if > > you can get that far. > > That's not the point. You can not rely on the gdbarch here. It > breaks the entire abstraction to circularly read the architecture > description from the architecture. Plus it will do the wrong thing if > the user gives the wrong executable, and this is our chance to get it > right. > > Why can't you figure this out with ptrace? Isn't there a bit in > flags, or something like that? Or a way to get at the kernel's > TIF_IA32 flag? I've looked at the Linux kernel sources for the kernel on my workstation (2.6.27 in its OpenSUSE incarnation), and the only way to distinguish between a 32-bit and a 64-bit process seems to be to attempt to write one of the debug address registers with a value that's larger than 0xffffffff. If that fails, you have a 32-bit process, otherwise it's a 64-bit process.