Getting GDB to save a list of breakpoints

后端 未结 11 1130
终归单人心
终归单人心 2020-12-04 05:32

OK, info break lists the breakpoints, but not in a format that would work well with reusing them using the --command as in this question. Does GDB have a method for

11条回答
  •  暖寄归人
    2020-12-04 06:09

    Extension to the answer from Johannes: you could automatically reformat the output of info break into a valid GDB command file:

    .gdbinit:
    
    define bsave
       shell rm -f brestore.txt
       set logging file brestore.txt
       set logging on
       info break
       set logging off
       # Reformat on-the-fly to a valid gdb command file
       shell perl -n -e 'print "break $1\n" if /^\d+.+?(\S+)$/g' brestore.txt > brestore.gdb
    end
    document bsave
      store actual breakpoints
    end
    

    Afterwards you have a valid commandfile in brestore.gdb.

    This worked for me when the application is compiled with -g.

    I also successfully tested it with GDB v6.8 on Ubuntu 9.10 (Karmic Koala).

提交回复
热议问题