|
Debugging |
|
---|---|---|
|
||
This chapter describes how to apply debuggers to code generated with KAI C++.
The best debugger to use with KAI C++ depends upon the platform and the type of debugging support that you need.
- KAI C++ Debugger
- TotalView Multiprocess Debugger
- gdb
The KAI C++ Debugger (KDB) is KAI's long-term solution to debugging C++. KDB is designed specifically to debug C++, including templates and exceptions. KDB does not provide debugging of multi-threaded applications running with more than one thread. KDB can be used at no additional charge on any platform where you are licensed to run KAI C++. See the online documentation for more information on KDB. KDB can be downloaded directly from the KAI C++ download page.
The TotalView Multiprocess Debugger (TotalView) is designed to debug parallel applications, both threaded SMP applications and distributed multi-process applications. TotalView is available from Etnus.
A KAI C++ aware version of the gnu debugger (gdb) was KAI's interm debugger solution. KAI modified gdb to make it aware of the method that KAI C++ uses to convert a C++ name into a C name (a process called name mangling). KAI did not extend the capabilities of the gnu debugger to make it more of a C++ debugger. Gdb should only be used on platforms where some other KAI C++ capable debugger is not available.
When debugging your code, use the +K0
option.
This option implicitly sets the -g
option, and
turns off inlining and other optimizations. The intent is to make
the code easy to understand by debuggers.
Debugging at +K1
is practical too.
The -g
option is not implicitly set,
so you should explicitly set -g
as well.
A good general rule to follow is to always code -g
after all other command line options that effect optimization.
The principle transformation at the +K1
level is inlining.
Thus at this level, the only surprise should be that you cannot
step into a call of an inlined function.
KAI does not recommend debugging at +K2
or +K3,
as these optimizations can perform
quite radical restructuring of the code, and that tends to
confuse even the best debuggers.