From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1229 invoked by alias); 29 Nov 2006 05:29:53 -0000 Received: (qmail 1215 invoked by uid 22791); 29 Nov 2006 05:29:51 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Wed, 29 Nov 2006 05:29:45 +0000 Received: from drow by nevyn.them.org with local (Exim 4.63) (envelope-from ) id 1GpI0s-0004ER-SW for gdb@sourceware.org; Wed, 29 Nov 2006 00:29:42 -0500 Date: Wed, 29 Nov 2006 05:29:00 -0000 From: Daniel Jacobowitz To: gdb@sourceware.org Subject: Single stepping and threads Message-ID: <20061129052942.GA16029@nevyn.them.org> Mail-Followup-To: gdb@sourceware.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) X-IsSubscribed: yes 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: 2006-11/txt/msg00211.txt.bz2 Ulrich's message earlier reminded me of something I've been meaning to discuss for a while. This isn't specific to software single stepping, but to single step in general for threaded programs. We have a knob "set scheduler-locking". It offers three values: Set mode for locking scheduler during execution. off == no locking (threads may preempt at any time) on == full locking (no thread except the current thread may run) step == scheduler locked during every single-step operation. In this mode, no other thread may run during a step command. Other threads may run while stepping over a function call ('next'). The default is "off". Should it be "step" instead? The example I used to use whenever someone asked me about this was single stepping through something like a barrier or mutex; if other threads don't run, you won't advance, because no other thread will have a chance to release the lock. That much is true. But it seems like a reasonable thing to document and reference "set scheduler-locking". And having threads run during single stepping has surprised a lot of users who've asked me about the current behavior. What do you all think? One reason I've procrastinated bringing this up is that set scheduler-locking off, the current default, has a lot more nasty corner cases that I've meant to look into; if step becomes the default, I suspect more of those will linger unfixed. But users won't encounter them as often, which is much like fixing them :-) A related issue is the tendency of "step" to let other threads run even in "set scheduler-locking step". For instance: - We use a breakpoint to skip the prologue of a function when we step into it. This could either be implemented with a stepping range instead, or else we could continue to use the breakpoint but honor the scheduler locking mode anyway, but the current behavior is silly. - "step" acts like "next" when stepping over a function without debug info. Should we honor "set scheduler-locking step" when doing this? -- Daniel Jacobowitz CodeSourcery