Fixing Segmentation faults in C++

前端 未结 6 1817
被撕碎了的回忆
被撕碎了的回忆 2020-11-27 09:44

I am writing a cross-platform C++ program for Windows and Unix. On the Window side, the code will compile and execute no problem. On the Unix side, it will compile however w

6条回答
  •  醉梦人生
    2020-11-27 10:26

    1. Compile your application with -g, then you'll have debug symbols in the binary file.

    2. Use gdb to open the gdb console.

    3. Use file and pass it your application's binary file in the console.

    4. Use run and pass in any arguments your application needs to start.

    5. Do something to cause a Segmentation Fault.

    6. Type bt in the gdb console to get a stack trace of the Segmentation Fault.

提交回复
热议问题