This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch/ARM] Add support for single-stepping through IF-THEN blocks


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]