Skip to content

Commit

Permalink
server: functional backtraces for OS X (#2549)
Browse files Browse the repository at this point in the history
Description:
bombela/backward-cpp now has some support for backtraces on OS X. Bump backward-cpp to a revision that contains the change. Modify stack trace output on OS X since addr2line (via homebrew's binutils package) doesn't seem to be able to resolve addresses from the stack trace (or lldb for that matter). Instead, print as much information as possible directly in the stack trace (which is equivalent to lldb's output given bazelbuild/bazel#2537).

Risk Level: Low

Testing:
Manually tested stack traces by forcing division by zero.

Signed-off-by: Stephan Zuercher stephan@turbinelabs.io
  • Loading branch information
zuercher authored and dnoe committed Feb 8, 2018
1 parent 07dc704 commit 9b42fc2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ REPOSITORY_LOCATIONS = dict(
remote = "https://github.com/abseil/abseil-cpp",
),
com_github_bombela_backward = dict(
commit = "cd1c4bd9e48afe812a0e996d335298c455afcd92", # v1.3
commit = "44ae9609e860e3428cd057f7052e505b4819eb84", # 2018-02-06
remote = "https://github.com/bombela/backward-cpp",
),
com_github_cyan4973_xxhash = dict(
Expand Down
13 changes: 13 additions & 0 deletions source/server/backtrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,14 @@ class BackwardsTrace : Logger::Loggable<Logger::Id::backtrace> {
backward::ResolvedTrace first_frame_trace = resolver.resolve(stack_trace_[0]);
auto obj_name = first_frame_trace.object_filename;

#ifdef __APPLE__
// The stack_decode.py script uses addr2line which isn't readily available and doesn't seem to
// work when installed.
ENVOY_LOG(critical, "Backtrace obj<{}> thr<{}>:", obj_name, thread_id);
#else
ENVOY_LOG(critical, "Backtrace obj<{}> thr<{}> (use tools/stack_decode.py):", obj_name,
thread_id);
#endif

// Backtrace gets tagged by ASAN when we try the object name resolution for the last
// frame on stack, so skip the last one. It has no useful info anyway.
Expand All @@ -92,7 +98,14 @@ class BackwardsTrace : Logger::Loggable<Logger::Id::backtrace> {
obj_name = trace.object_filename;
ENVOY_LOG(critical, "thr<{}> obj<{}>", thread_id, obj_name);
}

#ifdef __APPLE__
// In the absence of stack_decode.py, print the function name.
ENVOY_LOG(critical, "thr<{}> #{} {}: {}", thread_id, stack_trace_[i].idx,
stack_trace_[i].addr, trace.object_function);
#else
ENVOY_LOG(critical, "thr<{}> #{} {}", thread_id, stack_trace_[i].idx, stack_trace_[i].addr);
#endif
}
ENVOY_LOG(critical, "end backtrace thread {}", stack_trace_.thread_id());
}
Expand Down

0 comments on commit 9b42fc2

Please sign in to comment.