Go to the first, previous, next, last section, table of contents.
- TUI Overview: TUI overview
- TUI Keys: TUI key bindings
- TUI Commands: TUI specific commands
- TUI Configuration: TUI configuration variables
The GDB Text User Interface, TUI in short,is a terminal interface which uses the curses
libraryto show the source file, the assembly output, the program registersand GDB commands in separate text windows.The TUI is available only when GDB is configuredwith the --enable-tui
configure option (see section configure
options).
Gdb Mac Os Catalina
TUI overview
- Mac OS Sierra 10.13.6 gdb 8.0.1 I discovered that I already had gdbcert1 in my System. Followed everything from 7. – Sergej Fomin May 31 '19 at 9:12.
- VisualGDB is Visual Studio extension that adds C/C support for Embedded, Linux, and Android platforms. It supports building, debugging and provides a powerful IntelliSense engine.
Using GDB on Mac OS X INSTALLATION: if not installed already, install brew; if you have brew already on your system, you might want to update the brew installation, typing: brew update. This will give you the latest installation recipes; install GDB: brew install gdb. This will install the latest GDB.
The TUI has two display modes that can be switched whileGDB runs:
- A curses (or TUI) mode in which it displays several textwindows on the terminal.
- A standard mode which corresponds to the GDB configured withoutthe TUI.
In the TUI mode, GDB can display several text windowon the terminal:
The source, assembly and register windows are attached to the threadand the frame position. They are updated when the current threadchanges, when the frame changes or when the program counter changes.These three windows are arranged by the TUI according to severallayouts. The layout defines which of these three windows are visible.The following layouts are available:
- source
- assembly
- source and assembly
- source and registers
- assembly and registers
TUI Key Bindings
The TUI installs several key bindings in the readline keymaps(see section Command Line Editing).They allow to leave or enter in the TUI mode or they operatedirectly on the TUI layout and windows. The following key bindingsare installed for both TUI mode and the GDB standard mode.
The following key bindings are handled only by the TUI mode:
layout next
- Display the next layout.
layout prev
- Display the previous layout.
layout src
- Display the source window only.
layout asm
- Display the assembly window only.
layout split
- Display the source and assembly window.
layout regs
- Display the register window together with the source or assembly window.
focus next | prev | src | asm | regs | split
- Set the focus to the named window.This command allows to change the active window so that scrolling keyscan be affected to another window.
refresh
- Refresh the screen. This is similar to using C-L key.
update
- Update the source window and the current execution point.
winheight name +count
winheight name -count
- Change the height of the window name by countlines. Positive counts increase the height, while negative countsdecrease it.
TUI configuration variables
The TUI has several configuration variables that control theappearance of windows on the terminal.
space
- Use a space character to draw the border.
ascii
- Use ascii characters + - and | to draw the border.
acs
- Use the Alternate Character Set to draw the border. The border isdrawn using character line graphics if the terminal supports them.
set tui active-border-mode mode
normal
, standout
, reverse
,half
, half-standout
, bold
and bold-standout
.set tui border-mode mode
- Eclipse for python on mac.
Step 2. Launch gdb
Launch the C debugger (gdb) as shown below.
Step 3. Set up a break point inside C program
Other formats:
- break [file_name]:line_number
- break [file_name]:func_name
Places break point in the C program, where you suspect errors. While executing the program, the debugger will stop at the break point, and gives you the prompt to debug.
So before starting up the program, let us place the following break point in our program.
Step 4. Execute the C program in gdb debugger
You can start running the program using the run command in the gdb debugger. You can also give command line arguments to the program via run args. The example program we used here does not requires any command line arguments so let us give run, and start the program execution.
Once you executed the C program, it would execute until the first break point, and give you the prompt for debugging.
You can use various gdb commands to debug the C program as explained in the sections below.
Step 5. Printing the variable values inside gdb debugger
As you see above, in the factorial.c, we have not initialized the variable j. So, it gets garbage value resulting in a big numbers as factorial values.
Fix this issue by initializing variable j with 1, compile the C program and execute it again.
Install Gdb For Mac
Even after this fix there seems to be some problem in the factorial.c program, as it still gives wrong factorial value.
So, place the break point in 10th line, and continue as explained in the next section.
Step 6. Continue, stepping over and in – gdb commands
There are three kind of gdb operations you can choose when the program stops at a break point. They are continuing until the next break point, stepping in, or stepping over the next program lines.
- c or continue: Debugger will continue executing until the next break point.
- n or next: Debugger will execute the next line as single instruction.
- s or step: Same as next, but does not treats function as a single instruction, instead goes into the function and executes it line by line.
By continuing or stepping through you could have found that the issue is because we have not used the <= in the ‘for loop’ condition checking. So changing that from < to <= will solve the issue.
gdb command shortcuts
Use following shortcuts for most of the frequent gdb operations.
- l – list
- p – print
- c – continue
- s – step
- ENTER: pressing enter key would execute the previously executed command again.
Apple Vs Windows Pros And Cons
Miscellaneous gdb commands
- l command: Use gdb command l or list to print the source code in the debug mode. Use l line-number to view a specific line number (or) l function to view a specific function.
- bt: backtrack – Print backtrace of all stack frames, or innermost COUNT frames.
- help – View help for a particular gdb topic — help TOPICNAME.
- quit – Exit from the gdb debugger.