From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27998 invoked by alias); 6 Apr 2007 22:25:14 -0000 Received: (qmail 27984 invoked by uid 22791); 6 Apr 2007 22:25:13 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.palmsource.com (HELO mx1.palmsource.com) (12.7.175.13) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 06 Apr 2007 23:25:10 +0100 Received: from localhost (localhost [127.0.0.1]) by localhost.domain.tld (Postfix) with ESMTP id 647125EFED; Fri, 6 Apr 2007 15:25:09 -0700 (PDT) Received: from mx1.palmsource.com ([127.0.0.1]) by localhost (mx1.palmsource.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 18961-05-5; Fri, 6 Apr 2007 15:25:08 -0700 (PDT) Received: from ussunex03.svl.access-company.com (ussunm001.palmsource.com [192.168.101.12]) by mx1.palmsource.com (Postfix) with ESMTP id 16DD85EF75; Fri, 6 Apr 2007 15:25:08 -0700 (PDT) Received: from 192.168.92.56 ([192.168.92.56]) by ussunex03.svl.access-company.com ([192.168.101.12]) via Exchange Front-End Server owa.access-company.com ([10.0.20.19]) with Microsoft Exchange Server HTTP-DAV ; Fri, 6 Apr 2007 22:26:31 +0000 Received: from svmsnyderlnx by owa.access-company.com; 06 Apr 2007 15:25:09 -0700 Subject: Re: single-stepping and internal breakpoints on a multi-threaded program From: Michael Snyder To: Jim Blandy Cc: Emi SUZUKI , gdb@sourceware.org In-Reply-To: References: <20070405.205731.12335149.emi-suzuki@tjsys.co.jp> Content-Type: text/plain Content-Transfer-Encoding: 7bit Date: Fri, 06 Apr 2007 22:25:00 -0000 Message-Id: <1175898309.11945.72.camel@svmsnyderlnx.palmsource.com> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-04/txt/msg00040.txt.bz2 On Fri, 2007-04-06 at 15:12 -0700, Jim Blandy wrote: > Emi SUZUKI writes: > > The attached program makes two sub threads, and we do single-stepping > > on one of them. > > When the target get stopped by a internal breakpoint hit (ex. thread > > creation, thread death, shared library loading) during singe-stepping, > > GDB unconditionally resume all the thread and it result in running > > over the range of single-stepping. > > I'm able to reproduce this problem on my FC6 x86 dual core system. > Thanks very much for the clear reproduction instructions. > > > I saw that the context of single-stepping thread is preserved by > > context_switch called in handle_inferior_event, but GDB doesn't go > > back to that context till the thread is trapped in another reason > > (in the above case, the death of the thread). > > > > I think it should either stop immediately and prompt the user that the > > single-stepping has been cancelled, or goes back to the preserved > > context somehow and continue single-stepping. > > How do you think of it? > > So, if I'm understanding correctly, we single-step the 'counter' > thread, which proceeds normally until the 'no_counter' thread hits its > TD_CREATE event, to tell GDB about its existence. Then, GDB fails to > resume single-stepping the 'counter' thread, letting it run until it > exits and reports its TD_DEATH event. > > The fact that the inferior uses breakpoints to report thread creation > and thread death is supposed to be an internal detail of the thread > library --- or, more properly, of the thread debugging interface. One > thread stepping shouldn't be affected by other threads being created > (although GDB should still print the 'new thread' messages). > > So I think the right behavior would be for GDB to continue > single-stepping after processing creation and death events for other > threads. > > I have forgetten exactly how GDB handles multi-threaded single > stepping; I'm afraid I can't suggest how to do this. If you're unable > to fix it yourself, please file a bug report, and include your test > program. I'm thinking that gdb just loses the "I'm stepping this thread" bit of state info, which is normally handled in "proceed" and stored in the infrun-state struct - whereupon it just continues both threads without stepping. But that's just a hunch.