Call-stack for exceptions in C++

后端 未结 10 1384
忘了有多久
忘了有多久 2020-12-14 15:33

Today, in my C++ multi-platform code, I have a try-catch around every function. In every catch block I add the current function\'s name to the exception and throw it again,

10条回答
  •  既然无缘
    2020-12-14 15:48

    Linking with the libcsdbg library (see https://stackoverflow.com/a/18959030/364818 for original answer) looks like the cleanest way of getting a stack trace without modifying your source code or 3rd party source code (ie STL).

    This uses the compiler to instrument the actual stack collection, which is really want you want to do.

    I haven't used it and it is GPL tainted, but it looks like the right idea.

提交回复
热议问题