Check for _dl_find_object support

This commit is contained in:
Jeremy 2023-11-19 23:17:11 -06:00
parent ac7db48cef
commit 24e64ab385
No known key found for this signature in database
GPG Key ID: B4C8300FEC395042
3 changed files with 26 additions and 0 deletions

View File

@ -78,6 +78,10 @@ if(NOT WIN32 OR MINGW)
check_support(HAS_CXX_EXCEPTION_TYPE has_cxx_exception_type.cpp "" "" "")
endif()
if(UNIX AND NOT APPLE)
check_support(HAS_DL_FIND_OBJECT has_dl_find_object.cpp "" "" "")
endif()
# =============================================== Autoconfig unwinding ===============================================
# Unwind back-ends
if(
@ -276,6 +280,10 @@ if(HAS_CXX_EXCEPTION_TYPE)
target_compile_definitions(${target_name} PUBLIC CPPTRACE_HAS_CXX_EXCEPTION_TYPE)
endif()
if(HAS_DL_FIND_OBJECT)
target_compile_definitions(${target_name} PUBLIC CPPTRACE_HAS_DL_FIND_OBJECT)
endif()
# Symbols
if(CPPTRACE_GET_SYMBOLS_WITH_LIBBACKTRACE)
if(NOT HAS_BACKTRACE)

View File

@ -0,0 +1,6 @@
#include <dlfcn.h>
int main() {
dl_find_object result;
_dl_find_object(reinterpret_cast<void*>(main), &result);
}

View File

@ -12,6 +12,7 @@
#include <cstring>
#include <iostream>
#if CPPTRACE_HAS_DL_FIND_OBJECT
#if IS_LINUX || IS_APPLE
#include <unistd.h>
#include <dlfcn.h>
@ -55,5 +56,16 @@ namespace detail {
}
}
}
#else
namespace cpptrace {
namespace detail {
inline void get_minimal_object_frame(frame_ptr address, minimal_object_frame* out) {
out->raw_address = 0;
out->address_relative_to_object_base_in_memory = 0;
out->object_path[0] = 0;
}
}
}
#endif
#endif