mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 15:01:13 +07:00
af7a14a750
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>
74 lines
2.1 KiB
Plaintext
74 lines
2.1 KiB
Plaintext
|
|
1) perf build
|
|
=============
|
|
The perf build process consists of several separated building blocks,
|
|
which are linked together to form the perf binary:
|
|
- libperf library (static)
|
|
- perf builtin commands
|
|
- traceevent library (static)
|
|
- GTK ui library
|
|
|
|
Several makefiles govern the perf build:
|
|
|
|
- Makefile
|
|
top level Makefile working as a wrapper that calls the main
|
|
Makefile.perf with a -j option to do parallel builds.
|
|
|
|
- Makefile.perf
|
|
main makefile that triggers build of all perf objects including
|
|
installation and documentation processing.
|
|
|
|
- tools/build/Makefile.build
|
|
main makefile of the build framework
|
|
|
|
- tools/build/Build.include
|
|
build framework generic definitions
|
|
|
|
- Build makefiles
|
|
makefiles that defines build objects
|
|
|
|
Please refer to tools/build/Documentation/Build.txt for more
|
|
information about build framework.
|
|
|
|
|
|
2) perf build
|
|
=============
|
|
The Makefile.perf triggers the build framework for build objects:
|
|
perf, libperf, gtk
|
|
|
|
resulting in following objects:
|
|
$ ls *-in.o
|
|
gtk-in.o libperf-in.o perf-in.o
|
|
|
|
Those objects are then used in final linking:
|
|
libperf-gtk.so <- gtk-in.o libperf-in.o
|
|
perf <- perf-in.o libperf-in.o
|
|
|
|
|
|
NOTE this description is omitting other libraries involved, only
|
|
focusing on build framework outcomes
|
|
|
|
3) Build with ASan or UBSan
|
|
==========================
|
|
$ cd tools/perf
|
|
$ make DESTDIR=/usr
|
|
$ make DESTDIR=/usr install
|
|
|
|
AddressSanitizer (or ASan) is a GCC feature that detects memory corruption bugs
|
|
such as buffer overflows and memory leaks.
|
|
|
|
$ cd tools/perf
|
|
$ make DEBUG=1 EXTRA_CFLAGS='-fno-omit-frame-pointer -fsanitize=address'
|
|
$ ASAN_OPTIONS=log_path=asan.log ./perf record -a
|
|
|
|
ASan outputs all detected issues into a log file named 'asan.log.<pid>'.
|
|
|
|
UndefinedBehaviorSanitizer (or UBSan) is a fast undefined behavior detector
|
|
supported by GCC. UBSan detects undefined behaviors of programs at runtime.
|
|
|
|
$ cd tools/perf
|
|
$ make DEBUG=1 EXTRA_CFLAGS='-fno-omit-frame-pointer -fsanitize=undefined'
|
|
$ UBSAN_OPTIONS=print_stacktrace=1 ./perf record -a
|
|
|
|
If UBSan detects any problem at runtime, it outputs a “runtime error:” message.
|