Tools for testing and debugging memory issues (part 2)
This lesson contains approximately 25 minutes of video content.
Clang-14 and debugging symbols
When compiling by hand, you'd include -g
to have the compiler write debugging symbols. This is what
is shown in some of the videos presented in this lesson. For
the version of clang++
that we're using (v. 14.0.5), DWARFv5
debug format is used by default.
Unfortunately,some of our tools will not properly read the DWARF5
generated by
clang-14. Therefore, instead of using the -g
flag, use -gdwarf-4
.
UndefinedBehaviorSanitizer (UBSan)
Valgrind
You can request more detail about the leak presenting in your program
by passing
valgrind
the flag --leak-check=full
to show
each leak in detail, and --track-origins=yes
to have valgrind
track the origin of undefined values. For line-by-line details about
what went wrong, you need to tell clang++
to write the executable
with debugging symbols, which you can do by providing the compiler the
-gdwarf-4
flag. Additional tools
Questions
Answer the following questions with consideration to the material introduced in both Parts 1 and 2 of this lesson.