2 Commits

Author SHA1 Message Date
dd15bb2205 updated build system 2024-07-27 15:54:01 -05:00
4b53b5544f updated build system 2024-07-27 15:53:45 -05:00
11 changed files with 93 additions and 63 deletions

View File

@ -122,6 +122,7 @@ endif()
-DPROJECT_COPYRIGHT=${PROJECT_COPYRIGHT}
-DPROJECT_DESC=${PROJECT_DESC}
-DPROJECT_DIST_DIR=${PROJECT_DIST_DIR}
-DPROJECT_ENABLE_BACKWARD_CPP=${PROJECT_ENABLE_BACKWARD_CPP}
-DPROJECT_ENABLE_BOOST=${PROJECT_ENABLE_BOOST}
-DPROJECT_ENABLE_CPP_HTTPLIB=${PROJECT_ENABLE_CPP_HTTPLIB}
-DPROJECT_ENABLE_CURL=${PROJECT_ENABLE_CURL}

View File

@ -6,6 +6,7 @@ include(cmake/libraries/openssl.cmake)
include(cmake/libraries/boost.cmake)
include(cmake/libraries/backward_cpp.cmake)
include(cmake/libraries/cpp_httplib.cmake)
include(cmake/libraries/curl.cmake)
include(cmake/libraries/fuse.cmake)

View File

@ -0,0 +1,7 @@
if(PROJECT_ENABLE_BACKWARD_CPP AND PROJECT_BUILD)
add_definitions(-DPROJECT_ENABLE_BACKWARD_CPP)
if(PROJECT_IS_MINGW)
link_libraries(msvcr90)
endif()
endif()

View File

@ -1,3 +1,4 @@
option(PROJECT_ENABLE_BACKWARD_CPP "Enable backward-cpp" ON)
option(PROJECT_ENABLE_BOOST "Enable boost libraries" ON)
option(PROJECT_ENABLE_CPP_HTTPLIB "Enable cpp-httplib" ON)
option(PROJECT_ENABLE_CURL "Enable curl library" ON)

View File

@ -19,6 +19,7 @@ PROJECT_APP_LIST=(${PROJECT_NAME})
PROJECT_PRIVATE_KEY=${DEVELOPER_PRIVATE_KEY}
PROJECT_PUBLIC_KEY=${DEVELOPER_PUBLIC_KEY}
PROJECT_ENABLE_BACKWARD_CPP=ON
PROJECT_ENABLE_BOOST=ON
PROJECT_ENABLE_CPP_HTTPLIB=ON
PROJECT_ENABLE_CURL=ON
@ -33,6 +34,7 @@ PROJECT_ENABLE_STDUUID=ON
PROJECT_ENABLE_TESTING=ON
PROJECT_ENABLE_WINFSP=ON
PROJECT_KEEP_BACKWARD_CPP=1
PROJECT_STATIC_LINK=ON
PROJECT_MINGW64_COPY_DEPENDENCIES+=()

View File

@ -19,7 +19,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#if !defined(PROJECT_STATIC_LINK)
#if defined(PROJECT_ENABLE_BACKWARD_CPP)
#include "backward.hpp"
#endif
@ -32,7 +32,7 @@
using namespace repertory;
auto main(int argc, char **argv) -> int {
#if !defined(PROJECT_STATIC_LINK)
#if defined(PROJECT_ENABLE_BACKWARD_CPP)
static backward::SignalHandling sh;
#endif

View File

@ -19,7 +19,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#if !defined(PROJECT_STATIC_LINK)
#if defined(PROJECT_ENABLE_BACKWARD_CPP)
#include "backward.hpp"
#endif
@ -36,7 +36,7 @@ std::size_t PROVIDER_INDEX{0U};
#endif // _WIN32
auto main(int argc, char **argv) -> int {
#if !defined(PROJECT_STATIC_LINK)
#if defined(PROJECT_ENABLE_BACKWARD_CPP)
static backward::SignalHandling sh;
#endif

View File

@ -202,6 +202,7 @@ fi
if [ "${PROJECT_STATIC_LINK}" == "ON" ]; then
PROJECT_BUILD_SHARED_LIBS=OFF
PROJECT_ENABLE_BACKWARD_CPP=OFF
else
PROJECT_BUILD_SHARED_LIBS=ON
fi

View File

@ -1,6 +1,7 @@
#!/bin/bash
PROJECT_LIBRARIES=(
BACKWARD_CPP
BOOST
CPP_HTTPLIB
CURL
@ -17,6 +18,7 @@ PROJECT_LIBRARIES=(
)
declare -A PROJECT_CLEANUP
PROJECT_CLEANUP[BACKWARD_CPP]="include/backward.hpp:src/backward.cpp"
PROJECT_CLEANUP[BOOST]="boost_*"
PROJECT_CLEANUP[CPP_HTTPLIB]="cpp-httplib-*"
PROJECT_CLEANUP[CURL]="curl-*"

View File

@ -1,3 +1,4 @@
#if defined(PROJECT_ENABLE_BACKWARD_CPP)
/*
* backward.hpp
* Copyright 2013 Google Inc. All Rights Reserved.
@ -81,17 +82,17 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <exception>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <new>
#include <sstream>
#include <streambuf>
#include <string>
#include <vector>
#include <exception>
#include <iterator>
#if defined(BACKWARD_SYSTEM_LINUX)
@ -211,7 +212,7 @@
#else
#include <link.h>
#endif
#if defined(__ppc__) || defined(__powerpc) || defined(__powerpc__) || \
#if defined(__ppc__) || defined(__powerpc) || defined(__powerpc__) || \
defined(__POWERPC__)
// Linux kernel header required for the struct pt_regs definition
// to access the NIP (Next Instruction Pointer) register value
@ -507,11 +508,17 @@ typedef pdb_symbol current;
namespace details {
template <typename T> struct rm_ptr { typedef T type; };
template <typename T> struct rm_ptr {
typedef T type;
};
template <typename T> struct rm_ptr<T *> { typedef T type; };
template <typename T> struct rm_ptr<T *> {
typedef T type;
};
template <typename T> struct rm_ptr<const T *> { typedef const T type; };
template <typename T> struct rm_ptr<const T *> {
typedef const T type;
};
template <typename R, typename T, R (*F)(T)> struct deleter {
template <typename U> void operator()(U &ptr) const { (*F)(ptr); }
@ -521,7 +528,7 @@ template <typename T> struct default_delete {
void operator()(T &ptr) const { delete ptr; }
};
template <typename T, typename Deleter = deleter<void, void *, &::free> >
template <typename T, typename Deleter = deleter<void, void *, &::free>>
class handle {
struct dummy;
T _val;
@ -1134,7 +1141,7 @@ public:
NOINLINE
size_t load_here(size_t depth = 32, void *context = nullptr,
void *error_addr = nullptr) {
set_context(static_cast<CONTEXT*>(context));
set_context(static_cast<CONTEXT *>(context));
set_error_addr(error_addr);
CONTEXT localCtx; // used when no context is provided
@ -1228,7 +1235,7 @@ class TraceResolverImplBase {
public:
virtual ~TraceResolverImplBase() {}
virtual void load_addresses(void *const*addresses, int address_count) {
virtual void load_addresses(void *const *addresses, int address_count) {
(void)addresses;
(void)address_count;
}
@ -1252,7 +1259,8 @@ template <typename TAG> class TraceResolverImpl;
#ifdef BACKWARD_SYSTEM_UNKNOWN
template <> class TraceResolverImpl<system_tag::unknown_tag>
template <>
class TraceResolverImpl<system_tag::unknown_tag>
: public TraceResolverImplBase {};
#endif
@ -1327,7 +1335,7 @@ template <>
class TraceResolverLinuxImpl<trace_resolver_tag::backtrace_symbol>
: public TraceResolverLinuxBase {
public:
void load_addresses(void *const*addresses, int address_count) override {
void load_addresses(void *const *addresses, int address_count) override {
if (address_count == 0) {
return;
}
@ -1428,7 +1436,7 @@ public:
// this is preferable. Libbfd will search for stripped debug
// symbols in the same directory.
fobj = load_object_with_bfd(trace.object_filename);
} else{
} else {
// The original object file was *deleted*! The only hope is
// that the debug symbols are either inside the shared
// object file, or are in the same directory, and this is
@ -1559,7 +1567,7 @@ private:
bool _bfd_loaded;
typedef details::handle<bfd *,
details::deleter<bfd_boolean, bfd *, &bfd_close> >
details::deleter<bfd_boolean, bfd *, &bfd_close>>
bfd_handle_t;
typedef details::handle<asymbol **> bfd_symtab_t;
@ -1867,7 +1875,7 @@ public:
}
#endif
//#define BACKWARD_I_DO_NOT_RECOMMEND_TO_ENABLE_THIS_HORRIBLE_PIECE_OF_CODE
// #define BACKWARD_I_DO_NOT_RECOMMEND_TO_ENABLE_THIS_HORRIBLE_PIECE_OF_CODE
#ifdef BACKWARD_I_DO_NOT_RECOMMEND_TO_ENABLE_THIS_HORRIBLE_PIECE_OF_CODE
if (!cudie) {
// If it's still not enough, lets dive deeper in the shit, and try
@ -1931,9 +1939,9 @@ public:
}
private:
typedef details::handle<Dwfl *, details::deleter<void, Dwfl *, &dwfl_end> >
typedef details::handle<Dwfl *, details::deleter<void, Dwfl *, &dwfl_end>>
dwfl_handle_t;
details::handle<Dwfl_Callbacks *, details::default_delete<Dwfl_Callbacks *> >
details::handle<Dwfl_Callbacks *, details::default_delete<Dwfl_Callbacks *>>
_dwfl_cb;
dwfl_handle_t _dwfl_handle;
bool _dwfl_handle_initialized;
@ -2255,14 +2263,14 @@ public:
private:
bool _dwarf_loaded;
typedef details::handle<int, details::deleter<int, int, &::close> >
typedef details::handle<int, details::deleter<int, int, &::close>>
dwarf_file_t;
typedef details::handle<Elf *, details::deleter<int, Elf *, &elf_end> >
typedef details::handle<Elf *, details::deleter<int, Elf *, &elf_end>>
dwarf_elf_t;
typedef details::handle<Dwarf_Debug,
details::deleter<int, Dwarf_Debug, &close_dwarf> >
details::deleter<int, Dwarf_Debug, &close_dwarf>>
dwarf_handle_t;
typedef std::map<Dwarf_Addr, int> die_linemap_t;
@ -3349,9 +3357,10 @@ private:
char **srcfiles = 0;
Dwarf_Signed file_count = 0;
if (dwarf_srcfiles(cu_die, &srcfiles, &file_count, &error) == DW_DLV_OK) {
if (file_count > 0 && file_index <= static_cast<Dwarf_Unsigned>(file_count)) {
if (file_count > 0 &&
file_index <= static_cast<Dwarf_Unsigned>(file_count)) {
file = std::string(srcfiles[file_index - 1]);
}
}
// Deallocate all strings!
for (int i = 0; i < file_count; ++i) {
@ -3488,7 +3497,7 @@ template <>
class TraceResolverDarwinImpl<trace_resolver_tag::backtrace_symbol>
: public TraceResolverImplBase {
public:
void load_addresses(void *const*addresses, int address_count) override {
void load_addresses(void *const *addresses, int address_count) override {
if (address_count == 0) {
return;
}
@ -3605,7 +3614,8 @@ public:
}
};
template <> class TraceResolverImpl<system_tag::windows_tag>
template <>
class TraceResolverImpl<system_tag::windows_tag>
: public TraceResolverImplBase {
public:
TraceResolverImpl() {
@ -3619,13 +3629,13 @@ public:
DWORD symOptions = SymGetOptions();
symOptions |= SYMOPT_LOAD_LINES | SYMOPT_UNDNAME;
SymSetOptions(symOptions);
EnumProcessModules(process, &module_handles[0],
static_cast<DWORD>(module_handles.size() * sizeof(HMODULE)),
&cbNeeded);
EnumProcessModules(
process, &module_handles[0],
static_cast<DWORD>(module_handles.size() * sizeof(HMODULE)), &cbNeeded);
module_handles.resize(cbNeeded / sizeof(HMODULE));
EnumProcessModules(process, &module_handles[0],
static_cast<DWORD>(module_handles.size() * sizeof(HMODULE)),
&cbNeeded);
EnumProcessModules(
process, &module_handles[0],
static_cast<DWORD>(module_handles.size() * sizeof(HMODULE)), &cbNeeded);
std::transform(module_handles.begin(), module_handles.end(),
std::back_inserter(modules), get_mod_info(process));
void *base = modules[0].base_address;
@ -3652,14 +3662,14 @@ public:
if (!SymFromAddr(process, (ULONG64)t.addr, &displacement, &sym.sym)) {
// TODO: error handling everywhere
char* lpMsgBuf;
char *lpMsgBuf;
DWORD dw = GetLastError();
if (FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(char*)&lpMsgBuf, 0, NULL)) {
(char *)&lpMsgBuf, 0, NULL)) {
std::fprintf(stderr, "%s\n", lpMsgBuf);
LocalFree(lpMsgBuf);
}
@ -3698,7 +3708,7 @@ class TraceResolver : public TraceResolverImpl<system_tag::current_tag> {};
class SourceFile {
public:
typedef std::vector<std::pair<unsigned, std::string> > lines_t;
typedef std::vector<std::pair<unsigned, std::string>> lines_t;
SourceFile() {}
SourceFile(const std::string &path) {
@ -3809,15 +3819,16 @@ public:
}
#endif
// Allow adding to paths gotten from BACKWARD_CXX_SOURCE_PREFIXES after loading the
// library; this can be useful when the library is loaded when the locations are unknown
// Warning: Because this edits the static paths variable, it is *not* intrinsiclly thread safe
static void add_paths_to_env_variable_impl(const std::string & to_add) {
// Allow adding to paths gotten from BACKWARD_CXX_SOURCE_PREFIXES after
// loading the library; this can be useful when the library is loaded when the
// locations are unknown Warning: Because this edits the static paths
// variable, it is *not* intrinsiclly thread safe
static void add_paths_to_env_variable_impl(const std::string &to_add) {
get_mutable_paths_from_env_variable().push_back(to_add);
}
private:
details::handle<std::ifstream *, details::default_delete<std::ifstream *> >
details::handle<std::ifstream *, details::default_delete<std::ifstream *>>
_file;
static std::vector<std::string> get_paths_from_env_variable_impl() {
@ -3830,8 +3841,9 @@ private:
}
static std::vector<std::string> &get_mutable_paths_from_env_variable() {
static volatile std::vector<std::string> paths = get_paths_from_env_variable_impl();
return const_cast<std::vector<std::string>&>(paths);
static volatile std::vector<std::string> paths =
get_paths_from_env_variable_impl();
return const_cast<std::vector<std::string> &>(paths);
}
static const std::vector<std::string> &get_paths_from_env_variable() {
@ -4055,7 +4067,7 @@ private:
void print_stacktrace(ST &st, std::ostream &os, Colorize &colorize) {
print_header(os, st.thread_id());
_resolver.load_stacktrace(st);
if ( reverse ) {
if (reverse) {
for (size_t trace_idx = st.size(); trace_idx > 0; --trace_idx) {
print_trace(os, _resolver.resolve(st[trace_idx - 1]), colorize);
}
@ -4166,20 +4178,20 @@ class SignalHandling {
public:
static std::vector<int> make_default_signals() {
const int posix_signals[] = {
// Signals for which the default action is "Core".
SIGABRT, // Abort signal from abort(3)
SIGBUS, // Bus error (bad memory access)
SIGFPE, // Floating point exception
SIGILL, // Illegal Instruction
SIGIOT, // IOT trap. A synonym for SIGABRT
SIGQUIT, // Quit from keyboard
SIGSEGV, // Invalid memory reference
SIGSYS, // Bad argument to routine (SVr4)
SIGTRAP, // Trace/breakpoint trap
SIGXCPU, // CPU time limit exceeded (4.2BSD)
SIGXFSZ, // File size limit exceeded (4.2BSD)
// Signals for which the default action is "Core".
SIGABRT, // Abort signal from abort(3)
SIGBUS, // Bus error (bad memory access)
SIGFPE, // Floating point exception
SIGILL, // Illegal Instruction
SIGIOT, // IOT trap. A synonym for SIGABRT
SIGQUIT, // Quit from keyboard
SIGSEGV, // Invalid memory reference
SIGSYS, // Bad argument to routine (SVr4)
SIGTRAP, // Trace/breakpoint trap
SIGXCPU, // CPU time limit exceeded (4.2BSD)
SIGXFSZ, // File size limit exceeded (4.2BSD)
#if defined(BACKWARD_SYSTEM_DARWIN)
SIGEMT, // emulation instruction executed
SIGEMT, // emulation instruction executed
#endif
};
return std::vector<int>(posix_signals,
@ -4243,11 +4255,11 @@ public:
#elif defined(__arm__)
error_addr = reinterpret_cast<void *>(uctx->uc_mcontext.arm_pc);
#elif defined(__aarch64__)
#if defined(__APPLE__)
error_addr = reinterpret_cast<void *>(uctx->uc_mcontext->__ss.__pc);
#else
error_addr = reinterpret_cast<void *>(uctx->uc_mcontext.pc);
#endif
#if defined(__APPLE__)
error_addr = reinterpret_cast<void *>(uctx->uc_mcontext->__ss.__pc);
#else
error_addr = reinterpret_cast<void *>(uctx->uc_mcontext.pc);
#endif
#elif defined(__mips__)
error_addr = reinterpret_cast<void *>(
reinterpret_cast<struct sigcontext *>(&uctx->uc_mcontext)->sc_pc);
@ -4276,7 +4288,7 @@ public:
printer.address = true;
printer.print(st, stderr);
#if (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700) || \
#if (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700) || \
(defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200809L)
psiginfo(info, nullptr);
#else
@ -4494,3 +4506,4 @@ public:
} // namespace backward
#endif /* H_GUARD */
#endif // defined(PROJECT_ENABLE_BACKWARD_CPP)

View File

@ -1,3 +1,4 @@
#if defined(PROJECT_ENABLE_BACKWARD_CPP)
// Pick your poison.
//
// On GNU/Linux, you have few choices to get the most out of your stack trace.
@ -40,3 +41,4 @@ namespace backward {
backward::SignalHandling sh;
} // namespace backward
#endif // defined(PROJECT_ENABLE_BACKWARD_CPP)