问题描述:

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.

网友答案:

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.
相关阅读:
Top