On Mon, Apr 14, 2025 at 03:33:10PM +0200, Thomas Schwinge wrote:
> Hi!
> 
> I've got a question regarding the 'gcc/testsuite/lib/asan-dg.exp'
> overriding of '${tool}_load', which was introduced here,
> Subversion r193511 (Git commit 8335a6439ddb66aa9ebc67ee47aa2e6e317e3ef9):
> 
> On 2012-11-14T12:11:13+0100, Jakub Jelinek <ja...@redhat.com> wrote:
> > --- gcc/testsuite/lib/asan-dg.exp.jj        2012-11-14 09:11:13.086054131 
> > +0100
> > +++ gcc/testsuite/lib/asan-dg.exp   2012-11-14 11:45:40.142061595 +0100
> 
> > +# Replace ${tool}_load with a wrapper so that we can symbolize the output.
> > +if { [info procs ${tool}_load] != [list] \
> > +      && [info procs saved_asan_${tool}_load] == [list] } {
> > +    rename ${tool}_load saved_asan_${tool}_load
> > +
> > +    proc ${tool}_load { program args } {
> > +   global tool
> > +   set result [eval [list saved_asan_${tool}_load $program] $args]
> > +   set output [lindex $result 1]
> > +   set symbolized_output [asan_symbolize "$output"]
> > +   set result [list [lindex $result 0] $symbolized_output]
> > +   return $result
> > +    }
> > +}
> 
> So, once 'load_lib asan-dg.exp' has been done, this globally wraps
> '${tool}_load', forever, for all following '*.exp' test suites, too.
> This introduces overhead: routes every '${tool}_load' through
> 'asan_symbolize', even for non-ASAN '*.exp' test suites.
> 
> Following the usual pattern, shouldn't we do such wrapping only locally,
> where necessary?  Here, I suppose we could move this wrapping setup into
> 'asan_init', and then undo it in 'asan_finish'.
> 
> I'll be happy to draft a patch if someone confirms my thinking.

I think you're right.
The cost probably isn't that significant, as
    set addresses [regexp -inline -all -line "^ *#\[0-9\]+ 0x\[0-9a-f\]+ 
\[(\](\[^)\]+)\[+\](0x\[0-9a-f\]+)\[)\]$" "$output"]
will for most programs just result in empty list and so nothing will be
actually invoked, but it would be cleaner to deregister it, sure.

        Jakub

Reply via email to