From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21295 invoked by alias); 29 Jan 2010 15:34:50 -0000 Received: (qmail 21286 invoked by uid 22791); 29 Jan 2010 15:34:50 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 29 Jan 2010 15:34:46 +0000 Received: (qmail 7811 invoked from network); 29 Jan 2010 15:34:44 -0000 Received: from unknown (HELO caradoc.them.org) (dan@127.0.0.2) by mail.codesourcery.com with ESMTPA; 29 Jan 2010 15:34:44 -0000 Date: Fri, 29 Jan 2010 15:34:00 -0000 From: Daniel Jacobowitz To: Joel Brobecker Cc: gdb-patches@sourceware.org Subject: Re: [patch/ARM] Add support for single-stepping through IF-THEN blocks Message-ID: <20100129153442.GB30542@caradoc.them.org> Mail-Followup-To: Joel Brobecker , gdb-patches@sourceware.org References: <20100128224044.GF2813@caradoc.them.org> <20100129042431.GD26827@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100129042431.GD26827@adacore.com> User-Agent: Mutt/1.5.20 (2009-06-14) 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: 2010-01/txt/msg00642.txt.bz2 On Fri, Jan 29, 2010 at 08:24:31AM +0400, Joel Brobecker wrote: > > 1) We use an undefined instruction, rather than the architectural BKPT > > instruction, as the GNU/Linux software breakpoint. If a hardware > > debugger is connected to the system, BKPT will trigger it. > > I don't understand why we cannot use the BKPT insn... Suppose we put > a BKPT at the beginning of each block, what would happen? Would we > get a SIGTRAP even if the insn wasn't supposed to be called? Suppose you've got a system with a JTAG port and an Ethernet port. In fact, you don't actually need the Ethernet port - you can use a virtual Ethernet port over JTAG, with some of the fancier probes. You've got a debugger connected to the JTAG port because you are stress testing the system and want to stop on some unexpected fault condition. Or maybe it's in your data center and you just leave the JTAG connected all the time. Now someone goes and uses gdb or gdbserver on the target. If GDB inserts a BKPT instruction, that will trigger the hardware debugger. The kernel will never get control and it will never manage to generate the expected SIGTRAP. Obviously, you don't do this with production systems - the BKPT becomes a trivial way to halt the device. But I've been careful of this issue ever since I first got burned by it on PowerPC hardware, which IIRC has a similar setup. So we have to avoid BKPT for user-mode debug. -- Daniel Jacobowitz CodeSourcery