Commit 0db71a0d authored by Siddhartha S's avatar Siddhartha S Committed by Commit Bot

Reland "Enable extracting unwind table on official builds without channel"

This reverts commit a2474b64.

Reason for revert: The failure was due to parent CL getting reverted
Relanded parent in: https://chromium-review.googlesource.com/c/chromium/src/+/984452

Original change's description:
> Revert "Enable extracting unwind table on official builds without channel"
>
> This reverts commit eb07cea1.
>
> Reason for revert: Windows tryjobs are failing.
> https://logs.chromium.org/v/?s=chromium%2Fbb%2Ftryserver.chromium.win%2Fwin-msvc-rel%2F81420%2F%2B%2Frecipes%2Fsteps%2Fanalyze%2F0%2Fstdout for an example.
>
> ERROR at //base/BUILD.gn:1802:33: Undefined identifier in string expansion.
>     "CAN_UNWIND_WITH_CFI_TABLE=$can_unwind_with_cfi_table",
>                                 ^------------------------
> "can_unwind_with_cfi_table" is not currently in scope.
> See //BUILD.gn:65:5: which caused the file to be included.
>     "//base:base_perftests",
>     ^----------------------
> GN gen failed: 1
>
> Original change's description:
> > Enable extracting unwind table on official builds without channel
> >
> > This CL enables extraction of unwind tables for chrome when
> > is_official_build is set to true and when android_channel is not set to
> > a release channel. This affects build time only on official builds.
> > Also, Set legacy heap profiler to use unwinder for profiling.
> >
> > TBR=dpranke@chromium.org
> > BUG=819888
> >
> > Change-Id: If9732b5ac1f9dff49c58e88e2ffb6cb387715244
> > Reviewed-on: https://chromium-review.googlesource.com/976944
> > Reviewed-by: Siddhartha S <ssid@chromium.org>
> > Reviewed-by: agrieve <agrieve@chromium.org>
> > Commit-Queue: Siddhartha S <ssid@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#546425}
>
> TBR=dpranke@chromium.org,ssid@chromium.org,agrieve@chromium.org
>
> Change-Id: Id033094871dfcf74248f631390f15f379d9cd3c7
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 819888
> Reviewed-on: https://chromium-review.googlesource.com/983893
> Reviewed-by: agrieve <agrieve@chromium.org>
> Commit-Queue: agrieve <agrieve@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#546478}

TBR=dpranke@chromium.org,ssid@chromium.org,agrieve@chromium.org

Change-Id: I100f540c8d5bc9f59b9631ea207c7f290dc42e96
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 819888
Reviewed-on: https://chromium-review.googlesource.com/985112
Commit-Queue: Siddhartha S <ssid@chromium.org>
Reviewed-by: default avatarSiddhartha S <ssid@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547196}
parent 0265cda7
...@@ -1808,6 +1808,7 @@ buildflag_header("debugging_buildflags") { ...@@ -1808,6 +1808,7 @@ buildflag_header("debugging_buildflags") {
"ENABLE_PROFILING=$enable_profiling", "ENABLE_PROFILING=$enable_profiling",
"CAN_UNWIND_WITH_FRAME_POINTERS=$can_unwind_with_frame_pointers", "CAN_UNWIND_WITH_FRAME_POINTERS=$can_unwind_with_frame_pointers",
"UNSAFE_DEVELOPER_BUILD=$is_unsafe_developer_build", "UNSAFE_DEVELOPER_BUILD=$is_unsafe_developer_build",
"CAN_UNWIND_WITH_CFI_TABLE=$can_unwind_with_cfi_table",
] ]
} }
......
...@@ -15,6 +15,11 @@ ...@@ -15,6 +15,11 @@
#include "base/threading/platform_thread.h" #include "base/threading/platform_thread.h"
#include "base/threading/thread_local_storage.h" #include "base/threading/thread_local_storage.h"
#include "base/trace_event/heap_profiler_allocation_context.h" #include "base/trace_event/heap_profiler_allocation_context.h"
#include "build/build_config.h"
#if defined(OS_ANDROID) && BUILDFLAG(CAN_UNWIND_WITH_CFI_TABLE)
#include "base/trace_event/cfi_backtrace_android.h"
#endif
#if defined(OS_LINUX) || defined(OS_ANDROID) #if defined(OS_LINUX) || defined(OS_ANDROID)
#include <sys/prctl.h> #include <sys/prctl.h>
...@@ -214,20 +219,26 @@ bool AllocationContextTracker::GetContextSnapshot(AllocationContext* ctx) { ...@@ -214,20 +219,26 @@ bool AllocationContextTracker::GetContextSnapshot(AllocationContext* ctx) {
// kMaxFrameCount + 1 frames, so that we know if there are more frames // kMaxFrameCount + 1 frames, so that we know if there are more frames
// than our backtrace capacity. // than our backtrace capacity.
#if !defined(OS_NACL) // We don't build base/debug/stack_trace.cc for NaCl. #if !defined(OS_NACL) // We don't build base/debug/stack_trace.cc for NaCl.
#if BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS) #if defined(OS_ANDROID) && BUILDFLAG(CAN_UNWIND_WITH_CFI_TABLE)
const void* frames[Backtrace::kMaxFrameCount + 1];
static_assert(arraysize(frames) >= Backtrace::kMaxFrameCount,
"not requesting enough frames to fill Backtrace");
size_t frame_count = CFIBacktraceAndroid::GetInstance()->Unwind(
frames, arraysize(frames));
#elif BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS)
const void* frames[Backtrace::kMaxFrameCount + 1]; const void* frames[Backtrace::kMaxFrameCount + 1];
static_assert(arraysize(frames) >= Backtrace::kMaxFrameCount, static_assert(arraysize(frames) >= Backtrace::kMaxFrameCount,
"not requesting enough frames to fill Backtrace"); "not requesting enough frames to fill Backtrace");
size_t frame_count = debug::TraceStackFramePointers( size_t frame_count = debug::TraceStackFramePointers(
frames, arraysize(frames), frames, arraysize(frames),
1 /* exclude this function from the trace */); 1 /* exclude this function from the trace */);
#else // BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS) #else
// Fall-back to capturing the stack with base::debug::StackTrace, // Fall-back to capturing the stack with base::debug::StackTrace,
// which is likely slower, but more reliable. // which is likely slower, but more reliable.
base::debug::StackTrace stack_trace(Backtrace::kMaxFrameCount + 1); base::debug::StackTrace stack_trace(Backtrace::kMaxFrameCount + 1);
size_t frame_count = 0u; size_t frame_count = 0u;
const void* const* frames = stack_trace.Addresses(&frame_count); const void* const* frames = stack_trace.Addresses(&frame_count);
#endif // BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS) #endif
// If there are too many frames, keep the ones furthest from main(). // If there are too many frames, keep the ones furthest from main().
size_t backtrace_capacity = backtrace_end - backtrace; size_t backtrace_capacity = backtrace_end - backtrace;
......
...@@ -41,8 +41,13 @@ ...@@ -41,8 +41,13 @@
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "base/trace_event/java_heap_dump_provider_android.h" #include "base/trace_event/java_heap_dump_provider_android.h"
#if BUILDFLAG(CAN_UNWIND_WITH_CFI_TABLE)
#include "base/trace_event/cfi_backtrace_android.h"
#endif #endif
#endif // defined(OS_ANDROID)
namespace base { namespace base {
namespace trace_event { namespace trace_event {
...@@ -273,8 +278,15 @@ bool MemoryDumpManager::EnableHeapProfiling(HeapProfilingMode profiling_mode) { ...@@ -273,8 +278,15 @@ bool MemoryDumpManager::EnableHeapProfiling(HeapProfilingMode profiling_mode) {
break; break;
case kHeapProfilingModeNative: case kHeapProfilingModeNative:
// If we don't have frame pointers then native tracing falls-back to #if defined(OS_ANDROID) && BUILDFLAG(CAN_UNWIND_WITH_CFI_TABLE)
// using base::debug::StackTrace, which may be slow. {
bool can_unwind =
CFIBacktraceAndroid::GetInstance()->can_unwind_stack_frames();
DCHECK(can_unwind);
}
#endif
// If we don't have frame pointers and unwind tables then native tracing
// falls-back to using base::debug::StackTrace, which may be slow.
AllocationContextTracker::SetCaptureMode( AllocationContextTracker::SetCaptureMode(
AllocationContextTracker::CaptureMode::NATIVE_STACK); AllocationContextTracker::CaptureMode::NATIVE_STACK);
break; break;
......
...@@ -31,11 +31,11 @@ template("unwind_table_asset") { ...@@ -31,11 +31,11 @@ template("unwind_table_asset") {
"--dump_syms_path", "--dump_syms_path",
rebase_path("$root_out_dir/dump_syms", root_build_dir), rebase_path("$root_out_dir/dump_syms", root_build_dir),
] ]
deps = [
":${invoker.library_target}", deps = invoker.deps
"//third_party/breakpad:dump_syms", deps += [ "//third_party/breakpad:dump_syms" ]
]
} }
android_assets(target_name) { android_assets(target_name) {
if (defined(invoker.testonly)) { if (defined(invoker.testonly)) {
testonly = invoker.testonly testonly = invoker.testonly
......
...@@ -21,6 +21,7 @@ import("//tools/v8_context_snapshot/v8_context_snapshot.gni") ...@@ -21,6 +21,7 @@ import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
import("channel.gni") import("channel.gni")
import("java_sources.gni") import("java_sources.gni")
import("static_initializers.gni") import("static_initializers.gni")
import("//build/config/android/extract_unwind_tables.gni")
manifest_package = "org.chromium.chrome" manifest_package = "org.chromium.chrome"
...@@ -733,6 +734,22 @@ java_group("chrome_public_non_pak_assets") { ...@@ -733,6 +734,22 @@ java_group("chrome_public_non_pak_assets") {
} }
} }
# Enable stack unwinding only for local official builds. Enabling on all local
# builds would increase build time for developers. Choosing a release channel
# should be done based on the size of the unwind file and performance of
# unwinding.
_add_unwind_tables_in_apk = can_unwind_with_cfi_table && is_android &&
is_official_build && android_channel == "default"
if (_add_unwind_tables_in_apk) {
unwind_table_asset("chrome_public_unwind_assets") {
library_target = "chrome"
deps = [
":libchrome",
]
}
}
android_assets("chrome_public_pak_assets") { android_assets("chrome_public_pak_assets") {
sources = [ sources = [
"$root_out_dir/chrome_100_percent.pak", "$root_out_dir/chrome_100_percent.pak",
...@@ -744,6 +761,9 @@ android_assets("chrome_public_pak_assets") { ...@@ -744,6 +761,9 @@ android_assets("chrome_public_pak_assets") {
":chrome_public_locale_pak_assets", ":chrome_public_locale_pak_assets",
"//chrome:packed_resources", "//chrome:packed_resources",
] ]
if (_add_unwind_tables_in_apk) {
deps += [ ":chrome_public_unwind_assets" ]
}
} }
# This target is separate from chrome_public_pak_assets because it does not # This target is separate from chrome_public_pak_assets because it does not
...@@ -969,6 +989,15 @@ if (current_toolchain == default_toolchain) { ...@@ -969,6 +989,15 @@ if (current_toolchain == default_toolchain) {
] ]
} }
if (_add_unwind_tables_in_apk) {
unwind_table_asset("monochrome_unwind_assets") {
library_target = "monochrome"
deps = [
":monochrome",
]
}
}
# This target explicitly includes locale paks via deps. # This target explicitly includes locale paks via deps.
android_assets("monochrome_pak_assets") { android_assets("monochrome_pak_assets") {
sources = [ sources = [
...@@ -982,6 +1011,9 @@ if (current_toolchain == default_toolchain) { ...@@ -982,6 +1011,9 @@ if (current_toolchain == default_toolchain) {
":monochrome_paks", ":monochrome_paks",
"//android_webview:locale_pak_assets", "//android_webview:locale_pak_assets",
] ]
if (_add_unwind_tables_in_apk) {
deps += [ ":monochrome_unwind_assets" ]
}
} }
} # current_toolchain == host_toolchain } # current_toolchain == host_toolchain
......
...@@ -110,6 +110,9 @@ template("test") { ...@@ -110,6 +110,9 @@ template("test") {
unwind_table_asset(_unwind_table_asset_name) { unwind_table_asset(_unwind_table_asset_name) {
testonly = true testonly = true
library_target = _library_target library_target = _library_target
deps = [
":$_library_target",
]
} }
} }
......
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