From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16958 invoked by alias); 18 Jul 2010 20:22:04 -0000 Mailing-List: contact archer-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Received: (qmail 16947 invoked by uid 22791); 18 Jul 2010 20:22:03 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit From: Roland McGrath To: Oleg Nesterov Cc: archer@sourceware.org Subject: Re: Q: mutlithreaded tracees && clone/exit In-Reply-To: Oleg Nesterov's message of Sunday, 18 July 2010 19:48:51 +0200 <20100718174851.GA15528@redhat.com> References: <20100716205147.GA26313@redhat.com> <20100716213950.7A7BC40B45@magilla.sf.frob.com> <20100718174851.GA15528@redhat.com> Message-Id: <20100718202151.941B94B2C9@magilla.sf.frob.com> Date: Sun, 18 Jul 2010 20:22:00 -0000 X-SW-Source: 2010-q3/txt/msg00035.txt.bz2 > Yes, but this doesn't necessarily mean gdbserver can forget its exit > code (or some internal state), I do not see anything about this in docs. It means that any protocol requirement about this would almost certainly be broken, if there were one. It couldn't be implemented robustly. > > It's not really clear to me when gdb decides to ask for the thread > > list. > > Never in my (limited) testing. It clearly does have paths to do it in the code. So we need gdb folks to clarify how those are reached. > > > Q2: Shouldn't gdbstub let debugger know about sub-threads somehow? > > > > That's what I would expect in the abstract. But I know that gdb > > didn't used to get new-thread notifications from ptrace either. It > > looks like the linux-nat code does track PTRACE_EVENT_CLONE now. > > But it may be that the gdbserver code and remote protocol were made > > to match how things were when the native ptrace case didn't do that. > > gdbserver tracks PTRACE_EVENT_CLONE, yes. But it doesn't inform gdb. I was talking about the non-remote gdb code, not gdbserver. gdbserver does attach new threads implicitly, but indeed that is only noticed by gdb if a new thread happens to hit a signal (breakpoint or whatever). > I have already looked at this code in horror. I really hope this magic > is not needed for our purposes. > > It is gdbserver, not gdb, who uses libthread_db to find sub-threads and > do other things. Again, I was talking about what gdb does in the non-remote case. AFAIK, it does the same stuff on top of the remote layer too, but I'm not sure about that. > OK, so far it is not clear to me what should we do. If nothing else, > I can replicate the gdbserver's behaviour. But imho it makes sense to > do something more clever. We need some more feedback from the gdb folks. > However, there is the complication I already mentioned. If the main > thread exits, this confuses gdbserver at least. It sends the "$T05" > packets to gdb, then eventually gdb does vCont;c:pTGID.-1 and gdbserver > doesn't work. It doesn't resume sub-threads, doesn't react to ^C, etc. > > I guess, gdbserver shouldn't send '$W' packet in this case, this can > confuse gdb (but I didn't verify this yet). OTOH, it is not clear if > gdbserver can delay this notification until all threads exit. Say, > what should gdbserver do if gdb sends a private signal to the exited > main thread? Or do something else which assumes it alive. Yes, it's not clear what is intended or would be right here. The X/W packets are documented as talking about "the process". Perhaps some new flavors of notification packets are needed to distinguish thread-granularity events from process-granularity. Thanks, Roland