* [PATCH 1/2] Fix write endianness/size problem for fast tracepoint enabled flag
@ 2016-03-30 15:17 Simon Marchi
2016-03-30 15:17 ` [PATCH 2/2] Add test for fast tracepoint enable/disable Simon Marchi
` (2 more replies)
0 siblings, 3 replies; 16+ messages in thread
From: Simon Marchi @ 2016-03-30 15:17 UTC (permalink / raw)
To: gdb-patches; +Cc: Par Olsson
From: Par Olsson <par.olsson@windriver.com>
I am sending this fix on behalf of Par Olsson, as a follow-up of this
one:
https://www.sourceware.org/ml/gdb-patches/2015-10/msg00196.html
This problem is exposed when enabling/disabling fast tracepoints on big
endian machines. The flag is defined as an int8_t, but is written from
gdbserver as an integer (usually 32 bits). When the agent code reads it
as an int8_t, it only considers the most significant byte, which is
always 0.
Also, we were writing 32 bits in an 8 bits field, so the write would
overflow, but since the following bytes are padding (the next field is
an uint64_t), it luckily didn't cause any issue on little endian
systems.
The fix was originally tested on ARM big endian systems, but I don't
have access to such a system. However, thanks to Marcin's PowerPC fast
tracepoint patches and gcc110 (big endian Power7) on the gcc compile
farm, I was able to reproduce the problem, test the fix and write a
test (the following patch).
gdb/gdbserver/ChangeLog:
YYYY-MM-DD Par Olsson <par.olsson@windriver.com>
* tracepoint.c (write_inferior_int8): New function.
(cmd_qtenable_disable): Write enable flag using
write_inferior_int8.
---
gdb/gdbserver/tracepoint.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index 7c20612..3e0d57a 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -449,6 +449,12 @@ write_inferior_integer (CORE_ADDR symaddr, int val)
}
static int
+write_inferior_int8 (CORE_ADDR symaddr, int8_t val)
+{
+ return write_inferior_memory (symaddr, (unsigned char *) &val, sizeof (val));
+}
+
+static int
write_inferior_uinteger (CORE_ADDR symaddr, unsigned int val)
{
return write_inferior_memory (symaddr, (unsigned char *) &val, sizeof (val));
@@ -2784,7 +2790,7 @@ cmd_qtenable_disable (char *own_buf, int enable)
return;
}
- ret = write_inferior_integer (obj_addr, enable);
+ ret = write_inferior_int8 (obj_addr, enable);
done_accessing_memory ();
if (ret)
--
2.8.0
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH 2/2] Add test for fast tracepoint enable/disable 2016-03-30 15:17 [PATCH 1/2] Fix write endianness/size problem for fast tracepoint enabled flag Simon Marchi @ 2016-03-30 15:17 ` Simon Marchi 2016-03-31 10:58 ` Yao Qi 2016-03-31 10:51 ` [PATCH 1/2] Fix write endianness/size problem for fast tracepoint enabled flag Yao Qi 2016-05-05 7:58 ` Yao Qi 2 siblings, 1 reply; 16+ messages in thread From: Simon Marchi @ 2016-03-30 15:17 UTC (permalink / raw) To: gdb-patches; +Cc: Simon Marchi This patch adds a test for fast tracepoints enabling/disabling, which didn't work properly on big endian systems. gdb/testsuite/ChangeLog: * gdb.trace/ftrace-enable-disable.exp: New file. * gdb.trace/ftrace-enable-disable.c: New file. --- gdb/testsuite/gdb.trace/ftrace-enable-disable.c | 38 +++++++ gdb/testsuite/gdb.trace/ftrace-enable-disable.exp | 126 ++++++++++++++++++++++ 2 files changed, 164 insertions(+) create mode 100644 gdb/testsuite/gdb.trace/ftrace-enable-disable.c create mode 100644 gdb/testsuite/gdb.trace/ftrace-enable-disable.exp diff --git a/gdb/testsuite/gdb.trace/ftrace-enable-disable.c b/gdb/testsuite/gdb.trace/ftrace-enable-disable.c new file mode 100644 index 0000000..23453db --- /dev/null +++ b/gdb/testsuite/gdb.trace/ftrace-enable-disable.c @@ -0,0 +1,38 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2016 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "trace-common.h" + +static void +break_here (void) +{ +} + +int +main (void) +{ + int i; + + for (i = 0; i < 100; i++) + { + FAST_TRACEPOINT_LABEL(point_a); + FAST_TRACEPOINT_LABEL(point_b); + break_here (); + } + + return 0; +} diff --git a/gdb/testsuite/gdb.trace/ftrace-enable-disable.exp b/gdb/testsuite/gdb.trace/ftrace-enable-disable.exp new file mode 100644 index 0000000..883b5b9 --- /dev/null +++ b/gdb/testsuite/gdb.trace/ftrace-enable-disable.exp @@ -0,0 +1,126 @@ +# Copyright 2015-2016 Free Software Foundation, Inc. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +load_lib "trace-support.exp" + +standard_testfile +set executable $testfile +set expfile $testfile.exp + +# Some targets have leading underscores on assembly symbols. +set options [list debug [gdb_target_symbol_prefix_flags]] + +# Check that the target supports trace. +if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { + untested "Couldn't compile test program" + return -1 +} + +clean_restart ${testfile} + +if ![runto_main] { + fail "Can't run to main to check for trace support" + return -1 +} + +if ![gdb_target_supports_trace] { + unsupported "target does not support trace" + return -1 +} + +# Compile the test case with the in-process agent library. +set libipa [get_in_proc_agent] +gdb_load_shlibs $libipa + +lappend options shlib=$libipa + +if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { + untested "Couldn't compile test program with in-process agent library" + return -1 +} + +# This test makes sure that disabling and enabling fast tracepoints works +# correctly. + +proc test_ftrace_enable_disable { } { + with_test_prefix "test_ftrace_enable_disable" { + global executable binfile decimal + clean_restart ${executable} + + set expected 0 + + if ![runto_main] { + fail "Can't run to main." + return -1 + } + + gdb_test "ftrace point_a" "Fast tracepoint 2.*" + gdb_test "ftrace point_b" "Fast tracepoint 3.*" + gdb_breakpoint "break_here" + gdb_test_no_output "tstart" + + # Test that tracepoints start enabled + with_test_prefix "start" { + gdb_continue "break_here" + incr expected 2 + gdb_test "tstatus" "Collected $expected trace frames.*" + } + + # Test that disabling works + with_test_prefix "disable #1" { + gdb_test_no_output "disable 2" + gdb_continue "break_here" + incr expected 1 + gdb_test "tstatus" "Collected $expected trace frames.*" + } + + with_test_prefix "disable #2" { + gdb_test_no_output "disable 3" + gdb_continue "break_here" + gdb_test "tstatus" "Collected $expected trace frames.*" + } + + # Test that disabling an already disabled tracepoint works + with_test_prefix "disable #3" { + gdb_test_no_output "disable 2" + gdb_continue "break_here" + gdb_test "tstatus" "Collected $expected trace frames.*" + } + + # Test that enabling works + with_test_prefix "enable #1" { + gdb_test_no_output "enable 2" + gdb_continue "break_here" + incr expected 1 + gdb_test "tstatus" "Collected $expected trace frames.*" + } + + with_test_prefix "enable #2" { + gdb_test_no_output "enable 3" + gdb_continue "break_here" + incr expected 2 + gdb_test "tstatus" "Collected $expected trace frames.*" + } + + # Test that enabling an already enabled tracepoint works + with_test_prefix "enable #3" { + gdb_test_no_output "enable 3" + gdb_continue "break_here" + incr expected 2 + gdb_test "tstatus" "Collected $expected trace frames.*" + } + } +} + +test_ftrace_enable_disable -- 2.8.0 ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/2] Add test for fast tracepoint enable/disable 2016-03-30 15:17 ` [PATCH 2/2] Add test for fast tracepoint enable/disable Simon Marchi @ 2016-03-31 10:58 ` Yao Qi 2016-03-31 18:01 ` Simon Marchi 2016-04-28 15:30 ` Simon Marchi 0 siblings, 2 replies; 16+ messages in thread From: Yao Qi @ 2016-03-31 10:58 UTC (permalink / raw) To: Simon Marchi; +Cc: gdb-patches Simon Marchi <simon.marchi@ericsson.com> writes: > +# Check that the target supports trace. > +if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { > + untested "Couldn't compile test program" > + return -1 > +} Why do you compile program with pthread? > + > +clean_restart ${testfile} > + > +if ![runto_main] { > + fail "Can't run to main to check for trace support" > + return -1 > +} > + > +if ![gdb_target_supports_trace] { > + unsupported "target does not support trace" > + return -1 > +} > + > +# Compile the test case with the in-process agent library. > +set libipa [get_in_proc_agent] > +gdb_load_shlibs $libipa > + > +lappend options shlib=$libipa > + > +if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { > + untested "Couldn't compile test program with in-process agent library" > + return -1 > +} Likewise. > + > +# This test makes sure that disabling and enabling fast tracepoints works > +# correctly. > + > +proc test_ftrace_enable_disable { } { Can you extend the test to cover normal tracepoint as well? It shouldn't be hard. You can just pass argument "type" to "proc test_trace_enable_disable" like, proc test_trace_enable_disable { type } { and the type can be "trace" and "ftrace". -- Yao (齐尧) ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/2] Add test for fast tracepoint enable/disable 2016-03-31 10:58 ` Yao Qi @ 2016-03-31 18:01 ` Simon Marchi 2016-03-31 18:31 ` Simon Marchi 2016-04-01 13:36 ` Yao Qi 2016-04-28 15:30 ` Simon Marchi 1 sibling, 2 replies; 16+ messages in thread From: Simon Marchi @ 2016-03-31 18:01 UTC (permalink / raw) To: Yao Qi; +Cc: gdb-patches On 16-03-31 06:58 AM, Yao Qi wrote: > Simon Marchi <simon.marchi@ericsson.com> writes: > >> +# Check that the target supports trace. >> +if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { >> + untested "Couldn't compile test program" >> + return -1 >> +} > > Why do you compile program with pthread? Good question. Because the setup for testing fast tracepoints is tedious, I always use ftrace-lock.exp as a template, because it is relatively short. ftrace-lock.exp uses gdb_compile_pthreads. I think it makes sense, because the IPA starts a helper thread with pthread_create. Note that it still builds fine with gdb_compile instead of gdb_compile_pthreads, probably because libinproctrace.so has a DT_NEEDED for libpthreads.so, so it gets pulled in. But using gdb_compile_pthreads should add -pthread to the CFLAGS, which may impact compilation (e.g. choose re-entrant versions of functions). However, I just noticed that the command line includes -lpthreads instead of -pthreads: spawn gcc -Wl,--no-as-needed /home/emaisin/build/binutils-gdb/gdb/testsuite/../../../../src/binutils-gdb/gdb/testsuite/gdb.trace/ftrace-enable-disable.c \ /home/emaisin/build/binutils-gdb/gdb/testsuite/../gdbserver/libinproctrace.so -g \ -lpthread -lm -o \ /home/emaisin/build/binutils-gdb/gdb/testsuite/outputs/gdb.trace/ftrace-enable-disable/ftrace-enable-disable I think that to be more "correct", we should try -pthread before -lpthread in gdb_compile_pthreads... >> + >> +clean_restart ${testfile} >> + >> +if ![runto_main] { >> + fail "Can't run to main to check for trace support" >> + return -1 >> +} >> + >> +if ![gdb_target_supports_trace] { >> + unsupported "target does not support trace" >> + return -1 >> +} >> + >> +# Compile the test case with the in-process agent library. >> +set libipa [get_in_proc_agent] >> +gdb_load_shlibs $libipa >> + >> +lappend options shlib=$libipa >> + >> +if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { >> + untested "Couldn't compile test program with in-process agent library" >> + return -1 >> +} > > Likewise. Same response :) >> + >> +# This test makes sure that disabling and enabling fast tracepoints works >> +# correctly. >> + >> +proc test_ftrace_enable_disable { } { > > Can you extend the test to cover normal tracepoint as well? It > shouldn't be hard. You can just pass argument "type" to "proc > test_trace_enable_disable" like, > > proc test_trace_enable_disable { type } { > > and the type can be "trace" and "ftrace". I'll try to do that. Thanks, Simon ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/2] Add test for fast tracepoint enable/disable 2016-03-31 18:01 ` Simon Marchi @ 2016-03-31 18:31 ` Simon Marchi 2016-04-01 13:36 ` Yao Qi 1 sibling, 0 replies; 16+ messages in thread From: Simon Marchi @ 2016-03-31 18:31 UTC (permalink / raw) To: Yao Qi; +Cc: gdb-patches On 16-03-31 02:01 PM, Simon Marchi wrote: >> Can you extend the test to cover normal tracepoint as well? It >> shouldn't be hard. You can just pass argument "type" to "proc >> test_trace_enable_disable" like, >> >> proc test_trace_enable_disable { type } { >> >> and the type can be "trace" and "ftrace". > > I'll try to do that. > > Thanks, > > Simon Here is an updated patch that tests both trace and ftrace. I left gdb_compile_pthreads for now, while we discuss. One thing that could be improved is that the test should be organized so that it tests normal tracepoints even if fast tracepoints are not supported by the architecture. Right now, I think it will do both or none at all. From 09ccbccb0176feaaf8a385adad28dab6ff357f33 Mon Sep 17 00:00:00 2001 From: Simon Marchi <simon.marchi@ericsson.com> Date: Wed, 30 Mar 2016 10:24:05 -0400 Subject: [PATCH] Add test for tracepoint enable/disable This patch adds a test for tracepoints enabling/disabling, which didn't work properly for fast tracepoints on big endian systems. gdb/testsuite/ChangeLog: * gdb.trace/trace-enable-disable.exp: New file. * gdb.trace/trace-enable-disable.c: New file. --- gdb/testsuite/gdb.trace/trace-enable-disable.c | 38 +++++++ gdb/testsuite/gdb.trace/trace-enable-disable.exp | 128 +++++++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 gdb/testsuite/gdb.trace/trace-enable-disable.c create mode 100644 gdb/testsuite/gdb.trace/trace-enable-disable.exp diff --git a/gdb/testsuite/gdb.trace/trace-enable-disable.c b/gdb/testsuite/gdb.trace/trace-enable-disable.c new file mode 100644 index 0000000..23453db --- /dev/null +++ b/gdb/testsuite/gdb.trace/trace-enable-disable.c @@ -0,0 +1,38 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2016 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "trace-common.h" + +static void +break_here (void) +{ +} + +int +main (void) +{ + int i; + + for (i = 0; i < 100; i++) + { + FAST_TRACEPOINT_LABEL(point_a); + FAST_TRACEPOINT_LABEL(point_b); + break_here (); + } + + return 0; +} diff --git a/gdb/testsuite/gdb.trace/trace-enable-disable.exp b/gdb/testsuite/gdb.trace/trace-enable-disable.exp new file mode 100644 index 0000000..2d9d6c7 --- /dev/null +++ b/gdb/testsuite/gdb.trace/trace-enable-disable.exp @@ -0,0 +1,128 @@ +# Copyright 2015-2016 Free Software Foundation, Inc. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +load_lib "trace-support.exp" + +standard_testfile +set executable $testfile +set expfile $testfile.exp + +# Some targets have leading underscores on assembly symbols. +set options [list debug [gdb_target_symbol_prefix_flags]] + +# Check that the target supports trace. +if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { + untested "Couldn't compile test program" + return -1 +} + +clean_restart ${testfile} + +if ![runto_main] { + fail "Can't run to main to check for trace support" + return -1 +} + +if ![gdb_target_supports_trace] { + unsupported "target does not support trace" + return -1 +} + +# Compile the test case with the in-process agent library. +set libipa [get_in_proc_agent] +gdb_load_shlibs $libipa + +lappend options shlib=$libipa + +if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { + untested "Couldn't compile test program with in-process agent library" + return -1 +} + +# This test makes sure that disabling and enabling tracepoints works +# correctly. TRACEPOINT_CMD is the command used to set tracepoints +# (e.g. trace or ftrace). + +proc test_tracepoint_enable_disable { tracepoint_cmd } { + with_test_prefix "test_tracepoint_enable_disable" { + global executable binfile decimal + clean_restart ${executable} + + set expected 0 + + if ![runto_main] { + fail "Can't run to main." + return -1 + } + + gdb_test "$tracepoint_cmd point_a" "(Tracepoint|Fast tracepoint) 2.*" + gdb_test "$tracepoint_cmd point_b" "(Tracepoint|Fast tracepoint) 3.*" + gdb_breakpoint "break_here" + gdb_test_no_output "tstart" + + # Test that tracepoints start enabled + with_test_prefix "start" { + gdb_continue "break_here" + incr expected 2 + gdb_test "tstatus" "Collected $expected trace frames.*" + } + + # Test that disabling works + with_test_prefix "disable #1" { + gdb_test_no_output "disable 2" + gdb_continue "break_here" + incr expected 1 + gdb_test "tstatus" "Collected $expected trace frames.*" + } + + with_test_prefix "disable #2" { + gdb_test_no_output "disable 3" + gdb_continue "break_here" + gdb_test "tstatus" "Collected $expected trace frames.*" + } + + # Test that disabling an already disabled tracepoint works + with_test_prefix "disable #3" { + gdb_test_no_output "disable 2" + gdb_continue "break_here" + gdb_test "tstatus" "Collected $expected trace frames.*" + } + + # Test that enabling works + with_test_prefix "enable #1" { + gdb_test_no_output "enable 2" + gdb_continue "break_here" + incr expected 1 + gdb_test "tstatus" "Collected $expected trace frames.*" + } + + with_test_prefix "enable #2" { + gdb_test_no_output "enable 3" + gdb_continue "break_here" + incr expected 2 + gdb_test "tstatus" "Collected $expected trace frames.*" + } + + # Test that enabling an already enabled tracepoint works + with_test_prefix "enable #3" { + gdb_test_no_output "enable 3" + gdb_continue "break_here" + incr expected 2 + gdb_test "tstatus" "Collected $expected trace frames.*" + } + } +} + +test_tracepoint_enable_disable trace +test_tracepoint_enable_disable ftrace -- 2.8.0 ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/2] Add test for fast tracepoint enable/disable 2016-03-31 18:01 ` Simon Marchi 2016-03-31 18:31 ` Simon Marchi @ 2016-04-01 13:36 ` Yao Qi 2016-04-01 14:42 ` Simon Marchi 1 sibling, 1 reply; 16+ messages in thread From: Yao Qi @ 2016-04-01 13:36 UTC (permalink / raw) To: Simon Marchi; +Cc: Yao Qi, gdb-patches Simon Marchi <simon.marchi@ericsson.com> writes: > Good question. Because the setup for testing fast tracepoints is > tedious, I always > use ftrace-lock.exp as a template, because it is relatively short. > ftrace-lock.exp > uses gdb_compile_pthreads. I think it makes sense, because the IPA > starts a helper > thread with pthread_create. gdb_compile_pthreads is used in ftrace-lock.exp because ftrace-lock.c is a multi-threaded program, but ftrace-enable-disable.c isn't. The program to be tested is running in one thread, and it doesn't have any interaction with the helper thread. > > Note that it still builds fine with gdb_compile instead of gdb_compile_pthreads, > probably because libinproctrace.so has a DT_NEEDED for libpthreads.so, > so it gets > pulled in. But using gdb_compile_pthreads should add -pthread to the > CFLAGS, which > may impact compilation (e.g. choose re-entrant versions of functions). Using IPA/fast tracepoint shouldn't affect how the program is compiled. User is writing and debugging a single thread program, and he/she wants to use fast tracepoint to debug. He/She shouldn't recompile the program with -lpthreads or -pthreads, what needed here is to let IPA be loaded with the program. > > However, I just noticed that the command line includes -lpthreads > instead of -pthreads: > > spawn gcc -Wl,--no-as-needed > /home/emaisin/build/binutils-gdb/gdb/testsuite/../../../../src/binutils-gdb/gdb/testsuite/gdb.trace/ftrace-enable-disable.c > \ > /home/emaisin/build/binutils-gdb/gdb/testsuite/../gdbserver/libinproctrace.so > -g \ > -lpthread -lm -o \ > /home/emaisin/build/binutils-gdb/gdb/testsuite/outputs/gdb.trace/ftrace-enable-disable/ftrace-enable-disable > > I think that to be more "correct", we should try -pthread before -lpthread in > gdb_compile_pthreads... I am not sure, it is a separate issue, this applies to all test cases compiled with gdb_compile_pthreads. -- Yao (齐尧) ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/2] Add test for fast tracepoint enable/disable 2016-04-01 13:36 ` Yao Qi @ 2016-04-01 14:42 ` Simon Marchi 0 siblings, 0 replies; 16+ messages in thread From: Simon Marchi @ 2016-04-01 14:42 UTC (permalink / raw) To: Yao Qi; +Cc: gdb-patches On 16-04-01 09:36 AM, Yao Qi wrote: > Simon Marchi <simon.marchi@ericsson.com> writes: > >> Good question. Because the setup for testing fast tracepoints is >> tedious, I always >> use ftrace-lock.exp as a template, because it is relatively short. >> ftrace-lock.exp >> uses gdb_compile_pthreads. I think it makes sense, because the IPA >> starts a helper >> thread with pthread_create. > > gdb_compile_pthreads is used in ftrace-lock.exp because ftrace-lock.c is > a multi-threaded program, but ftrace-enable-disable.c isn't. The > program to be tested is running in one thread, and it doesn't have any > interaction with the helper thread. > >> >> Note that it still builds fine with gdb_compile instead of gdb_compile_pthreads, >> probably because libinproctrace.so has a DT_NEEDED for libpthreads.so, >> so it gets >> pulled in. But using gdb_compile_pthreads should add -pthread to the >> CFLAGS, which >> may impact compilation (e.g. choose re-entrant versions of functions). > > Using IPA/fast tracepoint shouldn't affect how the program is compiled. > User is writing and debugging a single thread program, and he/she wants > to use fast tracepoint to debug. He/She shouldn't recompile the program > with -lpthreads or -pthreads, what needed here is to let IPA be loaded with > the program. That totally makes sense, I'll change it to gdb_compile. >> >> However, I just noticed that the command line includes -lpthreads >> instead of -pthreads: >> >> spawn gcc -Wl,--no-as-needed >> /home/emaisin/build/binutils-gdb/gdb/testsuite/../../../../src/binutils-gdb/gdb/testsuite/gdb.trace/ftrace-enable-disable.c >> \ >> /home/emaisin/build/binutils-gdb/gdb/testsuite/../gdbserver/libinproctrace.so >> -g \ >> -lpthread -lm -o \ >> /home/emaisin/build/binutils-gdb/gdb/testsuite/outputs/gdb.trace/ftrace-enable-disable/ftrace-enable-disable >> >> I think that to be more "correct", we should try -pthread before -lpthread in >> gdb_compile_pthreads... > > I am not sure, it is a separate issue, this applies to all test cases > compiled with gdb_compile_pthreads. > ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/2] Add test for fast tracepoint enable/disable 2016-03-31 10:58 ` Yao Qi 2016-03-31 18:01 ` Simon Marchi @ 2016-04-28 15:30 ` Simon Marchi 2016-04-28 16:03 ` Yao Qi 1 sibling, 1 reply; 16+ messages in thread From: Simon Marchi @ 2016-04-28 15:30 UTC (permalink / raw) To: Yao Qi; +Cc: gdb-patches On 16-03-31 06:58 AM, Yao Qi wrote: > Simon Marchi <simon.marchi@ericsson.com> writes: > >> +# Check that the target supports trace. >> +if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { >> + untested "Couldn't compile test program" >> + return -1 >> +} > > Why do you compile program with pthread? > >> + >> +clean_restart ${testfile} >> + >> +if ![runto_main] { >> + fail "Can't run to main to check for trace support" >> + return -1 >> +} >> + >> +if ![gdb_target_supports_trace] { >> + unsupported "target does not support trace" >> + return -1 >> +} >> + >> +# Compile the test case with the in-process agent library. >> +set libipa [get_in_proc_agent] >> +gdb_load_shlibs $libipa >> + >> +lappend options shlib=$libipa >> + >> +if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { >> + untested "Couldn't compile test program with in-process agent library" >> + return -1 >> +} > > Likewise. > >> + >> +# This test makes sure that disabling and enabling fast tracepoints works >> +# correctly. >> + >> +proc test_ftrace_enable_disable { } { > > Can you extend the test to cover normal tracepoint as well? It > shouldn't be hard. You can just pass argument "type" to "proc > test_trace_enable_disable" like, > > proc test_trace_enable_disable { type } { > > and the type can be "trace" and "ftrace". > Hi Yao, Here's the v2. Changes: * gdb_compile instead of gdb_compile_pthreads. * Test with both trace and ftrace commands. From 991319e45356adcdb85c5db1e377e72fcd978f07 Mon Sep 17 00:00:00 2001 From: Simon Marchi <simon.marchi@ericsson.com> Date: Wed, 30 Mar 2016 10:24:05 -0400 Subject: [PATCH] Add test for tracepoint enable/disable This patch adds a test for tracepoints enabling/disabling, which didn't work properly for fast tracepoints on big endian systems. gdb/testsuite/ChangeLog: * gdb.trace/trace-enable-disable.exp: New file. * gdb.trace/trace-enable-disable.c: New file. --- gdb/testsuite/gdb.trace/trace-enable-disable.c | 38 +++++++ gdb/testsuite/gdb.trace/trace-enable-disable.exp | 128 +++++++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 gdb/testsuite/gdb.trace/trace-enable-disable.c create mode 100644 gdb/testsuite/gdb.trace/trace-enable-disable.exp diff --git a/gdb/testsuite/gdb.trace/trace-enable-disable.c b/gdb/testsuite/gdb.trace/trace-enable-disable.c new file mode 100644 index 0000000..23453db --- /dev/null +++ b/gdb/testsuite/gdb.trace/trace-enable-disable.c @@ -0,0 +1,38 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2016 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "trace-common.h" + +static void +break_here (void) +{ +} + +int +main (void) +{ + int i; + + for (i = 0; i < 100; i++) + { + FAST_TRACEPOINT_LABEL(point_a); + FAST_TRACEPOINT_LABEL(point_b); + break_here (); + } + + return 0; +} diff --git a/gdb/testsuite/gdb.trace/trace-enable-disable.exp b/gdb/testsuite/gdb.trace/trace-enable-disable.exp new file mode 100644 index 0000000..0c35c92 --- /dev/null +++ b/gdb/testsuite/gdb.trace/trace-enable-disable.exp @@ -0,0 +1,128 @@ +# Copyright 2015-2016 Free Software Foundation, Inc. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +load_lib "trace-support.exp" + +standard_testfile +set executable $testfile +set expfile $testfile.exp + +# Some targets have leading underscores on assembly symbols. +set options [list debug [gdb_target_symbol_prefix_flags]] + +# Check that the target supports trace. +if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { + untested "Couldn't compile test program" + return -1 +} + +clean_restart ${testfile} + +if ![runto_main] { + fail "Can't run to main to check for trace support" + return -1 +} + +if ![gdb_target_supports_trace] { + unsupported "target does not support trace" + return -1 +} + +# Compile the test case with the in-process agent library. +set libipa [get_in_proc_agent] +gdb_load_shlib $libipa + +lappend options shlib=$libipa + +if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { + untested "Couldn't compile test program with in-process agent library" + return -1 +} + +# This test makes sure that disabling and enabling tracepoints works +# correctly. TRACEPOINT_CMD is the command used to set tracepoints +# (e.g. trace or ftrace). + +proc test_tracepoint_enable_disable { tracepoint_cmd } { + with_test_prefix "test_tracepoint_enable_disable $tracepoint_cmd" { + global executable + clean_restart ${executable} + + set expected 0 + + if ![runto_main] { + fail "Can't run to main." + return -1 + } + + gdb_test "$tracepoint_cmd point_a" "(Tracepoint|Fast tracepoint) 2.*" + gdb_test "$tracepoint_cmd point_b" "(Tracepoint|Fast tracepoint) 3.*" + gdb_breakpoint "break_here" + gdb_test_no_output "tstart" + + # Test that tracepoints start enabled + with_test_prefix "start" { + gdb_continue "break_here" + incr expected 2 + gdb_test "tstatus" "Collected $expected trace frames.*" + } + + # Test that disabling works + with_test_prefix "disable #1" { + gdb_test_no_output "disable 2" + gdb_continue "break_here" + incr expected 1 + gdb_test "tstatus" "Collected $expected trace frames.*" + } + + with_test_prefix "disable #2" { + gdb_test_no_output "disable 3" + gdb_continue "break_here" + gdb_test "tstatus" "Collected $expected trace frames.*" + } + + # Test that disabling an already disabled tracepoint works + with_test_prefix "disable #3" { + gdb_test_no_output "disable 2" + gdb_continue "break_here" + gdb_test "tstatus" "Collected $expected trace frames.*" + } + + # Test that enabling works + with_test_prefix "enable #1" { + gdb_test_no_output "enable 2" + gdb_continue "break_here" + incr expected 1 + gdb_test "tstatus" "Collected $expected trace frames.*" + } + + with_test_prefix "enable #2" { + gdb_test_no_output "enable 3" + gdb_continue "break_here" + incr expected 2 + gdb_test "tstatus" "Collected $expected trace frames.*" + } + + # Test that enabling an already enabled tracepoint works + with_test_prefix "enable #3" { + gdb_test_no_output "enable 3" + gdb_continue "break_here" + incr expected 2 + gdb_test "tstatus" "Collected $expected trace frames.*" + } + } +} + +test_tracepoint_enable_disable trace +test_tracepoint_enable_disable ftrace -- 2.8.1 ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/2] Add test for fast tracepoint enable/disable 2016-04-28 15:30 ` Simon Marchi @ 2016-04-28 16:03 ` Yao Qi 2016-04-28 16:57 ` Simon Marchi 0 siblings, 1 reply; 16+ messages in thread From: Yao Qi @ 2016-04-28 16:03 UTC (permalink / raw) To: Simon Marchi; +Cc: Yao Qi, gdb-patches Simon Marchi <simon.marchi@ericsson.com> writes: > This patch adds a test for tracepoints enabling/disabling, which > didn't work properly for fast tracepoints on big endian systems. > > gdb/testsuite/ChangeLog: > > * gdb.trace/trace-enable-disable.exp: New file. > * gdb.trace/trace-enable-disable.c: New file. This is good to me. -- Yao (齐尧) ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/2] Add test for fast tracepoint enable/disable 2016-04-28 16:03 ` Yao Qi @ 2016-04-28 16:57 ` Simon Marchi 0 siblings, 0 replies; 16+ messages in thread From: Simon Marchi @ 2016-04-28 16:57 UTC (permalink / raw) To: Yao Qi; +Cc: gdb-patches On 16-04-28 12:03 PM, Yao Qi wrote: > Simon Marchi <simon.marchi@ericsson.com> writes: > >> This patch adds a test for tracepoints enabling/disabling, which >> didn't work properly for fast tracepoints on big endian systems. >> >> gdb/testsuite/ChangeLog: >> >> * gdb.trace/trace-enable-disable.exp: New file. >> * gdb.trace/trace-enable-disable.c: New file. > > This is good to me. > Thanks, both patches are pushed. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/2] Fix write endianness/size problem for fast tracepoint enabled flag 2016-03-30 15:17 [PATCH 1/2] Fix write endianness/size problem for fast tracepoint enabled flag Simon Marchi 2016-03-30 15:17 ` [PATCH 2/2] Add test for fast tracepoint enable/disable Simon Marchi @ 2016-03-31 10:51 ` Yao Qi 2016-03-31 11:33 ` Pedro Alves 2016-03-31 17:45 ` Simon Marchi 2016-05-05 7:58 ` Yao Qi 2 siblings, 2 replies; 16+ messages in thread From: Yao Qi @ 2016-03-31 10:51 UTC (permalink / raw) To: Simon Marchi; +Cc: gdb-patches, Par Olsson Simon Marchi <simon.marchi@ericsson.com> writes: > I am sending this fix on behalf of Par Olsson, as a follow-up of this > one: > > https://www.sourceware.org/ml/gdb-patches/2015-10/msg00196.html Hi Simon, The patch in the url above is to change 'enabled' field to uint32_t, so I guess you got the patch below from Par Olsson off list? The reason I ask this is that I find the author doesn't have the copyright assignment. We can take it as a tiny patch, if no one has objections. > > static int > +write_inferior_int8 (CORE_ADDR symaddr, int8_t val) > +{ > + return write_inferior_memory (symaddr, (unsigned char *) &val, sizeof (val)); This line is too long. > +} The patch itself is good to me. -- Yao (齐尧) ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/2] Fix write endianness/size problem for fast tracepoint enabled flag 2016-03-31 10:51 ` [PATCH 1/2] Fix write endianness/size problem for fast tracepoint enabled flag Yao Qi @ 2016-03-31 11:33 ` Pedro Alves 2016-03-31 12:58 ` Yao Qi 2016-03-31 17:45 ` Simon Marchi 1 sibling, 1 reply; 16+ messages in thread From: Pedro Alves @ 2016-03-31 11:33 UTC (permalink / raw) To: Yao Qi, Simon Marchi; +Cc: gdb-patches, Par Olsson On 03/31/2016 11:51 AM, Yao Qi wrote: > Simon Marchi <simon.marchi@ericsson.com> writes: > >> I am sending this fix on behalf of Par Olsson, as a follow-up of this >> one: >> >> https://www.sourceware.org/ml/gdb-patches/2015-10/msg00196.html > > Hi Simon, > The patch in the url above is to change 'enabled' field to uint32_t, so > I guess you got the patch below from Par Olsson off list? > > The reason I ask this is that I find the author doesn't have the copyright > assignment. We can take it as a tiny patch, if no one has objections. Actually Wind River has a blanket copyright assignment: BINUTILS DEJAGNU GCC GDB Wind River Systems 1997-09-04 Assigns past and future changes submitted to the FSF (gcc, g++, gdb, binutils, libg++, libstdc++, dejagnu, GNU C++ testsuite, GNU C testsuite). Thanks, Pedro Alves ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/2] Fix write endianness/size problem for fast tracepoint enabled flag 2016-03-31 11:33 ` Pedro Alves @ 2016-03-31 12:58 ` Yao Qi 0 siblings, 0 replies; 16+ messages in thread From: Yao Qi @ 2016-03-31 12:58 UTC (permalink / raw) To: Pedro Alves; +Cc: Yao Qi, Simon Marchi, gdb-patches, Par Olsson Pedro Alves <palves@redhat.com> writes: > Actually Wind River has a blanket copyright assignment: > > BINUTILS DEJAGNU GCC GDB Wind River Systems 1997-09-04 > Assigns past and future changes submitted to the FSF > (gcc, g++, gdb, binutils, libg++, libstdc++, dejagnu, > GNU C++ testsuite, GNU C testsuite). Oh, right, I searched "windriver" (no space), and only find one record for one person. -- Yao (齐尧) ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/2] Fix write endianness/size problem for fast tracepoint enabled flag 2016-03-31 10:51 ` [PATCH 1/2] Fix write endianness/size problem for fast tracepoint enabled flag Yao Qi 2016-03-31 11:33 ` Pedro Alves @ 2016-03-31 17:45 ` Simon Marchi 1 sibling, 0 replies; 16+ messages in thread From: Simon Marchi @ 2016-03-31 17:45 UTC (permalink / raw) To: Yao Qi; +Cc: gdb-patches, Par Olsson On 16-03-31 06:51 AM, Yao Qi wrote: > Simon Marchi <simon.marchi@ericsson.com> writes: > >> I am sending this fix on behalf of Par Olsson, as a follow-up of this >> one: >> >> https://www.sourceware.org/ml/gdb-patches/2015-10/msg00196.html > > Hi Simon, > The patch in the url above is to change 'enabled' field to uint32_t, so > I guess you got the patch below from Par Olsson off list? > > The reason I ask this is that I find the author doesn't have the copyright > assignment. We can take it as a tiny patch, if no one has objections. Par indeed sent us this off-list. But as Pedro mentioned, Wind River is covered. > >> static int >> +write_inferior_int8 (CORE_ADDR symaddr, int8_t val) >> +{ >> + return write_inferior_memory (symaddr, (unsigned char *) &val, sizeof (val)); > > This line is too long. It's 79 characters long, no? It's the same line as the line in write_inferior_integer, I think they are both ok. > The patch itself is good to me. Ok thanks, I'll push it when the corresponding test is accepted. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/2] Fix write endianness/size problem for fast tracepoint enabled flag 2016-03-30 15:17 [PATCH 1/2] Fix write endianness/size problem for fast tracepoint enabled flag Simon Marchi 2016-03-30 15:17 ` [PATCH 2/2] Add test for fast tracepoint enable/disable Simon Marchi 2016-03-31 10:51 ` [PATCH 1/2] Fix write endianness/size problem for fast tracepoint enabled flag Yao Qi @ 2016-05-05 7:58 ` Yao Qi 2016-05-05 13:50 ` Simon Marchi 2 siblings, 1 reply; 16+ messages in thread From: Yao Qi @ 2016-05-05 7:58 UTC (permalink / raw) To: Simon Marchi; +Cc: gdb-patches, Par Olsson Simon Marchi <simon.marchi@ericsson.com> writes: Hi Simon, > gdb/gdbserver/ChangeLog: > > YYYY-MM-DD Par Olsson <par.olsson@windriver.com> > > * tracepoint.c (write_inferior_int8): New function. > (cmd_qtenable_disable): Write enable flag using > write_inferior_int8. The format of committed changelog entry looks odd to me, 2016-04-28 Par Olsson <par.olsson@windriver.com> 2016-04-28 Simon Marchi <simon.marchi@ericsson.com> * tracepoint.c (write_inferior_int8): New function. (cmd_qtenable_disable): Write enable flag using write_inferior_int8. -- Yao (齐尧) ^ permalink raw reply [flat|nested] 16+ messages in thread
* RE: [PATCH 1/2] Fix write endianness/size problem for fast tracepoint enabled flag 2016-05-05 7:58 ` Yao Qi @ 2016-05-05 13:50 ` Simon Marchi 0 siblings, 0 replies; 16+ messages in thread From: Simon Marchi @ 2016-05-05 13:50 UTC (permalink / raw) To: Yao Qi; +Cc: gdb-patches, Par Olsson [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 7786 bytes --] >> gdb/gdbserver/ChangeLog: >> >> YYYY-MM-DD Par Olsson <par.olsson@windriver.com> >> >> * tracepoint.c (write_inferior_int8): New function. >> (cmd_qtenable_disable): Write enable flag using >> write_inferior_int8. > > The format of committed changelog entry looks odd to me, Fixed, thanks. From gdb-patches-return-131369-listarch-gdb-patches=sources.redhat.com@sourceware.org Thu May 05 18:19:21 2016 Return-Path: <gdb-patches-return-131369-listarch-gdb-patches=sources.redhat.com@sourceware.org> Delivered-To: listarch-gdb-patches@sources.redhat.com Received: (qmail 56286 invoked by alias); 5 May 2016 18:19:21 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 55548 invoked by uid 89); 5 May 2016 18:19:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 testsºYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*r:8.14.3, states, sleep X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 05 May 2016 18:19:09 +0000 Received: from elxcz23q12-y4.polymtl.ca (Sansfil-Public-Lassonde-201-57.polymtl.ca [132.207.201.57]) by smtp.polymtl.ca (8.14.3/8.14.3) with ESMTP id u45IJ4ac032566; Thu, 5 May 2016 14:19:05 -0400 From: Simon Marchi <simon.marchi@ericsson.com> To: gdb-patches@sourceware.org Cc: Simon Marchi <simon.marchi@ericsson.com> Subject: [PATCH v2] Add mi-threads-interrupt.exp test (PR 20039) Date: Thu, 05 May 2016 18:19:00 -0000 Message-Id: <1462472343-17772-1-git-send-email-simon.marchi@ericsson.com> X-Poly-FromMTA: (Sansfil-Public-Lassonde-201-57.polymtl.ca [132.207.201.57]) at Thu, 5 May 2016 18:19:04 +0000 X-IsSubscribed: yes X-SW-Source: 2016-05/txt/msg00075.txt.bz2 Content-length: 5280 Add a new test for PR 20039. The test spawns new threads, then tries to interrupt, continue, and interrupt again. This use case was fixed by commit 5fe966540d6b748f825774868463003700f0c878 in master, but gdb 7.11 is affected (so if you try it on the gdb-7.11-branch right now, the test will fail). New in v2, the test now handles mi-async on mode properly. The failure was specific to mi-async off, but I don't think it's bad to test the same thing under async on mode. I added a little hack when running in async mode to work around bug 20045. I also removed one continue/interrupt pair, as a single one was enough to trigger the problem. gdb/testsuite/ChangeLog: * gdb.mi/mi-threads-interrupt.c: New file. * gdb.mi/mi-threads-interrupt.exp: New file. --- gdb/testsuite/gdb.mi/mi-threads-interrupt.c | 61 ++++++++++++++++++++++ gdb/testsuite/gdb.mi/mi-threads-interrupt.exp | 75 +++++++++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 gdb/testsuite/gdb.mi/mi-threads-interrupt.c create mode 100644 gdb/testsuite/gdb.mi/mi-threads-interrupt.exp diff --git a/gdb/testsuite/gdb.mi/mi-threads-interrupt.c b/gdb/testsuite/gdb.mi/mi-threads-interrupt.c new file mode 100644 index 0000000..8747806 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-threads-interrupt.c @@ -0,0 +1,61 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2016 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include <pthread.h> +#include <unistd.h> + +#define NUM_THREADS 2 + +static pthread_barrier_t barrier; + +static void * +thread_func (void *v) +{ + int i; + + pthread_barrier_wait (&barrier); + + for (i = 0; i < 100; i++) + sleep (1); +} + +static void +all_threads_created (void) +{ +} + +int +main(void) +{ + int i; + pthread_t threads[NUM_THREADS]; + + /* +1 to account for the main thread */ + pthread_barrier_init (&barrier, NULL, NUM_THREADS + 1); + + for (i = 0; i < NUM_THREADS; i++) + pthread_create (&threads[i], NULL, thread_func, NULL); + + pthread_barrier_wait (&barrier); + + all_threads_created (); + + for (i = 0; i < 100; i++) + sleep (1); + + return 0; +} diff --git a/gdb/testsuite/gdb.mi/mi-threads-interrupt.exp b/gdb/testsuite/gdb.mi/mi-threads-interrupt.exp new file mode 100644 index 0000000..af5d99b --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-threads-interrupt.exp @@ -0,0 +1,75 @@ +# Copyright 2016 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +load_lib mi-support.exp +set MIFLAGS "-i=mi" + +standard_testfile + +if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable {debug}] != "" } { + return -1 +} + +# This tests the resolution of PR 20039. +# +# With a multi-threaded inferior and with MI/all-stop, it was not possible +# to interrupt it with ctrl-C after a continue. + +proc test_continue_interrupt { } { + global binfile + global async + + gdb_exit + if {[mi_gdb_start]} { + continue + } + + # Load the binary in gdb... + mi_gdb_load $binfile + + # ... and run it. + # + # Note this test relies on mi_runto deleting the breakpoint. + # A step-over here would mask the bug. + mi_runto "all_threads_created" + + # Consistency check. + mi_check_thread_states {"stopped" "stopped" "stopped"} "check thread states" + + # Continue. + mi_gdb_test "565-exec-continue" "565\\^running\r\n\\*running,thread-id=\"all\"" "continue" + if { $async } { + # Workaround for PR 20045, where -exec-continue will output two (gdb) prompts + # when in "mi-async on" mode. This mi_gdb_test will consume the extra (gdb). + # Once that bug is fixed, this can be removed. + mi_gdb_test + } + + # Wait a bit to make sure all MI events are sent, before sending the + # interruption request. + sleep 1 + + # Send the interrupt request. + if { $async } { + mi_gdb_test "888-exec-interrupt" "888\\^done" "interrupt" + } else { + send_gdb "\003" + } + + # Wait for the *stopped. + mi_expect_interrupt "interrupt reported" +} + +test_continue_interrupt -- 2.8.2 ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2016-05-05 13:50 UTC | newest] Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-03-30 15:17 [PATCH 1/2] Fix write endianness/size problem for fast tracepoint enabled flag Simon Marchi 2016-03-30 15:17 ` [PATCH 2/2] Add test for fast tracepoint enable/disable Simon Marchi 2016-03-31 10:58 ` Yao Qi 2016-03-31 18:01 ` Simon Marchi 2016-03-31 18:31 ` Simon Marchi 2016-04-01 13:36 ` Yao Qi 2016-04-01 14:42 ` Simon Marchi 2016-04-28 15:30 ` Simon Marchi 2016-04-28 16:03 ` Yao Qi 2016-04-28 16:57 ` Simon Marchi 2016-03-31 10:51 ` [PATCH 1/2] Fix write endianness/size problem for fast tracepoint enabled flag Yao Qi 2016-03-31 11:33 ` Pedro Alves 2016-03-31 12:58 ` Yao Qi 2016-03-31 17:45 ` Simon Marchi 2016-05-05 7:58 ` Yao Qi 2016-05-05 13:50 ` Simon Marchi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox