GDB Plugin

Martin Gergov

T.C. Hollingsworth

Introduction

Kate's GDB plugin provides a simple frontend to the popular GNU Project Debugger.

Important

Previous experience with GDB is strongly recommended. For more information on using GDB, visit the GDB website.

You can enable the GDB plugin in the Plugins section of Kate's configuration.

For the plugin to work properly, you must have a source file (of any type supported by GDB) and an executable.

Tip

If you compile using gcc/g++ you might want to use the -ggdb command line argument.

After these preparations are made, open the source file in Kate, enter the path to the executable in the Settings tab of the Debug View tool view, and select DebugStart Debugging from the menu to get started.

Menu and Toolbar Structure

All of these options are available in Kate's menus, and many are available on the Debug toolbar as well.

ViewTool ViewShow Debug View

Shows a tool view containing GDB output, the GDB command line used, and other settings.

ViewTool ViewShow Locals

Shows a list of all currently loaded variables and their values.

ViewTool ViewShow Call Stack

Shows a GDB backtrace.

DebugTargets

A submenu containing a list of targets (executables).

DebugArg Lists

A submenu containing all argument lists.

DebugStart Debugging

Starts GDB with a target.

DebugKill / Stop Debugging

Stops GDB.

DebugRestart Debugging

Restarts GDB.

DebugToggle Breakpoint / Break

Set a breakpoint at the current cursor position.

DebugStep In

Execute the present statement (function call will be debugged).

DebugStep Over

Execute the present statement (function call will not be debugged).

DebugStep Out

Resumes execution until the program that is executing terminates.

DebugMove PC

Move program counter (next execution).

DebugRun To Cursor

Runs the program until it reaches current cursor position.

DebugContinue

Ignores any breakpoints and executes program until it terminates (successfully or not).

DebugPrint Value

Prints the value of the variable that the cursor is currently pointing to.

SettingsToolbars ShownGDB Plugin

Display the debugging toolbar.

Debug View

The Debug View tool view consists of several tabs:

GDB Output

Contains output from GDB and a GDB command line.


The Output tab.

The Output tab displaying the output from a debugging session.


Settings
Target

Path to the target (executable) for debugging.

Working Directory

The current working directory provided to the target.

Arg List

Arguments passed to the program.

Keep focus

Keeps focus on the GDB command line.

Redirect IO

Opens a new IO tab in the Debug View where you can view output and provide input to the running program.


The Settings tab.

The Settings tab displaying the configuration of a debugging session.


IO

Contains an area that displays output from the running program and a command line where you may provide input to it.


The IO tab.

The IO tab displaying output from a simple test program.


Call Stack and Locals

The Call Stack tool view contains a list of the formatted backtrace returned from GDB.


The Call Stack tool view.

The GDB Plugin's Call Stack tool view.


The Locals tool view contains a list of all currently loaded variables from the program and their corresponding values.


The Locals tool view.

The GDB Plugin's Locals tool view.


Thanks and Acknowledgments

Special thanks to Google Code-In 2011 participant Martin Gergov for writing much of this section.