This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/7] New test case gdb.trace/signal.exp
- From: Pedro Alves <palves at redhat dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 11 Apr 2016 15:03:57 +0100
- Subject: Re: [PATCH 1/7] New test case gdb.trace/signal.exp
- Authentication-results: sourceware.org; auth=none
- References: <1458749384-19793-1-git-send-email-yao dot qi at linaro dot org> <1458749384-19793-2-git-send-email-yao dot qi at linaro dot org> <5707E1CC dot 2010609 at redhat dot com> <86a8l0leqy dot fsf at gmail dot com>
On 04/11/2016 09:40 AM, Yao Qi wrote:
> +# Record the hit times of each tracepoint in this array.
> +array set tracepoint_hits { }
> +
> +set test "tfind 0"
> +gdb_test_multiple $test $test {
Why do we need this separate "tfind 0" step? I'd think the
"tfind" loop below would be sufficient?
> + -re "Found trace frame 0, tracepoint ($decimal).*\r\n$gdb_prompt $" {
> +
> + set idx [expr $expect_out(1,string)]
> +
> + if {[info exists tracepoint_hits($idx)]} {
> + incr tracepoint_hits($idx)
> + } else {
> + set tracepoint_hits($idx) 1
> + }
> + }
> +}
> +
> +set loop 1
> +while { $loop } {
> + set test "tfind"
> + gdb_test_multiple $test $test {
> + -re "Found trace frame $decimal, tracepoint ($decimal).*\r\n$gdb_prompt $" {
> + set idx [expr $expect_out(1,string)]
> +
> + if {[info exists tracepoint_hits($idx)]} {
> + incr tracepoint_hits($idx)
> + } else {
> + set tracepoint_hits($idx) 1
> + }
> + }
> + -re "Target failed to find requested trace frame\..*\r\n$gdb_prompt $" {
> + set loop 0
> + }
> + }
If this gdb_test_multiple FAILs or times out, the loop
will continue, over and over, forever. So we need to reverse
the logic -- assume no looping, unless the "Found trace ..." regex matched.
I'd also suggest to preinitialize the array elements to 0, avoiding
the "info exists" calls in "Step 3", here:
> +# Step 3, check the number of collections on each tracepoint.
> +
> +for { set i $tpnum } { $i < [expr $tpnum + 2] } { incr i } {
> + if {[info exists tracepoint_hits($i)]} {
> + gdb_assert { $tracepoint_hits($i) == $iterations } \
> + "tracepoint $i hit $iterations times"
> + } else {
> + fail "can't find tracepoint $i hit"
Also, here I think it's nicer if PASS/FAIL messages are the same,
for test result diffing.
Thus, something like:
for { set i $tpnum } { $i < [expr $tpnum + 2] } { incr i } {
set tracepoint_hits($idx) 0
}
while { 1 } {
set test "tfind"
set idx 0
gdb_test_multiple $test $test {
-re "Found trace frame $decimal, tracepoint ($decimal).*\r\n$gdb_prompt $" {
set idx [expr $expect_out(1,string)]
incr tracepoint_hits($idx)
}
}
if {$idx == 0} {
break
}
}
# Step 3, check the number of collections on each tracepoint.
for { set i $tpnum } { $i < [expr $tpnum + 2] } { incr i } {
gdb_assert { $tracepoint_hits($i) == $iterations } \
"tracepoint $i hit $iterations times"
}
Otherwise looks good to me.
Thanks,
Pedro Alves