From aaafca31b66b3eb7383b15ca12f51e4944c0aea7 Mon Sep 17 00:00:00 2001 From: Sears Russell Date: Tue, 22 Feb 2011 19:17:03 +0000 Subject: [PATCH] support files for oink-based source to source transformations --- Makefile.oink | 41 +++++++++++++ src/stasis/transactional2.c | 3 + utilities/trace/dedup-patch.pl | 20 +++++++ utilities/trace/smoketest.ca | 2 + utilities/trace/toggle-interposition.pl | 77 ------------------------- 5 files changed, 66 insertions(+), 77 deletions(-) create mode 100644 Makefile.oink create mode 100755 utilities/trace/dedup-patch.pl create mode 100644 utilities/trace/smoketest.ca delete mode 100755 utilities/trace/toggle-interposition.pl diff --git a/Makefile.oink b/Makefile.oink new file mode 100644 index 0000000..a283b9b --- /dev/null +++ b/Makefile.oink @@ -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 diff --git a/src/stasis/transactional2.c b/src/stasis/transactional2.c index c25b288..9f7a391 100644 --- a/src/stasis/transactional2.c +++ b/src/stasis/transactional2.c @@ -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; diff --git a/utilities/trace/dedup-patch.pl b/utilities/trace/dedup-patch.pl new file mode 100755 index 0000000..c7bda7a --- /dev/null +++ b/utilities/trace/dedup-patch.pl @@ -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; +} diff --git a/utilities/trace/smoketest.ca b/utilities/trace/smoketest.ca new file mode 100644 index 0000000..f8d460c --- /dev/null +++ b/utilities/trace/smoketest.ca @@ -0,0 +1,2 @@ +Tinit +Tdeinit diff --git a/utilities/trace/toggle-interposition.pl b/utilities/trace/toggle-interposition.pl deleted file mode 100755 index 1ea2a0f..0000000 --- a/utilities/trace/toggle-interposition.pl +++ /dev/null @@ -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`;