From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19204 invoked by alias); 5 Jan 2012 18:03:14 -0000 Received: (qmail 19192 invoked by uid 22791); 5 Jan 2012 18:03:12 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from e06smtp11.uk.ibm.com (HELO e06smtp11.uk.ibm.com) (195.75.94.107) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 05 Jan 2012 18:02:58 +0000 Received: from /spool/local by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Jan 2012 18:02:57 -0000 Received: from d06nrmr1507.portsmouth.uk.ibm.com ([9.149.38.233]) by e06smtp11.uk.ibm.com ([192.168.101.141]) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 5 Jan 2012 18:02:37 -0000 Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q05I2bHl2089032 for ; Thu, 5 Jan 2012 18:02:37 GMT Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q05I2aNt016220 for ; Thu, 5 Jan 2012 11:02:37 -0700 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id q05I2ZCf016120; Thu, 5 Jan 2012 11:02:35 -0700 Message-Id: <201201051802.q05I2ZCf016120@d06av02.portsmouth.uk.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Thu, 05 Jan 2012 19:02:35 +0100 Subject: Re: [rfc] Options for "info mappings" etc. (Re: [PATCH] Implement new `info core mappings' command) To: alves.ped@gmail.com (Pedro Alves) Date: Thu, 05 Jan 2012 18:03:00 -0000 From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org, jan.kratochvil@redhat.com, sergiodj@redhat.com In-Reply-To: <4F05C983.8080905@gmail.com> from "Pedro Alves" at Jan 05, 2012 04:02:11 PM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit x-cbid: 12010518-5024-0000-0000-00000145252D 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: 2012-01/txt/msg00199.txt.bz2 Pedro Alves wrote: > On 12/20/2011 10:15 PM, Ulrich Weigand wrote: > > I actually completed an implementation of this (second) method, before > > I noticed that it fundamentally does not work with the current remote > > protocol, for one simple reason: I cannot open /proc/PID/... because > > I do not even know the PID to use. With the remote target, the "PID" > > used within GDB may have no relationship whatsoever to the actual PID > > on a Linux remote target; in fact, it usually is the "magic" 42000 ... > > In extended-remote (w/ multiprocess extensions on), we do know the PID, > because the TID's are in the form pPID.TID. With regular remote, we only > know the PID on "attach", because the user typed it, otherwise we fall back to > the magic 42000. But why not simply fix this? We can query the remote > end for the current process's ID, with target remote, and use that pid if > supported, otherwise fall back to the current magic 42000 use. All the > options so far require new packets, so this doesn't seem to make it worse. > The tdep code in question is handling linux specific bits, so it can > bail out on the magic 42000 safely. I'm wondering: How can I distinguish the "magic 42000" from a regular PID 42000 ? > Another option, perhaps the cleanest, > is to start allowing the multiprocess thread id extensions with > plain "target remote". GDB currently only sends "multiprocess+" qSupported > feature if connecting in extended-remote mode. I can help and try this is > you'd like. Yes, this does sound like an interesting approach. > > While in some cases, the (a) remote PID may be encoded into the GDB > > TID field,I cannot use this in -tdep code either, because when used > > with the native target, the TID is never a PID/LWP. > > Not sure what example you're referring to. :-( Well, GDB's "ptid_t" contains three fields: pid, lwp, and tid. From what I recall, these are used somewhat differently on different targets. In particular, with Linux native targets, "pid" is what getpid () returns; "lwp" is the Linux task ID -- which is equal to the pid for single-threaded processes, and "tid" is the value of "pthread_t" for the thread. Now, with the remote target, "pid" seems to be the magic 42000; "lwp" is never used, and "tid" is used for the thread ID used with the remote protocol -- and when using gdbserver, the latter is actually the LWP ID / Linux task ID. What I was trying to say with the statement above is: if I knew the LWP ID, I could use this to access /proc, since there is a /proc/... entry for all LWP IDs as well as for the main PID. And in fact, at least for multi-threaded processes, I *do* know the LWP ID, since it is in fact used as the TID field of the ptid_t with remote/gdbserver targets. The problem is, with the native target, the TID field is used to hold the "pthread_t" value, *not* the LWP ID. Since -tdep code needs to work with either target, I cannot really interpret that field in any way ... Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com