Commit 3f453689 authored by ochang's avatar ochang Committed by Commit bot

d8: Make in process stack dumping optional

Adds a flag (--disable-in-process-stack-traces) to not install
signal handlers so that e.g. ASan signal handlers will work.

This flag mirrors chromium's one.

R=jochen@chromium.org
BUG=chromium:716235

Review-Url: https://codereview.chromium.org/2854173002
Cr-Commit-Position: refs/heads/master@{#45142}
parent f0e95769
...@@ -13,6 +13,7 @@ namespace v8 { ...@@ -13,6 +13,7 @@ namespace v8 {
namespace platform { namespace platform {
enum class IdleTaskSupport { kDisabled, kEnabled }; enum class IdleTaskSupport { kDisabled, kEnabled };
enum class InProcessStackDumping { kDisabled, kEnabled };
/** /**
* Returns a new instance of the default v8::Platform implementation. * Returns a new instance of the default v8::Platform implementation.
...@@ -27,7 +28,9 @@ enum class IdleTaskSupport { kDisabled, kEnabled }; ...@@ -27,7 +28,9 @@ enum class IdleTaskSupport { kDisabled, kEnabled };
*/ */
V8_PLATFORM_EXPORT v8::Platform* CreateDefaultPlatform( V8_PLATFORM_EXPORT v8::Platform* CreateDefaultPlatform(
int thread_pool_size = 0, int thread_pool_size = 0,
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled); IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
InProcessStackDumping in_process_stack_dumping =
InProcessStackDumping::kEnabled);
/** /**
* Pumps the message loop for the given isolate. * Pumps the message loop for the given isolate.
......
...@@ -2602,6 +2602,9 @@ bool Shell::SetOptions(int argc, char* argv[]) { ...@@ -2602,6 +2602,9 @@ bool Shell::SetOptions(int argc, char* argv[]) {
} else if (strncmp(argv[i], "--lcov=", 7) == 0) { } else if (strncmp(argv[i], "--lcov=", 7) == 0) {
options.lcov_file = argv[i] + 7; options.lcov_file = argv[i] + 7;
argv[i] = NULL; argv[i] = NULL;
} else if (strcmp(argv[i], "--disable-in-process-stack-traces") == 0) {
options.disable_in_process_stack_traces = true;
argv[i] = NULL;
} }
} }
...@@ -2961,10 +2964,17 @@ int Shell::Main(int argc, char* argv[]) { ...@@ -2961,10 +2964,17 @@ int Shell::Main(int argc, char* argv[]) {
#endif // defined(_WIN32) || defined(_WIN64) #endif // defined(_WIN32) || defined(_WIN64)
if (!SetOptions(argc, argv)) return 1; if (!SetOptions(argc, argv)) return 1;
v8::V8::InitializeICUDefaultLocation(argv[0], options.icu_data_file); v8::V8::InitializeICUDefaultLocation(argv[0], options.icu_data_file);
v8::platform::InProcessStackDumping in_process_stack_dumping =
options.disable_in_process_stack_traces
? v8::platform::InProcessStackDumping::kDisabled
: v8::platform::InProcessStackDumping::kEnabled;
g_platform = i::FLAG_verify_predictable g_platform = i::FLAG_verify_predictable
? new PredictablePlatform() ? new PredictablePlatform()
: v8::platform::CreateDefaultPlatform( : v8::platform::CreateDefaultPlatform(
0, v8::platform::IdleTaskSupport::kEnabled); 0, v8::platform::IdleTaskSupport::kEnabled,
in_process_stack_dumping);
platform::tracing::TracingController* tracing_controller; platform::tracing::TracingController* tracing_controller;
if (options.trace_enabled) { if (options.trace_enabled) {
......
...@@ -303,7 +303,8 @@ class ShellOptions { ...@@ -303,7 +303,8 @@ class ShellOptions {
snapshot_blob(NULL), snapshot_blob(NULL),
trace_enabled(false), trace_enabled(false),
trace_config(NULL), trace_config(NULL),
lcov_file(NULL) {} lcov_file(NULL),
disable_in_process_stack_traces(false) {}
~ShellOptions() { ~ShellOptions() {
delete[] isolate_sources; delete[] isolate_sources;
...@@ -334,6 +335,7 @@ class ShellOptions { ...@@ -334,6 +335,7 @@ class ShellOptions {
bool trace_enabled; bool trace_enabled;
const char* trace_config; const char* trace_config;
const char* lcov_file; const char* lcov_file;
bool disable_in_process_stack_traces;
}; };
class Shell : public i::AllStatic { class Shell : public i::AllStatic {
......
...@@ -29,9 +29,12 @@ void PrintStackTrace() { ...@@ -29,9 +29,12 @@ void PrintStackTrace() {
} // namespace } // namespace
v8::Platform* CreateDefaultPlatform(int thread_pool_size, v8::Platform* CreateDefaultPlatform(
IdleTaskSupport idle_task_support) { int thread_pool_size, IdleTaskSupport idle_task_support,
v8::base::debug::EnableInProcessStackDumping(); InProcessStackDumping in_process_stack_dumping) {
if (in_process_stack_dumping == InProcessStackDumping::kEnabled) {
v8::base::debug::EnableInProcessStackDumping();
}
DefaultPlatform* platform = new DefaultPlatform(idle_task_support); DefaultPlatform* platform = new DefaultPlatform(idle_task_support);
platform->SetThreadPoolSize(thread_pool_size); platform->SetThreadPoolSize(thread_pool_size);
platform->EnsureInitialized(); platform->EnsureInitialized();
......
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