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 1/2] gdb.threads/attach-into-signal.exp: cleanup


>>>>> "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


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