AK: Fix libbacktrace fallback

Introducing cpptrace as the primary backtrace library broke the
backtrace fallback during the code move. This commit properly links AK
to libbacktrace.

It also fixes the function signatures for the fallback backtrace
handlers.
This commit is contained in:
R-Goc 2025-10-09 17:22:42 +02:00 committed by Jelle Raaijmakers
parent 5deeb55461
commit ba5ef052e4
Notes: github-actions[bot] 2025-10-10 10:47:34 +00:00
2 changed files with 6 additions and 6 deletions

View file

@ -52,11 +52,11 @@ void dump_backtrace(unsigned frames_to_skip, unsigned max_depth)
formatter.print(std::cerr, stacktrace); formatter.print(std::cerr, stacktrace);
} }
#elif defined(AK_HAS_BACKTRACE_HEADER) #elif defined(AK_HAS_BACKTRACE_HEADER)
void dump_backtrace(int frames_to_skip) void dump_backtrace(unsigned frames_to_skip, [[maybe_unused]] unsigned max_depth)
{ {
// Grab symbols and dso name for up to 256 frames // Grab symbols and dso name for up to 256 frames
void* trace[256] = {}; void* trace[256] = {};
int const num_frames = backtrace(trace, array_size(trace)); unsigned const num_frames = backtrace(trace, array_size(trace));
char** syms = backtrace_symbols(trace, num_frames); char** syms = backtrace_symbols(trace, num_frames);
for (auto i = frames_to_skip; i < num_frames; ++i) { for (auto i = frames_to_skip; i < num_frames; ++i) {
@ -98,7 +98,7 @@ void dump_backtrace(int frames_to_skip)
free(syms); free(syms);
} }
#else #else
void dump_backtrace([[maybe_unused]] int frames_to_skip) void dump_backtrace([[maybe_unused]] unsigned frames_to_skip, [[maybe_unused]] unsigned max_depth)
{ {
PRINT_ERROR("dump_backtrace() is not supported with the current compilation options.\n"); PRINT_ERROR("dump_backtrace() is not supported with the current compilation options.\n");
} }

View file

@ -57,10 +57,10 @@ if(cpptrace_FOUND AND LADYBIRD_ENABLE_CPPTRACE)
target_compile_definitions(AK PRIVATE AK_HAS_CPPTRACE=1) target_compile_definitions(AK PRIVATE AK_HAS_CPPTRACE=1)
elseif(Backtrace_FOUND) elseif(Backtrace_FOUND)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.30) if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.30)
target_link_libraries(${target} PRIVATE Backtrace::Backtrace) target_link_libraries(AK PRIVATE Backtrace::Backtrace)
else() else()
target_include_directories(${target} PRIVATE ${Backtrace_INCLUDE_DIRS}) target_include_directories(AK PRIVATE ${Backtrace_INCLUDE_DIRS})
target_link_libraries(${target} PRIVATE ${Backtrace_LIBRARIES}) target_link_libraries(AK PRIVATE ${Backtrace_LIBRARIES})
endif() endif()
else() else()
message(WARNING "Cpptrace and Backtrace.h not found. Stack traces will not be available.") message(WARNING "Cpptrace and Backtrace.h not found. Stack traces will not be available.")