How to get a stack trace when C++ program crashes? (using msvc8/2005)

后端 未结 7 715
不知归路
不知归路 2021-02-09 13:44

Sometimes my c++ program crashes in debug mode, and what I got is a message box saying that an assertion failed in some of the internal memory management routines (accessing una

7条回答
  •  悲&欢浪女
    2021-02-09 14:31

    If you have a crash, you can get information about where the crash happened whether you have a debug or a release build. And you can see the call stack even if you are on a computer that does not have the source code.

    To do this you need to use the PDB file that was built with your EXE. Put the PDB file inside the same directory as the EXE that crashed. Note: Even if you have the same source code, building twice and using the first EXE and the second PDB won't work. You need to use the exact PDB that was built with your EXE.

    Then attach a debugger to the process that crashed. Example: windbg or VS.

    Then simply checkout your call stack, while also having your threads window open. You will have to select the thread that crashed and check on the callstack for that thread. Each thread has a different call stack.

    If you already have your VS debugger attached, it will automatically go to the source code that is causing the crash for you.

    If the crash is happening inside a library you are using that you don't have the PDB for. There is nothing you can do.

提交回复
热议问题