-
Book Overview & Buying
-
Table Of Contents
LLVM Cookbook
By :
You might have used tools such as Valgrind for memory debugging. LLVM also provides us with tools for memory debugging, such as the address sanitizer, memory sanitizer, and so on. These tools are very fast compared to Valgrind, even though they are not as mature as Valgrind. Most of these tools are in their experimental stage, so if you want, you can contribute to the open source development of these tools.
To make use of these sanitizers, we need to check out the code for compiler-rt from the LLVM SVN:
cd llvm/projects svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
Build LLVM as we did in Chapter 1, LLVM Design and Use. By doing so, we get the runtime libraries required.
Now, we will test the address sanitizer on a test code.
Write a test case to check the address sanitizer:
$ cat asan.c int main() { int a[5]; int index = 6; int retval = a[index]; return retval; }
Compile the test code using the fsanitize=address command-line...
Change the font size
Change margin width
Change background colour