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]

[PATCH 3/4] tracepoint multithread and multiprocess support (test)


This patch is for the test.
The first parts of trace-multi.exp and trace-multi.c check if GDB and gdbserver is OK to support multithread with trace in thread2's function but set thread of tracepoint to thread1.
The second parts and trace-multi2.c check if GDB and gdbserver is OK to support multiprocess.

Please help me review it.

Thanks,
Hui

2013-12-04  Hui Zhu  <hui@codesourcery.com>

	* gdb.trace/trace-multi.exp: New file.
	* gdb.trace/trace-multi.c: New file.
	* gdb.trace/trace-multi2.c: New file.

--- a/gdb/testsuite/gdb.trace/Makefile.in
+++ b/gdb/testsuite/gdb.trace/Makefile.in
@@ -4,7 +4,8 @@ srcdir = @srcdir@
 .PHONY: all clean mostlyclean distclean realclean
PROGS = actions-changed ax backtrace deltrace disconnected-tracing \
-	infotrace packetlen passc-dyn passcount report save-trace tfile \
+	infotrace packetlen passc-dyn passcount trace-multi \
+	trace-multi2 report save-trace tfile \
 	tfind tracecmd tsv unavailable while-dyn while-stepping
all info install-info dvi install uninstall installcheck check:
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/trace-multi.c
@@ -0,0 +1,53 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2013 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 <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <pthread.h>
+
+void stop ()
+{
+}
+
+int thread_count;
+
+static void *
+thread (void *arg)
+{
+  int i;
+  for (i = 0; i < 5; ++i)
+    sleep (1);	/* set tracepoint1 here */
+}
+
+int main ()
+{
+  int i = 0;
+  pthread_t tid;
+
+  i = pthread_create (&tid, NULL, thread, NULL);
+  assert (i == 0);
+  stop ();
+
+  pthread_join (tid, NULL);
+  stop ();
+
+  while (i < 10)
+    ++i;	/* set tracepoint2 here */
+  stop ();
+  return 0;
+}
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/trace-multi.exp
@@ -0,0 +1,118 @@
+# Copyright 2013 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 exec1 ${testfile}
+set srcfile1 ${exec1}.c
+
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+    return -1
+}
+
+clean_restart ${exec1}
+
+if ![runto_main] {
+    return -1
+}
+
+if ![gdb_target_supports_trace] {
+    unsupported "target does not support trace"
+    return -1
+}
+
+gdb_breakpoint "stop"
+
+# Start thread and check if thread started
+gdb_test "continue" "Continuing.*Breakpoint $decimal.*" "first continue"
+gdb_test "info threads" \
+	 "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n.*2 *Thread.*\r\n.*1 *Thread.*"
+
+# Setup tracepoint1
+gdb_test "trace ${srcfile1}:[gdb_get_line_number "set tracepoint1 here" ${srcfile1}] thread 1" \
+	"Tracepoint $decimal .*" \
+	"set tracepoint1 to thread 1"
+gdb_trace_setactions "set tracepoint1 actions to thread 1" "" \
+	"collect i" "^$"
+
+gdb_test_no_output "tstart"
+gdb_test "continue" "Continuing.*Breakpoint $decimal.*" "second continue"
+gdb_test_no_output "tstop"
+
+gdb_test "tfind" "Target failed to find requested trace frame." "thread tfind"
+
+
+# Following part is multiprocess test
+
+# Multiple inferiors are needed, therefore both native and extended gdbserver
+# modes are supported.  Only non-extended gdbserver is not supported.
+if [target_info exists use_gdb_stub] {
+    untested ${testfile}.exp
+    return
+}
+
+standard_testfile
+set exec2 ${testfile}2
+set srcfile2 ${exec2}.c
+set binfile2 [standard_output_file ${exec2}]
+
+if { [build_executable ${testfile}.exp ${exec2} "${srcfile2}"] == -1 } {
+    return -1
+}
+
+gdb_test "add-inferior -exec ${binfile2}" \
+    "Added inferior 2.*" \
+    "add inferior 2 with -exec ${exec2}"
+
+gdb_test "trace ${srcfile1}:[gdb_get_line_number "set tracepoint2 here" ${srcfile1}]" \
+	"Tracepoint $decimal .*" \
+	"set tracepoint to inferior 1"
+gdb_trace_setactions "set tracepoint actions to inferior 1" "" \
+	"collect i" "^$"
+gdb_test "trace ${srcfile2}:[gdb_get_line_number "set tracepoint here" ${srcfile2}]" \
+	"Tracepoint $decimal .*" \
+	"set tracepoint to inferior 2"
+gdb_trace_setactions "set tracepoint actions to inferior 2" "" \
+	"collect \$reg" "^$"
+
+gdb_test "tstart" ".*" "tstart with tracepoint of inferior 2"
+
+delete_breakpoints
+gdb_test "trace ${srcfile1}:[gdb_get_line_number "set tracepoint2 here" ${srcfile1}]" \
+	"Tracepoint $decimal .*" \
+	"set tracepoint to inferior 1 again"
+gdb_trace_setactions "set tracepoint actions to inferior 1 again" "" \
+	"collect i" "^$"
+
+gdb_test_no_output "tstart"
+gdb_breakpoint "stop"
+gdb_test "continue" "Continuing.*Breakpoint $decimal.*" "run trace"
+gdb_test_no_output "tstop"
+
+gdb_test "tfind"
+gdb_test "print i" " = 0" "Print i 0"
+gdb_test "tfind"
+gdb_test "print i" " = 1" "Print i 1"
+gdb_test "tfind"
+gdb_test "print i" " = 2" "Print i 2"
+gdb_test "tfind"
+gdb_test "print i" " = 3" "Print i 3"
+gdb_test "tfind"
+gdb_test "print i" " = 4" "Print i 4"
+gdb_test "tfind"
+gdb_test "print i" " = 5" "Print i 5"
+gdb_test "tfind"
+gdb_test "print i" " = 6" "Print i 6"
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/trace-multi2.c
@@ -0,0 +1,30 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2013 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/>.  */
+
+void stop ()
+{
+}
+
+int main ()
+{
+  int i = 10;
+
+  while (i > 0)
+    --i;	/* set tracepoint here */
+  stop ();
+  return 0;
+}


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