mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
71 lines
2.2 KiB
Diff
71 lines
2.2 KiB
Diff
diff --git mlibc-clean/options/glibc/generic/execinfo.cpp mlibc-workdir/options/glibc/generic/execinfo.cpp
|
|
index 1ed110d..ded9114 100644
|
|
--- mlibc-clean/options/glibc/generic/execinfo.cpp
|
|
+++ mlibc-workdir/options/glibc/generic/execinfo.cpp
|
|
@@ -4,6 +4,7 @@
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <unwind.h>
|
|
+#include <errno.h>
|
|
|
|
#include <bits/ensure.h>
|
|
#include <mlibc/debug.hpp>
|
|
@@ -52,29 +53,7 @@ _Unwind_Reason_Code trace(_Unwind_Context *context, void *arg) {
|
|
} // namespace
|
|
|
|
int backtrace(void **buffer, int size) {
|
|
- if (size <= 0)
|
|
- return 0;
|
|
-
|
|
- if (!libgccHandle) {
|
|
- libgccHandle = dlopen("libgcc_s.so.1", RTLD_LAZY | RTLD_LOCAL);
|
|
- if (!libgccHandle || libgccHandle.value() == nullptr) {
|
|
- auto error = dlerror();
|
|
- mlibc::infoLogger() << "Failed to load libgcc_s.so.1: " << (error ? error : "") << frg::endlog;
|
|
- return 0;
|
|
- }
|
|
-
|
|
- unwindBacktrace = reinterpret_cast<UnwindBacktrace>(dlsym(libgccHandle.value(), "_Unwind_Backtrace"));
|
|
- unwindGetIP = reinterpret_cast<UnwindGetIP>(dlsym(libgccHandle.value(), "_Unwind_GetIP"));
|
|
-
|
|
- if (!unwindBacktrace || !unwindGetIP) {
|
|
- mlibc::infoLogger() << "Failed to find unwind functions in libgcc_s.so.1: " << dlerror() << frg::endlog;
|
|
- return 0;
|
|
- }
|
|
- }
|
|
-
|
|
- UnwindState state{buffer, size};
|
|
- unwindBacktrace(trace, &state);
|
|
- return state.current_frame;
|
|
+ return ENOSYS;
|
|
}
|
|
|
|
char **backtrace_symbols(void *const *, int) {
|
|
@@ -82,25 +61,5 @@ char **backtrace_symbols(void *const *, int) {
|
|
__builtin_unreachable();
|
|
}
|
|
|
|
-void backtrace_symbols_fd(void *const *buffer, int size, int fd) {
|
|
- if (size <= 0 || fd < 0)
|
|
- return;
|
|
-
|
|
- for (int frame_num = 0; frame_num < size; frame_num++) {
|
|
- Dl_info info;
|
|
- if (dladdr(buffer[frame_num], &info) != 0) {
|
|
- if (info.dli_fname != nullptr)
|
|
- write(fd, info.dli_fname, strlen(info.dli_fname));
|
|
-
|
|
- if (info.dli_sname != nullptr)
|
|
- dprintf(fd, "(%s+0x%" PRIxPTR ") ", info.dli_sname,
|
|
- reinterpret_cast<uintptr_t>(buffer[frame_num]) - reinterpret_cast<uintptr_t>(info.dli_saddr));
|
|
- else if(info.dli_saddr)
|
|
- dprintf(fd, "(+%p) ", info.dli_saddr);
|
|
- else
|
|
- dprintf(fd, "() ");
|
|
- }
|
|
-
|
|
- dprintf(fd, "[%p]\n", buffer[frame_num]);
|
|
- }
|
|
+void backtrace_symbols_fd(void *const *, int, int) {
|
|
}
|