## ## PIN tools ## ############################################################## # # Here are some things you might want to configure # ############################################################## #TARGET_COMPILER?=ms TARGET_COMPILER?=gnu ############################################################## # # include *.config files # ############################################################## ifeq ($(TARGET_COMPILER),gnu) include ../makefile.gnu.config LINKER?=${CXX} CXXFLAGS ?= -Wall -Werror -Wno-unknown-pragmas $(DBG) $(OPT) -MMD endif ifeq ($(TARGET_COMPILER),ms) include ../makefile.ms.config DBG?= endif ############################################################## # # Tools sets # ############################################################## EXTRA_LIBS = SUF = $(PINTOOL_SUFFIX) all: tools SANITY_TOOLS = TOOLS = # rc added this test, but not ready for general testing #TOOL_ROOTS = replaceebx # linux tests go here: ifeq ($(TARGET_OS),l) ifeq ($(TARGET),ia32) # malloctrace2 does not work on on systems where libdl.so is not built with symbols TOOL_ROOTS += malloctrace atraceprobe probemalloctrace iprtool proto1 proto2 endif ifeq ($(TARGET),ia32e) TOOL_ROOTS += probemalloctrace iprtool proto1 proto2 endif ifeq ($(TARGET),ipf) # malloctrace2 does not work on on systems where libdl.so is not built with symbols TOOL_ROOTS += malloctrace probemalloctrace iprtool proto1 proto2 endif TOOLS = $(TOOL_ROOTS:%=%$(PINTOOL_SUFFIX)) CP = $(TESTAPP) DLTEST=dltest MALLOCWRAPPERS=mallocwrappers.so endif # windows test goes here: ifeq ($(TARGET_OS),w) ifeq ($(TARGET),ia32) # proto2 uses a local symbol. Only imports and exports can be replaced on windows. TOOL_ROOTS += iprtool probemalloctrace proto1 endif #ifeq ($(TARGET),ia32e) #TOOL_ROOTS += iprtool proto1 #endif TOOLS = $(TOOL_ROOTS:%=%$(PINTOOL_SUFFIX)) CP = $(TESTAPP) DLTEST=dltest.exe MALLOCWRAPPERS=mallocwrappers.dll endif # mac tests go here: ifeq ($(TARGET_OS),m) #TOOL_ROOTS = malloctrace malloctrace2 probemalloctrace TOOL_ROOTS = TOOLS = $(TOOL_ROOTS:%=%$(PINTOOL_SUFFIX)) DLTEST=dltest-mac MALLOCWRAPPERS=mallocwrappers-mac.so endif tools: $(TOOLS) test: $(TOOLS:%=%.test) tests-sanity: $(SANITY_TOOLS:%=%.test) DL_LIB = -ldl #cp-win.exe: cp-win.cpp # $(CXX) -o cp-win.exe cp-win.cpp -g traceapp: traceapp.c $(CC) $(PIN_LPATHS) -I../Include -I. -o traceapp traceapp.c -lpinapp -g mttraceapp: mttraceapp.c $(CC) $(PIN_LPATHS) -I../Include -I. -o mttraceapp mttraceapp.c -lpinapp -lpthread -g $(PIN) -probe -t $< -- $(CP) makefile $<.makefile.copy > $<.out 2>&1 diff makefile $<.makefile.copy rm $<.out $<.makefile.copy malloctrace$(SUF).test : malloctrace$(SUF) malloctrace.tested malloctrace.failed $(PIN) -probe -t $< -- $(CP) makefile $<.makefile.copy > $<.out 2>&1 diff makefile $<.makefile.copy rm malloctrace.failed $<.out $<.makefile.copy probemalloctrace$(SUF).test : probemalloctrace$(SUF) probemalloctrace.tested probemalloctrace.failed $(PIN) -probe -t $< -- $(CP) makefile $<.makefile.copy > $<.out 2>&1 diff makefile $<.makefile.copy rm probemalloctrace.failed $<.out $<.makefile.copy proto1$(SUF).test : proto1$(SUF) proto1.tested proto1.failed $(PIN) -probe -t $< -- $(CP) makefile $<.makefile.copy > $<.out 2>&1 diff makefile $<.makefile.copy rm proto1.failed $<.out $<.makefile.copy proto2$(SUF).test : proto2$(SUF) protofoo proto2.tested proto2.failed $(PIN) -probe -t $< -- ./protofoo > $<.out 2>&1 grep -e "33" $<.out grep -e "100" $<.out rm proto2.failed $<.out protofoo: protofoo.c protobar.c $(CC) $(PIN_LPATHS) -I../Include -I. -o protofoo protofoo.c protobar.c -g iprtool$(SUF).test : iprtool$(SUF) iprtool.tested iprtool.failed ipr $(PIN) -probe -t $< -- ./ipr > $<.out 2>&1 grep -e "a = 1" $<.out rm iprtool.failed $<.out ipr: ipr.c $(CC) -g -o ipr ipr.c atraceprobe$(SUF).test : atraceprobe$(SUF) atraceprobe.tested atraceprobe.failed traceapp $(PIN) -probe -t $< -- ./traceapp rm atraceprobe.failed mtatraceprobe$(SUF).test : atraceprobe$(SUF) mtatraceprobe.tested mtatraceprobe.failed mttraceapp $(PIN) -probe -mt -t $< -- ./mttraceapp rm mtatraceprobe.failed malloctrace2$(SUF).test : malloctrace2$(SUF) malloctrace2.tested malloctrace2.failed $(DLTEST) $(MALLOCWRAPPERS) $(PIN) -probe -t $< -- ./$(DLTEST) rm malloctrace2.failed mallocwrappers.so: mallocwrappers.c $(CC) -o mallocwrappers.so -fpic -shared mallocwrappers.c -g mallocwrappers-mac.so: mallocwrappers.c $(CC) -o mallocwrappers-mac.so -fPIC -dynamiclib mallocwrappers.c -g dltest: dltest.c one.c two.c $(CC) -o two.so -fpic -shared two.c -g $(CC) -o one.so -fpic -shared one.c -g $(CC) -o dltest $(APP_CXXFLAGS) dltest.c $(DL_LIB) -Wl,-rpath,`pwd` -g dltest-mac: dltest.c one.c two.c $(CC) -o two.so -fPIC -dynamiclib two.c -g $(CC) -o one.so -fPIC -dynamiclib one.c -g $(CC) -o dltest-mac $(APP_CXXFLAGS) dltest.c $(DL_LIB) -g ebxhandle: ebxhandle.c ebx.s $(CC) -g -o ebxhandle ebxhandle.c ebx.s replaceebx$(SUF).test : replaceebx$(SUF) replaceebx.tested replaceebx.failed ebxhandle $(PIN) -probe -mt -t $< -- ./ebxhandle > $<.out 2>&1 cmp $<.out $<.reference rm replaceebx.failed ## build rules %.o : %.cpp $(CXX) -c $(CXXFLAGS) $(PIN_CXXFLAGS) ${OUTOPT}$@ $< $(TOOLS): $(PIN_LIBNAMES) $(TOOLS): %$(PINTOOL_SUFFIX) : %.o ${LINKER} $(PIN_LDFLAGS) $(LINK_DEBUG) ${LINK_OUT}$@ $< ${PIN_LPATHS} $(PIN_LIBS) $(EXTRA_LIBS) $(DBG) ## cleaning clean: -rm -f dltest dltest-mac *.so *.o $(TOOLS) *.out *.tested *.failed *.d pin.log -rm -f traceapp mttraceapp ebxhandle ipr protofoo -include *.d