Commit 6eb906e6 authored by Chad Austin's avatar Chad Austin Committed by Facebook Github Bot

build folly/experimental/symbolizer:stack_trace on mac

Summary:
ssize_t is not standard, so include <sys/types.h>. (I considered
switching to intptr_t but decided against it.)

Also, on macOS, the function appears to be called backtrace, not
unw_backtrace.

Reviewed By: yfeldblum

Differential Revision: D14307252

fbshipit-source-id: d919bd37fea8f68b5d610e771e577c8ce385f6ec
parent 7a5aa125
......@@ -19,6 +19,10 @@
#define UNW_LOCAL_ONLY 1
#include <libunwind.h>
#ifdef __APPLE__
#include <execinfo.h>
#endif
namespace folly {
namespace symbolizer {
......@@ -28,7 +32,11 @@ ssize_t getStackTrace(uintptr_t* addresses, size_t maxAddresses) {
// The libunwind documentation says that unw_backtrace is async-signal-safe
// but, as of libunwind 1.0.1, it isn't (tdep_trace allocates memory on
// x86_64)
#ifdef __APPLE__
int r = backtrace(reinterpret_cast<void**>(addresses), maxAddresses);
#else
int r = unw_backtrace(reinterpret_cast<void**>(addresses), maxAddresses);
#endif
return r < 0 ? -1 : r;
}
......
......@@ -16,6 +16,7 @@
#pragma once
#include <sys/types.h>
#include <cstdint>
#include <cstdlib>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment