How do I check the current line number that I'm stopped in when debugging with GDB? I would have thought this would be obvious (and maybe it is) but I don't see it on the GDB Cheat Sheet.
Asked
Active
Viewed 2.0k times
24
-
possible duplicate of [gdb: how to print the current line or find the current line number?](http://stackoverflow.com/questions/14581837/gdb-how-to-print-the-current-line-or-find-the-current-line-number) – Ciro Santilli OurBigBook.com Jun 10 '15 at 19:15
2 Answers
38
Some digging around revealed the following methods:
frame
: This command was exactly what I was looking for. Output looked as follows:(gdb) frame #0 MyDialog::on_saveButton_clicked (this=0x72bf9e0) at src/ui/dialog/MyDialog.cxx:86 86 _item->save(); (gdb)
where
orbt
(same effect): This prints out the call stack, ending on the current line.list *$pc
: This doesn't tell you the exact line but it prints out the surrounding lines with the current line in the center.

Freedom_Ben
- 11,247
- 10
- 69
- 89
-
3I know you mention GDB but just as a suggestion have you tried using gdbtui? It has a nice terminal GUI that let's you see the current and surround lines. You can also scroll up down using the keyboard directional keys. – Nobilis May 21 '13 at 03:12
-