![](https://csdnimg.cn/release/download_crawler_static/8289805/bg6.jpg)
Chapter 2: Understanding the core concepts of CGDB 3
2 Understanding the core concepts of CGDB
The CGDB user interface currently consists of two windows and a status bar. The source
window is currently on the top and the GDB window is on the bottom. The status bar
currently separates the two windows.
The interface has several modes depending on which window is focused. CGDB mode
is when the source window is focused, GDB mode is when the GDB window is focused and
TTY mode is when the TTY window is focused.
Beginning with CGDB version 1.0, the windows are movable, and the user will be able
to create as many or as few that is desired. Currently however, all of my time is spent
developing the interface between CGDB and GDB. Once this is complete, the UI of CGDB
will become much more polished. If you are a ncurses developer, and have spare time to
work on this task, please contact me.
2.1 Understanding the source window.
The source window is the window that provides you a view of the source code that the
debugged program is made up of. It will display to the user a single source file at a time.
While the user is debugging, via next and step, CGDB will update the source file and line
number to keep you informed as to where GDB is debugging.
CGDB has several features that make debugging easier than using plain old GDB. One
feature you will notice right away while debugging a C, C++ or ADA program, is that the
source files are syntax highlighted. This allows the user to easily navigate through the
source file to look for certain places in the source code. If you would like to see another
source language highlighted, contact us. To understanding how to navigate through the
source window look at the commands in Section 3.1 [CGDB Mode], page 6.
In addition to showing the source code, CGDB also displays to the user the currently
executing line. The line number will be highlighted green, to represent that the particular
line, is the current line being debugged by GDB. Also, CGDB will display an arrow extend-
ing from the line number, to the source line. You can configure what type of arrow CGDB
uses with the :set arrowstyle configuration option. By default, the short arrow is used.
However, my personal favorite is the long arrow.
As you navigate through the source window, the current line the cursor is on will be
highlighted white. This simply helps you keep track of where you are in the file.
Also, you can set or delete breakpoints in CGDB from the source window. Simply
navigate to the line that you are interested in setting a breakpoint, and hit the space bar.
This will set a breakpoint on the line if one did not already exist. The line number should
turn red to indicate that a breakpoint has been set. Hitting the space bar again will delete
the breakpoint. If you disable the breakpoint, the line number will turn yellow, to represent
the disabled breakpoint.
CGDB also supports regular expression searching within the source window. If you type
/ or ? you can search in the source window for a string of interest. The C library regular
expression functions are used to perform this search, which honors things like ‘*’ or ‘+’.
The full list of commands that are available in the source window is in Section 3.1 [CGDB
Mode], page 6.