How does one obtain the pid of the currently debugged process in gdb?

c++, gdb, linux

Solution

One simple way is `info inferior`. Here I'm debugging gdb with itself and this command shows the PID of the debuggee:

(top-gdb) info inferior
  Num  Description       Executable        
* 1    process 14068     /home/tromey/gdb/build/gdb/gdb 

You can also just call the ordinary C function:

(top-gdb) print getpid()
$3 = 14068

Problem

Inside gdb, what command will provide the pid of the process getting debugged? Most of the google results discuss only how to attach gdb to a process once we know the pid.

Original source