Compiler settings for memory error analysis in Intel® Inspector*

By Eric W Moore,

Published: 04/03/2012   Last Updated: 12/13/2018

Introduction

Memory error analysis in Intel® Inspector can analyze most native binaries. However, some settings make analysis easier. In this article, "Intel Inspector" refers to the memory error analysis feature in particular.

Useful settings for memory error analysis in Intel® Inspector
Switch Effect

Linux*:
-g

Windows*:
/Zi
/ZI

Highly Recommended.

Intel Inspector 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.

Linux*:
-fno-omit-frame-pointer

Windows*:
/Oy-

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. This option is for frame pointers.

Linux*:
-fasynchronous-unwind-tables
-fexceptions
-O0

Windows*:
/Od

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. These options are for exception handling information.

Settings which impact memory error analysis in Intel® Inspector
Switch Effect

Linux*:
-O0

Windows*:
/Od

Recommended for Initial analysis.

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

Intel Inspector 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
Switch Effect

Linux*:
-fmudflap
-ftrapuv

Windows*:
/RTC[su1]

Not Recommended.

Options on the compiler which add functionality similar to Intel Inspector XE can cause Intel Inspector 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 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 - and may potentially catch additional issues that Intel Inspector does not find.

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

Linux*:
-msse4a
-m3dnow

Windows*:
N/A

Do not use.

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

Linux*:
-debug [keyword]

Linux*:
/debug [keyword]

Not Recommended.

Intel Inspector 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.

Settings which have no impact on memory error analysis of Intel® Inspector
Switch Effect

Linux*:
-static
-static-libgcc
-static-intel
-shared-libgcc
-openmp-link

Windows*:
/MDd [1]
/MD
/MT
/MTd [1]
/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.

Linux*:
-DTBB_USE_THREADING_TOOLS

Windows*:
/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

Linux*:
N/A

Windows*:
/FIXED[:NO]

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

Notes

[1] 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®  Inspector - 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 Forum.

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.