From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6854 invoked by alias); 14 Dec 2001 15:53:43 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 6789 invoked from network); 14 Dec 2001 15:53:40 -0000 Received: from unknown (HELO c0mailgw02.prontomail.com) (216.163.180.10) by sources.redhat.com with SMTP; 14 Dec 2001 15:53:40 -0000 Received: from C6SERVICE10.prontomail.com (216.163.178.10) by c0mailgw02.prontomail.com (NPlex 5.5.029) id 3C0D6E39003358DB; Fri, 14 Dec 2001 07:46:44 -0800 Received: from starband.net (148.63.239.105) by C6SERVICE10.prontomail.com (NPlex 5.5.015) id 3BC2BEE00016EB49; Fri, 14 Dec 2001 07:46:44 -0800 Message-ID: <3C1A1F92.1090509@starband.net> Date: Fri, 14 Dec 2001 07:53:00 -0000 From: Robert Baruch User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.6) Gecko/20011120 X-Accept-Language: en-us MIME-Version: 1.0 To: Pierre Muller CC: gdb@sources.redhat.com, Eli Zaretskii , Christopher Faylor Subject: Re: [Q] Accessing fs:0 on x86 Linux? References: <4.2.0.58.20011214092106.00aca8d8@ics.u-strasbg.fr> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2001-12/txt/msg00132.txt.bz2 Hi Pierre, > On that target, its rather easy, as the debugger and debuggee share the same local descriptors. > It should also be possible to do this on cygwin target. > We would need to use GetThreadSelectorEntry > win32 API function to get > the linear base address of the %fs selector. > This function is not called in current xwin32-nat.c code and this only works > because win32 kernel does give a zero linear base address to the > ordinary code and data selector (value of %cs for code , %ds, %es and %ss for data selector). True, but I'm more concerned about how to do this on Linux, since it uses a flat memory model. > > Regarding wine on linux, this really depends on how wine does set the %fs selector > base and size, I have no idea how this is done... Here's the code from Wine which gets some %fs data for an i386 platform. #if defined(__i386__) && defined(__GNUC__) extern inline struct _TEB WINAPI *NtCurrentTeb(void); extern inline struct _TEB WINAPI *NtCurrentTeb(void) { struct _TEB *teb; __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb)); return teb; } #else extern struct _TEB WINAPI *NtCurrentTeb(void); #endif This is the corresponding disassembly from gdb: 0x400911e2 : mov %fs:0x18,%esi So basically it uses inline assembly to manually get fs data. --Rob