refactor: drop std::stacktrace and use boost's replacement.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/stacktrace.hpp>
|
||||
|
||||
namespace di {
|
||||
|
||||
class BaseException {
|
||||
@@ -24,7 +26,7 @@ public:
|
||||
Args&&... args
|
||||
)
|
||||
: m_reason(std::format(fmt, std::forward<Args>(args)...)),
|
||||
m_stacktrace(std::stacktrace::current()) {}
|
||||
m_stacktrace(boost::stacktrace::stacktrace()) {}
|
||||
|
||||
constexpr std::string category() const {
|
||||
return static_cast<const Derived*>(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 = "<unknown>";
|
||||
if (source_file.empty()) source_file = "<\?\?>";
|
||||
@@ -92,7 +94,7 @@ private:
|
||||
std::string m_reason;
|
||||
|
||||
std::unordered_map<std::string, std::string> m_context_information;
|
||||
std::stacktrace m_stacktrace;
|
||||
boost::stacktrace::stacktrace m_stacktrace;
|
||||
};
|
||||
|
||||
class UnixException : public RuntimeException<UnixException> {
|
||||
|
||||
@@ -11,7 +11,7 @@ using namespace llvm;
|
||||
#include <print>
|
||||
|
||||
#include <exception>
|
||||
#include <stacktrace>
|
||||
// #include <stacktrace>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
19
xmake.lua
19
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'
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user