From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31659 invoked by alias); 24 Mar 2013 11:33:18 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 31645 invoked by uid 89); 24 Mar 2013 11:33:10 -0000 X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.1 Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sun, 24 Mar 2013 11:33:06 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1UJjAe-0000Lt-Ah from Hui_Zhu@mentor.com ; Sun, 24 Mar 2013 04:33:04 -0700 Received: from SVR-ORW-FEM-04.mgc.mentorg.com ([147.34.97.41]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Sun, 24 Mar 2013 04:33:03 -0700 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.1.289.1; Sun, 24 Mar 2013 04:33:02 -0700 Message-ID: <514EE46A.4070808@mentor.com> Date: Sun, 24 Mar 2013 23:23:00 -0000 From: Hui Zhu User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20130126 Thunderbird/19.0 MIME-Version: 1.0 To: gdb-patches ml CC: Stan Shebs , Joel Brobecker Subject: [PATCH] Reset tracepoint step_count to 0 before set it action Content-Type: multipart/mixed; boundary="------------000603000200000808070809" X-Virus-Found: No X-SW-Source: 2013-03/txt/msg00896.txt.bz2 --------------000603000200000808070809 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 2281 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 * 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 * gdb.trace/Makefile.in (PROGS): Add actions-changed. * gdb.trace/actions-changed.c: New. * gdb.trace/actions-changed.exp: New. --------------000603000200000808070809 Content-Type: text/plain; charset="us-ascii"; name="tp-actions-clear-step_count.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="tp-actions-clear-step_count.txt" Content-length: 1066 --- 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); --------------000603000200000808070809 Content-Type: text/plain; charset="us-ascii"; name="tp-actions-clear-step_count-test.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="tp-actions-clear-step_count-test.txt" Content-length: 5155 --- 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 . */ + +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 . + +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 --------------000603000200000808070809--