kuilin
kuilin

Reputation: 119

Why is there "no 'stop' command" in gdb?

I'm trying to learn the basics of gdb. I saw that, in gdb's help obscure, there's a line that says:

stop -- There is no 'stop' command

However, entering stop does not do the same thing as entering a nonexistant command - it doesn't print the "undefined command" message. Moreover, it appears to do nothing and output nothing.

Is this "command" there for some sort of backward compatibility reason? If not, why is there a command that doesn't do anything but have a line in the help that asserts that it is not a command? If so, why doesn't it print out at least something back to user indicating that nothing has been done, so that they are not confused if they assumed it does something related to its name? Or does it actually do something?

I feel like there's some sort of obvious-in-hindsight reason behind this weird command, but surprisingly I've found no way I can phrase it to Google such that it comes up with anyone else asking this question. I hope I'm not just being dumb and wasting y'alls' time, but I'm honestly stumped.

Upvotes: 1

Views: 386

Answers (1)

ks1322
ks1322

Reputation: 35716

help obscure for stop command is indeed a bit obscure. To get more info about it you can read help stop:

(gdb) help stop 
There is no `stop' command, but you can set a hook on `stop'.
This allows you to set a list of commands to be run each time execution
of the program stops.

Actually there is stop command but it does nothing. It is intended to be used in gdb hooks. See also hooks documentation:

In addition, a pseudo-command, ‘stop’ exists. Defining (‘hook-stop’) makes the associated commands execute every time execution stops in your program: before breakpoint commands are run, displays are printed, or the stack frame is printed.

Upvotes: 2

Related Questions