I have a file that is several thousand lines long opened in TUI mode of gdb. I would like to search the file for a variable, is that possible? Because the file is long, I am really trying to avoid hunting for the word manually.
1 Answers
There are no TUI specific search commands defined in manual. And gdb is debugger, not code navigation tool (use ctags/cscope/lxr/source navigator; or use IDE with debugger and with code navigator).
Try to use gdb (non-TUI) command, but it will work only for one next location (I see no "next search" here):
https://sourceware.org/gdb/onlinedocs/gdb/Search.html#Search
There are two commands for searching through the current source file for a regular expression.
forward-search regexp search regexp
The command ‘
forward-search regexp
’ checks each line, starting with the one following the last line listed, for a match forregexp
. It lists the line that is found. You can use the synonym ‘search regexp
’ or abbreviate the command name asfo
.reverse-search regexp
The command ‘
reverse-search regexp
’ checks each line, starting with the one before the last line listed and going backward, for a match forregexp
. It lists the line that is found. You can abbreviate this command asrev
.
You can also use list
commands to change lines displayed in TUI source window - https://sourceware.org/gdb/onlinedocs/gdb/List.html#List

- 90,338
- 53
- 357
- 513