mirror of
https://github.com/pocoproject/poco.git
synced 2025-12-18 03:28:45 +01:00
Enable building Poco::Trace on FreeBSD
This commit is contained in:
@@ -47,6 +47,16 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
target_compile_definitions (Trace PRIVATE CPPTRACE_DEMANGLE_WITH_CXXABI CPPTRACE_UNWIND_WITH_UNWIND)
|
||||
target_compile_definitions (Trace PRIVATE CPPTRACE_GET_SYMBOLS_WITH_LIBBACKTRACE)
|
||||
target_link_libraries(Trace PRIVATE backtrace)
|
||||
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
||||
find_library(BACKTRACE_LIBRARY backtrace REQUIRED)
|
||||
cmake_path(GET BACKTRACE_LIBRARY PARENT_PATH BACKTRACE_LIBDIR)
|
||||
set(BACKTRACE_INCLUDE_DIR "${BACKTRACE_LIBDIR}/../include")
|
||||
cmake_path(ABSOLUTE_PATH BACKTRACE_INCLUDE_DIR NORMALIZE)
|
||||
find_file(BACKTRACE_H backtrace.h PATHS ${BACKTRACE_INCLUDE_DIR} REQUIRED)
|
||||
target_compile_definitions (Trace PRIVATE CPPTRACE_DEMANGLE_WITH_CXXABI CPPTRACE_UNWIND_WITH_UNWIND)
|
||||
target_compile_definitions (Trace PRIVATE CPPTRACE_GET_SYMBOLS_WITH_LIBBACKTRACE)
|
||||
target_include_directories(Trace PRIVATE ${BACKTRACE_INCLUDE_DIR})
|
||||
target_link_libraries(Trace PRIVATE ${BACKTRACE_LIBRARY})
|
||||
elseif (APPLE)
|
||||
target_compile_definitions (Trace PRIVATE CPPTRACE_DEMANGLE_WITH_CXXABI CPPTRACE_UNWIND_WITH_UNWIND)
|
||||
target_compile_definitions (Trace PRIVATE CPPTRACE_GET_SYMBOLS_WITH_LIBDL)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "utils/common.hpp"
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
#if IS_LINUX
|
||||
#if IS_LINUX || IS_FREEBSD
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "binary/elf.hpp"
|
||||
|
||||
#if IS_LINUX
|
||||
#if IS_LINUX || IS_FREEBSD
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
#if IS_LINUX || IS_APPLE
|
||||
#if IS_LINUX || IS_APPLE || IS_FREEBSD
|
||||
#include <unistd.h>
|
||||
#include <dlfcn.h>
|
||||
#if IS_APPLE
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
namespace cpptrace {
|
||||
namespace detail {
|
||||
#if IS_LINUX
|
||||
#if IS_LINUX || IS_FREEBSD
|
||||
Result<std::uintptr_t, internal_error> get_module_image_base(const std::string& object_path) {
|
||||
static std::mutex mutex;
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
#if IS_LINUX || IS_APPLE
|
||||
#if IS_LINUX || IS_APPLE || IS_FREEBSD
|
||||
#include <unistd.h>
|
||||
#include <dlfcn.h>
|
||||
#if IS_LINUX
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
namespace cpptrace {
|
||||
namespace detail {
|
||||
#if IS_LINUX || IS_APPLE
|
||||
#if IS_LINUX || IS_APPLE || IS_FREEBSD
|
||||
#if defined(CPPTRACE_HAS_DL_FIND_OBJECT) || defined(CPPTRACE_HAS_DLADDR1)
|
||||
std::string resolve_l_name(const char* l_name) {
|
||||
if(l_name != nullptr && l_name[0] != 0) {
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
#elif defined(__APPLE__)
|
||||
#undef IS_APPLE
|
||||
#define IS_APPLE 1
|
||||
#elif defined(__FreeBSD__)
|
||||
#undef IS_FREEBSD
|
||||
#define IS_FREEBSD 1
|
||||
#else
|
||||
#error "Unexpected platform"
|
||||
#endif
|
||||
|
||||
@@ -95,6 +95,18 @@ namespace detail {
|
||||
}
|
||||
}
|
||||
|
||||
#elif IS_FREEBSD
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace cpptrace {
|
||||
namespace detail {
|
||||
inline const char* program_name() {
|
||||
return getprogname();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user