support files for oink-based source to source transformations

This commit is contained in:
Sears Russell 2011-02-22 19:17:03 +00:00
parent de8bf53e98
commit aaafca31b6
5 changed files with 66 additions and 77 deletions

41
Makefile.oink Normal file
View file

@ -0,0 +1,41 @@
# find . -type f -name *.c | grep -v \/pobj\/ | grep -v \/cht\/ | grep -v \/fuse\/ | grep -v \/libdfa\/ | grep -v \/cyrus\/ | grep -v \/lladd-old\/ | xargs -iqq mcpp -m64 -K -DPBL_COMPAT -I. -I src -I /usr/include -I /usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/ -I build qq > /dev/null
GCC_INC = -I /usr/lib/gcc/i486-linux-gnu/4.1/include
#/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include
TRACE_DIR = ./utilities/trace
OINK = ../oink-stack/oink/xform
OINK_ARGS = -fx-wrap-fun-call -x-wrap-fun-call-config-file $(TRACE_DIR)/smoketest.ca
STANDARD_INC = -I build -I . -I src -I /usr/include
cfiles = $(wildcard src/stasis/*.c) \
$(wildcard src/stasis/*/*.c) \
$(wildcard test/stasis/*.c)
ifiles = $(patsubst %.c,build-oink/%.i,$(cfiles))
patches = $(patsubst %.c,build-oink/%.patch,$(cfiles))
.PHONY : clean TREE
all : wrap.patch
wrap.patch : $(patches)
cat $^ > $@.tmp
$(TRACE_DIR)/dedup-patch.pl < $@.tmp > $@
build-oink/% : %
mkdir -p $@
TREE : $(dir $(ifiles))
@true
mkdir -p $^
build-oink/%.i : %.c TREE
mcpp -K -DPBL_COMPAT $(STANDARD_INC) $(GCC_INC) $< -o $@
%.patch : %.i $(OINK)
$(OINK) $(OINK_ARGS) $< > $@
clean :
rm -f $(ifiles) $(patches) wrap.patch

View file

@ -28,6 +28,9 @@
static int stasis_initted = 0;
static long long stasis_dummy_dbug_timestamp = 0;
long long * stasis_dbug_timestamp = &stasis_dummy_dbug_timestamp;
static stasis_log_t* stasis_log_file = 0;
static stasis_dirty_page_table_t * stasis_dirty_page_table = 0;
static stasis_transaction_table_t * stasis_transaction_table;

20
utilities/trace/dedup-patch.pl Executable file
View file

@ -0,0 +1,20 @@
#!/usr/bin/perl -w
use strict;
my %seen;
my $printing = 1;
while(my $line = <>) {
if($line =~ /^\-\-\- (.+)$/) {
my $section = $1;
if($seen{$section}
||($section !~ /^\/home\//)
# ||($section =~ /\/test\//) # comment this line out for stress testing.
){
$printing = 0;
} else {
$printing = 1;
}
$seen{$section}++;
}
($printing || $line =~ /^\-\-\-\-/) && print $line;
}

View file

@ -0,0 +1,2 @@
Tinit
Tdeinit

View file

@ -1,77 +0,0 @@
#!/usr/bin/perl -w
use strict;
if(!defined($ARGV[0])) { $ARGV[0] = 'garbage'; }
my $enable;
if($ARGV[0] eq '--disable') {
$enable = 0;
} elsif($ARGV[0] eq '--enable') {
$enable = 1;
} else {
die "usage: $0 [--enable|--disable]\n";
}
#Tupdate TupdateWithPage TupdateStr TreorderableUpdate TwritebackUpdate TreorderableWritebackUpdate
#Tcommit TsoftCommit TforceCommits Tabort Tbegin Tforget Tprepare Trevive
# TnestedTopAction TbeginNestedTopAction TendNestedTopAction
my @funcs = qw ( Tinit
Tread TreadWithpage TreadRaw TreadStr
Tdeinit TuncleanShutdown
loadPage loadPageOfType loadUninitializedPage loadPageForOperation releasePage getCachedPage
stasis_log_force stasis_log_begin_transaction stasis_log_prepare_transaction stasis_log_commit_transaction
stasis_log_abort_transaction stasis_log_end_aborted_transaction stasis_log_write_update stasis_log_write_clr
stasis_log_write_dummy_clr stasis_log_begin_nta stasis_log_end_nta
);
my %opts;
my @opts = qw (CMAKE_EXE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS);
foreach my $opt (@opts) {
$opts{$opt} = 1;
}
my $prefix = ' -Wl,--wrap,';
my $val = $prefix . join $prefix, @funcs;
if(!-f 'CMakeCache.txt') { die 'CMakeCache not found\n'; }
my @file = `cat CMakeCache.txt`;
my $hits = 0;
open OUT, ">CMakeCache.txt.toggle~";
foreach my $line (@file) {
chomp $line;
if($line =~ /^\s*([^\:]+)\:([^\=]+)\=(.*)$/) {
my ($k,$t,$v) = ($1,$2,$3);
if($opts{$k}) {
$hits++;
if($enable) {
print OUT "$k:$t=$val\n";
} else {
print OUT "$k:$t=\n";
}
} else {
print OUT "$line\n";
}
} else {
print OUT "$line\n";
}
}
my $continue = 1;
if($hits != @opts+0) {
warn "replaced $hits lines, but expected " . (@opts+0) . ".\n";
$continue = 0;
}
close OUT;
$continue || die "Hit trobule. Bailing out.\n";
`mv CMakeCache.txt.toggle~ CMakeCache.txt`;
`make clean`;