gdb: how to print the current line or find the current line number?

Boris Burkov picture Boris Burkov · Jan 29, 2013 · Viewed 104.8k times · Source

list commands prints a set of lines, but I need one single line, where I am and where an error has probably occurred.

Answer

user3162307 picture user3162307 · Jan 9, 2014

The 'frame' command will give you what you are looking for. (This can be abbreviated just 'f'). Here is an example:

(gdb) frame
\#0  zmq::xsub_t::xrecv (this=0x617180, msg_=0x7ffff00008e0) at xsub.cpp:139
139         int rc = fq.recv (msg_);
(gdb)

Without an argument, 'frame' just tells you where you are at (with an argument it changes the frame). More information on the frame command can be found here.