How can I rerun a program with gdb until a segmentation fault occurs?

前端 未结 1 1905
再見小時候
再見小時候 2020-12-04 12:04

My program has a segmentation fault problem, but it faults rarely(once in 20 times or more), and to debug it in GDB, I need to manually rerun the program until the segmentat

相关标签:
1条回答
  • 2020-12-04 12:46

    Put a breakpoint at the exit of your program that triggers the run command, and don't forget set pagination off. Information on settings commands is available in the Breakpoint Command Lists section of the gdb documentation. In short:

    set pagination off
    break _exit
    commands
    run
    end
    

    After the commands line you'll see that the next two lines are being entered as the command to execute when the breakpoint is reached.

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