Home | History | Annotate | Download | only in tests
      1 #!/usr/bin/perl
      2 
      3 # Replace stack frame for a thread created by pthread_create():
      4 #     by 0x........: _thrp_setup (in /lib/libc.so.1)
      5 # with a stack frame expected on Linux:
      6 #     by 0x........: start_thread (pthread_create.c:123)
      7 # It will be further reduced and mangled by the main filter_stderr script.
      8 # This needs to be done first.
      9 s/_thrp_setup \(in .*libc.*\)/start_thread \(pthread_create.c:123\)/g;
     10 
     11 # We need to filter out the Solaris libc's stack frame which looks like:
     12 #     by 0x........: pthread_mutex_init (in /...libc...)
     13 # to be consistent with the expected output of test cases.
     14 #
     15 # Stack frames for synchronization functions are missing on Linux because
     16 # of optimalization. 
     17 # 
     18 s/.*\(in \/...libc...\)\R//m;
     19 
     20 # We need to replace Solaris threading and sychronization function
     21 # names with POSIX ones for drd_pthread_intercepts.c stack frame:
     22 #     by 0x........: cond_init (drd_pthread_intercepts.c:123)
     23 # See also comments in drd_pthread_intercepts.c.
     24 my %regex = (
     25     'thr_create'     => 'pthread_create',
     26     'thr_join'       => 'pthread_join',
     27     'mutex_init'     => 'pthread_mutex_init',
     28     'mutex_destroy'  => 'pthread_mutex_destroy',
     29     'mutex_lock'     => 'pthread_mutex_lock',
     30     'mutex_trylock'  => 'pthread_mutex_trylock',
     31     'mutex_unlock'   => 'pthread_mutex_unlock',
     32     'cond_init'      => 'pthread_cond_init',
     33     'cond_destroy'   => 'pthread_cond_destroy',
     34     'cond_wait'      => 'pthread_cond_wait',
     35     'cond_timedwait' => 'pthread_cond_timedwait',
     36     'cond_signal'    => 'pthread_cond_signal',
     37     'cond_broadcast' => 'pthread_cond_broadcast',
     38     'sema_init'      => 'sem_init',
     39     'sema_destroy'   => 'sem_destroy',
     40     'sema_wait'      => 'sem_wait',
     41     'sema_trywait'   => 'sem_trywait',
     42     'sema_timedwait' => 'sem_timedwait',
     43     'sema_post'      => 'sem_post',
     44     'rwlock_init'    => 'pthread_rwlock_init',
     45     'rwlock_destroy' => 'pthread_rwlock_destroy',
     46     'rw_rdlock'      => 'pthread_rwlock_rdlock',
     47     'rw_wrlock'      => 'pthread_rwlock_wrlock',
     48     'rw_tryrdlock'   => 'pthread_rwlock_tryrdlock',
     49     'rw_trywrlock'   => 'pthread_rwlock_trywrlock',
     50     'rw_unlock'      => 'pthread_rwlock_unlock'
     51 );
     52 my $check = join "|", keys %regex;
     53 if (! /: pthread_/) {
     54     s/($check)(.*drd_pthread_intercepts.c)/$regex{$1}$2/g;
     55 }
     56