Compiler settings for memory error analysis in Intel® Inspector XE*

Introduction:
Memory error analysis in Intel® Inspector XE and/or Intel® Parallel Inspector can analyze most native binaries. However, some settings make analysis easier.

For the purposes of this article - when I refer to Intel Inspector XE - I am referring to the memory error analysis within Intel Inspector XE and/or Intel Parallel Inspector

Useful Settings for memory error analysis in Intel® Inspector XE:

Linux* Switch

Windows* Switch

Purpose

-g

/Zi, /ZI

Highly Recommended.

Intel Inspector XE uses the symbols to associate addresses to source lines.

Additionally using this setting is one of the ways in which memory error analysis filters out false positives.

Settings which impact memory error analysis in Intel Inspector XE:

Linux Switch Windows Switch Purpose

-O0

/Od

Recommended for Initial analysis.

Allows Intel Inspector XE to more easily associate errors to the correct source line.

Intel Inspector XE can also analyze optimized binaries, but it is difficult to pinpoint the source code location causing a problem in optimized assembly that does not have specific source lines.

Note: While it is easier to do analysis of binaries built with -O0, it is also important to check for memory errors in your "released" (not -O0) version of your binaries.

Settings not recommended for use with memory error analysis in Intel® Inspector XE:

Linux Switch

Windows
Switch

Purpose

-fmudflap
-ftrapuv

/RTC[su1]

Not Recommended.

Options on the compiler which add functionality similar to Intel Inspector XE can cause Intel Inspector XE to have false positives and false negatives.

-fmudflap switch is known to cause false positives and false negatives with Intel Inspector XE.
-ftrapuv is known to cause false negatives. 
/RTC[us] initializes uninitialized memory with a bit pattern preventing memory error analysis in Intel® Inspector XE from identifying uninitialized memory errors in your code.  There is some duplication in the kinds of errors that memory error analysis will do at Level 4 with this switch.

Switches such as this may impact performance without adding additional functionality.

These switches may be useful outside Intel Inspector XE - and may potentially catch additional issues that Intel Inspector XE does not find.

-fstack-security-check which add functionality similar to Intel Inspector XE is not known to cause false positives or false negatives with Intel Inspector XE.

-tprofile

/Qtprofile

Do not use.

This Intel Compiler setting is an alternative method of instrumentation for Intel® Thread Profiler. The instrumentation added by -tprofile is not supported by Intel Inspector XE.

-tcheck

/Qtcheck

Do not use.

This Intel Compiler setting is an alternative method of instrumentation for Intel® Thread Checker. The instrumentation added by -tcheck is not supported by Intel Inspector XE.

-msse4a,
-m3dnow

N/A

Do not use.

Binaries which use instructions not supported by Intel Processors may cause unknown behaviors in Intel Inspector XE.

-debug [keyword]

/debug
[keyword]

Not Recommended.

Intel Inspector XE works best with -debug full (the default). Other options including parallel, extended, emit-column, expr-source-pos, inline-debug-info, semantic-stepping, & variable-locations are not supported by Intel Inspector XE.

Settings which have no impact on memory error analysis of Intel Inspector XE:

Linux Switch

Windows Switch

Purpose

-static
-static-libgcc
-static-intel
-shared-libgcc
-openmp-link

/MDd, /MD, /MT, MTd, Qopenmp-link

These setting directs the compiler to link in various libraries statically or dynamically. These switches impact Intel® Amplifier XE and threading error analysis for Intel Inspector XE. Memory error analysis in Intel Inspector XE works with statically linked libraries.

-DTBB_USE_THREADING_TOOLS

/DTBB_USE_THREADING_TOOLS

Setting TBB_USE_THREADING_TOOLS causes Intel Threading Building Blocks (TBB) to be instrumented. This switch impacts Intel® Amplifier XE and threading error analysis for Intel® Inspector XE. Setting _DEBUG or TBB_USE_DEBUG will in turn set TBB_USE_THREADING_TOOLS

N/A

/FIXED[:NO]

This setting allows binaries to be instrumented and is not required for Intel Inspector XE.

Notes:
1) Memory Error Analysis Level 1 (Memory Leak Detection) requires information in the executable and all shared libs in your application to properly walk the call stack:

a) Frame pointers: Use -fno-omit-frame-pointer.

b) Exception handling information: enabled via -fasynchronous-unwind-tables, -fexceptions, or -O0

2) Using Debug versions of the Microsoft C Runtime Libraries (/MDd and /MTd) enables the Microsoft* debug heap manager. see: Using the Microsoft* debug heap manager with memory error analysis of Intel® Parallel Inspector.

Note: There are other options which may add frame pointer or Exception handling to your binary as a side effect, Examples: -fexceptions (which is the default for C++).or -O0 . To make sure the executable (and shared libs) have this information, use the objdump -h <binary> command. You should see .eh_frame_hdr section there.

More Information:

This article addressed the most obvious switches that developers would have concerns over. Most switches will work with Intel® Parallel Inspector and/or Intel Inspector XE - but not every switch combination is tested. If you have information regarding other switches, please add a comment to this article. If you have question regarding a particular switch please submit an issue to the Intel Inspector XE Forum.

Versions:
Intel® Inspector XE 2011
Intel® C++ Compiler 11.X,12.X
GCC Compiler 3.4.6 – GCC 4.5.0
MS Visual Studio 2005, 2008, 2010

Para obter informações mais completas sobre otimizações do compilador, consulte nosso aviso de otimização.