linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* 32-bit Thumb-2 breakpoints
@ 2010-01-11 21:58 Daniel Jacobowitz
  2010-01-11 22:35 ` Russell King - ARM Linux
  2010-01-12 10:34 ` Catalin Marinas
  0 siblings, 2 replies; 38+ messages in thread
From: Daniel Jacobowitz @ 2010-01-11 21:58 UTC (permalink / raw)
  To: linux-arm-kernel

I have been working the past week on GDB support for Thumb-2.  It
turns out that there's a case where we need a 32-bit software
breakpoint instruction to get things right (explanation below).

The kernel currently reserves two architecturally undefined
instructions for breakpoints, one ARM and one Thumb.  I suggest
another for Thumb-2, provisionally 0xfff7 0xffcf, but I'm open
to any other suggestion.  Any comments?  If that sounds OK,
I can put together a patch.

The problem I'm solving is that of stepping through IT blocks.  We
shouldn't use the BKPT instruction, which would interfere with an
attached hardware debugger.  The undefined instruction pattern
currently used as a breakpoint will not trigger an exception if the IT
block flags prevent its execution.  And without adding most of a
Thumb-2 simulator to GDB, we can't statically predict what the
next instruction will do to the CPSR flags, so we don't know which
of the following instructions in the IT block will be executed.
For example:

   cmp   r0, r0
   itt   eq
A: cmpeq r0, r1
B: moveq r0, r2
C: nop

At A, we try to single-step.  Unless we simulate the cmp instruction,
we do not know whether B or C will be executed next.  So we have to
set a breakpoint at each of the two possibilities.  If we set a 16-bit
breakpoint on a 32-bit instruction and it is not taken, then the
second half of that 32-bit instruction will be treated as the next
instruction.

This approach keeps the single-stepping code considerably simpler than
if it had to recognize and simulate every flag-setting instruction (~
40 instruction forms).  It's not the only approach, obviously; if
someone has a good reason why I ought to simulate every possible
flag-setting instruction, I can write the code to do that instead.

GDB can work around receiving a SIGILL so a patched GDB will mostly
work on existing kernels; for best results and abstract correctness,
though, there should be a reserved instruction pattern for SIGTRAP.

-- 
Daniel Jacobowitz
CodeSourcery

^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2010-02-04 22:46 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-11 21:58 32-bit Thumb-2 breakpoints Daniel Jacobowitz
2010-01-11 22:35 ` Russell King - ARM Linux
2010-01-11 22:54   ` Daniel Jacobowitz
2010-01-11 23:10     ` Jamie Lokier
2010-01-11 23:15       ` Russell King - ARM Linux
2010-01-12  0:15         ` Jamie Lokier
2010-01-11 23:17       ` Daniel Jacobowitz
2010-01-12  0:17         ` Jamie Lokier
2010-01-12  0:22           ` Daniel Jacobowitz
2010-02-03 17:23         ` Jamie Lokier
2010-02-03 17:44           ` Daniel Jacobowitz
2010-02-04 22:46             ` Pavel Machek
2010-01-11 23:31     ` Russell King - ARM Linux
2010-01-11 23:51       ` Daniel Jacobowitz
2010-01-12  9:53         ` Catalin Marinas
2010-01-12 10:34 ` Catalin Marinas
2010-01-12 14:25   ` Daniel Jacobowitz
2010-01-28 20:21     ` Daniel Jacobowitz
2010-02-02 22:43       ` Russell King - ARM Linux
2010-02-03  0:50         ` Daniel Jacobowitz
2010-02-03 11:52           ` Catalin Marinas
2010-02-03 13:28             ` Russell King - ARM Linux
2010-02-03 13:48               ` Daniel Jacobowitz
2010-02-03 14:43                 ` Russell King - ARM Linux
2010-02-03 14:56                   ` Daniel Jacobowitz
2010-02-03 13:59               ` Jamie Iles
2010-02-03 14:40                 ` Russell King - ARM Linux
2010-02-03 15:31                   ` Jamie Iles
2010-02-03 16:01                     ` Will Deacon
2010-02-03 15:02               ` Matthieu CASTET
2010-02-03 15:04                 ` Catalin Marinas
2010-02-03 15:19                   ` Nicolas Pitre
2010-02-03 15:19                 ` Daniel Jacobowitz
2010-02-03 15:30                   ` Russell King - ARM Linux
2010-02-03 15:35                     ` Daniel Jacobowitz
2010-02-03 16:35                       ` Russell King - ARM Linux
2010-02-03 17:45                         ` Daniel Jacobowitz
2010-02-03 15:35                   ` Nicolas Pitre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).