How to get GCC to print useful RUNTIME error messages?

#defineing _GLIBCXX_DEBUGforces GCC to catch a large class of C ++ runtime errors, for example, accessing STLs outside boundaries, invalid iterators, etc.

Unfortunately, when an error occurs, the printed message is not very useful. I know how to print a backtrace with a function, __FILE__and __LINE__with a macro.

Is there an easy way to convince GCC to do this, or to specify a function / macro to call if errors actually _GLIBCXX_DEBUGcatch that happen ?

+5
source share
2 answers

, , , , - , GCC.

, .../debug/macros.h , , _GLIBCXX_DEBUG_VERIFY. .

: , .

+3

, abort(), , , , . , , , backtrace.

, abort() ( libstdc++-v3/src/c++11/debug.cc). , , std::terminate(), terminate_handler set_terminate, .

+3

All Articles