This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix tracepoint tstart again get gdb_assert
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 (éå)
2011-12-08 Hui Zhu <teawater@gmail.com>
Yao Qi <yao@codesourcery.com>
* 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
2011-12-08 Yao Qi <yao@codesourcery.com>
* 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 <http://www.gnu.org/licenses/>.
+
+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