Debugging ncurses application with gdb

后端 未结 2 761
野性不改
野性不改 2020-12-17 20:51

I\'m trying to debug my ncurses application, using gdb. I use tty command to redirect program\'s I/O to another terminal. Output works like a charm, but I\'m having

2条回答
  •  暖寄归人
    2020-12-17 21:20

    Maybe it's a bit late to answer, but hope this helps: It took some time to figure out how to debug ncurses applications, finally i made a very comfy way with the help of gdbserver and tmux.

    This way I/O of gdb and the application are completely separated:

    debug.sh (the script that starts debugging):

    #!/bin/bash
    tmux splitw -h -p 50 "gdbserver :12345 ./yourapplication"
    tmux selectp -t 0
    gdb -x debug.gdb
    

    debug.gdb (one-liner gdb scriptfile for comfort):

    target remote localhost:12345
    

    So this way, application starts up on right side, gdb on left waiting to hit continue or any other usual gdb stuff :)

    Once you exit, tmux automatically closes the gdbserver (therefore right panel as well) and that's all :)

提交回复
热议问题