7

When searching gdb command history, is there a way to go through only those command matching a given one?

for example, sometimes I only want to search previous break commands, not the entire command history. Is there a shortcut to only go through commands that start with "break" or "b"? That can save me a million keystroke.

2
  • How are you searching history now?
    – ams
    Jan 16, 2013 at 17:16
  • i normally use cgdb. The up-arrow key in the command line let me go through history.
    – user1252446
    Jan 16, 2013 at 18:27

1 Answer 1

17

In regular GDB, CtrlR enables search mode. This works the same as bash, zsh, and many other shells.

Once in search mode, the prompt changes:

(reverse-i-search)`': 

Typing letters then enters the text to find:

(reverse-i-search)`br': break main

To find the next command that matches, hit CtrlR again.

To run the command again, hit Enter.

To edit the command, hit the left or right cursor key.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.