Debugging using libmudflap
QNX includes support for Mudflap through libmudflap. Mudflap provides you with pointer checking capabilities based on compile time instrumentation as it transparently includes protective code to potentially unsafe C/C++ constructs at run time.
For information about the available options for this feature, see the GNU website at: http://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Optimize-Options.html#index-fmudflap-502
For more debugging information, you can search the GNU website for the topic Mudflap Pointer Debugging.
This debugging feature is enabled by passing the option -fmudflap to the compiler. For front ends that support it, it instruments all risky pointer and array dereferencing operations, some standard library string and heap functions, and some associated constructs with range and validity tests.
The instrumentation relies on a separate runtime library (libmudflap), which is linked into a program if -fmudflap -lmudflap is given at link time. Runtime behavior of the instrumented program is controlled by the environment variable MUDFLAP_OPTIONS. You can obtain a list of options by setting MUDFLAP_OPTIONS to -help and calling a Mudflap compiled program.
For your multithreaded programs:
- To compile, you must use the option -fmudflapth instead of -fmudflap
- To link, you must use the option -fmudflapth -lmudflapth
Additionally, if you want instrumentation to ignore pointer reads, you'll need to use the option -fmudflapir in addition to the option -fmudflap or -fmudflapth (for multithreaded). This option creates less instrumentation, resulting in faster execution.
Regardless of whether you're using qcc or gcc, for both the compile and link steps you must specify the option -fmudflap or -fmudflapth.
Last modified: 2014-12-11