From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10383 invoked by alias); 9 Dec 2011 05:40:35 -0000 Received: (qmail 10101 invoked by uid 22791); 9 Dec 2011 05:40:32 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,TW_XP X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 09 Dec 2011 05:40:18 +0000 Received: from nat-jpt.mentorg.com ([192.94.33.2] helo=PR1-MAIL.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1RYtBw-0001tT-7Q from Yao_Qi@mentor.com ; Thu, 08 Dec 2011 21:40:16 -0800 Received: from [127.0.0.1] ([172.16.63.104]) by PR1-MAIL.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 9 Dec 2011 14:40:13 +0900 Message-ID: <4EE19F37.4070604@codesourcery.com> Date: Fri, 09 Dec 2011 08:19:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1 MIME-Version: 1.0 To: Hui Zhu CC: Stan Shebs , gdb-patches@sourceware.org Subject: Re: [PATCH] Fix tracepoint tstart again get gdb_assert References: <4EDEE6D8.8010301@codesourcery.com> <4EDFFBB4.1070007@earthlink.net> In-Reply-To: Content-Type: multipart/mixed; boundary="------------020809020504090408030806" X-IsSubscribed: yes 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 X-SW-Source: 2011-12/txt/msg00278.txt.bz2 This is a multi-part message in MIME format. --------------020809020504090408030806 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-length: 1801 On 12/08/2011 11:40 AM, Hui Zhu wrote: > Hi guys, > > I am sorry that I didn't talk clear about the issue of tstatus. > When we use tstatus, it can auto set the tracepoint back to stop when > it full or got error. Then user can use tstart without tstop that set > loc->inserted. So we will still meet that issue if we just set > loc->inserted in tstop. > > For examp: > This gdb is just set loc->inserted in tstop but not tstatus. > (gdb) tstart > (gdb) tstop > (gdb) tstart > (gdb) tstop > (gdb) tstart > xxx > xxx > (gdb) tstatus > Trace stopped because the buffer was full. > Buffer contains 0 trace frames (of 49072 created total). > Trace buffer has 908408 bytes of 10414080 bytes free (91% full). > Trace will stop if GDB disconnects. > Not looking at any trace frame. > (gdb) tstart > ../../src/gdb/tracepoint.c:1770: internal-error: start_tracing: > Assertion `!loc->inserted' failed. > A problem internal to GDB has been detected, > further debugging may prove unreliable. > Quit this debugging session? (y or n) n > > ../../src/gdb/tracepoint.c:1770: internal-error: start_tracing: > Assertion `!loc->inserted' failed. > A problem internal to GDB has been detected, > further debugging may prove unreliable. > Create a core file of GDB? (y or n) n This internal-error is caused by two consequent `tstart' commands, and `inserted' flag is not cleared before calling start_tracing for the 2nd `tstart' command. My patch (on base of Hui's version) fixes this problem by 1) clearing `inserted' flag at stop_tracing, and 2) calling stop_tracing in start_tracing when existing tracing is still running. There is no existing test case fit for this test, so I create a new test case gdb.trace/tstart.exp. Patch is tested on x86_64-linux, OK for mainline and 7.4 branch? -- Yao (齐尧) --------------020809020504090408030806 Content-Type: text/x-patch; name="0001-clear-inserted-in-stop_tracing.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-clear-inserted-in-stop_tracing.patch" Content-length: 1289 2011-12-08 Hui Zhu Yao Qi * tracepoint.c (trace_start_command): Call sto_tracing. (stop_tracing): Clear `inserted' flag in each location. --- gdb/tracepoint.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index e00538c..ac6d112 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -1824,6 +1824,8 @@ trace_start_command (char *args, int from_tty) if (from_tty && !query (_("A trace is running already. Start a new run? "))) error (_("New trace run not started.")); + + stop_tracing (NULL); } start_tracing (args); @@ -1847,6 +1849,9 @@ void stop_tracing (char *note) { int ret; + VEC(breakpoint_p) *tp_vec = NULL; + int ix; + struct breakpoint *b; target_trace_stop (); @@ -1859,6 +1864,16 @@ stop_tracing (char *note) /* Should change in response to reply? */ current_trace_status ()->running = 0; + + tp_vec = all_tracepoints (); + for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, b); ix++) + { + struct bp_location *loc; + + for (loc = b->loc; loc; loc = loc->next) + loc->inserted = 0; + } + VEC_free (breakpoint_p, tp_vec); } /* tstatus command */ -- 1.7.0.4 --------------020809020504090408030806 Content-Type: text/x-patch; name="0002-tstart.exp.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002-tstart.exp.patch" Content-length: 3060 2011-12-08 Yao Qi * gdb.trace/tstart.exp: New. --- gdb/testsuite/gdb.trace/tstart.exp | 88 ++++++++++++++++++++++++++++++++++++ 1 files changed, 88 insertions(+), 0 deletions(-) create mode 100644 gdb/testsuite/gdb.trace/tstart.exp diff --git a/gdb/testsuite/gdb.trace/tstart.exp b/gdb/testsuite/gdb.trace/tstart.exp new file mode 100644 index 0000000..2690dad --- /dev/null +++ b/gdb/testsuite/gdb.trace/tstart.exp @@ -0,0 +1,88 @@ +# Copyright 2011 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"; + +set testfile "tstart" +set executable $testfile +set srcfile collection.c +set binfile $objdir/$subdir/$testfile +set expfile $testfile.exp + + +if [prepare_for_testing $expfile $executable $srcfile \ + {debug nowarnings}] { + untested "failed to prepare for trace tests" + return -1 +} + +# Verify that the sequence of commands "tstart tstop tstart" works well. + +proc test_tstart_tstop_tstart { } { + global executable + global pf_prefix + global hex + + set old_pf_prefix $pf_prefix + set pf_prefix "$pf_prefix tstart_tstop_tstart:" + + # Start with a fresh gdb. + clean_restart ${executable} + if ![runto_main] { + fail "Can't run to main" + set pf_prefix $old_pf_prefix + return -1 + } + + gdb_test "trace args_test_func" "Tracepoint \[0-9\] at $hex: file.*" + gdb_test_no_output "tstart" + + gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*" + gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end" + + gdb_test_no_output "tstop" + + gdb_test_no_output "tstart" + + set pf_prefix $old_pf_prefix +} + +# Verify the sequence of commands "tstart tstart" works well. + +proc test_tstart_tstart { } { + global executable + global pf_prefix + global hex + + set old_pf_prefix $pf_prefix + set pf_prefix "$pf_prefix tstart_tstart:" + + # Start with a fresh gdb. + clean_restart ${executable} + if ![runto_main] { + fail "Can't run to main" + set pf_prefix $old_pf_prefix + return -1 + } + + gdb_test "trace args_test_func" "Tracepoint \[0-9\] at $hex: file.*" + gdb_test_no_output "tstart" + + gdb_test "tstart" "" "tstart again" "A trace is running already. Start a new run\\? \\(y or n\\) " "y" + +} + +test_tstart_tstop_tstart + +test_tstart_tstart \ No newline at end of file -- 1.7.0.4 --------------020809020504090408030806--