Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium 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 #include "platform/v8_inspector/V8Debugger.h" | 5 #include "platform/v8_inspector/V8Debugger.h" |
| 6 | 6 |
| 7 #include "platform/v8_inspector/DebuggerScript.h" | 7 #include "platform/v8_inspector/DebuggerScript.h" |
| 8 #include "platform/v8_inspector/ScriptBreakpoint.h" | 8 #include "platform/v8_inspector/ScriptBreakpoint.h" |
| 9 #include "platform/v8_inspector/V8Compat.h" | 9 #include "platform/v8_inspector/V8Compat.h" |
| 10 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" | 10 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 const char stepOutV8MethodName[] = "stepOutOfFunction"; | 21 const char stepOutV8MethodName[] = "stepOutOfFunction"; |
| 22 static const char v8AsyncTaskEventEnqueue[] = "enqueue"; | 22 static const char v8AsyncTaskEventEnqueue[] = "enqueue"; |
| 23 static const char v8AsyncTaskEventWillHandle[] = "willHandle"; | 23 static const char v8AsyncTaskEventWillHandle[] = "willHandle"; |
| 24 static const char v8AsyncTaskEventDidHandle[] = "didHandle"; | 24 static const char v8AsyncTaskEventDidHandle[] = "didHandle"; |
| 25 | 25 |
| 26 inline v8::Local<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate) | 26 inline v8::Local<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate) |
| 27 { | 27 { |
| 28 return value ? v8::True(isolate) : v8::False(isolate); | 28 return value ? v8::True(isolate) : v8::False(isolate); |
| 29 } | 29 } |
| 30 | 30 |
| 31 v8::Local<v8::Value> createInternalLocation(v8::Isolate* isolate, v8::Local<v8:: Context> context, v8::Local<v8::String> scriptId, v8::Local<v8::Number> lineNumb er, v8::Local<v8::Number> columnNumber) | |
| 32 { | |
| 33 v8::Local<v8::Object> location = v8::Object::New(isolate); | |
| 34 if (!location->SetPrototype(context, v8::Null(isolate)).FromMaybe(false)) | |
| 35 return v8::Null(isolate); | |
| 36 if (!location->Set(context, toV8StringInternalized(isolate, "scriptId"), scr iptId).FromMaybe(false)) | |
| 37 return v8::Null(isolate); | |
| 38 if (!location->Set(context, toV8StringInternalized(isolate, "lineNumber"), l ineNumber).FromMaybe(false)) | |
| 39 return v8::Null(isolate); | |
| 40 if (!location->Set(context, toV8StringInternalized(isolate, "columnNumber"), columnNumber).FromMaybe(false)) | |
| 41 return v8::Null(isolate); | |
| 42 if (!markAsInternal(context, location, V8InternalValueType::kLocation)) | |
| 43 return v8::Null(isolate); | |
| 44 return location; | |
| 45 } | |
| 46 | |
| 47 v8::Local<v8::Value> createInternalLocation(v8::Isolate* isolate, v8::Local<v8:: Context> fromContext, v8::Local<v8::Context> toContext, v8::Local<v8::Object> lo cation) | |
| 48 { | |
| 49 v8::Local<v8::Value> scriptId; | |
| 50 if (!location->Get(fromContext, toV8StringInternalized(isolate, "scriptId")) .ToLocal(&scriptId) || !scriptId->IsString()) | |
| 51 return v8::Null(isolate); | |
| 52 v8::Local<v8::Value> lineNumber; | |
| 53 if (!location->Get(fromContext, toV8StringInternalized(isolate, "lineNumber" )).ToLocal(&lineNumber) || !lineNumber->IsNumber()) | |
| 54 return v8::Null(isolate); | |
| 55 v8::Local<v8::Value> columnNumber; | |
| 56 if (!location->Get(fromContext, toV8StringInternalized(isolate, "columnNumbe r")).ToLocal(&columnNumber) || !columnNumber->IsNumber()) | |
| 57 return v8::Null(isolate); | |
| 58 return createInternalLocation(isolate, toContext, scriptId.As<v8::String>(), lineNumber.As<v8::Number>(), columnNumber.As<v8::Number>()); | |
| 59 } | |
| 60 | |
| 31 } | 61 } |
| 32 | 62 |
| 33 static bool inLiveEditScope = false; | 63 static bool inLiveEditScope = false; |
| 34 | 64 |
| 35 v8::MaybeLocal<v8::Value> V8Debugger::callDebuggerMethod(const char* functionNam e, int argc, v8::Local<v8::Value> argv[]) | 65 v8::MaybeLocal<v8::Value> V8Debugger::callDebuggerMethod(const char* functionNam e, int argc, v8::Local<v8::Value> argv[]) |
| 36 { | 66 { |
| 37 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr otasks); | 67 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr otasks); |
| 38 v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate); | 68 v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate); |
| 39 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(debuggerScr ipt->Get(toV8StringInternalized(m_isolate, functionName))); | 69 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(debuggerScr ipt->Get(toV8StringInternalized(m_isolate, functionName))); |
| 40 DCHECK(m_isolate->InContext()); | 70 DCHECK(m_isolate->InContext()); |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 574 DCHECK(value->IsObject()); | 604 DCHECK(value->IsObject()); |
| 575 m_debuggerScript.Reset(m_isolate, value.As<v8::Object>()); | 605 m_debuggerScript.Reset(m_isolate, value.As<v8::Object>()); |
| 576 } | 606 } |
| 577 | 607 |
| 578 v8::Local<v8::Context> V8Debugger::debuggerContext() const | 608 v8::Local<v8::Context> V8Debugger::debuggerContext() const |
| 579 { | 609 { |
| 580 DCHECK(!m_debuggerContext.IsEmpty()); | 610 DCHECK(!m_debuggerContext.IsEmpty()); |
| 581 return m_debuggerContext.Get(m_isolate); | 611 return m_debuggerContext.Get(m_isolate); |
| 582 } | 612 } |
| 583 | 613 |
| 584 v8::MaybeLocal<v8::Value> V8Debugger::functionScopes(v8::Local<v8::Function> fun ction) | 614 v8::MaybeLocal<v8::Value> V8Debugger::functionScopes(v8::Local<v8::Context> cont ext, v8::Local<v8::Function> function) |
| 585 { | 615 { |
| 586 if (!enabled()) { | 616 if (!enabled()) { |
| 587 NOTREACHED(); | 617 NOTREACHED(); |
| 588 return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate)); | 618 return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate)); |
| 589 } | 619 } |
| 590 v8::Local<v8::Value> argv[] = { function }; | 620 v8::Local<v8::Value> argv[] = { function }; |
| 591 v8::Local<v8::Value> scopesValue; | 621 v8::Local<v8::Value> scopesValue; |
| 592 if (!callDebuggerMethod("getFunctionScopes", 1, argv).ToLocal(&scopesValue) || !scopesValue->IsArray()) | 622 if (!callDebuggerMethod("getFunctionScopes", 1, argv).ToLocal(&scopesValue) || !scopesValue->IsArray()) |
| 593 return v8::MaybeLocal<v8::Value>(); | 623 return v8::MaybeLocal<v8::Value>(); |
| 594 v8::Local<v8::Array> scopes = scopesValue.As<v8::Array>(); | 624 v8::Local<v8::Array> scopes = scopesValue.As<v8::Array>(); |
| 595 v8::Local<v8::Context> context = m_debuggerContext.Get(m_isolate); | 625 |
| 596 if (!markAsInternal(context, scopes, V8InternalValueType::kScopeList)) | 626 v8::Local<v8::Array> result = v8::Array::New(m_isolate, scopes->Length()); |
|
pfeldman
2016/08/16 17:07:36
This is too fragile and adhock. You leak one array
dgozman
2016/08/17 00:58:32
Updated.
| |
| 627 if (!result->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(false)) | |
| 597 return v8::MaybeLocal<v8::Value>(); | 628 return v8::MaybeLocal<v8::Value>(); |
| 598 if (!markArrayEntriesAsInternal(context, scopes, V8InternalValueType::kScope )) | 629 if (!markAsInternal(context, result, V8InternalValueType::kScopeList)) |
| 599 return v8::MaybeLocal<v8::Value>(); | 630 return v8::MaybeLocal<v8::Value>(); |
| 600 if (!scopes->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(false)) | 631 |
| 601 return v8::Undefined(m_isolate); | 632 for (size_t i = 0; i < scopes->Length(); ++i) { |
| 602 return scopes; | 633 v8::Local<v8::Value> scopeValue; |
| 634 if (!scopes->Get(debuggerContext(), i).ToLocal(&scopeValue) || !scopeVal ue->IsObject()) | |
| 635 return v8::MaybeLocal<v8::Value>(); | |
| 636 v8::Local<v8::Object> scope = scopeValue.As<v8::Object>(); | |
| 637 | |
| 638 v8::Local<v8::Object> resultScope = v8::Object::New(m_isolate); | |
| 639 if (!resultScope->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(f alse)) | |
| 640 return v8::MaybeLocal<v8::Value>(); | |
| 641 if (!markAsInternal(context, resultScope, V8InternalValueType::kScope)) | |
| 642 return v8::MaybeLocal<v8::Value>(); | |
| 643 | |
| 644 v8::Local<v8::Value> type; | |
| 645 if (!scope->Get(debuggerContext(), toV8StringInternalized(m_isolate, "ty pe")).ToLocal(&type) || !type->IsString()) | |
| 646 return v8::MaybeLocal<v8::Value>(); | |
| 647 if (!resultScope->Set(context, toV8StringInternalized(m_isolate, "type") , type).FromMaybe(false)) | |
| 648 return v8::MaybeLocal<v8::Value>(); | |
| 649 | |
| 650 v8::Local<v8::Value> object; | |
| 651 if (!scope->Get(debuggerContext(), toV8StringInternalized(m_isolate, "ob ject")).ToLocal(&object) || !object->IsObject()) | |
| 652 return v8::MaybeLocal<v8::Value>(); | |
| 653 if (!resultScope->Set(context, toV8StringInternalized(m_isolate, "object "), object).FromMaybe(false)) | |
| 654 return v8::MaybeLocal<v8::Value>(); | |
| 655 | |
| 656 if (scope->HasOwnProperty(debuggerContext(), toV8StringInternalized(m_is olate, "name")).FromMaybe(false)) { | |
| 657 v8::Local<v8::Value> name; | |
| 658 if (!scope->Get(debuggerContext(), toV8StringInternalized(m_isolate, "name")).ToLocal(&name) || !name->IsString()) | |
| 659 return v8::MaybeLocal<v8::Value>(); | |
| 660 if (!resultScope->Set(context, toV8StringInternalized(m_isolate, "na me"), name).FromMaybe(false)) | |
| 661 return v8::MaybeLocal<v8::Value>(); | |
| 662 } | |
| 663 | |
| 664 if (scope->HasOwnProperty(debuggerContext(), toV8StringInternalized(m_is olate, "startLocation")).FromMaybe(false)) { | |
| 665 v8::Local<v8::Value> startLocation; | |
| 666 if (!scope->Get(debuggerContext(), toV8StringInternalized(m_isolate, "startLocation")).ToLocal(&startLocation) || !startLocation->IsObject()) | |
| 667 return v8::MaybeLocal<v8::Value>(); | |
| 668 v8::Local<v8::Object> startLocationObject = startLocation.As<v8::Obj ect>(); | |
| 669 v8::Local<v8::Value> resultStartLocation = createInternalLocation(m_ isolate, debuggerContext(), context, startLocationObject); | |
| 670 if (resultStartLocation->IsNull() || !resultScope->Set(context, toV8 StringInternalized(m_isolate, "startLocation"), resultStartLocation).FromMaybe(f alse)) | |
| 671 return v8::MaybeLocal<v8::Value>(); | |
| 672 } | |
| 673 | |
| 674 if (scope->HasOwnProperty(debuggerContext(), toV8StringInternalized(m_is olate, "endLocation")).FromMaybe(false)) { | |
| 675 v8::Local<v8::Value> endLocation; | |
| 676 if (!scope->Get(debuggerContext(), toV8StringInternalized(m_isolate, "endLocation")).ToLocal(&endLocation) || !endLocation->IsObject()) | |
| 677 return v8::MaybeLocal<v8::Value>(); | |
| 678 v8::Local<v8::Object> endLocationObject = endLocation.As<v8::Object> (); | |
| 679 v8::Local<v8::Value> resultEndLocation = createInternalLocation(m_is olate, debuggerContext(), context, endLocationObject); | |
| 680 if (resultEndLocation->IsNull() || !resultScope->Set(context, toV8St ringInternalized(m_isolate, "endLocation"), resultEndLocation).FromMaybe(false)) | |
| 681 return v8::MaybeLocal<v8::Value>(); | |
| 682 } | |
| 683 | |
| 684 if (!result->Set(context, i, resultScope).FromMaybe(false)) | |
| 685 return v8::MaybeLocal<v8::Value>(); | |
| 686 } | |
| 687 return result; | |
| 603 } | 688 } |
| 604 | 689 |
| 605 v8::MaybeLocal<v8::Array> V8Debugger::internalProperties(v8::Local<v8::Context> context, v8::Local<v8::Value> value) | 690 v8::MaybeLocal<v8::Array> V8Debugger::internalProperties(v8::Local<v8::Context> context, v8::Local<v8::Value> value) |
| 606 { | 691 { |
| 607 v8::Local<v8::Array> properties; | 692 v8::Local<v8::Array> properties; |
| 608 if (!v8::Debug::GetInternalProperties(m_isolate, value).ToLocal(&properties) ) | 693 if (!v8::Debug::GetInternalProperties(m_isolate, value).ToLocal(&properties) ) |
| 609 return v8::MaybeLocal<v8::Array>(); | 694 return v8::MaybeLocal<v8::Array>(); |
| 610 if (value->IsFunction()) { | 695 if (value->IsFunction()) { |
| 611 v8::Local<v8::Function> function = value.As<v8::Function>(); | 696 v8::Local<v8::Function> function = value.As<v8::Function>(); |
| 612 v8::Local<v8::Value> location = functionLocation(context, function); | 697 v8::Local<v8::Value> location = functionLocation(context, function); |
| 613 if (location->IsObject()) { | 698 if (location->IsObject()) { |
| 614 properties->Set(properties->Length(), toV8StringInternalized(m_isola te, "[[FunctionLocation]]")); | 699 properties->Set(properties->Length(), toV8StringInternalized(m_isola te, "[[FunctionLocation]]")); |
| 615 properties->Set(properties->Length(), location); | 700 properties->Set(properties->Length(), location); |
| 616 } | 701 } |
| 617 if (function->IsGeneratorFunction()) { | 702 if (function->IsGeneratorFunction()) { |
| 618 properties->Set(properties->Length(), toV8StringInternalized(m_isola te, "[[IsGenerator]]")); | 703 properties->Set(properties->Length(), toV8StringInternalized(m_isola te, "[[IsGenerator]]")); |
| 619 properties->Set(properties->Length(), v8::True(m_isolate)); | 704 properties->Set(properties->Length(), v8::True(m_isolate)); |
| 620 } | 705 } |
| 621 } | 706 } |
| 622 if (!enabled()) | 707 if (!enabled()) |
| 623 return properties; | 708 return properties; |
| 624 if (value->IsMap() || value->IsWeakMap() || value->IsSet() || value->IsWeakS et() || value->IsSetIterator() || value->IsMapIterator()) { | 709 if (value->IsMap() || value->IsWeakMap() || value->IsSet() || value->IsWeakS et() || value->IsSetIterator() || value->IsMapIterator()) { |
| 625 v8::Local<v8::Value> entries = collectionEntries(context, v8::Local<v8:: Object>::Cast(value)); | 710 v8::Local<v8::Value> entries = collectionEntries(context, v8::Local<v8:: Object>::Cast(value)); |
| 626 if (entries->IsArray()) { | 711 if (entries->IsArray()) { |
| 627 properties->Set(properties->Length(), toV8StringInternalized(m_isola te, "[[Entries]]")); | 712 properties->Set(properties->Length(), toV8StringInternalized(m_isola te, "[[Entries]]")); |
| 628 properties->Set(properties->Length(), entries); | 713 properties->Set(properties->Length(), entries); |
| 629 } | 714 } |
| 630 } | 715 } |
| 631 if (value->IsGeneratorObject()) { | 716 if (value->IsGeneratorObject()) { |
| 632 v8::Local<v8::Value> location = generatorObjectLocation(v8::Local<v8::Ob ject>::Cast(value)); | 717 v8::Local<v8::Value> location = generatorObjectLocation(context, v8::Loc al<v8::Object>::Cast(value)); |
| 633 if (location->IsObject()) { | 718 if (location->IsObject()) { |
| 634 properties->Set(properties->Length(), toV8StringInternalized(m_isola te, "[[GeneratorLocation]]")); | 719 properties->Set(properties->Length(), toV8StringInternalized(m_isola te, "[[GeneratorLocation]]")); |
| 635 properties->Set(properties->Length(), location); | 720 properties->Set(properties->Length(), location); |
| 636 } | 721 } |
| 637 } | 722 } |
| 638 if (value->IsFunction()) { | 723 if (value->IsFunction()) { |
| 639 v8::Local<v8::Function> function = value.As<v8::Function>(); | 724 v8::Local<v8::Function> function = value.As<v8::Function>(); |
| 640 v8::Local<v8::Value> boundFunction = function->GetBoundFunction(); | 725 v8::Local<v8::Value> boundFunction = function->GetBoundFunction(); |
| 641 v8::Local<v8::Value> scopes; | 726 v8::Local<v8::Value> scopes; |
| 642 if (boundFunction->IsUndefined() && functionScopes(function).ToLocal(&sc opes)) { | 727 if (boundFunction->IsUndefined() && functionScopes(context, function).To Local(&scopes)) { |
| 643 properties->Set(properties->Length(), toV8StringInternalized(m_isola te, "[[Scopes]]")); | 728 properties->Set(properties->Length(), toV8StringInternalized(m_isola te, "[[Scopes]]")); |
| 644 properties->Set(properties->Length(), scopes); | 729 properties->Set(properties->Length(), scopes); |
| 645 } | 730 } |
| 646 } | 731 } |
| 647 return properties; | 732 return properties; |
| 648 } | 733 } |
| 649 | 734 |
| 650 v8::Local<v8::Value> V8Debugger::collectionEntries(v8::Local<v8::Context> contex t, v8::Local<v8::Object> object) | 735 v8::Local<v8::Value> V8Debugger::collectionEntries(v8::Local<v8::Context> contex t, v8::Local<v8::Object> object) |
| 651 { | 736 { |
| 652 if (!enabled()) { | 737 if (!enabled()) { |
| 653 NOTREACHED(); | 738 NOTREACHED(); |
| 654 return v8::Undefined(m_isolate); | 739 return v8::Undefined(m_isolate); |
| 655 } | 740 } |
| 656 v8::Local<v8::Value> argv[] = { object }; | 741 v8::Local<v8::Value> argv[] = { object }; |
| 657 v8::Local<v8::Value> entriesValue = callDebuggerMethod("getCollectionEntries ", 1, argv).ToLocalChecked(); | 742 v8::Local<v8::Value> entriesValue = callDebuggerMethod("getCollectionEntries ", 1, argv).ToLocalChecked(); |
| 658 if (!entriesValue->IsArray()) | 743 if (!entriesValue->IsArray()) |
| 659 return v8::Undefined(m_isolate); | 744 return v8::Undefined(m_isolate); |
| 660 v8::Local<v8::Array> entries = entriesValue.As<v8::Array>(); | 745 v8::Local<v8::Array> entries = entriesValue.As<v8::Array>(); |
| 661 if (!markArrayEntriesAsInternal(context, entries, V8InternalValueType::kEntr y)) | 746 |
| 747 v8::Local<v8::Array> result = v8::Array::New(m_isolate, entries->Length()); | |
| 748 if (!result->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(false)) | |
| 662 return v8::Undefined(m_isolate); | 749 return v8::Undefined(m_isolate); |
| 663 if (!entries->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(false)) | 750 |
| 664 return v8::Undefined(m_isolate); | 751 for (size_t i = 0; i < entries->Length(); ++i) { |
| 665 return entries; | 752 v8::Local<v8::Value> entryValue; |
| 753 if (!entries->Get(debuggerContext(), i).ToLocal(&entryValue) || !entryVa lue->IsObject()) | |
| 754 return v8::Undefined(m_isolate); | |
| 755 v8::Local<v8::Object> entry = entryValue.As<v8::Object>(); | |
| 756 | |
| 757 v8::Local<v8::Object> resultEntry = v8::Object::New(m_isolate); | |
| 758 if (!resultEntry->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(f alse)) | |
| 759 return v8::Undefined(m_isolate); | |
| 760 if (!markAsInternal(context, resultEntry, V8InternalValueType::kEntry)) | |
| 761 return v8::Undefined(m_isolate); | |
| 762 | |
| 763 v8::Local<v8::Value> value; | |
| 764 if (!entry->Get(debuggerContext(), toV8StringInternalized(m_isolate, "va lue")).ToLocal(&value)) | |
| 765 return v8::Undefined(m_isolate); | |
| 766 if (!resultEntry->Set(context, toV8StringInternalized(m_isolate, "value" ), value).FromMaybe(false)) | |
| 767 return v8::Undefined(m_isolate); | |
| 768 | |
| 769 if (entry->HasOwnProperty(debuggerContext(), toV8StringInternalized(m_is olate, "key")).FromMaybe(false)) { | |
| 770 v8::Local<v8::Value> key; | |
| 771 if (!entry->Get(debuggerContext(), toV8StringInternalized(m_isolate, "key")).ToLocal(&key)) | |
| 772 return v8::Undefined(m_isolate); | |
| 773 if (!resultEntry->Set(context, toV8StringInternalized(m_isolate, "ke y"), key).FromMaybe(false)) | |
| 774 return v8::Undefined(m_isolate); | |
| 775 } | |
| 776 | |
| 777 if (!result->Set(context, i, resultEntry).FromMaybe(false)) | |
| 778 return v8::Undefined(m_isolate); | |
| 779 } | |
| 780 return result; | |
| 666 } | 781 } |
| 667 | 782 |
| 668 v8::Local<v8::Value> V8Debugger::generatorObjectLocation(v8::Local<v8::Object> o bject) | 783 v8::Local<v8::Value> V8Debugger::generatorObjectLocation(v8::Local<v8::Context> context, v8::Local<v8::Object> object) |
| 669 { | 784 { |
| 670 if (!enabled()) { | 785 if (!enabled()) { |
| 671 NOTREACHED(); | 786 NOTREACHED(); |
| 672 return v8::Null(m_isolate); | 787 return v8::Null(m_isolate); |
| 673 } | 788 } |
| 674 v8::Local<v8::Value> argv[] = { object }; | 789 v8::Local<v8::Value> argv[] = { object }; |
| 675 v8::Local<v8::Value> location = callDebuggerMethod("getGeneratorObjectLocati on", 1, argv).ToLocalChecked(); | 790 v8::Local<v8::Value> locationValue = callDebuggerMethod("getGeneratorObjectL ocation", 1, argv).ToLocalChecked(); |
| 676 if (!location->IsObject()) | 791 if (!locationValue->IsObject()) |
| 677 return v8::Null(m_isolate); | 792 return v8::Null(m_isolate); |
| 678 v8::Local<v8::Context> context = m_debuggerContext.Get(m_isolate); | 793 v8::Local<v8::Object> location = locationValue.As<v8::Object>(); |
| 679 if (!markAsInternal(context, v8::Local<v8::Object>::Cast(location), V8Intern alValueType::kLocation)) | 794 return createInternalLocation(m_isolate, debuggerContext(), context, locatio n); |
| 680 return v8::Null(m_isolate); | |
| 681 return location; | |
| 682 } | 795 } |
| 683 | 796 |
| 684 v8::Local<v8::Value> V8Debugger::functionLocation(v8::Local<v8::Context> context , v8::Local<v8::Function> function) | 797 v8::Local<v8::Value> V8Debugger::functionLocation(v8::Local<v8::Context> context , v8::Local<v8::Function> function) |
| 685 { | 798 { |
| 686 int scriptId = function->ScriptId(); | 799 int scriptId = function->ScriptId(); |
| 687 if (scriptId == v8::UnboundScript::kNoScriptId) | 800 if (scriptId == v8::UnboundScript::kNoScriptId) |
| 688 return v8::Null(m_isolate); | 801 return v8::Null(m_isolate); |
| 689 int lineNumber = function->GetScriptLineNumber(); | 802 int lineNumber = function->GetScriptLineNumber(); |
| 690 int columnNumber = function->GetScriptColumnNumber(); | 803 int columnNumber = function->GetScriptColumnNumber(); |
| 691 if (lineNumber == v8::Function::kLineOffsetNotFound || columnNumber == v8::F unction::kLineOffsetNotFound) | 804 if (lineNumber == v8::Function::kLineOffsetNotFound || columnNumber == v8::F unction::kLineOffsetNotFound) |
| 692 return v8::Null(m_isolate); | 805 return v8::Null(m_isolate); |
| 693 v8::Local<v8::Object> location = v8::Object::New(m_isolate); | 806 return createInternalLocation(m_isolate, context, toV8String(m_isolate, Stri ng16::fromInteger(scriptId)), v8::Integer::New(m_isolate, lineNumber), v8::Integ er::New(m_isolate, columnNumber)); |
| 694 if (!location->Set(context, toV8StringInternalized(m_isolate, "scriptId"), t oV8String(m_isolate, String16::fromInteger(scriptId))).FromMaybe(false)) | |
| 695 return v8::Null(m_isolate); | |
| 696 if (!location->Set(context, toV8StringInternalized(m_isolate, "lineNumber"), v8::Integer::New(m_isolate, lineNumber)).FromMaybe(false)) | |
| 697 return v8::Null(m_isolate); | |
| 698 if (!location->Set(context, toV8StringInternalized(m_isolate, "columnNumber" ), v8::Integer::New(m_isolate, columnNumber)).FromMaybe(false)) | |
| 699 return v8::Null(m_isolate); | |
| 700 if (!markAsInternal(context, location, V8InternalValueType::kLocation)) | |
| 701 return v8::Null(m_isolate); | |
| 702 return location; | |
| 703 } | 807 } |
| 704 | 808 |
| 705 bool V8Debugger::isPaused() | 809 bool V8Debugger::isPaused() |
| 706 { | 810 { |
| 707 return !m_pausedContext.IsEmpty(); | 811 return !m_pausedContext.IsEmpty(); |
| 708 } | 812 } |
| 709 | 813 |
| 710 std::unique_ptr<V8StackTraceImpl> V8Debugger::createStackTrace(v8::Local<v8::Sta ckTrace> stackTrace) | 814 std::unique_ptr<V8StackTraceImpl> V8Debugger::createStackTrace(v8::Local<v8::Sta ckTrace> stackTrace) |
| 711 { | 815 { |
| 712 int contextGroupId = m_isolate->InContext() ? getGroupId(m_isolate->GetCurre ntContext()) : 0; | 816 int contextGroupId = m_isolate->InContext() ? getGroupId(m_isolate->GetCurre ntContext()) : 0; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 830 return nullptr; | 934 return nullptr; |
| 831 | 935 |
| 832 size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; | 936 size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; |
| 833 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) | 937 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) |
| 834 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; | 938 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; |
| 835 | 939 |
| 836 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); | 940 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
| 837 } | 941 } |
| 838 | 942 |
| 839 } // namespace blink | 943 } // namespace blink |
| OLD | NEW |