TotalView User Guide : Part II: Debugging Tools and Tasks : Common Session Setup and Tools : Compiling Programs
Compiling Programs
The first step in get-ting a program ready for debugging is to add your compiler’s -g debugging command-line option. This option tells your compiler to generate symbol table debugging information; for example:
cc -g -o executable source_program
You can also debug programs that you did not compile using the -g option, or programs for which you do not have source code. For more information, see
The following table presents some general considerations. “Compilers and Platforms in the TotalView Reference Guide contains additional considerations.
 
Compiler Option or Library
What It Does
When to Use It
Debugging symbols option (usually -g)
Generates debugging information in the symbol table.
Before debugging any program with TotalView.
Optimization option (usually -O)
Rearranges code to optimize your program’s execution.
Some compilers won’t let you use the -O option and the -g option at the same time.
Even if your compiler lets you use the -O option, don’t use it when debugging your program, since strange results often occur.
After you finish debugging your program.
multi-process programming library (usually dbfork)
Uses special versions of the fork() and execve() system calls.
In some cases, you need to use the -lpthread option.
For more information about dbfork, see “Linking with the dbfork Library” contained in the “Compilers and Platforms” Chapter of the TotalView Reference Guide.
Before debugging a multi-process program that explicitly calls fork() or execve().
 
RELATED TOPICS 
 
Compilers and platforms
"Compilers and Platforms" in the TotalView Platforms Guide
The dbfork library
"Linking with the dbfork Library" in the TotalView Platforms Guide
Assembler code
 
Using File Extensions
When opening a file, TotalView uses the file's extension to determine the programming language used. If you are using an unusual extension, you can manually associate your extension with a programming language by setting the TV::suffixes variable in a startup file. For more information, see the “TotalView Variables” chapter in the TotalView Reference Guide.
Note that your installation may have its own guidelines for compiling programs.