From: Markus Metzger <markus.t.metzger@intel.com>
To: palves@redhat.com
Cc: gdb-patches@sourceware.org, Eli Zaretskii <eliz@gnu.org>
Subject: [PATCH v3 13/19] btrace: non-stop
Date: Thu, 17 Sep 2015 14:10:00 -0000 [thread overview]
Message-ID: <1442498990-1222-14-git-send-email-markus.t.metzger@intel.com> (raw)
In-Reply-To: <1442498990-1222-1-git-send-email-markus.t.metzger@intel.com>
Support non-stop mode in record btrace.
CC: Eli Zaretskii <eliz@gnu.org>
2015-09-17 Markus Metzger <markus.t.metzger@intel.com>
gdb/
* record-btrace.c (record_btrace_open): Remove non_stop check.
* NEWS: Announce that record btrace supports non-stop mode.
testsuite/
* gdb.btrace/non-stop.c: New.
* gdb.btrace/non-stop.exp: New.
---
gdb/NEWS | 2 +
gdb/record-btrace.c | 3 -
gdb/testsuite/gdb.btrace/non-stop.c | 45 +++++++
gdb/testsuite/gdb.btrace/non-stop.exp | 245 ++++++++++++++++++++++++++++++++++
4 files changed, 292 insertions(+), 3 deletions(-)
create mode 100644 gdb/testsuite/gdb.btrace/non-stop.c
create mode 100644 gdb/testsuite/gdb.btrace/non-stop.exp
diff --git a/gdb/NEWS b/gdb/NEWS
index f563b8c..0d17ef4 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,8 @@
*** Changes since GDB 7.10
+* Record btrace now supports non-stop mode.
+
* Support for tracepoints on aarch64-linux was added in GDBserver.
* The 'record instruction-history' command now indicates speculative execution
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 764b349..8eefae2 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -216,9 +216,6 @@ record_btrace_open (const char *args, int from_tty)
if (!target_has_execution)
error (_("The program is not being run."));
- if (non_stop)
- error (_("Record btrace can't debug inferior in non-stop mode."));
-
gdb_assert (record_btrace_thread_observer == NULL);
disable_chain = make_cleanup (null_cleanup, NULL);
diff --git a/gdb/testsuite/gdb.btrace/non-stop.c b/gdb/testsuite/gdb.btrace/non-stop.c
new file mode 100644
index 0000000..2fc8dfb
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/non-stop.c
@@ -0,0 +1,45 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2015 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>
+
+static int global;
+
+static void *
+test (void *arg)
+{
+ unsigned int i;
+
+ i = 0; /* bp.1 */
+ for (; i < 10; ++i) global += i; /* loop */
+
+ return arg; /* bp.2 */
+}
+
+int
+main (void)
+{
+ pthread_t th;
+
+ pthread_create (&th, NULL, test, NULL);
+
+ test (NULL);
+
+ pthread_join (th, NULL);
+
+ return 0; /* bp.3 */
+}
diff --git a/gdb/testsuite/gdb.btrace/non-stop.exp b/gdb/testsuite/gdb.btrace/non-stop.exp
new file mode 100644
index 0000000..bc4ffb1
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/non-stop.exp
@@ -0,0 +1,245 @@
+# This testcase is part of GDB, the GNU debugger.
+#
+# Copyright 2015 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/>.
+
+# check for btrace support
+if { [skip_btrace_tests] } { return -1 }
+
+
+# start inferior
+standard_testfile
+if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" "$binfile" executable {debug}] != "" } {
+ return -1
+}
+clean_restart $testfile
+
+gdb_test_no_output "set non-stop on"
+
+if ![runto_main] {
+ return -1
+}
+
+# set up breakpoints
+set bp_1 [gdb_get_line_number "bp.1" $srcfile]
+set bp_2 [gdb_get_line_number "bp.2" $srcfile]
+set bp_3 [gdb_get_line_number "bp.3" $srcfile]
+
+gdb_breakpoint $bp_1
+gdb_breakpoint $bp_2
+
+# get the line number containing most of the trace
+set loop [gdb_get_line_number "loop" $srcfile]
+
+# a stop on the above line as reported by GDB
+set loop_line "$loop\[^\\\r\\\n\]*/\\\* loop \\\*/"
+
+# make sure $line matches the full expected output per thread.
+# and let's hope that GDB never mixes the output from different threads.
+proc gdb_cont_to { threads cmd line nthreads } {
+ global gdb_prompt
+ set full_cmd "thread apply $threads $cmd"
+
+ # consume the prompt. since we started the command in the background,
+ # the prompt precedes any further output except some errors.
+ gdb_test_multiple "$full_cmd &" "$full_cmd: prompt" {
+ -re "$gdb_prompt " {
+ pass "$full_cmd: prompt"
+ }
+ }
+
+ # now check for the expected line - one per thread.
+ for {set i 0} {$i < $nthreads} {incr i} {
+ set test "$full_cmd: thread $i"
+
+ gdb_test_multiple "" $test {
+ -re "$line\[^\\\r\\\n\]*\r\n" {
+ pass $test
+ }
+ }
+ }
+}
+
+proc gdb_cont_to_bp_line { line threads nthreads } {
+ gdb_cont_to $threads "continue" \
+ [multi_line \
+ "Breakpoint\[^\\\r\\\n\]*$line" \
+ "\[^\\\r\\\n\]*" \
+ ] \
+ $nthreads
+}
+
+proc gdb_cont_to_no_history { threads cmd nthreads } {
+ gdb_cont_to $threads $cmd \
+ [multi_line \
+ "No more reverse-execution history\." \
+ "\[^\\\r\\\n\]*" \
+ "\[^\\\r\\\n\]*" \
+ ] \
+ $nthreads
+}
+
+# trace the code between the two breakpoints
+gdb_cont_to_bp_line "$srcfile:$bp_1" all 2
+gdb_test_no_output "record btrace"
+gdb_cont_to_bp_line "$srcfile:$bp_2" all 2
+
+# we don't need those breakpoints any longer.
+# they will only disturb our stepping.
+delete_breakpoints
+
+# show the threads - this is useful for debugging fails
+gdb_test "thread apply all info rec" ".*"
+gdb_test "info threads" ".*"
+
+with_test_prefix "navigate" {
+ gdb_test "thread apply 1 record goto 2" "$loop_line"
+ gdb_test "thread apply 2 record goto 4" "$loop_line"
+ gdb_test "thread apply 1 info record" \
+ ".*Replay in progress\. At instruction 2\."
+ gdb_test "thread apply 2 info record" \
+ ".*Replay in progress\. At instruction 4\."
+
+ gdb_test "thread apply all record goto 5" "$loop_line"
+ gdb_test "thread apply 1 info record" \
+ ".*Replay in progress\. At instruction 5\."
+ gdb_test "thread apply 2 info record" \
+ ".*Replay in progress\. At instruction 5\."
+}
+
+with_test_prefix "step" {
+ with_test_prefix "thread 1" {
+ gdb_test "thread apply 1 stepi 2" "$loop_line"
+ gdb_test "thread apply 1 info record" \
+ ".*Replay in progress\. At instruction 7\."
+ gdb_test "thread apply 2 info record" \
+ ".*Replay in progress\. At instruction 5\."
+ }
+
+ with_test_prefix "thread 2" {
+ gdb_test "thread apply 2 stepi 3" "$loop_line"
+ gdb_test "thread apply 1 info record" \
+ ".*Replay in progress\. At instruction 7\."
+ gdb_test "thread apply 2 info record" \
+ ".*Replay in progress\. At instruction 8\."
+ }
+
+ with_test_prefix "all" {
+ gdb_cont_to all "stepi 4" "$loop_line" 2
+ gdb_test "thread apply 1 info record" \
+ ".*Replay in progress\. At instruction 11\."
+ gdb_test "thread apply 2 info record" \
+ ".*Replay in progress\. At instruction 12\."
+ }
+}
+
+with_test_prefix "reverse-step" {
+ with_test_prefix "thread 1" {
+ gdb_test "thread apply 1 reverse-stepi 2" "$loop_line"
+ gdb_test "thread apply 1 info record" \
+ ".*Replay in progress\. At instruction 9\."
+ gdb_test "thread apply 2 info record" \
+ ".*Replay in progress\. At instruction 12\."
+ }
+
+ with_test_prefix "thread 2" {
+ gdb_test "thread apply 2 reverse-stepi 3" "$loop_line"
+ gdb_test "thread apply 1 info record" \
+ ".*Replay in progress\. At instruction 9\."
+ gdb_test "thread apply 2 info record" \
+ ".*Replay in progress\. At instruction 9\."
+ }
+
+ with_test_prefix "all" {
+ gdb_cont_to all "reverse-stepi 4" "$loop_line" 2
+ gdb_test "thread apply 1 info record" \
+ ".*Replay in progress\. At instruction 5\."
+ gdb_test "thread apply 2 info record" \
+ ".*Replay in progress\. At instruction 5\."
+ }
+}
+
+with_test_prefix "continue" {
+ with_test_prefix "thread 1" {
+ gdb_cont_to_no_history 1 "continue" 1
+ gdb_test "thread apply 1 info record" \
+ ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
+ gdb_test "thread apply 2 info record" \
+ ".*Replay in progress\. At instruction 5\."
+
+ gdb_cont_to_no_history 1 "reverse-continue" 1
+ gdb_test "thread apply 1 info record" \
+ ".*Replay in progress\. At instruction 1\."
+ gdb_test "thread apply 2 info record" \
+ ".*Replay in progress\. At instruction 5\."
+ }
+
+ with_test_prefix "thread 2" {
+ gdb_cont_to_no_history 2 "continue" 1
+ gdb_test "thread apply 1 info record" \
+ ".*Replay in progress\. At instruction 1\."
+ gdb_test "thread apply 2 info record" \
+ ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
+
+ gdb_cont_to_no_history 2 "reverse-continue" 1
+ gdb_test "thread apply 1 info record" \
+ ".*Replay in progress\. At instruction 1\."
+ gdb_test "thread apply 2 info record" \
+ ".*Replay in progress\. At instruction 1\."
+ }
+}
+
+# a thread may only resume if no thread is still replaying
+with_test_prefix "no progress" {
+ with_test_prefix "thread 1" {
+ gdb_test "thread apply 1 record goto end" ".*"
+ gdb_test "thread apply 2 record goto begin" ".*"
+
+ gdb_cont_to_no_history 1 "continue" 1
+ gdb_cont_to_no_history 1 "step" 1
+ gdb_test "thread apply 1 info record" \
+ ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
+ gdb_test "thread apply 2 info record" \
+ ".*Replay in progress\. At instruction 1\."
+ }
+
+ with_test_prefix "thread 2" {
+ gdb_test "thread apply 1 record goto begin" ".*"
+ gdb_test "thread apply 2 record goto end" ".*"
+
+ gdb_cont_to_no_history 2 "continue" 1
+ gdb_cont_to_no_history 2 "step" 1
+ gdb_test "thread apply 1 info record" \
+ ".*Replay in progress\. At instruction 1\."
+ gdb_test "thread apply 2 info record" \
+ ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
+ }
+
+ with_test_prefix "all" {
+ gdb_test "thread apply all record goto begin" ".*"
+
+ gdb_cont_to_no_history all "continue" 2
+ gdb_test "thread apply 1 info record" \
+ ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
+ gdb_test "thread apply 2 info record" \
+ ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
+ }
+}
+
+# now that both threads stopped replaying we may resume recording
+with_test_prefix "cont to end" {
+ gdb_breakpoint $bp_3
+ gdb_cont_to_bp_line "$srcfile:$bp_3" all 1
+}
--
1.8.3.1
next prev parent reply other threads:[~2015-09-17 14:10 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-17 14:10 [PATCH v3 00/19] record btrace: non-stop, scheduler-locking, and ASNS Markus Metzger
2015-09-17 14:09 ` [PATCH v3 01/19] btrace: fix non-stop check in to_wait Markus Metzger
2015-09-17 14:10 ` [PATCH v3 05/19] btrace: split record_btrace_step_thread Markus Metzger
2015-09-17 14:10 ` [PATCH v3 10/19] btrace: temporarily set inferior_ptid in record_btrace_start_replaying Markus Metzger
2015-09-17 14:10 ` [PATCH v3 18/19] infrun: scheduler-locking replay Markus Metzger
2015-09-18 11:39 ` Pedro Alves
2015-09-17 14:10 ` [PATCH v3 04/19] btrace: extract the breakpoint check from record_btrace_step_thread Markus Metzger
2015-09-17 14:10 ` [PATCH v3 16/19] target: add to_record_stop_replaying target method Markus Metzger
2015-09-17 14:10 ` [PATCH v3 15/19] btrace: allow full memory and register access for non-replaying threads Markus Metzger
2015-09-17 14:10 ` [PATCH v3 06/19] btrace: move breakpoint checking into stepping functions Markus Metzger
2015-09-17 14:10 ` [PATCH v3 02/19] btrace: support to_stop Markus Metzger
2015-09-17 14:10 ` [PATCH v3 14/19] target, record: add PTID argument to to_record_is_replaying Markus Metzger
2015-09-17 14:10 ` [PATCH v3 09/19] btrace: resume all requested threads Markus Metzger
2015-09-17 14:10 ` [PATCH v3 12/19] infrun: switch to NO_HISTORY thread Markus Metzger
2015-09-17 14:10 ` [PATCH v3 17/19] target: add to_record_will_replay target method Markus Metzger
2015-09-18 11:39 ` Pedro Alves
2015-09-17 14:10 ` Markus Metzger [this message]
2015-09-17 14:10 ` [PATCH v3 03/19] btrace: improve stepping debugging Markus Metzger
2015-09-17 14:10 ` [PATCH v3 11/19] btrace: async Markus Metzger
2015-09-17 14:10 ` [PATCH v3 19/19] btrace: honour scheduler-locking for all-stop targets Markus Metzger
2015-09-18 11:39 ` Pedro Alves
2015-09-17 14:10 ` [PATCH v3 08/19] btrace: lock-step Markus Metzger
2015-09-17 14:10 ` [PATCH v3 07/19] btrace: add missing NO_HISTORY Markus Metzger
2015-09-18 11:41 ` [PATCH v3 00/19] record btrace: non-stop, scheduler-locking, and ASNS Pedro Alves
2015-09-18 11:52 ` Metzger, Markus T
2015-09-18 11:56 ` Jan Kratochvil
2015-09-18 12:14 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1442498990-1222-14-git-send-email-markus.t.metzger@intel.com \
--to=markus.t.metzger@intel.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox