1#!/usr/bin/perl 2 3# Replace pthread_create with pthread_create@* which is expected on Linux 4s/pthread_create \(hg_intercepts.c:/pthread_create@* \(hg_intercepts.c:/g; 5 6# We need to remove stack frames containing redundant function 7# names from libc, for example 8# by 0x........: pthread_mutex_init (in /...libc...) 9my $check = join "|", ('pthread_mutex_init', 'pthread_cond_wait', 'pthread_cond_timedwait'); 10s/^\s*by 0x........: (?:$check) \(in \/...libc...\)\s*//; 11 12# We also need to replace Solaris threading and sychronization function 13# names with POSIX ones for hg_intercepts.c stack frame: 14# at 0x........: mutex_lock (hg_intercepts.c:1234) 15# See also comments in hg_intercepts.c. 16my %regex = ( 17 'cond_broadcast' => 'pthread_cond_broadcast@*', 18 'cond_destroy' => 'pthread_cond_destroy@*', 19 'cond_signal' => 'pthread_cond_signal@*', 20 'cond_wait' => 'pthread_cond_wait@*', 21 'cond_timedwait' => 'pthread_cond_timedwait@*', 22 'mutex_destroy' => 'pthread_mutex_destroy', 23 'mutex_init' => 'pthread_mutex_init', 24 'mutex_lock' => 'pthread_mutex_lock', 25 'mutex_trylock' => 'pthread_mutex_trylock', 26 'mutex_unlock' => 'pthread_mutex_unlock', 27 'rwlock_init' => 'pthread_rwlock_init', 28 'rw_unlock' => 'pthread_rwlock_unlock' 29); 30my $check = join "|", keys %regex; 31if (! /: pthread_/ && ! /WRK/) { 32 s/($check)(.*hg_intercepts.c)/$regex{$1}$2/g; 33} 34