Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GDB: How to check current line number during debug

Tags:

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.

like image 242
Freedom_Ben Avatar asked May 20 '13 19:05

Freedom_Ben


1 Answers

Some digging around revealed the following methods:

  1. 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)  
  2. where or bt (same effect): This prints out the call stack, ending on the current line.

  3. list *$pc: This doesn't tell you the exact line but it prints out the surrounding lines with the current line in the center.
like image 56
Freedom_Ben Avatar answered Nov 05 '22 13:11

Freedom_Ben