diff --git a/src/error.h b/src/error.h index 9410c67..2e55e8c 100644 --- a/src/error.h +++ b/src/error.h @@ -1,5 +1,7 @@ #pragma once +#include + namespace di { class BaseException { @@ -24,7 +26,7 @@ public: Args&&... args ) : m_reason(std::format(fmt, std::forward(args)...)), - m_stacktrace(std::stacktrace::current()) {} + m_stacktrace(boost::stacktrace::stacktrace()) {} constexpr std::string category() const { return static_cast(this)->category(); @@ -54,7 +56,7 @@ public: for (const auto& entry : m_stacktrace) { stack_idx++; if (stack_idx == 0) continue; - auto func_name = entry.description(); + auto func_name = entry.name(); auto source_file = entry.source_file(); if (func_name.empty()) func_name = ""; if (source_file.empty()) source_file = "<\?\?>"; @@ -92,7 +94,7 @@ private: std::string m_reason; std::unordered_map m_context_information; - std::stacktrace m_stacktrace; + boost::stacktrace::stacktrace m_stacktrace; }; class UnixException : public RuntimeException { diff --git a/src/pch.h b/src/pch.h index 3d63e80..2ea5f39 100644 --- a/src/pch.h +++ b/src/pch.h @@ -11,7 +11,7 @@ using namespace llvm; #include #include -#include +// #include #include #include diff --git a/xmake.lua b/xmake.lua index 9cddd90..f492f2f 100644 --- a/xmake.lua +++ b/xmake.lua @@ -3,6 +3,7 @@ add_rules('mode.debug', 'mode.release') add_requires('argparse 3.1') add_requires('nlohmann_json 3.11.3') add_requires('xxhash 0.8.3') +add_requires('boost 1.87.0') add_requires('llvm') @@ -36,14 +37,16 @@ set_warnings('all') add_includedirs('src') --- workaround to fix std::stacktrace link problem +-- now use boost::stacktrace, due to MacOSX (libc++) compatibility issues. +-- ~~workaround to fix std::stacktrace link problem~~ +-- -- for gcc == 14 -- see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/libstdc++/manual/manual/using.html -- for gcc == 13 -- see https://gcc.gnu.org/onlinedocs/gcc-13.2.0/libstdc++/manual/manual/using.html -if is_plat('linux') then - add_links('stdc++exp') -end +-- if is_plat('linux') then +-- add_links('stdc++exp') +-- end if is_mode('debug') then add_defines('DI_DEBUG') @@ -63,11 +66,17 @@ target('libdi') remove_files('src/tools/**') set_basename('di') - add_ldflags('$(shell llvm-config --libs)') -- xrepo llvm bug? + if is_plat('linux') then + add_ldflags('$(shell llvm-config --libs)') -- xrepo llvm bug? + end + if is_plat('linux') or is_plat('macosx') then + add_defines('BOOST_STACKTRACE_USE_ADDR2LINE=1') + end add_packages( 'xxhash', 'nlohmann_json', + 'boost', 'llvm' )