Commit a19369a0 authored by Ben Pastene's avatar Ben Pastene Committed by Commit Bot

base: Symbolize stace traces on official builds if unwind tables are present.

This will allow tests built with is_official_build=true to produce symbolized
stack traces during failures by explicitly setting exclude_unwind_tables
to false. This will be used by the chrome-branded + is_official testers that
have been spun up on https://ci.chromium.org/p/chrome/g/chrome/console

Note that any official build that doesn't touch exclude_unwind_tables will still
have unsymbolized stack traces since exclude_unwind_tables defaults to true
for official builds:
https://source.chromium.org/chromium/chromium/src/+/master:build/config/compiler/compiler.gni;l=96

Consequently, every other official builder will still have this symbolizing
code excluded from the build products.

Bug: 1041069
Change-Id: I937dbe01c38a29b1aff01d471807a9a492109645
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2001749Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732830}
parent 8a0b5eca
...@@ -531,7 +531,7 @@ class SandboxSymbolizeHelper { ...@@ -531,7 +531,7 @@ class SandboxSymbolizeHelper {
int GetFileDescriptor(const char* file_path) { int GetFileDescriptor(const char* file_path) {
int fd = -1; int fd = -1;
#if !defined(OFFICIAL_BUILD) #if !defined(OFFICIAL_BUILD) || !defined(NO_UNWIND_TABLES)
if (file_path) { if (file_path) {
// The assumption here is that iterating over std::map<std::string, int> // The assumption here is that iterating over std::map<std::string, int>
// using a const_iterator does not allocate dynamic memory, hense it is // using a const_iterator does not allocate dynamic memory, hense it is
...@@ -552,7 +552,7 @@ class SandboxSymbolizeHelper { ...@@ -552,7 +552,7 @@ class SandboxSymbolizeHelper {
fd = -1; fd = -1;
} }
} }
#endif // !defined(OFFICIAL_BUILD) #endif // !defined(OFFICIAL_BUILD) || !defined(NO_UNWIND_TABLES)
return fd; return fd;
} }
...@@ -681,7 +681,7 @@ class SandboxSymbolizeHelper { ...@@ -681,7 +681,7 @@ class SandboxSymbolizeHelper {
// Pre-opening and caching the file descriptors of all loaded modules is // Pre-opening and caching the file descriptors of all loaded modules is
// not safe for production builds. Hence it is only done in non-official // not safe for production builds. Hence it is only done in non-official
// builds. For more details, take a look at: http://crbug.com/341966. // builds. For more details, take a look at: http://crbug.com/341966.
#if !defined(OFFICIAL_BUILD) #if !defined(OFFICIAL_BUILD) || !defined(NO_UNWIND_TABLES)
// Open the object files for all read-only executable regions and cache // Open the object files for all read-only executable regions and cache
// their file descriptors. // their file descriptors.
std::vector<MappedMemoryRegion>::const_iterator it; std::vector<MappedMemoryRegion>::const_iterator it;
...@@ -718,7 +718,7 @@ class SandboxSymbolizeHelper { ...@@ -718,7 +718,7 @@ class SandboxSymbolizeHelper {
} }
} }
} }
#endif // !defined(OFFICIAL_BUILD) #endif // !defined(OFFICIAL_BUILD) || !defined(NO_UNWIND_TABLES)
} }
// Initializes and installs the symbolization callback. // Initializes and installs the symbolization callback.
...@@ -740,7 +740,7 @@ class SandboxSymbolizeHelper { ...@@ -740,7 +740,7 @@ class SandboxSymbolizeHelper {
// Closes all file descriptors owned by this instance. // Closes all file descriptors owned by this instance.
void CloseObjectFiles() { void CloseObjectFiles() {
#if !defined(OFFICIAL_BUILD) #if !defined(OFFICIAL_BUILD) || !defined(NO_UNWIND_TABLES)
std::map<std::string, int>::iterator it; std::map<std::string, int>::iterator it;
for (it = modules_.begin(); it != modules_.end(); ++it) { for (it = modules_.begin(); it != modules_.end(); ++it) {
int ret = IGNORE_EINTR(close(it->second)); int ret = IGNORE_EINTR(close(it->second));
...@@ -748,18 +748,18 @@ class SandboxSymbolizeHelper { ...@@ -748,18 +748,18 @@ class SandboxSymbolizeHelper {
it->second = -1; it->second = -1;
} }
modules_.clear(); modules_.clear();
#endif // !defined(OFFICIAL_BUILD) #endif // !defined(OFFICIAL_BUILD) || !defined(NO_UNWIND_TABLES)
} }
// Set to true upon successful initialization. // Set to true upon successful initialization.
bool is_initialized_; bool is_initialized_;
#if !defined(OFFICIAL_BUILD) #if !defined(OFFICIAL_BUILD) || !defined(NO_UNWIND_TABLES)
// Mapping from file name to file descriptor. Includes file descriptors // Mapping from file name to file descriptor. Includes file descriptors
// for all successfully opened object files and the file descriptor for // for all successfully opened object files and the file descriptor for
// /proc/self/maps. This code is not safe for production builds. // /proc/self/maps. This code is not safe for production builds.
std::map<std::string, int> modules_; std::map<std::string, int> modules_;
#endif // !defined(OFFICIAL_BUILD) #endif // !defined(OFFICIAL_BUILD) || !defined(NO_UNWIND_TABLES)
// Cache for the process memory regions. Produced by parsing the contents // Cache for the process memory regions. Produced by parsing the contents
// of /proc/self/maps cache. // of /proc/self/maps cache.
......
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