How to get GDB to do a 'list' after every step?

前端 未结 3 933
庸人自扰
庸人自扰 2020-12-09 04:05

I can step along with gdb, but I have to give the \"list\" command every time I want to see where I am in source code.

(gdb) next
351     int right = get_va         


        
相关标签:
3条回答
  • 2020-12-09 04:41

    You can use a GDB macro for this:

    (gdb) def n
    Type commands for definition of "n".
    End with a line saying just "end".
    >next
    >list
    >end
    

    If you want an arrow pointing at the current line, you might consider using a GDB front-end instead (e.g. M-x gdb in Emacs).

    0 讨论(0)
  • 2020-12-09 04:46

    Use gdb TUI mode http://sourceware.org/gdb/onlinedocs/gdb/TUI-Overview.html#TUI-Overview You can enter or leave the TUI mode with C-x A key binding.

    0 讨论(0)
  • 2020-12-09 04:51

    hook-stop

    define hook-stop
      l
    end
    

    Doc: https://sourceware.org/gdb/current/onlinedocs/gdb/Hooks.html

    In addition, a pseudo-command, ‘stop’ exists. Defining (‘hook-stop’) makes the associated commands execute every time execution stops in your program: before breakpoint commands are run, displays are printed, or the stack frame is printed.

    Learned from: https://stackoverflow.com/a/8374474/895245

    Highlight the current line

    This is the only thing missing to completely replace the buggy -tui mode completely.

    It is currently not possible without Python scripting: https://sourceware.org/bugzilla/show_bug.cgi?id=21044

    With Python scripting, I'm currently using: https://github.com/cyrus-and/gdb-dashboard

    See also: How to highlight and color gdb output during interactive debugging?

    0 讨论(0)
提交回复
热议问题