diff --git a/port/stack_trace.cc b/port/stack_trace.cc index b1a9ba08d..76866e63c 100644 --- a/port/stack_trace.cc +++ b/port/stack_trace.cc @@ -70,19 +70,23 @@ void PrintStackTraceLine(const char* symbol, void* frame) { #elif OS_MACOSX void PrintStackTraceLine(const char* symbol, void* frame) { - if (symbol) { - char filename[64], function[512], plus[2], line[10]; - sscanf(symbol, "%*s %64s %*s %512s %2s %10s", filename, function, plus, - line); - int status; - char* demangled = abi::__cxa_demangle(function, 0, 0, &status); - fprintf(stderr, "%s %s %s %s", filename, - (status == 0) ? demangled : function, plus, line); - if (demangled) { - free(demangled); + static int pid = getpid(); + // out source to atos, for the address translation + const int kLineMax = 256; + char cmd[kLineMax]; + snprintf(cmd, kLineMax, "xcrun atos %p -p %d 2>&1", frame, pid); + auto f = popen(cmd, "r"); + if (f) { + char line[kLineMax]; + while (fgets(line, sizeof(line), f)) { + line[strlen(line) - 1] = 0; // remove newline + fprintf(stderr, "%s\t", line); } + pclose(f); + } else if (symbol) { + fprintf(stderr, "%s ", symbol); } - fprintf(stderr, " %p", frame); + fprintf(stderr, "\n"); } diff --git a/util/testharness.cc b/util/testharness.cc index 7051ccf66..4208d2c46 100644 --- a/util/testharness.cc +++ b/util/testharness.cc @@ -8,12 +8,11 @@ // found in the LICENSE file. See the AUTHORS file for names of contributors. #include "util/testharness.h" -#include "port/stack_trace.h" - #include #include #include #include +#include "port/stack_trace.h" namespace rocksdb { namespace test {