From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7281 invoked by alias); 27 Feb 2004 01:24:51 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 7273 invoked from network); 27 Feb 2004 01:24:50 -0000 Received: from unknown (HELO localhost.redhat.com) (216.129.200.20) by sources.redhat.com with SMTP; 27 Feb 2004 01:24:50 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id C3A442B92 for ; Thu, 26 Feb 2004 20:24:47 -0500 (EST) Message-ID: <403E9C5F.2050803@redhat.com> Date: Fri, 27 Feb 2004 01:24:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.4.1) Gecko/20040217 MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [rfa:amd64] Fetch 32-bit thread area Content-Type: multipart/mixed; boundary="------------060700050005020906070607" X-SW-Source: 2004-02/txt/msg00794.txt.bz2 This is a multi-part message in MIME format. --------------060700050005020906070607 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 155 Hello, This modifies the amd64 code so that, when 32-bit, it fetches the 32-bit thread area register (I think this has been posted before?). ok? Andrew --------------060700050005020906070607 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 2901 * amd64-linux-nat.c (ps_get_thread_area): When architecture is i386 use PTRACE_GET_THREAD_AREA. Suggested by Roland McGrath. Index: amd64-linux-nat.c =================================================================== RCS file: /cvs/src/src/gdb/amd64-linux-nat.c,v retrieving revision 1.1 diff -u -r1.1 amd64-linux-nat.c --- amd64-linux-nat.c 25 Feb 2004 20:45:30 -0000 1.1 +++ amd64-linux-nat.c 27 Feb 2004 01:22:36 -0000 @@ -350,10 +350,14 @@ } +/* This function is called by libthread_db as part of its handling of + a request for a thread's local storage address. */ + ps_err_e ps_get_thread_area (const struct ps_prochandle *ph, lwpid_t lwpid, int idx, void **base) { +#if 0 /* This definition comes from prctl.h, but some kernels may not have it. */ #ifndef PTRACE_ARCH_PRCTL #define PTRACE_ARCH_PRCTL 30 @@ -377,6 +381,67 @@ return PS_BADADDR; } return PS_ERR; /* ptrace failed. */ +#else + switch (TARGET_ARCHITECTURE->mach) + { + case bfd_mach_i386_i386: + case bfd_mach_i386_i386_intel_syntax: + { + /* The full structure is found in . The + second integer is the LDT's base_address and that is used + to locate the thread's local storage. See i386-linux-nat.c + more info. */ + unsigned int desc[4]; + + /* This code assumes that "int" is 32 bits and that + GET_THREAD_AREA returns no more than 4 int values. */ + gdb_assert (sizeof (int) == 4); +#ifndef PTRACE_GET_THREAD_AREA +#define PTRACE_GET_THREAD_AREA 25 +#endif + if (ptrace (PTRACE_GET_THREAD_AREA, + lwpid, (void *) (long) idx, (unsigned long) &desc) < 0) + return PS_ERR; + + /* Extend the value to 64 bits. Here it's assumed that a + "long" and a "void *" are the same. */ + (*base) = (void *) (long) desc[1]; + return PS_OK; + } + + case bfd_mach_x86_64: + case bfd_mach_x86_64_intel_syntax: + + /* This definition comes from prctl.h, but some kernels may not + have it. */ +#ifndef PTRACE_ARCH_PRCTL +#define PTRACE_ARCH_PRCTL 30 +#endif + /* FIXME: ezannoni-2003-07-09 see comment above about include + file order. We could be getting bogus values for these two. */ + gdb_assert (FS < ELF_NGREG); + gdb_assert (GS < ELF_NGREG); + switch (idx) + { + case FS: + if (ptrace (PTRACE_ARCH_PRCTL, lwpid, base, ARCH_GET_FS) == 0) + return PS_OK; + break; + case GS: + if (ptrace (PTRACE_ARCH_PRCTL, lwpid, base, ARCH_GET_GS) == 0) + return PS_OK; + break; + default: /* Should not happen. */ + return PS_BADADDR; + } + return PS_ERR; /* ptrace failed. */ + + case bfd_mach_i386_i8086: + internal_error (__FILE__, __LINE__, "bad i8086 machine"); + default: + internal_error (__FILE__, __LINE__, "bad_switch"); + } +#endif } --------------060700050005020906070607--