author | Alberto Bertogli
<albertito@blitiri.com.ar> 2009-06-19 16:26:51 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2009-06-19 17:58:34 UTC |
parent | 942e952f87b72bebf6df1bcf001928943876d0ed |
.gitignore | +2 | -0 |
preload/posix/Makefile | +20 | -6 |
preload/posix/function_list | +0 | -60 |
preload/posix/function_list.skel | +18 | -0 |
preload/posix/generate | +19 | -0 |
diff --git a/.gitignore b/.gitignore index 18e44ba..68ac8d0 100644 --- a/.gitignore +++ b/.gitignore @@ -7,8 +7,10 @@ libfiu/libfiu.pc libfiu/libfiu.so preload/posix/*.o preload/posix/*.so +preload/posix/function_list preload/posix/modules/*.o preload/posix/modules/*.mod.c +preload/posix/modules/*.mod.fl preload/run/*.o preload/run/*.so preload/run/fiu-run diff --git a/preload/posix/Makefile b/preload/posix/Makefile index 411f61d..e470e70 100644 --- a/preload/posix/Makefile +++ b/preload/posix/Makefile @@ -14,9 +14,10 @@ endif # prefix for installing the binaries PREFIX=/usr/local - -GEN_C = $(addsuffix .c,$(wildcard modules/*.mod)) -GEN_OBJS = $(addsuffix .o,$(wildcard modules/*.mod)) +MODS = $(wildcard modules/*.mod) +GEN_C = $(addsuffix .c,$(MODS)) +GEN_OBJS = $(addsuffix .o,$(MODS)) +GEN_FL = $(addsuffix .fl,$(MODS)) CUSTOM_OBJS = $(patsubst %.c,%.o,$(wildcard modules/*.custom.c)) OBJS = codegen.o $(GEN_OBJS) $(CUSTOM_OBJS) @@ -24,20 +25,22 @@ OBJS = codegen.o $(GEN_OBJS) $(CUSTOM_OBJS) ifneq ($(V), 1) NICE_CC = @echo " CC $@"; $(CC) NICE_GEN = @echo " GEN $@"; ./generate + Q = @ else NICE_CC = $(CC) NICE_GEN = ./generate + Q = endif default: all -all: fiu_posix_preload.so +all: fiu_posix_preload.so function_list $(GEN_OBJS): $(GEN_C) %.mod.c: %.mod - $(NICE_GEN) $< $@ + $(NICE_GEN) $< $@ $<.fl .c.o: $(NICE_CC) $(ALL_CFLAGS) -c $< -o $@ @@ -46,12 +49,23 @@ fiu_posix_preload.so: $(OBJS) $(NICE_CC) $(ALL_CFLAGS) -shared -fPIC $(OBJS) -lfiu -ldl \ -o fiu_posix_preload.so +# this should only be needed when building the function list and not the +# preload library +%.mod.fl: %.mod + $(NICE_GEN) $< $<.c $@ + +function_list: $(GEN_FL) function_list.skel + @echo " function_list" + $(Q) cp function_list.skel function_list + $(Q) for i in $(GEN_FL); do cat $$i >> function_list; done + install: fiu_posix_preload.so install -d $(PREFIX)/lib install -m 0755 fiu_posix_preload.so $(PREFIX)/lib clean: - rm -f $(OBJS) $(GEN_OBJS:.o=.c) fiu_posix_preload.so + rm -f $(OBJS) $(GEN_OBJS:.o=.c) $(GEN_FL) + rm -f function_list fiu_posix_preload.so rm -f *.bb *.bbg *.da *.gcov *.gcda *.gcno gmon.out .PHONY: default install clean diff --git a/preload/posix/function_list b/preload/posix/function_list deleted file mode 100644 index 3a83717..0000000 --- a/preload/posix/function_list +++ /dev/null @@ -1,60 +0,0 @@ - -What follows is a list with the POSIX functions and their corresponding -failure point names, as implemented in the preload library. - -It is not set in stone, although it shouldn't change frequently. - - -Function Failure point name --------- ------------------ - -malloc libc/mm/malloc -realloc libc/mm/realloc - -open posix/io/oc/open -close posix/io/oc/close - -fsync posix/io/sync/fsync -fdatasync posix/io/sync/fdatasync - -read posix/io/rw/read -pread posix/io/rw/pread -readv posix/io/rw/readv -write posix/io/rw/write -pwrite posix/io/rw/pwrite -writev posix/io/rw/writev - -socket posix/io/net/socket -bind posix/io/net/bind -listen posix/io/net/listen -accept posix/io/net/accept -connect posix/io/net/connect -recv posix/io/net/recv -recvfrom posix/io/net/recvfrom -recvmsg posix/io/net/recvmsg -send posix/io/net/send -sendto posix/io/net/sendto -sendmsg posix/io/net/sendmsg -shutdown posix/io/net/shutdown -select posix/io/net/select -pselect posix/io/net/pselect -poll posix/io/net/poll - -opendir posix/io/dir/opendir -fdopendir posix/io/dir/fdopendir -readdir posix/io/dir/readdir -readdir_r posix/io/dir/readdir_r -closedir posix/io/dir/closedir - -mmap posix/mm/mmap -munmap posix/mm/munmap -msync posix/mm/msync -mprotect posix/mm/mprotect -madvise posix/mm/madvise -mlock posix/mm/mlock -munlock posix/mm/munlock -mlockall posix/mm/mlockall -munlockall posix/mm/munlockall - -sync_file_range linux/io/sync_file_range (Linux-only) - diff --git a/preload/posix/function_list.skel b/preload/posix/function_list.skel new file mode 100644 index 0000000..d82bf59 --- /dev/null +++ b/preload/posix/function_list.skel @@ -0,0 +1,18 @@ + +What follows is a list with the POSIX functions and their corresponding +failure point names, as implemented in the preload library. + +It is not set in stone, although it shouldn't change frequently. + + +Manually written +---------------- + +malloc libc/mm/malloc +realloc libc/mm/realloc +open posix/io/oc/open + + +Automatically generated +----------------------- + diff --git a/preload/posix/generate b/preload/posix/generate index 792878f..dc3e6f4 100755 --- a/preload/posix/generate +++ b/preload/posix/generate @@ -261,13 +261,32 @@ def generate_code(directives, path): directive.generate_to(f) +def write_function_list(directives, path): + "Writes the function list to the given path" + f = open(path, 'a') + for d in directives: + if isinstance(d, Function): + f.write("%-32s%s\n" % (d.name, d.fiu_name)) + + +def usage(): + print "Use: ./generate input.mod output.c file_list.fl" + def main(): + if len(sys.argv) < 4: + usage() + sys.exit(1) + input_name = sys.argv[1] output_name = sys.argv[2] + filelist_name = sys.argv[3] + directives = parse_module(input_name) #import pprint #pprint.pprint(directives) + generate_code(directives, output_name) + write_function_list(directives, filelist_name) if __name__ == '__main__': main()