@@ -449,14 +449,17 @@ NAN_METHOD(WallProfiler::Start) {
449
449
WallProfiler* wallProfiler =
450
450
Nan::ObjectWrap::Unwrap<WallProfiler>(info.Holder ());
451
451
452
- if (info.Length () != 2 ) {
453
- return Nan::ThrowTypeError (" Start must have two arguments." );
452
+ if (info.Length () != 3 ) {
453
+ return Nan::ThrowTypeError (" Start must have three arguments." );
454
454
}
455
455
if (!info[0 ]->IsString ()) {
456
456
return Nan::ThrowTypeError (" Profile name must be a string." );
457
457
}
458
458
if (!info[1 ]->IsBoolean ()) {
459
- return Nan::ThrowTypeError (" Include lines must be a boolean." );
459
+ return Nan::ThrowTypeError (" Include lines flag must be a boolean." );
460
+ }
461
+ if (!info[2 ]->IsBoolean ()) {
462
+ return Nan::ThrowTypeError (" With labels flag must be a boolean." );
460
463
}
461
464
462
465
Local<String> name =
@@ -465,29 +468,34 @@ NAN_METHOD(WallProfiler::Start) {
465
468
bool includeLines =
466
469
Nan::MaybeLocal<Boolean>(info[1 ].As <Boolean>()).ToLocalChecked ()->Value ();
467
470
468
- wallProfiler->StartImpl (name, includeLines);
471
+ bool withLabels =
472
+ Nan::MaybeLocal<Boolean>(info[2 ].As <Boolean>()).ToLocalChecked ()->Value ();
469
473
470
- #ifdef DD_WALL_USE_SIGPROF
471
- struct sigaction sa, old_sa;
472
- sa.sa_flags = SA_SIGINFO | SA_RESTART;
473
- sa.sa_sigaction = &sighandler;
474
- sigemptyset (&sa.sa_mask );
475
- sigaction (SIGPROF, &sa, &old_sa);
474
+ wallProfiler->StartImpl (name, includeLines, withLabels);
476
475
477
- // At the end of a cycle start is called before stop,
478
- // at this point old_sa.sa_sigaction is sighandler !
479
- if (!old_handler) {
480
- old_handler = old_sa.sa_sigaction ;
476
+ #ifdef DD_WALL_USE_SIGPROF
477
+ if (withLabels) {
478
+ struct sigaction sa, old_sa;
479
+ sa.sa_flags = SA_SIGINFO | SA_RESTART;
480
+ sa.sa_sigaction = &sighandler;
481
+ sigemptyset (&sa.sa_mask );
482
+ sigaction (SIGPROF, &sa, &old_sa);
483
+
484
+ // At the end of a cycle start is called before stop,
485
+ // at this point old_sa.sa_sigaction is sighandler !
486
+ if (!old_handler) {
487
+ old_handler = old_sa.sa_sigaction ;
488
+ }
481
489
}
482
490
#endif
483
491
}
484
492
485
- void WallProfiler::StartImpl (Local<String> name, bool includeLines) {
493
+ void WallProfiler::StartImpl (Local<String> name, bool includeLines, bool withLabels ) {
486
494
if (includeLines) {
487
495
GetProfiler ()->StartProfiling (
488
- name, CpuProfilingMode::kCallerLineNumbers , true );
496
+ name, CpuProfilingMode::kCallerLineNumbers , withLabels );
489
497
} else {
490
- GetProfiler ()->StartProfiling (name, true );
498
+ GetProfiler ()->StartProfiling (name, withLabels );
491
499
}
492
500
493
501
last_start = current_start;
0 commit comments