Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Hui Zhu <hui_zhu@mentor.com>
To: gdb-patches ml <gdb-patches@sourceware.org>
Cc: Stan Shebs <stan@codesourcery.com>,
	Joel Brobecker <brobecker@adacore.com>
Subject: [PATCH] Reset tracepoint step_count to 0 before set it action
Date: Sun, 24 Mar 2013 23:23:00 -0000	[thread overview]
Message-ID: <514EE46A.4070808@mentor.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2281 bytes --]

Hi,

If a tracepoint's action include a while-stepping, when it set to actions without while-stepping.  The step_count will keep to its old value.  For example:
(gdb) trace subr
Tracepoint 1 at 0x4004d9: file ../../../src/gdb/testsuite//actions-changed.c, line 31.
(gdb) actions
Enter actions for tracepoint 1, one per line.
End with a line saying just "end".
>collect $reg
>end
(gdb) set debug remote 1
(gdb) tstart
Sending packet: $QTinit#59...Packet received: OK
Sending packet: $QTDP:1:00000000004004d9:E:0:0-#a3...Packet received: OK
Sending packet: $QTDP:-1:00000000004004d9:R03FFFFFFFFFFFFFFFFFF#2b...Packet received: OK
(gdb) tstop
Sending packet: $QTStop#4b...Packet received: OK
Sending packet: $QTNotes:#e8...Packet received: OK
(gdb) actions
Enter actions for tracepoint 1, one per line.
End with a line saying just "end".
>collect $reg
>while-stepping 1
  >collect $reg
  >end
>end
(gdb) tstart
Sending packet: $QTinit#59...Packet received: OK
Sending packet: $QTDP:1:00000000004004d9:E:1:0-#a4...Packet received: OK
Sending packet: $QTDP:-1:00000000004004d9:R03FFFFFFFFFFFFFFFFFF-#58...Packet received: OK
Sending packet: $QTDP:-1:00000000004004d9:SR03FFFFFFFFFFFFFFFFFF#7e...Packet received: OK
(gdb) tstop
Sending packet: $QTStop#4b...Packet received: OK
Sending packet: $QTNotes:#e8...Packet received: OK
(gdb) actions
Enter actions for tracepoint 1, one per line.
End with a line saying just "end".
>collect $regs
>end
(gdb) tstart
Sending packet: $QTinit#59...Packet received: OK
Sending packet: $QTDP:1:00000000004004d9:E:1:0-#a4...Packet received: OK
Sending packet: $QTDP:-1:00000000004004d9:R03FFFFFFFFFFFFFFFFFF#2b...Packet received: OK

The last "$QTDP:1:00000000004004d9:E:1:0-#a4" should be "$QTDP:1:00000000004004d9:E:0:0-#a3".

Post a patch to fix it and there also a test for this issue.

Please help me review it.  And I suggest this change can be checked to 7.6 branch.

Thanks,
Hui

2013-03-24  Hui Zhu  <hui@codesourcery.com>

	* breakpoint.c (do_map_commands_command): Reset step_count to 0
	if this is a tracepoint.
	* tracepoint.c (trace_actions_command): Ditto.

2013-03-24  Stan Shebs  <stan@codesourcery.com>

	* gdb.trace/Makefile.in (PROGS): Add actions-changed.
	* gdb.trace/actions-changed.c: New.
	* gdb.trace/actions-changed.exp: New.

[-- Attachment #2: tp-actions-clear-step_count.txt --]
[-- Type: text/plain, Size: 1066 bytes --]

--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1296,6 +1296,16 @@ do_map_commands_command (struct breakpoi
 {
   struct commands_info *info = data;
 
+  if (b->type == bp_tracepoint)
+    {
+      struct tracepoint *t = (struct tracepoint *) b;
+
+      /* Reset the step count to 0 because if this tracepoint has step
+         action in before, it will not reset it to 0 if new actions
+         doesn't have while-stepping.  */
+      t->step_count = 0;
+    }
+
   if (info->cmd == NULL)
     {
       struct command_line *l;
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -666,6 +666,11 @@ trace_actions_command (char *args, int f
 		    t->base.number);
       struct cleanup *cleanups = make_cleanup (xfree, tmpbuf);
 
+      /* Reset the step count to 0 because if this tracepoint has step
+         action in before, it will not reset it to 0 if new actions
+         doesn't have while-stepping.  */
+      t->step_count = 0;
+
       l = read_command_lines (tmpbuf, from_tty, 1,
 			      check_tracepoint_command, t);
       do_cleanups (cleanups);

[-- Attachment #3: tp-actions-clear-step_count-test.txt --]
[-- Type: text/plain, Size: 5155 bytes --]

--- a/gdb/testsuite/gdb.trace/Makefile.in
+++ b/gdb/testsuite/gdb.trace/Makefile.in
@@ -3,9 +3,9 @@ srcdir = @srcdir@
 
 .PHONY: all clean mostlyclean distclean realclean
 
-PROGS = ax backtrace deltrace disconnected-tracing infotrace packetlen \
-	passc-dyn passcount report save-trace tfile tfind tracecmd tsv \
-	unavailable while-dyn while-stepping
+PROGS = actions-changed ax backtrace deltrace disconnected-tracing \
+	infotrace packetlen passc-dyn passcount report save-trace tfile \
+	tfind tracecmd tsv unavailable while-dyn while-stepping
 
 all info install-info dvi install uninstall installcheck check:
 	@echo "Nothing to be done for $@..."
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/actions-changed.c
@@ -0,0 +1,65 @@
+/* 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/>.  */
+
+int
+begin ()
+{
+}
+
+int
+middle ()
+{
+}
+
+int
+later ()
+{
+}
+
+int
+endish ()
+{
+}
+
+int
+end ()
+{
+}
+
+int
+subr (int parm)
+{
+  int keeping, busy;
+
+  keeping = parm + parm;
+  busy = keeping * keeping;
+
+  return busy;
+}
+
+main()
+{
+  begin ();
+  subr (1);
+  middle ();
+  subr (2);
+  later ();
+  subr (3);
+  endish ();
+  subr (4);
+  end ();
+}
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/actions-changed.exp
@@ -0,0 +1,121 @@
+# 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 actions-changed.c
+if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
+	  executable {debug nowarnings}] != "" } {
+    untested actions-changed.exp
+    return -1
+}
+
+proc test_actions_changed { } \
+{
+    gdb_breakpoint "begin"
+    gdb_breakpoint "middle"
+    gdb_breakpoint "later"
+    gdb_breakpoint "endish"
+    gdb_breakpoint "end"
+
+    gdb_test "continue" ".*Breakpoint \[0-9\]+, begin .*" \
+	"advance to tracing"
+
+    gdb_test "trace subr" "Tracepoint .*" \
+	"tracepoint at subr"
+
+    # First pass, define simple action
+
+    gdb_trace_setactions "define simple action" \
+	"" \
+	"collect parm" "^$"
+
+    gdb_test_no_output "tstart"
+
+    gdb_test "continue" ".*Breakpoint \[0-9\]+, middle .*" \
+	"advance through tracing, 1st"
+
+    gdb_test "tstatus" ".*Collected 1 trace frame.*" \
+	"check on first trace status"
+
+    gdb_test_no_output "tstop"
+
+    # Redefine action, run second trace
+
+    gdb_trace_setactions "redefine simple action" \
+	"" \
+	"collect keeping, busy" "^$"
+
+    gdb_test_no_output "tstart"
+
+    gdb_test "continue" ".*Breakpoint \[0-9\]+, later .*" \
+	"advance through tracing, 2nd"
+
+    gdb_test "tstatus" ".*Collected 1 trace frame.*" \
+	"check on redefined trace status"
+
+    gdb_test_no_output "tstop"
+
+    # Redefine to stepping action, run third trace
+
+    gdb_trace_setactions "redefine to stepping action" \
+	"" \
+	"collect parm" "^$" \
+	"while-stepping 5" "^$" \
+	"collect parm" "^$" \
+	"end" "^$"
+
+    gdb_test_no_output "tstart"
+
+    gdb_test "continue" ".*Breakpoint \[0-9\]+, endish .*" \
+	"advance through tracing, 3rd"
+
+    gdb_test "tstatus" ".*Collected 6 trace frame.*" \
+	"check on stepping trace status"
+
+    gdb_test_no_output "tstop"
+
+    # Redefine to non-stepping, run fourth trace.
+
+    gdb_trace_setactions "redefine to non-stepping action" \
+	"" \
+	"collect parm" "^$"
+
+    gdb_test_no_output "tstart"
+
+    gdb_test "continue" ".*Breakpoint \[0-9\]+, end .*" \
+	"advance to tracing, 4th"
+
+    gdb_test "tstatus" ".*Collected 1 trace frame.*" \
+	"check on redefined non-stepping trace status"
+}
+
+# Test if target supports tracepoints or not.
+
+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 "Current target does not support trace"
+    return -1;
+}
+
+test_actions_changed
+
+return 0

             reply	other threads:[~2013-03-24 11:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-24 23:23 Hui Zhu [this message]
2013-03-25  2:39 ` Yao Qi
2013-03-25  7:52   ` Hui Zhu
2013-03-25  8:30     ` Yao Qi
2013-04-01  4:52 ` Hui Zhu
2013-04-05 13:03 ` Pedro Alves
2013-04-05 13:03   ` Pedro Alves
2013-04-08  7:58     ` Hui Zhu

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=514EE46A.4070808@mentor.com \
    --to=hui_zhu@mentor.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=stan@codesourcery.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