Author: Johannes Sixt

# KDbg - User's Manual

## Contents

- Introduction
- Using KDbg
- KDbg's information windows
- Tips and such
- Advanced topic: Type tables
- How to invoke KDbg from the command line
- Author

## 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 Settings|Global Options.

#### Specifying a debugging target

To debug a program, choose File|Load 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 Settings|This Program, in the Program Settings dialog.

Furthermore, it is possible to debug XSLT scripts.

#### 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. From the list processes specify the one you want to attach to and click OK. The running program is halted (not terminated), and the current point of execution is displayed in the source window.

On some systems the list of processes may not be available. In this case a simple edit box is available where the process number can be specified.

#### 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. You can use Settings|Configure Shortcuts if you want to bind the functions to different keys.

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 animation in the toolbar indicates whether the program is running. It stops when the program stopped in a breakpoint or for some other reason or when the program exited. This animated button is a shortcut for Execution|Break.

## 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.

- The source code window
- The local variables window
- The stack window
- The watched expressions window
- The breakpoint list
- The output window
- The register dump window
- The memory dump window
- The threads window

## Tips and such

The following topics give some useful hints on using KDbg.

- Tips and Tricks
- How do I...?

## Author

KDbg is written by Johannes Sixt with contributions from many people, among others (in no particular order):

- Marc Font Freixa
- Michael Hansen
- Daniel Black
- Max Tomilov
- Charles Samuels
- David Edmundson
- Stefan Taferner
- Keith Isdale
- Daniel Thor Kristjansson
- Matthew Allen

KDbg homepage is at https://www.kdbg.org/.