Download Integrated Development Environment:User's Guide

Transcript
Finding Memory Errors and Leaks
Interpret memory errors
Although the QNX Memory Analysis perspective shows you how your program uses
memory, and can quickly direct you to memory errors in your development and testing
environments, you need to understand the types of memory errors that you might run
into. For detailed information about interpreting errors, see Interpret errors during
memory analysis (p. 495).
Use Mudflap
Support for Mudflap has been removed in the upstream FSF gcc, and therefore
future releases of the QNX Neutrino version of gcc won't support it either.
Mudflap provides runtime pointer checking capability to the GNU C/C++ compiler
(gcc). It adds runtime error checking for pointers that are typically the cause for many
programming errors in C and C++. Since Mudflap is included with the compiler, it
doesn't require any additional tools in the tool chain, and it can be easily added to a
build by specifying the necessary GCC options (see Configure Mudflap to find errors
(p. 436).)
Mudflap instruments all of the risky pointer and array dereferencing operations, some
standard library string/heap functions, and some other associated constructs with
range and validity tests. Instrumented modules will detect buffer overflows, invalid
heap use, and some other classes of C/C++ programming errors. The instrumentation
relies on a separate runtime library (libmudflap), which will be linked into a program
when the compile option (-fmudflapth) option is provided for the build.
If your binary is instrumented with Mudflap, you can't run Memory Analysis
on it because there will be a conflict (trying to overload the same functions),
and it will cause the program to crash.
For QNX and Managed projects that have multithreaded applications, you'll
need to use the -fmudflapth option for the compiler.
Prerequisites
The use of Mudflap requires GCC with Mudflap support. This means that you'll need
GCC 4.x with the Mudflap enabled flag, and you'll need to set appropriate configuration
settings (see Configure Mudflap to find errors (p. 436).) Once configured, the IDE adds
options to the Makefile: -fmudflapth to LD_SEARCH_FLAGS and -fmudflapth to
CFLAGS1.
Since Mudflap slows down your application, ensure that you disable Mudflap
during your final compilation.
©
2014, QNX Software Systems Limited
433