From 8e6816ab4d84e4f61686438ad2d872bd76ce4f2a Mon Sep 17 00:00:00 2001 From: Mactavish <maczhanchao@yahoo.com> Date: Thu, 27 Apr 2023 07:18:23 +0200 Subject: [PATCH] add dynamic analysis in sildes --- slides/pages/clang-5.md | 23 +++++++++++++++++++++++ slides/slides.md | 6 ++++++ 2 files changed, 29 insertions(+) create mode 100644 slides/pages/clang-5.md diff --git a/slides/pages/clang-5.md b/slides/pages/clang-5.md new file mode 100644 index 0000000..2abfadd --- /dev/null +++ b/slides/pages/clang-5.md @@ -0,0 +1,23 @@ +--- +title: Dynamic Analysis +--- + +# Dynamic Analysis + +There are tools that help you automatically detect memory management and threading bugs. + +- [Valgrind](https://valgrind.org/) (not available on lower version of OS X and Windows) +- [Sanitizer](https://github.com/google/sanitizers) (integrated into `gcc` and `clang`) + +## Basic Usage + +```bash +# Using AddressSanitizer - dectect memory errors, memory leaks etc. +clang -fsanitize=address -g -O2 -fno-omit-frame-pointer <your c source file> + +# Using MemorySanitizer - detect uninitialized memory read +clang -fsanitize=memory -fPIE -pie -fno-omit-frame-pointer -g -O2 <your c source file> + +# Using Valgrind, you need to first compile your program +valgrind --leak-check=full --show-leak-kinds=all <program> <arg1> <arg2> ... +``` diff --git a/slides/slides.md b/slides/slides.md index f29ad94..c3bc38b 100644 --- a/slides/slides.md +++ b/slides/slides.md @@ -68,3 +68,9 @@ src: ./pages/clang-3.md transition: slide-left src: ./pages/clang-4.md --- + +--- +transition: slide-left +src: ./pages/clang-5.md +--- + -- GitLab