Skip to content

Commit 3f45368

Browse files
oliverchangCommit bot
authored andcommitted
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. [email protected] BUG=chromium:716235 Review-Url: https://codereview.chromium.org/2854173002 Cr-Commit-Position: refs/heads/master@{#45142}
1 parent f0e9576 commit 3f45368

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

include/libplatform/libplatform.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace v8 {
1313
namespace platform {
1414

1515
enum class IdleTaskSupport { kDisabled, kEnabled };
16+
enum class InProcessStackDumping { kDisabled, kEnabled };
1617

1718
/**
1819
* Returns a new instance of the default v8::Platform implementation.
@@ -27,7 +28,9 @@ enum class IdleTaskSupport { kDisabled, kEnabled };
2728
*/
2829
V8_PLATFORM_EXPORT v8::Platform* CreateDefaultPlatform(
2930
int thread_pool_size = 0,
30-
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled);
31+
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
32+
InProcessStackDumping in_process_stack_dumping =
33+
InProcessStackDumping::kEnabled);
3134

3235
/**
3336
* Pumps the message loop for the given isolate.

src/d8.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2602,6 +2602,9 @@ bool Shell::SetOptions(int argc, char* argv[]) {
26022602
} else if (strncmp(argv[i], "--lcov=", 7) == 0) {
26032603
options.lcov_file = argv[i] + 7;
26042604
argv[i] = NULL;
2605+
} else if (strcmp(argv[i], "--disable-in-process-stack-traces") == 0) {
2606+
options.disable_in_process_stack_traces = true;
2607+
argv[i] = NULL;
26052608
}
26062609
}
26072610

@@ -2961,10 +2964,17 @@ int Shell::Main(int argc, char* argv[]) {
29612964
#endif // defined(_WIN32) || defined(_WIN64)
29622965
if (!SetOptions(argc, argv)) return 1;
29632966
v8::V8::InitializeICUDefaultLocation(argv[0], options.icu_data_file);
2967+
2968+
v8::platform::InProcessStackDumping in_process_stack_dumping =
2969+
options.disable_in_process_stack_traces
2970+
? v8::platform::InProcessStackDumping::kDisabled
2971+
: v8::platform::InProcessStackDumping::kEnabled;
2972+
29642973
g_platform = i::FLAG_verify_predictable
29652974
? new PredictablePlatform()
29662975
: v8::platform::CreateDefaultPlatform(
2967-
0, v8::platform::IdleTaskSupport::kEnabled);
2976+
0, v8::platform::IdleTaskSupport::kEnabled,
2977+
in_process_stack_dumping);
29682978

29692979
platform::tracing::TracingController* tracing_controller;
29702980
if (options.trace_enabled) {

src/d8.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ class ShellOptions {
303303
snapshot_blob(NULL),
304304
trace_enabled(false),
305305
trace_config(NULL),
306-
lcov_file(NULL) {}
306+
lcov_file(NULL),
307+
disable_in_process_stack_traces(false) {}
307308

308309
~ShellOptions() {
309310
delete[] isolate_sources;
@@ -334,6 +335,7 @@ class ShellOptions {
334335
bool trace_enabled;
335336
const char* trace_config;
336337
const char* lcov_file;
338+
bool disable_in_process_stack_traces;
337339
};
338340

339341
class Shell : public i::AllStatic {

src/libplatform/default-platform.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ void PrintStackTrace() {
2929

3030
} // namespace
3131

32-
v8::Platform* CreateDefaultPlatform(int thread_pool_size,
33-
IdleTaskSupport idle_task_support) {
34-
v8::base::debug::EnableInProcessStackDumping();
32+
v8::Platform* CreateDefaultPlatform(
33+
int thread_pool_size, IdleTaskSupport idle_task_support,
34+
InProcessStackDumping in_process_stack_dumping) {
35+
if (in_process_stack_dumping == InProcessStackDumping::kEnabled) {
36+
v8::base::debug::EnableInProcessStackDumping();
37+
}
3538
DefaultPlatform* platform = new DefaultPlatform(idle_task_support);
3639
platform->SetThreadPoolSize(thread_pool_size);
3740
platform->EnsureInitialized();

0 commit comments

Comments
 (0)