]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/stacktrace/detail/frame_decl.hpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / boost / stacktrace / detail / frame_decl.hpp
CommitLineData
f67539c2 1// Copyright Antony Polukhin, 2016-2020.
b32b8144
FG
2//
3// Distributed under the Boost Software License, Version 1.0. (See
4// accompanying file LICENSE_1_0.txt or copy at
5// http://www.boost.org/LICENSE_1_0.txt)
6
7#ifndef BOOST_STACKTRACE_DETAIL_FRAME_DECL_HPP
8#define BOOST_STACKTRACE_DETAIL_FRAME_DECL_HPP
9
10#include <boost/config.hpp>
11#ifdef BOOST_HAS_PRAGMA_ONCE
12# pragma once
13#endif
14
15#include <iosfwd>
16#include <string>
17
18#include <boost/core/explicit_operator_bool.hpp>
19
20#include <boost/stacktrace/safe_dump_to.hpp> // boost::stacktrace::detail::native_frame_ptr_t
21#include <boost/stacktrace/detail/void_ptr_cast.hpp>
22
23#include <boost/stacktrace/detail/push_options.h>
24
25/// @file boost/stacktrace/detail/frame_decl.hpp
26/// Use <boost/stacktrace/frame.hpp> header instead of this one!
27
28namespace boost { namespace stacktrace {
29
30/// @class boost::stacktrace::frame boost/stacktrace/detail/frame_decl.hpp <boost/stacktrace/frame.hpp>
31/// @brief Class that stores frame/function address and can get information about it at runtime.
32class frame {
33public:
34 typedef boost::stacktrace::detail::native_frame_ptr_t native_frame_ptr_t;
35
36private:
37 /// @cond
38 native_frame_ptr_t addr_;
39 /// @endcond
40
41public:
42 /// @brief Constructs frame that references NULL address.
43 /// Calls to source_file() and source_line() will return empty string.
44 /// Calls to source_line() will return 0.
45 ///
46 /// @b Complexity: O(1).
47 ///
48 /// @b Async-Handler-Safety: Safe.
49 /// @throws Nothing.
50 BOOST_CONSTEXPR frame() BOOST_NOEXCEPT
51 : addr_(0)
52 {}
53
54#ifdef BOOST_STACKTRACE_DOXYGEN_INVOKED
55 /// @brief Copy constructs frame.
56 ///
57 /// @b Complexity: O(1).
58 ///
59 /// @b Async-Handler-Safety: Safe.
60 /// @throws Nothing.
61 constexpr frame(const frame&) = default;
62
63 /// @brief Copy assigns frame.
64 ///
65 /// @b Complexity: O(1).
66 ///
67 /// @b Async-Handler-Safety: Safe.
68 /// @throws Nothing.
69 constexpr frame& operator=(const frame&) = default;
70#endif
71
72 /// @brief Constructs frame that references addr and could later generate information about that address using platform specific features.
73 ///
74 /// @b Complexity: O(1).
75 ///
76 /// @b Async-Handler-Safety: Safe.
77 /// @throws Nothing.
78 BOOST_CONSTEXPR explicit frame(native_frame_ptr_t addr) BOOST_NOEXCEPT
79 : addr_(addr)
80 {}
81
82 /// @brief Constructs frame that references function_addr and could later generate information about that function using platform specific features.
83 ///
84 /// @b Complexity: O(1).
85 ///
86 /// @b Async-Handler-Safety: Safe.
87 /// @throws Nothing.
88 template <class T>
89 explicit frame(T* function_addr) BOOST_NOEXCEPT
90 : addr_(boost::stacktrace::detail::void_ptr_cast<native_frame_ptr_t>(function_addr))
91 {}
92
93 /// @returns Name of the frame (function name in a human readable form).
94 ///
95 /// @b Complexity: unknown (lots of platform specific work).
96 ///
97 /// @b Async-Handler-Safety: Unsafe.
98 /// @throws std::bad_alloc if not enough memory to construct resulting string.
99 BOOST_STACKTRACE_FUNCTION std::string name() const;
100
101 /// @returns Address of the frame function.
102 ///
103 /// @b Complexity: O(1).
104 ///
105 /// @b Async-Handler-Safety: Safe.
106 /// @throws Nothing.
107 BOOST_CONSTEXPR native_frame_ptr_t address() const BOOST_NOEXCEPT {
108 return addr_;
109 }
110
111 /// @returns Path to the source file, were the function of the frame is defined. Returns empty string
112 /// if this->source_line() == 0.
113 /// @throws std::bad_alloc if not enough memory to construct resulting string.
114 ///
115 /// @b Complexity: unknown (lots of platform specific work).
116 ///
117 /// @b Async-Handler-Safety: Unsafe.
118 BOOST_STACKTRACE_FUNCTION std::string source_file() const;
119
120 /// @returns Code line in the source file, were the function of the frame is defined.
121 /// @throws std::bad_alloc if not enough memory to construct string for internal needs.
122 ///
123 /// @b Complexity: unknown (lots of platform specific work).
124 ///
125 /// @b Async-Handler-Safety: Unsafe.
126 BOOST_STACKTRACE_FUNCTION std::size_t source_line() const;
127
128 /// @brief Checks that frame is not references NULL address.
129 /// @returns `true` if `this->address() != 0`
130 ///
131 /// @b Complexity: O(1)
132 ///
133 /// @b Async-Handler-Safety: Safe.
134 BOOST_EXPLICIT_OPERATOR_BOOL()
135
136 /// @brief Checks that frame references NULL address.
137 /// @returns `true` if `this->address() == 0`
138 ///
139 /// @b Complexity: O(1)
140 ///
141 /// @b Async-Handler-Safety: Safe.
142 BOOST_CONSTEXPR bool empty() const BOOST_NOEXCEPT { return !address(); }
143
144 /// @cond
145 BOOST_CONSTEXPR bool operator!() const BOOST_NOEXCEPT { return !address(); }
146 /// @endcond
147};
148
149
150namespace detail {
151 BOOST_STACKTRACE_FUNCTION std::string to_string(const frame* frames, std::size_t size);
152} // namespace detail
153
154}} // namespace boost::stacktrace
155
156
157#include <boost/stacktrace/detail/pop_options.h>
158
159#endif // BOOST_STACKTRACE_DETAIL_FRAME_DECL_HPP