Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize to cpp11 #139

Merged
merged 20 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@ function(stacktrace_add_library suffix opt libs defs)

target_link_libraries(boost_stacktrace_${suffix}
PUBLIC
Boost::array
Boost::config
Boost::container_hash
Boost::core
Boost::predef
Boost::static_assert
Boost::type_traits
Boost::winapi
PRIVATE
${libs}
Expand Down
5 changes: 4 additions & 1 deletion build/Jamfile.v2
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# Copyright (C) 2016-2022, Antony Polukhin.
# Copyright (C) 2016-2023, Antony Polukhin.
#
# Use, modification and distribution is subject to the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#

import ../../config/checks/config : requires ;

project
: source-location .
: requirements
[ requires cxx11 ]
<visibility>hidden
;

Expand Down
8 changes: 4 additions & 4 deletions include/boost/stacktrace/detail/addr2line_impls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace boost { namespace stacktrace { namespace detail {

#if defined(BOOST_STACKTRACE_ADDR2LINE_LOCATION) && !defined(BOOST_NO_CXX11_CONSTEXPR)

constexpr bool is_abs_path(const char* path) BOOST_NOEXCEPT {
constexpr bool is_abs_path(const char* path) noexcept {
return *path != '\0' && (
*path == ':' || *path == '/' || is_abs_path(path + 1)
);
Expand All @@ -41,7 +41,7 @@ class addr2line_pipe {
::pid_t pid;

public:
explicit addr2line_pipe(const char *flag, const char* exec_path, const char* addr) BOOST_NOEXCEPT
explicit addr2line_pipe(const char *flag, const char* exec_path, const char* addr) noexcept
: p(0)
, pid(0)
{
Expand Down Expand Up @@ -97,11 +97,11 @@ class addr2line_pipe {
::close(pdes[1]);
}

operator ::FILE*() const BOOST_NOEXCEPT {
operator ::FILE*() const noexcept {
return p;
}

~addr2line_pipe() BOOST_NOEXCEPT {
~addr2line_pipe() noexcept {
if (p) {
::fclose(p);
int pstat = 0;
Expand Down
2 changes: 1 addition & 1 deletion include/boost/stacktrace/detail/collect_msvc.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace boost { namespace stacktrace { namespace detail {

std::size_t this_thread_frames::collect(native_frame_ptr_t* out_frames, std::size_t max_frames_count, std::size_t skip) BOOST_NOEXCEPT {
std::size_t this_thread_frames::collect(native_frame_ptr_t* out_frames, std::size_t max_frames_count, std::size_t skip) noexcept {
return boost::winapi::RtlCaptureStackBackTrace(
static_cast<boost::winapi::ULONG_>(skip),
static_cast<boost::winapi::ULONG_>(max_frames_count),
Expand Down
2 changes: 1 addition & 1 deletion include/boost/stacktrace/detail/collect_noop.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace boost { namespace stacktrace { namespace detail {

std::size_t this_thread_frames::collect(native_frame_ptr_t* /*out_frames*/, std::size_t /*max_frames_count*/, std::size_t /*skip*/) BOOST_NOEXCEPT {
std::size_t this_thread_frames::collect(native_frame_ptr_t* /*out_frames*/, std::size_t /*max_frames_count*/, std::size_t /*skip*/) noexcept {
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion include/boost/stacktrace/detail/collect_unwind.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ inline _Unwind_Reason_Code unwind_callback(::_Unwind_Context* context, void* arg
}
#endif //!defined(BOOST_STACKTRACE_USE_LIBC_BACKTRACE_FUNCTION)

std::size_t this_thread_frames::collect(native_frame_ptr_t* out_frames, std::size_t max_frames_count, std::size_t skip) BOOST_NOEXCEPT {
std::size_t this_thread_frames::collect(native_frame_ptr_t* out_frames, std::size_t max_frames_count, std::size_t skip) noexcept {
std::size_t frames_count = 0;
if (!max_frames_count) {
return frames_count;
Expand Down
18 changes: 6 additions & 12 deletions include/boost/stacktrace/detail/frame_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#include <iosfwd>
#include <string>

#include <boost/core/explicit_operator_bool.hpp>

#include <boost/stacktrace/safe_dump_to.hpp> // boost::stacktrace::detail::native_frame_ptr_t
#include <boost/stacktrace/detail/void_ptr_cast.hpp>

Expand Down Expand Up @@ -47,7 +45,7 @@ class frame {
///
/// @b Async-Handler-Safety: Safe.
/// @throws Nothing.
BOOST_CONSTEXPR frame() BOOST_NOEXCEPT
constexpr frame() noexcept
: addr_(0)
{}

Expand Down Expand Up @@ -75,7 +73,7 @@ class frame {
///
/// @b Async-Handler-Safety: Safe.
/// @throws Nothing.
BOOST_CONSTEXPR explicit frame(native_frame_ptr_t addr) BOOST_NOEXCEPT
constexpr explicit frame(native_frame_ptr_t addr) noexcept
: addr_(addr)
{}

Expand All @@ -86,7 +84,7 @@ class frame {
/// @b Async-Handler-Safety: Safe.
/// @throws Nothing.
template <class T>
explicit frame(T* function_addr) BOOST_NOEXCEPT
explicit frame(T* function_addr) noexcept
: addr_(boost::stacktrace::detail::void_ptr_cast<native_frame_ptr_t>(function_addr))
{}

Expand All @@ -104,7 +102,7 @@ class frame {
///
/// @b Async-Handler-Safety: Safe.
/// @throws Nothing.
BOOST_CONSTEXPR native_frame_ptr_t address() const BOOST_NOEXCEPT {
constexpr native_frame_ptr_t address() const noexcept {
return addr_;
}

Expand All @@ -131,19 +129,15 @@ class frame {
/// @b Complexity: O(1)
///
/// @b Async-Handler-Safety: Safe.
BOOST_EXPLICIT_OPERATOR_BOOL()
constexpr explicit operator bool () const noexcept { return !empty(); }

/// @brief Checks that frame references NULL address.
/// @returns `true` if `this->address() == 0`
///
/// @b Complexity: O(1)
///
/// @b Async-Handler-Safety: Safe.
BOOST_CONSTEXPR bool empty() const BOOST_NOEXCEPT { return !address(); }

/// @cond
BOOST_CONSTEXPR bool operator!() const BOOST_NOEXCEPT { return !address(); }
/// @endcond
constexpr bool empty() const noexcept { return !address(); }
};


Expand Down
22 changes: 11 additions & 11 deletions include/boost/stacktrace/detail/frame_msvc.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,23 @@ class com_holder: boost::noncopyable {
T* holder_;

public:
com_holder() BOOST_NOEXCEPT
com_holder() noexcept
: holder_(0)
{}

T* operator->() const BOOST_NOEXCEPT {
T* operator->() const noexcept {
return holder_;
}

void** to_void_ptr_ptr() BOOST_NOEXCEPT {
void** to_void_ptr_ptr() noexcept {
return reinterpret_cast<void**>(&holder_);
}

bool is_inited() const BOOST_NOEXCEPT {
bool is_inited() const noexcept {
return !!holder_;
}

~com_holder() BOOST_NOEXCEPT {
~com_holder() noexcept {
if (holder_) {
holder_->Release();
}
Expand Down Expand Up @@ -101,7 +101,7 @@ inline void trim_right_zeroes(std::string& s) {
}

class debugging_symbols: boost::noncopyable {
static void try_init_com(com_holder< ::IDebugSymbols>& idebug) BOOST_NOEXCEPT {
static void try_init_com(com_holder< ::IDebugSymbols>& idebug) noexcept {
com_holder< ::IDebugClient> iclient;
if (S_OK != ::DebugCreate(__uuidof(IDebugClient), iclient.to_void_ptr_ptr())) {
return;
Expand Down Expand Up @@ -137,7 +137,7 @@ class debugging_symbols: boost::noncopyable {

com_holder< ::IDebugSymbols> idebug_;
public:
debugging_symbols() BOOST_NOEXCEPT
debugging_symbols() noexcept
{
try_init_com(idebug_);
}
Expand All @@ -148,7 +148,7 @@ public:
# error Your compiler does not support C++11 thread_local storage. It`s impossible to build with BOOST_STACKTRACE_USE_WINDBG_CACHED.
#endif

static com_holder< ::IDebugSymbols>& get_thread_local_debug_inst() BOOST_NOEXCEPT {
static com_holder< ::IDebugSymbols>& get_thread_local_debug_inst() noexcept {
// [class.mfct]: A static local variable or local type in a member function always refers to the same entity, whether
// or not the member function is inline.
static thread_local com_holder< ::IDebugSymbols> idebug;
Expand All @@ -162,13 +162,13 @@ public:

com_holder< ::IDebugSymbols>& idebug_;
public:
debugging_symbols() BOOST_NOEXCEPT
debugging_symbols() noexcept
: idebug_( get_thread_local_debug_inst() )
{}

#endif // #ifndef BOOST_STACKTRACE_USE_WINDBG_CACHED

bool is_inited() const BOOST_NOEXCEPT {
bool is_inited() const noexcept {
return idebug_.is_inited();
}

Expand Down Expand Up @@ -230,7 +230,7 @@ public:
return result;
}

std::size_t get_line_impl(const void* addr) const BOOST_NOEXCEPT {
std::size_t get_line_impl(const void* addr) const noexcept {
ULONG result = 0;
if (!is_inited()) {
return result;
Expand Down
6 changes: 3 additions & 3 deletions include/boost/stacktrace/detail/libbacktrace_impls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ inline int libbacktrace_full_callback(void *data, uintptr_t /*pc*/, const char *
return 0;
}

inline void libbacktrace_error_callback(void* /*data*/, const char* /*msg*/, int /*errnum*/) BOOST_NOEXCEPT {
inline void libbacktrace_error_callback(void* /*data*/, const char* /*msg*/, int /*errnum*/) noexcept {
// Do nothing, just return.
}

Expand All @@ -68,7 +68,7 @@ inline void libbacktrace_error_callback(void* /*data*/, const char* /*msg*/, int
//
// Currently `backtrace_create_state` can not detect file name on Windows https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82543
// That's why we provide a `prog_location` here.
BOOST_SYMBOL_VISIBLE inline ::backtrace_state* construct_state(const program_location& prog_location) BOOST_NOEXCEPT {
BOOST_SYMBOL_VISIBLE inline ::backtrace_state* construct_state(const program_location& prog_location) noexcept {
// [dcl.inline]: A static local variable in an inline function with external linkage always refers to the same object.

// TODO: The most obvious solution:
Expand Down Expand Up @@ -155,7 +155,7 @@ struct to_string_using_backtrace {
return true;
}

to_string_using_backtrace() BOOST_NOEXCEPT {
to_string_using_backtrace() noexcept {
state = boost::stacktrace::detail::construct_state(prog_location);
}
};
Expand Down
18 changes: 9 additions & 9 deletions include/boost/stacktrace/detail/location_from_symbol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,26 @@ class location_from_symbol {
::Dl_info dli_;

public:
explicit location_from_symbol(const void* addr) BOOST_NOEXCEPT
explicit location_from_symbol(const void* addr) noexcept
: dli_()
{
if (!::dladdr(const_cast<void*>(addr), &dli_)) { // `dladdr` on Solaris accepts nonconst addresses
dli_.dli_fname = 0;
}
}

bool empty() const BOOST_NOEXCEPT {
bool empty() const noexcept {
return !dli_.dli_fname;
}

const char* name() const BOOST_NOEXCEPT {
const char* name() const noexcept {
return dli_.dli_fname;
}
};

class program_location {
public:
const char* name() const BOOST_NOEXCEPT {
const char* name() const noexcept {
return 0;
}
};
Expand All @@ -56,7 +56,7 @@ class location_from_symbol {
char file_name_[DEFAULT_PATH_SIZE_];

public:
explicit location_from_symbol(const void* addr) BOOST_NOEXCEPT {
explicit location_from_symbol(const void* addr) noexcept {
file_name_[0] = '\0';

boost::winapi::MEMORY_BASIC_INFORMATION_ mbi;
Expand All @@ -71,11 +71,11 @@ class location_from_symbol {
}
}

bool empty() const BOOST_NOEXCEPT {
bool empty() const noexcept {
return file_name_[0] == '\0';
}

const char* name() const BOOST_NOEXCEPT {
const char* name() const noexcept {
return file_name_;
}
};
Expand All @@ -85,7 +85,7 @@ class program_location {
char file_name_[DEFAULT_PATH_SIZE_];

public:
program_location() BOOST_NOEXCEPT {
program_location() noexcept {
file_name_[0] = '\0';

const boost::winapi::HMODULE_ handle = 0;
Expand All @@ -94,7 +94,7 @@ class program_location {
}
}

const char* name() const BOOST_NOEXCEPT {
const char* name() const noexcept {
return file_name_[0] ? file_name_ : 0;
}
};
Expand Down
6 changes: 3 additions & 3 deletions include/boost/stacktrace/detail/safe_dump_noop.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ namespace boost { namespace stacktrace { namespace detail {


#if defined(BOOST_WINDOWS)
std::size_t dump(void* /*fd*/, const native_frame_ptr_t* /*frames*/, std::size_t /*frames_count*/) BOOST_NOEXCEPT {
std::size_t dump(void* /*fd*/, const native_frame_ptr_t* /*frames*/, std::size_t /*frames_count*/) noexcept {
return 0;
}
#else
std::size_t dump(int /*fd*/, const native_frame_ptr_t* /*frames*/, std::size_t /*frames_count*/) BOOST_NOEXCEPT {
std::size_t dump(int /*fd*/, const native_frame_ptr_t* /*frames*/, std::size_t /*frames_count*/) noexcept {
return 0;
}
#endif


std::size_t dump(const char* /*file*/, const native_frame_ptr_t* /*frames*/, std::size_t /*frames_count*/) BOOST_NOEXCEPT {
std::size_t dump(const char* /*file*/, const native_frame_ptr_t* /*frames*/, std::size_t /*frames_count*/) noexcept {
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions include/boost/stacktrace/detail/safe_dump_posix.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace boost { namespace stacktrace { namespace detail {

std::size_t dump(int fd, const native_frame_ptr_t* frames, std::size_t frames_count) BOOST_NOEXCEPT {
std::size_t dump(int fd, const native_frame_ptr_t* frames, std::size_t frames_count) noexcept {
// We do not retry, because this function must be typically called from signal handler so it's:
// * to scary to continue in case of EINTR
// * EAGAIN or EWOULDBLOCK may occur only in case of O_NONBLOCK is set for fd,
Expand All @@ -33,7 +33,7 @@ std::size_t dump(int fd, const native_frame_ptr_t* frames, std::size_t frames_co
return frames_count;
}

std::size_t dump(const char* file, const native_frame_ptr_t* frames, std::size_t frames_count) BOOST_NOEXCEPT {
std::size_t dump(const char* file, const native_frame_ptr_t* frames, std::size_t frames_count) noexcept {
const int fd = ::open(
file,
O_CREAT | O_WRONLY | O_TRUNC,
Expand Down
4 changes: 2 additions & 2 deletions include/boost/stacktrace/detail/safe_dump_win.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace boost { namespace stacktrace { namespace detail {

std::size_t dump(void* /*fd*/, const native_frame_ptr_t* /*frames*/, std::size_t /*frames_count*/) BOOST_NOEXCEPT {
std::size_t dump(void* /*fd*/, const native_frame_ptr_t* /*frames*/, std::size_t /*frames_count*/) noexcept {
#if 0 // This code potentially could cause deadlocks (according to the MSDN). Disabled
boost::winapi::DWORD_ written;
const boost::winapi::DWORD_ bytes_to_write = static_cast<boost::winapi::DWORD_>(
Expand All @@ -38,7 +38,7 @@ std::size_t dump(void* /*fd*/, const native_frame_ptr_t* /*frames*/, std::size_t
return 0;
}

std::size_t dump(const char* /*file*/, const native_frame_ptr_t* /*frames*/, std::size_t /*frames_count*/) BOOST_NOEXCEPT {
std::size_t dump(const char* /*file*/, const native_frame_ptr_t* /*frames*/, std::size_t /*frames_count*/) noexcept {
#if 0 // This code causing deadlocks on some platforms. Disabled
void* const fd = boost::winapi::CreateFileA(
file,
Expand Down
Loading
Loading