]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/core/verbose_terminate_handler.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / core / verbose_terminate_handler.hpp
CommitLineData
1e59de90
TL
1#ifndef BOOST_CORE_VERBOSE_TERMINATE_HANDLER_HPP_INCLUDED
2#define BOOST_CORE_VERBOSE_TERMINATE_HANDLER_HPP_INCLUDED
3
4// MS compatible compilers support #pragma once
5
6#if defined(_MSC_VER) && (_MSC_VER >= 1020)
7# pragma once
8#endif
9
10// Copyright 2022 Peter Dimov
11// Distributed under the Boost Software License, Version 1.0.
12// https://www.boost.org/LICENSE_1_0.txt
13
14#include <boost/core/demangle.hpp>
15#include <boost/throw_exception.hpp>
16#include <boost/config.hpp>
17#include <exception>
18#include <typeinfo>
19#include <cstdlib>
20#include <cstdio>
21
22namespace boost
23{
24namespace core
25{
26
27BOOST_NORETURN inline void verbose_terminate_handler()
28{
29 std::set_terminate( 0 );
30
31#if defined(BOOST_NO_EXCEPTIONS)
32
33 std::fputs( "std::terminate called with exceptions disabled\n", stderr );
34
35#else
36
37 try
38 {
39 throw;
40 }
41 catch( std::exception const& x )
42 {
43#if defined(BOOST_NO_RTTI)
44
45 char const * typeid_name = "unknown (RTTI is disabled)";
46
47#else
48
49 char const * typeid_name = typeid( x ).name();
50
51 boost::core::scoped_demangled_name typeid_demangled_name( typeid_name );
52
53 if( typeid_demangled_name.get() != 0 )
54 {
55 typeid_name = typeid_demangled_name.get();
56 }
57
58#endif
59
60 boost::source_location loc = boost::get_throw_location( x );
61
62 std::fprintf( stderr,
63 "std::terminate called after throwing an exception:\n\n"
64 " type: %s\n"
65 " what(): %s\n"
66 " location: %s:%lu:%lu in function '%s'\n",
67
68 typeid_name,
69 x.what(),
70 loc.file_name(), static_cast<unsigned long>( loc.line() ),
71 static_cast<unsigned long>( loc.column() ), loc.function_name()
72 );
73 }
74 catch( ... )
75 {
76 std::fputs( "std::terminate called after throwing an unknown exception\n", stderr );
77 }
78
79#endif
80
81 std::fflush( stdout );
82 std::abort();
83}
84
85} // namespace core
86} // namespace boost
87
88#endif // #ifndef BOOST_CORE_VERBOSE_TERMINATE_HANDLER_HPP_INCLUDED