From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29527 invoked by alias); 22 Feb 2010 22:05:43 -0000 Received: (qmail 29509 invoked by uid 22791); 22 Feb 2010 22:05:41 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from terminus.zytor.com (HELO mail.zytor.com) (198.137.202.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 22 Feb 2010 22:05:36 +0000 Received: from anacreon.sc.intel.com (hpa@localhost [127.0.0.1]) (authenticated bits=0) by mail.zytor.com (8.14.3/8.14.3) with ESMTP id o1MM2ABx018853 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Mon, 22 Feb 2010 14:02:11 -0800 Message-ID: <4B82FEE2.2090501@zytor.com> Date: Mon, 22 Feb 2010 22:05:00 -0000 From: "H. Peter Anvin" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.7) Gecko/20100120 Fedora/3.0.1-1.fc12 Thunderbird/3.0.1 MIME-Version: 1.0 To: "H.J. Lu" CC: Mark Kettenis , dan@codesourcery.com, gdb-patches@sourceware.org, Suresh Siddha Subject: Re: PATCH: Enable x86 XML target descriptions References: <20100218054312.GA9022@lucon.org> <6dc9ffc81002220734i15bd1279mb54cb0b64a37f3dc@mail.gmail.com> <20100222155243.GC30100@caradoc.them.org> <6dc9ffc81002220757v5e9b48bdnba56a260f0f3c0a8@mail.gmail.com> <20100222161040.GD30100@caradoc.them.org> <201002221656.o1MGuw5q009795@glazunov.sibelius.xs4all.nl> <20100222170303.GG9493@caradoc.them.org> <201002221950.o1MJoomn007989@glazunov.sibelius.xs4all.nl> <6dc9ffc81002221306y6287491dv5aaac541ba303199@mail.gmail.com> <201002222130.o1MLU3ub013661@glazunov.sibelius.xs4all.nl> <6dc9ffc81002221341j735bdedeo7285951f4fc39c27@mail.gmail.com> In-Reply-To: <6dc9ffc81002221341j735bdedeo7285951f4fc39c27@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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/msg00561.txt.bz2 On 02/22/2010 01:41 PM, H.J. Lu wrote: >>> >>> Please see if my latest patch is OK: >>> >>> --- >>> /* Get CS register. */ >>> errno = 0; >>> cs = ptrace (PTRACE_PEEKUSER, tid, >>> offsetof (struct user_regs_struct, cs), 0); >>> if (errno != 0) >>> perror_with_name (_("Couldn't get CS register")); >>> >>> /* Value of CS register: >>> 1. 64bit: 0x33. >>> 2. 32bit: 0x23. >>> */ >>> if (cs == 0x33) >>> return tdesc_amd64_linux; >>> else >>> return tdesc_i386_linux; >>> --- >>> >>> In kernel, there is >>> >>> regs->cs = test_thread_flag(TIF_64BIT_ILP32) ? __USER_CS : __USER32_CS; >> >> I fear that's rather fragile. I mean, the actual value of >> __USER_CS/__USER32_CS is just an implementation detail isn't it? >> > > That is how strace checks 32bit process on Linux/x86-64 I have > discussed it with Peter and Suresh. It is very unlikely Linux kernel will > break strace. In any case, we will add a new ptrace option to Linux > 2.6.35 to get TIF_64BIT_ILP32 among other things. I will update gdb > to try the new ptrace option first and then fail back to CS register. > Uhm... TIF_64BIT_ILP32 didn't go upstream (remember, we shut down that project?) What I suggested was to add an strace option to get the segment descriptor flags, which would include the CS.L bit for 64-bit mode. -hpa