This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 5/6] Test tracepoints are installed or not


On 12/09/2012 12:53 PM, Yao Qi wrote:
> On 12/07/2012 10:20 PM, Pedro Alves wrote:
>>> >> When pending tracepoint is resolved, breakpoint_modified observer is notified, and then, when tracepoint is downloaded, the breakpoint_modified observer is notified again.
>> > Okay.  Could you add a comment mentioning this in the test?
> Sure.  Comments are added in the new version.

Thanks.

On 12/09/2012 12:53 PM, Yao Qi wrote:
>      set test "tracepoint on pendfunc2 resolved"
> +    # It is expected to get two "=breakpoint-modified" notifications.
>      gdb_expect {
> -	-re ".*=breakpoint-modified,bkpt=\{number=\"1\",type=\"tracepoint\".*.*times=\"0\"" {
> +	-re "=breakpoint-modified,bkpt=\{number=\"1\",type=\"tracepoint\".*.*times=\"0\".*installed=\"n\"" {
> +	    # Pending tracepoint is resolved.
>  	    pass "$test"
> +	    exp_continue
> +	}
> +	-re "=breakpoint-modified,bkpt=\{number=\"1\",type=\"tracepoint\".*.*times=\"0\".*installed=\"y\"" {
> +	    # Resolved tracepoint is installed.
> +	    pass "tracepoint on pendfunc2 installed"
>  	}
>  	-re ".*${mi_gdb_prompt}$" {
>  	    fail $test

Actually, sorry for not thinking of this before, but, it seems to me
this use of pass+exp_continue is fragile.  Say a GDB bug is
introduced, and the second =breakpoint-modified fails to be output.  In
that case, this will result in:

     PASS: tracepoint on pendfunc2 resolved
     FAIL: tracepoint on pendfunc2 resolved

instead of
     PASS: tracepoint on pendfunc2 resolved
     FAIL: tracepoint on pendfunc2 installed

You could fix that by doing:

 +	    # Pending tracepoint is resolved.
  	    pass "$test"
 +	    set test "tracepoint on pendfunc2 installed"
 +	    exp_continue

But then, if the order of the notifications changes (IOW, due to a bug,
we end up with the tracepoint not installed), this won't catch it.
It seems best to me to only use exp_continue in cases we won't to
consume/skip output, and in the case of this patch, split the two
tests into two consecutive gdb_expects.

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]