Update trace objects to just be aggregates

This commit is contained in:
Jeremy 2023-10-05 12:33:43 -04:00
parent 5079aef62f
commit c3a27d15fb
No known key found for this signature in database
GPG Key ID: 19AA8270105E8EB4
3 changed files with 15 additions and 23 deletions

View File

@ -140,8 +140,6 @@ namespace cpptrace {
struct stacktrace { struct stacktrace {
std::vector<stacktrace_frame> frames; std::vector<stacktrace_frame> frames;
explicit stacktrace();
explicit stacktrace(std::vector<stacktrace_frame>&& frames);
static stacktrace current(std::uint_least32_t skip = 0); // here as a drop-in for std::stacktrace static stacktrace current(std::uint_least32_t skip = 0); // here as a drop-in for std::stacktrace
static stacktrace current(std::uint_least32_t skip, std::uint_least32_t max_depth); static stacktrace current(std::uint_least32_t skip, std::uint_least32_t max_depth);
void print() const; void print() const;
@ -175,7 +173,6 @@ namespace cpptrace {
struct object_trace { struct object_trace {
std::vector<object_frame> frames; std::vector<object_frame> frames;
explicit object_trace(std::vector<object_frame>&& frames);
static object_trace current(std::uint_least32_t skip = 0); static object_trace current(std::uint_least32_t skip = 0);
static object_trace current(std::uint_least32_t skip, std::uint_least32_t max_depth); static object_trace current(std::uint_least32_t skip, std::uint_least32_t max_depth);
stacktrace resolve() const; stacktrace resolve() const;
@ -200,7 +197,6 @@ Note it is important executables and shared libraries in memory aren't somehow u
namespace cpptrace { namespace cpptrace {
struct raw_trace { struct raw_trace {
std::vector<uintptr_t> frames; std::vector<uintptr_t> frames;
explicit raw_trace(std::vector<uintptr_t>&& frames);
static raw_trace current(std::uint_least32_t skip = 0); static raw_trace current(std::uint_least32_t skip = 0);
static raw_trace current(std::uint_least32_t skip, std::uint_least32_t max_depth); static raw_trace current(std::uint_least32_t skip, std::uint_least32_t max_depth);
object_trace resolve_object_trace() const; object_trace resolve_object_trace() const;

View File

@ -29,7 +29,6 @@ namespace cpptrace {
struct raw_trace { struct raw_trace {
std::vector<uintptr_t> frames; std::vector<uintptr_t> frames;
explicit raw_trace(std::vector<uintptr_t>&& frames_) : frames(frames_) {}
CPPTRACE_API static raw_trace current(std::uint_least32_t skip = 0); CPPTRACE_API static raw_trace current(std::uint_least32_t skip = 0);
CPPTRACE_API static raw_trace current(std::uint_least32_t skip, std::uint_least32_t max_depth); CPPTRACE_API static raw_trace current(std::uint_least32_t skip, std::uint_least32_t max_depth);
CPPTRACE_API object_trace resolve_object_trace() const; CPPTRACE_API object_trace resolve_object_trace() const;
@ -56,7 +55,6 @@ namespace cpptrace {
struct object_trace { struct object_trace {
std::vector<object_frame> frames; std::vector<object_frame> frames;
explicit object_trace(std::vector<object_frame>&& frames_) : frames(frames_) {}
CPPTRACE_API static object_trace current(std::uint_least32_t skip = 0); CPPTRACE_API static object_trace current(std::uint_least32_t skip = 0);
CPPTRACE_API static object_trace current(std::uint_least32_t skip, std::uint_least32_t max_depth); CPPTRACE_API static object_trace current(std::uint_least32_t skip, std::uint_least32_t max_depth);
CPPTRACE_API stacktrace resolve() const; CPPTRACE_API stacktrace resolve() const;
@ -95,8 +93,6 @@ namespace cpptrace {
struct stacktrace { struct stacktrace {
std::vector<stacktrace_frame> frames; std::vector<stacktrace_frame> frames;
explicit stacktrace() {}
explicit stacktrace(std::vector<stacktrace_frame>&& frames_) : frames(frames_) {}
CPPTRACE_API static stacktrace current(std::uint_least32_t skip = 0); CPPTRACE_API static stacktrace current(std::uint_least32_t skip = 0);
CPPTRACE_API static stacktrace current(std::uint_least32_t skip, std::uint_least32_t max_depth); CPPTRACE_API static stacktrace current(std::uint_least32_t skip, std::uint_least32_t max_depth);
CPPTRACE_API void print() const; CPPTRACE_API void print() const;
@ -166,7 +162,7 @@ namespace cpptrace {
e.what() e.what()
); );
} }
return raw_trace({}); return raw_trace{};
} }
} ()) {} } ()) {}
explicit exception(std::uint_least32_t skip) noexcept : exception(skip + 1, UINT_LEAST32_MAX) {} explicit exception(std::uint_least32_t skip) noexcept : exception(skip + 1, UINT_LEAST32_MAX) {}

View File

@ -39,12 +39,12 @@ namespace cpptrace {
CPPTRACE_API CPPTRACE_API
object_trace raw_trace::resolve_object_trace() const { object_trace raw_trace::resolve_object_trace() const {
try { try {
return object_trace(detail::get_frames_object_info(frames)); return object_trace{detail::get_frames_object_info(frames)};
} catch(...) { // NOSONAR } catch(...) { // NOSONAR
if(!detail::should_absorb_trace_exceptions()) { if(!detail::should_absorb_trace_exceptions()) {
throw; throw;
} }
return object_trace({}); return object_trace{};
} }
} }
@ -55,12 +55,12 @@ namespace cpptrace {
for(auto& frame : trace) { for(auto& frame : trace) {
frame.symbol = detail::demangle(frame.symbol); frame.symbol = detail::demangle(frame.symbol);
} }
return stacktrace(std::move(trace)); return stacktrace{std::move(trace)};
} catch(...) { // NOSONAR } catch(...) { // NOSONAR
if(!detail::should_absorb_trace_exceptions()) { if(!detail::should_absorb_trace_exceptions()) {
throw; throw;
} }
return stacktrace(); return stacktrace{};
} }
} }
@ -87,7 +87,7 @@ namespace cpptrace {
CPPTRACE_API CPPTRACE_API
stacktrace object_trace::resolve() const { stacktrace object_trace::resolve() const {
try { try {
return stacktrace(detail::resolve_frames(frames)); return stacktrace{detail::resolve_frames(frames)};
} catch(...) { // NOSONAR } catch(...) { // NOSONAR
if(!detail::should_absorb_trace_exceptions()) { if(!detail::should_absorb_trace_exceptions()) {
throw; throw;
@ -240,48 +240,48 @@ namespace cpptrace {
CPPTRACE_FORCE_NO_INLINE CPPTRACE_API CPPTRACE_FORCE_NO_INLINE CPPTRACE_API
raw_trace generate_raw_trace(std::uint_least32_t skip) { raw_trace generate_raw_trace(std::uint_least32_t skip) {
try { try {
return raw_trace(detail::capture_frames(skip + 1, UINT_LEAST32_MAX)); return raw_trace{detail::capture_frames(skip + 1, UINT_LEAST32_MAX)};
} catch(...) { // NOSONAR } catch(...) { // NOSONAR
if(!detail::should_absorb_trace_exceptions()) { if(!detail::should_absorb_trace_exceptions()) {
throw; throw;
} }
return raw_trace({}); return raw_trace{};
} }
} }
CPPTRACE_FORCE_NO_INLINE CPPTRACE_API CPPTRACE_FORCE_NO_INLINE CPPTRACE_API
raw_trace generate_raw_trace(std::uint_least32_t skip, std::uint_least32_t max_depth) { raw_trace generate_raw_trace(std::uint_least32_t skip, std::uint_least32_t max_depth) {
try { try {
return raw_trace(detail::capture_frames(skip + 1, max_depth)); return raw_trace{detail::capture_frames(skip + 1, max_depth)};
} catch(...) { // NOSONAR } catch(...) { // NOSONAR
if(!detail::should_absorb_trace_exceptions()) { if(!detail::should_absorb_trace_exceptions()) {
throw; throw;
} }
return raw_trace({}); return raw_trace{};
} }
} }
CPPTRACE_FORCE_NO_INLINE CPPTRACE_API CPPTRACE_FORCE_NO_INLINE CPPTRACE_API
object_trace generate_object_trace(std::uint_least32_t skip) { object_trace generate_object_trace(std::uint_least32_t skip) {
try { try {
return object_trace(detail::get_frames_object_info(detail::capture_frames(skip + 1, UINT_LEAST32_MAX))); return object_trace{detail::get_frames_object_info(detail::capture_frames(skip + 1, UINT_LEAST32_MAX))};
} catch(...) { // NOSONAR } catch(...) { // NOSONAR
if(!detail::should_absorb_trace_exceptions()) { if(!detail::should_absorb_trace_exceptions()) {
throw; throw;
} }
return object_trace({}); return object_trace{};
} }
} }
CPPTRACE_FORCE_NO_INLINE CPPTRACE_API CPPTRACE_FORCE_NO_INLINE CPPTRACE_API
object_trace generate_object_trace(std::uint_least32_t skip, std::uint_least32_t max_depth) { object_trace generate_object_trace(std::uint_least32_t skip, std::uint_least32_t max_depth) {
try { try {
return object_trace(detail::get_frames_object_info(detail::capture_frames(skip + 1, max_depth))); return object_trace{detail::get_frames_object_info(detail::capture_frames(skip + 1, max_depth))};
} catch(...) { // NOSONAR } catch(...) { // NOSONAR
if(!detail::should_absorb_trace_exceptions()) { if(!detail::should_absorb_trace_exceptions()) {
throw; throw;
} }
return object_trace({}); return object_trace{};
} }
} }
@ -298,7 +298,7 @@ namespace cpptrace {
for(auto& frame : trace) { for(auto& frame : trace) {
frame.symbol = detail::demangle(frame.symbol); frame.symbol = detail::demangle(frame.symbol);
} }
return stacktrace(std::move(trace)); return stacktrace{std::move(trace)};
} catch(...) { // NOSONAR } catch(...) { // NOSONAR
if(!detail::should_absorb_trace_exceptions()) { if(!detail::should_absorb_trace_exceptions()) {
throw; throw;