Skip to content

Commit af7a14a

Browse files
changbinduacmel
authored andcommitted
perf tools: Add doc about how to build perf with Asan and UBSan
AddressSanitizer (or ASan) and UndefinedBehaviorSanitizer (or UBSan) are very useful tools to detect program bugs: - AddressSanitizer (or ASan) is a GCC feature that detects memory corruption bugs such as buffer overflows and memory leaks. - UndefinedBehaviorSanitizer (or UBSan) is a fast undefined behavior detector supported by GCC. UBSan detects undefined behaviors of programs at runtime. This patch adds a document about how to use them on perf. Later patches will fix some of the issues disclosed by them. Signed-off-by: Changbin Du <changbin.du@gmail.com> Reviewed-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt (VMware) <rostedt@goodmis.org> Link: http://lkml.kernel.org/r/20190316080556.3075-2-changbin.du@gmail.com [ Make some changes based on comments made by Jiri Olsa ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent c3b4d5c commit af7a14a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tools/perf/Documentation/Build.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,27 @@ Those objects are then used in final linking:
4747

4848
NOTE this description is omitting other libraries involved, only
4949
focusing on build framework outcomes
50+
51+
3) Build with ASan or UBSan
52+
==========================
53+
$ cd tools/perf
54+
$ make DESTDIR=/usr
55+
$ make DESTDIR=/usr install
56+
57+
AddressSanitizer (or ASan) is a GCC feature that detects memory corruption bugs
58+
such as buffer overflows and memory leaks.
59+
60+
$ cd tools/perf
61+
$ make DEBUG=1 EXTRA_CFLAGS='-fno-omit-frame-pointer -fsanitize=address'
62+
$ ASAN_OPTIONS=log_path=asan.log ./perf record -a
63+
64+
ASan outputs all detected issues into a log file named 'asan.log.<pid>'.
65+
66+
UndefinedBehaviorSanitizer (or UBSan) is a fast undefined behavior detector
67+
supported by GCC. UBSan detects undefined behaviors of programs at runtime.
68+
69+
$ cd tools/perf
70+
$ make DEBUG=1 EXTRA_CFLAGS='-fno-omit-frame-pointer -fsanitize=undefined'
71+
$ UBSAN_OPTIONS=print_stacktrace=1 ./perf record -a
72+
73+
If UBSan detects any problem at runtime, it outputs a “runtime error:” message.

0 commit comments

Comments
 (0)