Commit 6a272677 authored by James Darpinian's avatar James Darpinian Committed by Commit Bot

Add print_unsymbolized_stack_traces gn arg.

This allows using asan_symbolizer.py to get improved stack traces with
line numbers even in non-ASAN, non-debug builds.

Change-Id: I047b7e936c54b79ab057616a9e6a4c013a94b1fc
Reviewed-on: https://chromium-review.googlesource.com/940771Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: James Darpinian <jdarpinian@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540366}
parent 71ea9ff0
......@@ -2,6 +2,17 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/compiler/compiler.gni")
declare_args() {
# Stack traces will not include function names. Instead they will contain
# file and offset information that can be used with
# tools/valgrind/asan/asan_symbolize.py. By piping stderr through this script,
# and also enabling symbol_level = 2, you can get much more detailed stack
# traces with file names and line numbers, even in non-ASAN builds.
print_unsymbolized_stack_traces = is_asan || is_lsan || is_msan || is_tsan
}
static_library("symbolize") {
visibility = [ "//base/*" ]
sources = [
......@@ -15,6 +26,11 @@ static_library("symbolize") {
"utilities.h",
]
defines = []
if (print_unsymbolized_stack_traces) {
defines += [ "PRINT_UNSYMBOLIZED_STACK_TRACES" ]
}
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
......@@ -779,8 +779,7 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
}
// Check whether a file name was returned.
#if !defined(ADDRESS_SANITIZER) && !defined(LEAK_SANITIZER) && \
!defined(MEMORY_SANITIZER) && !defined(THREAD_SANITIZER)
#if !defined(PRINT_UNSYMBOLIZED_STACK_TRACES)
if (object_fd < 0) {
#endif
if (out[1]) {
......@@ -796,8 +795,7 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
}
// Failed to determine the object file containing PC. Bail out.
return false;
#if !defined(ADDRESS_SANITIZER) && !defined(LEAK_SANITIZER) && \
!defined(MEMORY_SANITIZER) && !defined(THREAD_SANITIZER)
#if !defined(PRINT_UNSYMBOLIZED_STACK_TRACES)
}
#endif
FileDescriptor wrapped_object_fd(object_fd);
......
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