OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if !defined(_WIN32) && !defined(_WIN64) | 5 #if !defined(_WIN32) && !defined(_WIN64) |
6 #include <unistd.h> // NOLINT | 6 #include <unistd.h> // NOLINT |
7 #endif // !defined(_WIN32) && !defined(_WIN64) | 7 #endif // !defined(_WIN32) && !defined(_WIN64) |
8 | 8 |
9 #include <locale.h> | 9 #include <locale.h> |
10 | 10 |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 return accessing_context.IsEmpty(); | 432 return accessing_context.IsEmpty(); |
433 } | 433 } |
434 | 434 |
435 class InspectorExtension : public v8::Extension { | 435 class InspectorExtension : public v8::Extension { |
436 public: | 436 public: |
437 InspectorExtension() | 437 InspectorExtension() |
438 : v8::Extension("v8_inspector/inspector", | 438 : v8::Extension("v8_inspector/inspector", |
439 "native function attachInspector();" | 439 "native function attachInspector();" |
440 "native function detachInspector();" | 440 "native function detachInspector();" |
441 "native function setMaxAsyncTaskStacks();" | 441 "native function setMaxAsyncTaskStacks();" |
| 442 "native function dumpAsyncTaskStacksStateForTest();" |
442 "native function breakProgram();" | 443 "native function breakProgram();" |
443 "native function createObjectWithStrictCheck();" | 444 "native function createObjectWithStrictCheck();" |
444 "native function callWithScheduledBreak();" | 445 "native function callWithScheduledBreak();" |
445 "native function allowAccessorFormatting();") {} | 446 "native function allowAccessorFormatting();") {} |
446 | 447 |
447 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( | 448 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( |
448 v8::Isolate* isolate, v8::Local<v8::String> name) { | 449 v8::Isolate* isolate, v8::Local<v8::String> name) { |
449 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 450 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
450 if (name->Equals(context, | 451 if (name->Equals(context, |
451 v8::String::NewFromUtf8(isolate, "attachInspector", | 452 v8::String::NewFromUtf8(isolate, "attachInspector", |
452 v8::NewStringType::kNormal) | 453 v8::NewStringType::kNormal) |
453 .ToLocalChecked()) | 454 .ToLocalChecked()) |
454 .FromJust()) { | 455 .FromJust()) { |
455 return v8::FunctionTemplate::New(isolate, InspectorExtension::Attach); | 456 return v8::FunctionTemplate::New(isolate, InspectorExtension::Attach); |
456 } else if (name->Equals(context, | 457 } else if (name->Equals(context, |
457 v8::String::NewFromUtf8(isolate, "detachInspector", | 458 v8::String::NewFromUtf8(isolate, "detachInspector", |
458 v8::NewStringType::kNormal) | 459 v8::NewStringType::kNormal) |
459 .ToLocalChecked()) | 460 .ToLocalChecked()) |
460 .FromJust()) { | 461 .FromJust()) { |
461 return v8::FunctionTemplate::New(isolate, InspectorExtension::Detach); | 462 return v8::FunctionTemplate::New(isolate, InspectorExtension::Detach); |
462 } else if (name->Equals(context, v8::String::NewFromUtf8( | 463 } else if (name->Equals(context, v8::String::NewFromUtf8( |
463 isolate, "setMaxAsyncTaskStacks", | 464 isolate, "setMaxAsyncTaskStacks", |
464 v8::NewStringType::kNormal) | 465 v8::NewStringType::kNormal) |
465 .ToLocalChecked()) | 466 .ToLocalChecked()) |
466 .FromJust()) { | 467 .FromJust()) { |
467 return v8::FunctionTemplate::New( | 468 return v8::FunctionTemplate::New( |
468 isolate, InspectorExtension::SetMaxAsyncTaskStacks); | 469 isolate, InspectorExtension::SetMaxAsyncTaskStacks); |
469 } else if (name->Equals(context, | 470 } else if (name->Equals(context, |
| 471 v8::String::NewFromUtf8( |
| 472 isolate, "dumpAsyncTaskStacksStateForTest", |
| 473 v8::NewStringType::kNormal) |
| 474 .ToLocalChecked()) |
| 475 .FromJust()) { |
| 476 return v8::FunctionTemplate::New( |
| 477 isolate, InspectorExtension::DumpAsyncTaskStacksStateForTest); |
| 478 } else if (name->Equals(context, |
470 v8::String::NewFromUtf8(isolate, "breakProgram", | 479 v8::String::NewFromUtf8(isolate, "breakProgram", |
471 v8::NewStringType::kNormal) | 480 v8::NewStringType::kNormal) |
472 .ToLocalChecked()) | 481 .ToLocalChecked()) |
473 .FromJust()) { | 482 .FromJust()) { |
474 return v8::FunctionTemplate::New(isolate, | 483 return v8::FunctionTemplate::New(isolate, |
475 InspectorExtension::BreakProgram); | 484 InspectorExtension::BreakProgram); |
476 } else if (name->Equals(context, v8::String::NewFromUtf8( | 485 } else if (name->Equals(context, v8::String::NewFromUtf8( |
477 isolate, "createObjectWithStrictCheck", | 486 isolate, "createObjectWithStrictCheck", |
478 v8::NewStringType::kNormal) | 487 v8::NewStringType::kNormal) |
479 .ToLocalChecked()) | 488 .ToLocalChecked()) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 Exit(); | 540 Exit(); |
532 } | 541 } |
533 v8_inspector::V8Inspector* inspector = | 542 v8_inspector::V8Inspector* inspector = |
534 InspectorClientImpl::InspectorFromContext( | 543 InspectorClientImpl::InspectorFromContext( |
535 args.GetIsolate()->GetCurrentContext()); | 544 args.GetIsolate()->GetCurrentContext()); |
536 CHECK(inspector); | 545 CHECK(inspector); |
537 v8_inspector::SetMaxAsyncTaskStacksForTest( | 546 v8_inspector::SetMaxAsyncTaskStacksForTest( |
538 inspector, args[0].As<v8::Int32>()->Value()); | 547 inspector, args[0].As<v8::Int32>()->Value()); |
539 } | 548 } |
540 | 549 |
| 550 static void DumpAsyncTaskStacksStateForTest( |
| 551 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 552 if (args.Length() != 0) { |
| 553 fprintf(stderr, "Internal error: dumpAsyncTaskStacksStateForTest()."); |
| 554 Exit(); |
| 555 } |
| 556 v8_inspector::V8Inspector* inspector = |
| 557 InspectorClientImpl::InspectorFromContext( |
| 558 args.GetIsolate()->GetCurrentContext()); |
| 559 CHECK(inspector); |
| 560 v8_inspector::DumpAsyncTaskStacksStateForTest(inspector); |
| 561 } |
| 562 |
541 static void BreakProgram(const v8::FunctionCallbackInfo<v8::Value>& args) { | 563 static void BreakProgram(const v8::FunctionCallbackInfo<v8::Value>& args) { |
542 if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsString()) { | 564 if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsString()) { |
543 fprintf(stderr, "Internal error: breakProgram('reason', 'details')."); | 565 fprintf(stderr, "Internal error: breakProgram('reason', 'details')."); |
544 Exit(); | 566 Exit(); |
545 } | 567 } |
546 v8_inspector::V8InspectorSession* session = | 568 v8_inspector::V8InspectorSession* session = |
547 InspectorClientImpl::SessionFromContext( | 569 InspectorClientImpl::SessionFromContext( |
548 args.GetIsolate()->GetCurrentContext()); | 570 args.GetIsolate()->GetCurrentContext()); |
549 CHECK(session); | 571 CHECK(session); |
550 | 572 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 argv[i]); | 738 argv[i]); |
717 Exit(); | 739 Exit(); |
718 } | 740 } |
719 frontend_runner.Append(new ExecuteStringTask(chars)); | 741 frontend_runner.Append(new ExecuteStringTask(chars)); |
720 } | 742 } |
721 | 743 |
722 frontend_runner.Join(); | 744 frontend_runner.Join(); |
723 backend_runner.Join(); | 745 backend_runner.Join(); |
724 return 0; | 746 return 0; |
725 } | 747 } |
OLD | NEW |