From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32403 invoked by alias); 12 Mar 2008 20:08:03 -0000 Received: (qmail 32362 invoked by uid 22791); 12 Mar 2008 20:08:01 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 12 Mar 2008 20:07:43 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id AAE6C2AAC0B for ; Wed, 12 Mar 2008 16:07:41 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id VGWMUyOmkFKw for ; Wed, 12 Mar 2008 16:07:41 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 4543E2AAC0A for ; Wed, 12 Mar 2008 16:07:41 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 290CCE7ACB; Wed, 12 Mar 2008 13:07:39 -0700 (PDT) Date: Wed, 12 Mar 2008 20:08:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: Re: [RFA/RFC] Fix broken user-thread debugging on x86-solaris Message-ID: <20080312200739.GD3738@adacore.com> References: <20080312170814.GC4433@adacore.com> <20080312172129.GA25188@caradoc.them.org> <20080312180445.GC3738@adacore.com> <20080312181312.GA28610@caradoc.them.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="WIyZ46R2i8wDzkSu" Content-Disposition: inline In-Reply-To: <20080312181312.GA28610@caradoc.them.org> User-Agent: Mutt/1.4.2.2i 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: 2008-03/txt/msg00135.txt.bz2 --WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 718 > I have no preference whatsoever; just whatever is easier in practice. That works for me :) - we can always adjust later if I hear some more comments. Here is what I ended up checking-in (I used the opportunity to add a little comment explaining why the function is needed, as well as grouping the two LDT-related functions in procfs.c together). 2008-02-12 Joel Brobecker * sol-thread.c: Replace use of TM_I386SOL2_H by an expression that is true only on x86-solaris and x86_64-solaris. * procfs.c: Likewise. Move procfs_find_LDT_entry up together with proc_get_LDT_entry. Tested on x86-solaris, no regression. Applied to head and branch. Thanks! -- Joel --WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="x86-solaris-thread.diff" Content-length: 3769 Index: sol-thread.c =================================================================== RCS file: /cvs/src/src/gdb/sol-thread.c,v retrieving revision 1.63 diff -u -p -r1.63 sol-thread.c --- sol-thread.c 23 Jan 2008 11:26:28 -0000 1.63 +++ sol-thread.c 12 Mar 2008 18:39:54 -0000 @@ -1283,9 +1283,12 @@ ps_pdmodel (gdb_ps_prochandle_t ph, int } #endif /* PR_MODEL_LP64 */ -#ifdef TM_I386SOL2_H +#if (defined(__i386__) || defined(__x86_64__)) && defined (sun) -/* Reads the local descriptor table of a LWP. */ +/* Reads the local descriptor table of a LWP. + + This function is necessary on x86-solaris only. Without it, the loading + of libthread_db would fail because of ps_lgetLDT being undefined. */ ps_err_e ps_lgetLDT (gdb_ps_prochandle_t ph, lwpid_t lwpid, @@ -1311,7 +1314,7 @@ ps_lgetLDT (gdb_ps_prochandle_t ph, lwpi /* LDT not found. */ return PS_ERR; } -#endif /* TM_I386SOL2_H */ +#endif /* Convert PTID to printable form. */ Index: procfs.c =================================================================== RCS file: /cvs/src/src/gdb/procfs.c,v retrieving revision 1.85 diff -u -p -r1.85 procfs.c --- procfs.c 25 Jan 2008 00:09:49 -0000 1.85 +++ procfs.c 12 Mar 2008 18:39:55 -0000 @@ -2919,7 +2919,7 @@ proc_set_watchpoint (procinfo *pi, CORE_ #endif } -#ifdef TM_I386SOL2_H /* Is it hokey to use this? */ +#if (defined(__i386__) || defined(__x86_64__)) && defined (sun) #include @@ -3011,7 +3011,45 @@ proc_get_LDT_entry (procinfo *pi, int ke #endif } -#endif /* TM_I386SOL2_H */ +/* + * Function: procfs_find_LDT_entry + * + * Input: + * ptid_t ptid; // The GDB-style pid-plus-LWP. + * + * Return: + * pointer to the corresponding LDT entry. + */ + +struct ssd * +procfs_find_LDT_entry (ptid_t ptid) +{ + gdb_gregset_t *gregs; + int key; + procinfo *pi; + + /* Find procinfo for the lwp. */ + if ((pi = find_procinfo (PIDGET (ptid), TIDGET (ptid))) == NULL) + { + warning (_("procfs_find_LDT_entry: could not find procinfo for %d:%d."), + PIDGET (ptid), TIDGET (ptid)); + return NULL; + } + /* get its general registers. */ + if ((gregs = proc_get_gregs (pi)) == NULL) + { + warning (_("procfs_find_LDT_entry: could not read gregs for %d:%d."), + PIDGET (ptid), TIDGET (ptid)); + return NULL; + } + /* Now extract the GS register's lower 16 bits. */ + key = (*gregs)[GS] & 0xffff; + + /* Find the matching entry and return it. */ + return proc_get_LDT_entry (pi, key); +} + +#endif /* =============== END, non-thread part of /proc "MODULE" =============== */ @@ -5331,46 +5369,6 @@ procfs_stopped_by_watchpoint (ptid_t pti return 0; } -#ifdef TM_I386SOL2_H -/* - * Function: procfs_find_LDT_entry - * - * Input: - * ptid_t ptid; // The GDB-style pid-plus-LWP. - * - * Return: - * pointer to the corresponding LDT entry. - */ - -struct ssd * -procfs_find_LDT_entry (ptid_t ptid) -{ - gdb_gregset_t *gregs; - int key; - procinfo *pi; - - /* Find procinfo for the lwp. */ - if ((pi = find_procinfo (PIDGET (ptid), TIDGET (ptid))) == NULL) - { - warning (_("procfs_find_LDT_entry: could not find procinfo for %d:%d."), - PIDGET (ptid), TIDGET (ptid)); - return NULL; - } - /* get its general registers. */ - if ((gregs = proc_get_gregs (pi)) == NULL) - { - warning (_("procfs_find_LDT_entry: could not read gregs for %d:%d."), - PIDGET (ptid), TIDGET (ptid)); - return NULL; - } - /* Now extract the GS register's lower 16 bits. */ - key = (*gregs)[GS] & 0xffff; - - /* Find the matching entry and return it. */ - return proc_get_LDT_entry (pi, key); -} -#endif /* TM_I386SOL2_H */ - /* * Memory Mappings Functions: */ --WIyZ46R2i8wDzkSu--