Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Expect SI_KERNEL si_code for a MIPS software breakpoint trap
@ 2015-09-18 16:11 Luis Machado
  2015-09-18 16:56 ` Maciej W. Rozycki
  0 siblings, 1 reply; 12+ messages in thread
From: Luis Machado @ 2015-09-18 16:11 UTC (permalink / raw)
  To: gdb-patches; +Cc: macro

While doing some MIPS/Linux tests, i've found a number of threading tests
failing due to spurious SIGTRAP's. Turns out those spurious SIGTRAP's were
actually software breakpoint hits that were supposed to be handled silently by
GDB/GDBserver, returning a swbreak event.

gdb.threads/continue-pending-status.exp is one of the testcases that show this
behavior.

--

Breakpoint 1, main () at gdb.threads/continue-pending-status.c:44^M
44        pthread_barrier_init (&barrier, NULL, NUM_THREADS);^M
(gdb) b continue-pending-status.c:36^M
Breakpoint 2 at 0x400a04: file gdb.threads/continue-pending-status.c, line 36.^M
(gdb) PASS: gdb.threads/continue-pending-status.exp: attempt 0: set break in tight loop
continue^M
Continuing.^M
[New Thread 5850]^M
[New Thread 5851]^M
[Switching to Thread 5850]^M
^M
Breakpoint 2, thread_function (arg=0x0) at gdb.threads/continue-pending-status.c:36^M
36        while (1); /* break here */^M
(gdb) PASS: gdb.threads/continue-pending-status.exp: attempt 0: continue to tight loop
print /x $_thread^M
$1 = 0x2^M
(gdb) PASS: gdb.threads/continue-pending-status.exp: attempt 0: get thread number
thread 3^M
[Switching to thread 3 (Thread 5851)]^M
36        while (1); /* break here */^M
(gdb) PASS: gdb.threads/continue-pending-status.exp: attempt 0: switch to non-event thread
delete breakpoints^M
Delete all breakpoints? (y or n) y^M
(gdb) info breakpoints^M
No breakpoints or watchpoints.^M
(gdb) continue^M
Continuing.^M
^M
Program received signal SIGTRAP, Trace/breakpoint trap.^M

<<<< This SIGTRAP was a pending breakpoint event that wasn't supposed to cause
<<<< a stop, but gdbserver did not figure out this was a breakpoint hit.

PASS: gdb.threads/continue-pending-status.exp: attempt 0: continue for ctrl-c
thread_function (arg=0x0) at gdb.threads/continue-pending-status.c:36^M
36        while (1); /* break here */^M
(gdb) FAIL: gdb.threads/continue-pending-status.exp: attempt 0: caught interrupt

--

I tracked this down to the lack of a proper definition of what MIPS' kernel
returns in the si_code for a software breakpoint trap.

Though i did not find documentation about this, tests showed that we should
check for SI_KERNEL, just like i386. I've cc-ed Maciej, just to be sure this
is indeed correct.

With the following patch i have cleaner results for thread tests on
MIPS/Linux.

Regression-tested on a few MIPS boards.

OK?

gdb/ChangeLog:

2015-09-18  Luis Machado  <lgustavo@codesourcery.com>

	* nat/linux-ptrace.h: Check for SI_KERNEL si_code for MIPS.
---
 gdb/nat/linux-ptrace.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
index 1be38fe..09c8bc5 100644
--- a/gdb/nat/linux-ptrace.h
+++ b/gdb/nat/linux-ptrace.h
@@ -142,7 +142,7 @@ struct buffer;
 
    The generic Linux target code should use GDB_ARCH_IS_TRAP_BRKPT
    instead of TRAP_BRKPT to abstract out these peculiarities.  */
-#if defined __i386__ || defined __x86_64__
+#if defined __i386__ || defined __x86_64__ || defined __mips__
 # define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == SI_KERNEL)
 #elif defined __powerpc__
 # define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == SI_KERNEL || (X) == TRAP_BRKPT)
-- 
1.9.1


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

end of thread, other threads:[~2016-02-24 11:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-18 16:11 [PATCH] Expect SI_KERNEL si_code for a MIPS software breakpoint trap Luis Machado
2015-09-18 16:56 ` Maciej W. Rozycki
2015-09-18 17:04   ` David Daney
2015-09-18 18:36     ` Maciej W. Rozycki
2016-02-09 14:30   ` Luis Machado
2016-02-09 21:01     ` Maciej W. Rozycki
2016-02-10 12:53       ` Luis Machado
2016-02-15 23:50         ` Maciej W. Rozycki
2016-02-16  0:30           ` Pedro Alves
2016-02-19 16:21             ` Maciej W. Rozycki
2016-02-24 11:52               ` Pedro Alves
2016-02-16  0:57         ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox