Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: output native stack if HAVE_EXECINFO_H defined #196

Merged
merged 1 commit into from
Sep 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions src/platform/unix/report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@
#define __STDC_FORMAT_MACROS
#endif

#if defined(__linux__) && !defined(__GLIBC__) || defined(__UCLIBC__) || \
defined(_AIX)
#define HAVE_EXECINFO_H 0
#else
#define HAVE_EXECINFO_H 1
#endif

#if HAVE_EXECINFO_H
#include <cxxabi.h>
#include <dlfcn.h>
#include <execinfo.h>
#endif

#include <dlfcn.h>
#include <inttypes.h>
#include <sys/resource.h>
#include <sys/utsname.h>
Expand Down Expand Up @@ -47,12 +57,7 @@ string GetPcAddress(void* pc) {
return (string)buf;
}

#if (defined(__linux__) && !defined(__GLIBC__))
void PrintNativeStack(JSONWriter* writer) {
writer->json_arraystart("nativeStacks");
writer->json_arrayend();
}
#else
#if (HAVE_EXECINFO_H)
void PrintNativeStack(JSONWriter* writer) {
writer->json_arraystart("nativeStacks");
void* frames[256];
Expand Down Expand Up @@ -81,6 +86,11 @@ void PrintNativeStack(JSONWriter* writer) {
}
writer->json_arrayend();
}
#else
void PrintNativeStack(JSONWriter* writer) {
writer->json_arraystart("nativeStacks");
writer->json_arrayend();
}
#endif

void PrintSystemEnv(JSONWriter* writer) {
Expand Down