summaryrefslogtreecommitdiff
path: root/src/debug/CrashReporter.cpp
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2024-03-05 17:51:34 -0500
committerGitHub <noreply@github.com>2024-03-05 22:51:34 +0000
commitb1e2ca04a016b1ea24344d3cfb2eb3370863eb5e (patch)
tree411216636fc47a28ccc45c7ce2b858727ec762ba /src/debug/CrashReporter.cpp
parent05dd204c5feddd18084a4ae5e4747579b0728a23 (diff)
CrashReporter: Fix compilation with musl libc (#4805)
It can be assumed this doesn't function correctly: my 'configuration does not support execinfo.h', so I have no backtrace to test against
Diffstat (limited to 'src/debug/CrashReporter.cpp')
-rw-r--r--src/debug/CrashReporter.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/debug/CrashReporter.cpp b/src/debug/CrashReporter.cpp
index cf648191..a4bdc761 100644
--- a/src/debug/CrashReporter.cpp
+++ b/src/debug/CrashReporter.cpp
@@ -108,18 +108,23 @@ void CrashReporter::createAndSaveCrash(int sig) {
std::string addrs = "";
for (size_t i = 0; i < CALLSTACK.size(); ++i) {
+#ifdef __GLIBC__
// convert in memory address to VMA address
Dl_info info;
struct link_map* linkMap;
dladdr1((void*)CALLSTACK[i].adr, &info, (void**)&linkMap, RTLD_DL_LINKMAP);
size_t vmaAddr = (size_t)CALLSTACK[i].adr - linkMap->l_addr;
+#else
+ // musl doesn't define dladdr1
+ size_t vmaAddr = (size_t)CALLSTACK[i].adr;
+#endif
addrs += std::format("0x{:x} ", vmaAddr);
}
#ifdef __clang__
const auto CMD = std::format("llvm-addr2line -e {} -Cf {}", FPATH.c_str(), addrs);
#else
- const auto CMD = std::format("addr2line -e {} -Cf {}", FPATH.c_str(), addrs);
+ const auto CMD = std::format("addr2line -e {} -Cf {}", FPATH.c_str(), addrs);
#endif
const auto ADDR2LINE = execAndGet(CMD.c_str());