Skip to content

Commit

Permalink
Bump to cpptrace 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed Nov 23, 2023
1 parent bc32154 commit af088d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ if(ASSERT_STATIC)
add_library(assert STATIC src/assert.cpp include/assert.hpp)
else()
add_library(assert SHARED src/assert.cpp include/assert.hpp)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

target_include_directories(
Expand Down Expand Up @@ -76,10 +77,10 @@ else()
FetchContent_Declare(
cpptrace
GIT_REPOSITORY https://github.com/jeremy-rifkin/cpptrace.git
GIT_TAG v0.2.1
GIT_TAG 4ec11d00de87fa8354170c8956e69b6650774146
)
FetchContent_MakeAvailable(cpptrace)
set(ASSERT_CPPTRACE_TARGET_NAME cpptrace)
set(ASSERT_CPPTRACE_TARGET_NAME cpptrace::cpptrace)
endif()
target_link_libraries(assert PRIVATE ${ASSERT_CPPTRACE_TARGET_NAME})

Expand Down
8 changes: 4 additions & 4 deletions src/assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1648,15 +1648,15 @@ namespace libassert::detail {
// NOLINTNEXTLINE(bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions)
trace.begin() + end + 1,
[](const cpptrace::stacktrace_frame& a, const cpptrace::stacktrace_frame& b) {
return a.line < b.line;
return a.line.value_or(0) < b.line.value_or(0);
}
)->line;
const size_t max_line_number_width = n_digits(max_line_number);
const size_t max_line_number_width = n_digits(max_line_number.value_or(0));
const size_t max_frame_width = n_digits(end - start);
// do the actual trace
for(size_t i = start; i <= end; i++) {
const auto& [address, line, col, source_path, signature] = trace.frames[i];
const std::string line_number = line == 0 ? "?" : std::to_string(line);
const auto& [address, line, col, source_path, signature, is_inline] = trace.frames[i];
const std::string line_number = line.has_value() ? std::to_string(line.value()) : "?";
// look for repeats, i.e. recursion we can fold
size_t recursion_folded = 0;
if(end - i >= 4) {
Expand Down

0 comments on commit af088d0

Please sign in to comment.