KDbg - User's Manual

Contents


Introduction

KDbg is a front-end for gdb, the GNU debugger.

This means that KDbg itself is not the debugger. Rather, it communicates with gdb, a command line debugger, by sending commands to it and receiving the output, such as variable values. The menu commands and mouse clicks are translated into gdb commands, and the output of gdb is translated into (more or less) visible information, such as structured variable contents.

The upshot of all this is that KDbg completely relies on the capabilities of the underlying command line debugger, gdb. KDbg can do no more than gdb can. For example, if you have a gdb that does not supports debugging of threaded programs, KDbg cannot, either (even though it offers a threads window).

Using KDbg

Before you start using KDbg, you may want to review the options in the Global Options dialog that you invoke with File|Global Options.

Specifying a debugging target

To debug a program, choose File|Executable from the menu. If you have debugged the program earlier, you can choose it from File|Recent Executables. The program is loaded.

If you want to debug a core dump, you must first load the executable that produced the core dump, then choose File|Core Dump from the menu. Now KDbg goes to the point in the program that caused the core dump.

You can now set breakpoints, using the Breakpoint menu, the right mouse button menu, or the breakpoint window.

You can also choose program specific settings that apply only to the currently loaded executable using File|Settings, in the Program Settings dialog.

Running the program

Now run the program by selecting Execution|Run. The program now executes as usual until it either exits, hits a breakpoint or watchpoint, or receives a signal.

You can run the program with arguments, set a working directory, or set environment variables. To do this, choose Execution|Arguments and specify your options in the Program Arguments dialog (before you start the program).

You can also attach to a program that is currently running. To do this, first load the executable file like above. Then choose Execution|Attach. Specify the process number and click OK. The running program is halted (not terminated), and the current point of execution is displayed in the source window.

The program stopped - now what?

When the program stops at a breakpoint, watchpoint, or due to a signal, the source code window displays the line where the program stopped. It is very common that the program stops due to a signal (usually a SIGSEGV, segmentation violation) in a function that is not part of the program, that you have written. In this case you investigate the stack window and look for a function that you have written (start at the top of the list) and click on it. This will bring you to a location that you can start your search for the real bug.

In the menu Execution you find the commands that you need to run the program, step through code, and to interrupt the program (Break) while it is running. The important commands (Run and all kinds of Step) are bound to function keys. For efficient debugging it is strongly recommend that you get used to using them.
The functions are not configurable, but perhaps you want to contribute a bit of code that does it?

In the menu Breakpoint you find commands to set, clear, disable, and enable permanent and temporary breakpoints. You can display a list of breakpoints in the breakpoints window. You can also set a breakpoint by clicking at the left end of the source line (using the left mouse button), and you can enable and disable a breakpoint by clicking it using the middle mouse button.

The gearwheel in the toolbar indicates whether gdb is working, in which case it rotates. It rotates fast while KDbg wouldn't accept execution commands, and it rotates slowly while KDbg retrieves the values of variable.

KDbg's information windows

KDbg displays information and accepts commands in number of different windows. In the menu View you find commands to show and hide these windows. They are docking windows, which means that you can drag them around and arrange them in any manner you like.

Tips and such

The following topics give some useful hints on using KDbg.

Known problems

gdb 4.16 has problems in handling C++ classes with virtual base classes. (Such classes commonly occur in CORBA programs.) It dies quite often due to a segmentation violation. KDbg reports when gdb exits unexpectedly. Unfortunately, you cannot really do anything about it. You have to restart gdb by choosing File|Executable, which restarts your debugging session :-(.

KDbg's type recognition only works for libraries that are linked dynamically to the program being debugged.

Author

KDbg is written by Johannes Sixt with the help of many others.
KDbg homepage is at http://members.nextra.at/johsixt/kdbg.html.