Imagix 4D User Guide


Loading in Your C/C++ Code

Once you have created an empty new project, there are three main steps for populating the new database with information about the source code that you want to analyze.

1. Select and configure a compiler configuration file

Imagix 4D's source analyzer itself does a compiler independent semantic analysis of your source code. Through compiler configuration files, the analyzer is extended so that it behaves like your compiler. The result of this is that Imagix 4D's analysis of your software matches that of your compiler.

Selecting and configuring a compiler configuration file is a one-time activity. You can use the resulting configuration file to load in any of your source code that you compile with that compiler.

2. Specify your source files and how to analyze them

The central step in importing your source code into Imagix 4D is having the tool analyze your source code. The Imagix 4D analyzer semantically parses your code, much like a compiler. Just like with a compiler, you'll pass it a list of source files, along with a list of options indicating where to look for include files, and what macro definitions to use in the analysis. Whereas a compiler generates object files that are later linked into an executable, the Imagix 4D analyzer creates data files, which are later loaded and integrated in the Imagix 4D database.

For C and C++ code, there are a several different approaches available for specifying your source code and how to analyze it.

Import from Microsoft Visual Studio One approach supports Microsoft Visual Studio (MSVC) projects and solutions. It extracts the file and preprocessor flag information directly from the makefile, .dsp, .vcproj or .vcxproj file created by Visual Studio. For solutions (called workspaces prior to the .NET version), .dsw or .sln files are read.

Recommended if you already have Microsoft Visual Studio projects defined for the code

Extract from Build Log

A second approach involves dialogs containing data source definitions. These dialogs are populated automatically from the command line invocations of the compiler. While compiling your code, you may have a way to directly capture the build-issued commands into a log file. If not, you can use the imagix-cc-monitor utility to monitor system commands and capture any compiler invocations to a file. Whichever way you generate the log file, this approach then processes that file, analyzes the compiler invocations, and identifies the source file and -I, -D and -U arguments passed to the compiler. From this, a series of data source entries are defined, one for each group of source files sharing similar flags.

Recommended if you can compile your source code

Dialog-Based (C/C++)

A third approach is the most generic. It also involves filling out a dialog, but here it is done manually. In the dialog, you'll specify:

-- the directory where the source files are located
-- the names of the source files (using *.c style expansions)
-- the -I, -D and -U preprocessor flags to use

Recommended if neither Import from Microsoft Visual Studio nor Extract from Build Log apply

Add Targets to Makefile

A final approach uses your make system actively rather than passively, by adding targets to your makefiles. Since your makefile contains information about source files and preprocessor flags, this third approach leverages the already existing definitions. While the makefile approach offers some advantages in on-going production use of the tool, it is generally much more difficult to get started with, and is not recommended for initial evaluation of the tool.

Recommended only if dialog-based approach does not yield sufficient precision

3. Adjust the project settings to refine the analysis results

Once you have defined your project settings and started the analyzer, any issues encountered by the analyzer will be reported to the Analyzer Results window. You can use these reported results to fine-tune your project settings and achieve a more precise representation of your software.