-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
73 lines (48 loc) · 2.35 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
VERBOSITY ?= 0
CXX ?= g++
CXXFLAGS = -Wall -fno-omit-frame-pointer -fvisibility=hidden -std=gnu++11 $(UNWIND_INCLUDES) -DVERBOSITY=$(VERBOSITY)
PYTHON ?= python3
all: libmemtrail.so sample benchmark
libmemtrail.so: memtrail.cpp memtrail.version
ifeq ($(shell test -d libunwind && echo true),true)
$(info info: using local libunwind)
libunwind/configure: libunwind/configure.ac
autoreconf -i libunwind
libunwind/Makefile: libunwind/configure
cd libunwind && ./configure --disable-cxx-exceptions --disable-debug-frame --disable-block-signals --disable-shared --enable-static --with-pic --prefix=$(abspath local)
local/lib/pkgconfig/libunwind.pc: libunwind/Makefile
$(MAKE) -C libunwind install
libmemtrail.so: local/lib/pkgconfig/libunwind.pc
export PKG_CONFIG_PATH := $(abspath local)/lib/pkgconfig:$(PKG_CONFIG_PATH)
else
$(info info: using system's libunwind)
endif
libmemtrail.so:
pkg-config --cflags --libs --static libunwind
$(CXX) -O2 -g2 $(CXXFLAGS) -shared -fPIC -Wl,--version-script,memtrail.version -o $@ $< $$(pkg-config --cflags --libs --static libunwind) -ldl
%: %.cpp
$(CXX) -O0 -g2 -Wno-unused-result -o $@ $< -ldl
gprof2dot.py:
wget --quiet --timestamping https://raw.githubusercontent.com/jrfonseca/gprof2dot/master/gprof2dot.py
chmod +x gprof2dot.py
sample: sample.cpp memtrail.h
test: libmemtrail.so sample gprof2dot.py
$(RM) memtrail.data $(wildcard memtrail.*.json) $(wildcard memtrail.*.dot)
$(PYTHON) memtrail record ./sample
$(PYTHON) memtrail dump
$(PYTHON) memtrail report --show-snapshots --show-snapshot-deltas --show-cumulative-snapshot-delta --show-maximum --show-leaks --output-graphs
$(foreach LABEL, snapshot-0 snapshot-1 snapshot-1-delta maximum leaked, ./gprof2dot.py -f json memtrail.$(LABEL).json > memtrail.$(LABEL).dot ;)
test-debug: libmemtrail.so sample
$(RM) memtrail.data $(wildcard memtrail.*.json) $(wildcard memtrail.*.dot)
$(PYTHON) memtrail record --debug ./sample
bench: libmemtrail.so benchmark
$(RM) memtrail.data
$(PYTHON) memtrail record ./benchmark
time -p $(PYTHON) memtrail report --show-maximum
profile: benchmark gprof2dot.py
$(PYTHON) memtrail record ./benchmark
$(PYTHON) -m cProfile -o memtrail.pstats -- memtrail report --show-maximum
./gprof2dot.py -f pstats memtrail.pstats > memtrail.dot
clean:
$(RM) libmemtrail.so gprof2dot.py sample benchmark
.PHONY: all test test-debug bench profile clean