diff --git a/backward.hpp b/backward.hpp index 33cb0ce..413d507 100644 --- a/backward.hpp +++ b/backward.hpp @@ -611,7 +611,7 @@ template class StackTraceImpl { public: size_t size() const { return 0; } - Trace operator[](size_t) { return Trace(); } + Trace operator[](size_t) const { return Trace(); } size_t load_here(size_t=0) { return 0; } size_t load_from(void*, size_t=0) { return 0; } size_t thread_id() const { return 0; } @@ -1686,7 +1686,7 @@ public: Dl_info symbol_info; int dladdr_result = 0; -#ifndef __ANDROID__ +#if defined(__GLIBC__) link_map *link_map; // We request the link map so we can get information about offsets dladdr_result = dladdr1(trace.addr, &symbol_info, @@ -1742,7 +1742,7 @@ public: return trace; // sad, we couldn't load the object :( } -#ifndef __ANDROID__ +#if defined(__GLIBC__) // Convert the address to a module relative one by looking at // the module's loading address in the link map Dwarf_Addr address = reinterpret_cast(trace.addr) - diff --git a/test/_test_main.cpp b/test/_test_main.cpp index 829bfcd..ebaef49 100644 --- a/test/_test_main.cpp +++ b/test/_test_main.cpp @@ -24,15 +24,21 @@ #include "test.hpp" #include #include -#ifndef __APPLE__ -#include -#endif #include #include -#ifdef __APPLE__ +#if defined(__has_include) && __has_include() +#include +#else #include +#ifndef __APPLE__ +// N.B. getprogname() is an Apple/BSD-ism. +// program_invocation_name is a GLIBC-ism, but it's also +// supported by libmusl. +#define getprogname() program_invocation_name +#endif + void error(int status, int errnum, const char *format, ...) { fflush(stdout); fprintf(stderr, "%s: ", getprogname());