|Skip Navigation Links|
|Exit Print View|
|Oracle Solaris Studio 12.3: Debugging a Program With dbx Oracle Solaris Studio 12.3 Information Library|
For example, to compile using the C++ compiler, type:
% CC -g example_source.cc
For the C++ compiler:
The -g option alone (with no optimization level specified) turns on debugging information and turns off inlining of functions.
The -g option used with the -O option or the -xOlevel option turns on debugging information and does not turn off inlining of functions. This set of options produces limited debugging information and inlined functions.
The -g0 (zero) option turns on debugging information and does not affect inlining of functions. You cannot debug inline functions in code compiled with the -g0 option. The -g0 option can significantly decrease link time and dbx start-up time (depending on the use of inlined functions by the program).
dbx lets you use options in the objcopy command on Linux platforms and the gobjcopy command on Solaris platforms to copy the debugging information from an executable to a separate debug file, strip that information from the executable, and create a link between these two files.
dbx searches for the separate debug file in the following order and reads the debugging information from the first file it finds:
The directory that contains the executable file.
A subdirectory named debug in the directory that contains the executable file.
A subdirectory of the global debug file directory, which you can view or change if the dbx environment variable debug_file_directory is set to the path name of the directory. The default value of the environment variable is /usr/lib/debug.
For example, to create a separate debug file for executable a.out, you would do the following.
objcopy --only-keep-debug a.out a.out.debug
objcopy --strip-debug a.out
objcopy --add-gnu-debuglink=a.out.debug a.out
On Solaris platforms, use the gobjcopy command. On Linux platforms, use the objcopy command.
On a Linux platform, you can use the command objcopy -help to find out whether or not the -add-gnu-debuglink option is supported on the platform. You can replace the -only-keep-debug option of the objcopy command with the command cp a.out a.out.debug to make a.out.debug a fully executable file.