简体   繁体   中英

how to simply create a C++ stacktrace dump on crash on windows

I'm not looking for anything other than logging a stacktrace to a file when the program crashes. I don't care for it to email me or upload anything to a server. It's fine for the moment if that means it only works for RelWithDebInfo builds, or for builds with access to .pdb files or whatever. How can I accomplish this?

You can use MiniDumpWriteDump from dbghelp.dll.

I'm not looking for anything other than logging a stacktrace to a file when the program crashes.

Use Ian Taylor's libbacktrace .

It is ported to several OSes. On Linux, it works better if executables and libraries are compiled with DWARF debug information. (eg with g++ -Wall -g -O2 if using recent GCC ). Be also aware of signal(7) and signal-safety(7) on Linux.

RefPerSys uses it. And so does recent GCC compilers in 2021.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM