Re: [PATCH 1/2] gdb.threads/attach-into-signal.exp: cleanup

Tom Tromey
2012-02-17T21:31:40Z

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> Hmm, the only thing dejagnu does with it is 'concat'.

Pedro> /usr/share/dejagnu/framework.exp:681: global pf_prefix
Pedro> /usr/share/dejagnu/framework.exp:688: if {[info exists pf_prefix]} {
Pedro> /usr/share/dejagnu/framework.exp:689: set message [concat $pf_prefix " " $message]

Hm, I thought I had seen weird output in gdb.log caused by using lappend
here, which is why I used append elsewhere.

Pedro> $ grep -rn pf_prefix *| grep append | grep lappend | wc -l
Pedro> 40

Pedro> $ grep -rn pf_prefix *| grep append | grep append | grep -v lappend | wc -l
Pedro> 2

Also search for 'set pf_prefix', but filter out the restoring ones.
Maybe the bad one is the initial set in lib/gdb.exp:

set pf_prefix "[file tail [file dirname $file]]/[file tail $file]:";

... this should perhaps be wrapped in [list]

>> I've occasionally wanted a wrapper like 'with_pf_prefix $whatever { body }'.
>> But not enough to write it :)

Pedro> Oh, that's a good idea!

Try this. I didn't test it in dejagnu, so...

proc with_test_prefix {prefix body} {
global pf_prefix errorInfo errorCode

set saved $pf_prefix
lappend pf_prefix $prefix
set r [catch {uplevel 1 $body} message]
set pf_prefix $saved

if {$r == 0} {
return $message
} else {
return -code $r -errorinfo $errorInfo -errorcode $errorCode $message
}
}

I've often thought more of our tests could use this "macro" style.

Tom