Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:31

0001 #ifndef BOOST_CORE_VERBOSE_TERMINATE_HANDLER_HPP_INCLUDED
0002 #define BOOST_CORE_VERBOSE_TERMINATE_HANDLER_HPP_INCLUDED
0003 
0004 // MS compatible compilers support #pragma once
0005 
0006 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
0007 # pragma once
0008 #endif
0009 
0010 //  Copyright 2022 Peter Dimov
0011 //  Distributed under the Boost Software License, Version 1.0.
0012 //  https://www.boost.org/LICENSE_1_0.txt
0013 
0014 #include <boost/core/demangle.hpp>
0015 #include <boost/throw_exception.hpp>
0016 #include <boost/config.hpp>
0017 #include <exception>
0018 #include <typeinfo>
0019 #include <cstdlib>
0020 #include <cstdio>
0021 
0022 namespace boost
0023 {
0024 namespace core
0025 {
0026 
0027 BOOST_NORETURN inline void verbose_terminate_handler()
0028 {
0029     std::set_terminate( 0 );
0030 
0031 #if defined(BOOST_NO_EXCEPTIONS)
0032 
0033     std::fputs( "std::terminate called with exceptions disabled\n", stderr );
0034 
0035 #else
0036 
0037     try
0038     {
0039         throw;
0040     }
0041     catch( std::exception const& x )
0042     {
0043 #if defined(BOOST_NO_RTTI)
0044 
0045         char const * typeid_name = "unknown (RTTI is disabled)";
0046 
0047 #else
0048 
0049         char const * typeid_name = typeid( x ).name();
0050 
0051         boost::core::scoped_demangled_name typeid_demangled_name( typeid_name );
0052 
0053         if( typeid_demangled_name.get() != 0 )
0054         {
0055             typeid_name = typeid_demangled_name.get();
0056         }
0057 
0058 #endif
0059 
0060         boost::source_location loc = boost::get_throw_location( x );
0061 
0062         std::fprintf( stderr,
0063             "std::terminate called after throwing an exception:\n\n"
0064             "      type: %s\n"
0065             "    what(): %s\n"
0066             "  location: %s:%lu:%lu in function '%s'\n",
0067 
0068             typeid_name,
0069             x.what(),
0070             loc.file_name(), static_cast<unsigned long>( loc.line() ),
0071             static_cast<unsigned long>( loc.column() ), loc.function_name()
0072         );
0073     }
0074     catch( ... )
0075     {
0076         std::fputs( "std::terminate called after throwing an unknown exception\n", stderr );
0077     }
0078 
0079 #endif
0080 
0081     std::fflush( stdout );
0082     std::abort();
0083 }
0084 
0085 } // namespace core
0086 } // namespace boost
0087 
0088 #endif  // #ifndef BOOST_CORE_VERBOSE_TERMINATE_HANDLER_HPP_INCLUDED