Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp

Issue 1838683002: [DevTools] Debugger::currentCallFrames returns array instead linked list (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wrap-with-corrrect-injected-script
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. 2 * Copyright (c) 2010-2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "platform/v8_inspector/V8DebuggerImpl.h" 31 #include "platform/v8_inspector/V8DebuggerImpl.h"
32 32
33 #include "platform/inspector_protocol/Values.h" 33 #include "platform/inspector_protocol/Values.h"
34 #include "platform/v8_inspector/Atomics.h" 34 #include "platform/v8_inspector/Atomics.h"
35 #include "platform/v8_inspector/DebuggerScript.h" 35 #include "platform/v8_inspector/DebuggerScript.h"
36 #include "platform/v8_inspector/JavaScriptCallFrame.h"
37 #include "platform/v8_inspector/ScriptBreakpoint.h" 36 #include "platform/v8_inspector/ScriptBreakpoint.h"
38 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" 37 #include "platform/v8_inspector/V8DebuggerAgentImpl.h"
39 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" 38 #include "platform/v8_inspector/V8RuntimeAgentImpl.h"
40 #include "platform/v8_inspector/V8StackTraceImpl.h" 39 #include "platform/v8_inspector/V8StackTraceImpl.h"
41 #include "platform/v8_inspector/V8StringUtil.h" 40 #include "platform/v8_inspector/V8StringUtil.h"
42 #include "platform/v8_inspector/public/V8DebuggerClient.h" 41 #include "platform/v8_inspector/public/V8DebuggerClient.h"
43 42
44 namespace blink { 43 namespace blink {
45 44
46 namespace { 45 namespace {
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 void V8DebuggerImpl::clearStepping() 388 void V8DebuggerImpl::clearStepping()
390 { 389 {
391 ASSERT(enabled()); 390 ASSERT(enabled());
392 v8::HandleScope scope(m_isolate); 391 v8::HandleScope scope(m_isolate);
393 v8::Context::Scope contextScope(debuggerContext()); 392 v8::Context::Scope contextScope(debuggerContext());
394 393
395 v8::Local<v8::Value> argv[] = { v8::Undefined(m_isolate) }; 394 v8::Local<v8::Value> argv[] = { v8::Undefined(m_isolate) };
396 callDebuggerMethod("clearStepping", 0, argv); 395 callDebuggerMethod("clearStepping", 0, argv);
397 } 396 }
398 397
399 bool V8DebuggerImpl::setScriptSource(const String16& sourceID, const String16& n ewContent, bool preview, ErrorString* error, Maybe<protocol::Debugger::SetScript SourceError>* errorData, OwnPtr<JavaScriptCallFrame>* newCallFrames, Maybe<bool> * stackChanged) 398 bool V8DebuggerImpl::setScriptSource(const String16& sourceID, const String16& n ewContent, bool preview, ErrorString* error, Maybe<protocol::Debugger::SetScript SourceError>* errorData, JavaScriptCallFrames* newCallFrames, Maybe<bool>* stack Changed)
400 { 399 {
401 class EnableLiveEditScope { 400 class EnableLiveEditScope {
402 public: 401 public:
403 explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate) 402 explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate)
404 { 403 {
405 v8::Debug::SetLiveEditEnabled(m_isolate, true); 404 v8::Debug::SetLiveEditEnabled(m_isolate, true);
406 inLiveEditScope = true; 405 inLiveEditScope = true;
407 } 406 }
408 ~EnableLiveEditScope() 407 ~EnableLiveEditScope()
409 { 408 {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 .setMessage(toProtocolStringWithTypeCheck(resultTuple->Get(2))) 457 .setMessage(toProtocolStringWithTypeCheck(resultTuple->Get(2)))
459 .setLineNumber(resultTuple->Get(3)->ToInteger(m_isolate)->Value( )) 458 .setLineNumber(resultTuple->Get(3)->ToInteger(m_isolate)->Value( ))
460 .setColumnNumber(resultTuple->Get(4)->ToInteger(m_isolate)->Valu e()).build(); 459 .setColumnNumber(resultTuple->Get(4)->ToInteger(m_isolate)->Valu e()).build();
461 return false; 460 return false;
462 } 461 }
463 } 462 }
464 *error = "Unknown error."; 463 *error = "Unknown error.";
465 return false; 464 return false;
466 } 465 }
467 466
468 int V8DebuggerImpl::frameCount() 467 JavaScriptCallFrames V8DebuggerImpl::currentCallFrames(int limit)
469 {
470 ASSERT(isPaused());
471 ASSERT(!m_executionState.IsEmpty());
472 v8::Local<v8::Value> argv[] = { m_executionState };
473 v8::Local<v8::Value> result = callDebuggerMethod("frameCount", WTF_ARRAY_LEN GTH(argv), argv).ToLocalChecked();
474 if (result->IsInt32())
475 return result->Int32Value();
476 return 0;
477 }
478
479 PassOwnPtr<JavaScriptCallFrame> V8DebuggerImpl::currentCallFrames()
480 { 468 {
481 if (!m_isolate->InContext()) 469 if (!m_isolate->InContext())
482 return nullptr; 470 return JavaScriptCallFrames();
483 v8::Local<v8::Value> currentCallFrameV8; 471 v8::Local<v8::Value> currentCallFramesV8;
484 if (m_executionState.IsEmpty()) { 472 if (m_executionState.IsEmpty()) {
485 v8::Local<v8::Function> currentCallFrameFunction = v8::Local<v8::Functio n>::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("currentCallF rame"))); 473 v8::Local<v8::Function> currentCallFramesFunction = v8::Local<v8::Functi on>::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("currentCall Frames")));
486 currentCallFrameV8 = v8::Debug::Call(debuggerContext(), currentCallFrame Function).ToLocalChecked(); 474 currentCallFramesV8 = v8::Debug::Call(debuggerContext(), currentCallFram esFunction, v8::Integer::New(m_isolate, limit)).ToLocalChecked();
487 } else { 475 } else {
488 v8::Local<v8::Value> argv[] = { m_executionState }; 476 v8::Local<v8::Value> argv[] = { m_executionState, v8::Integer::New(m_iso late, limit) };
489 currentCallFrameV8 = callDebuggerMethod("currentCallFrame", WTF_ARRAY_LE NGTH(argv), argv).ToLocalChecked(); 477 currentCallFramesV8 = callDebuggerMethod("currentCallFrames", WTF_ARRAY_ LENGTH(argv), argv).ToLocalChecked();
490 } 478 }
491 ASSERT(!currentCallFrameV8.IsEmpty()); 479 ASSERT(!currentCallFramesV8.IsEmpty());
492 if (!currentCallFrameV8->IsObject()) 480 if (!currentCallFramesV8->IsArray())
493 return nullptr; 481 return JavaScriptCallFrames();
494 return JavaScriptCallFrame::create(debuggerContext(), v8::Local<v8::Object>: :Cast(currentCallFrameV8)); 482 v8::Local<v8::Array> callFramesArray = currentCallFramesV8.As<v8::Array>();
495 } 483 JavaScriptCallFrames callFrames;
496 484 for (size_t i = 0; i < callFramesArray->Length(); ++i) {
497 PassOwnPtr<JavaScriptCallFrame> V8DebuggerImpl::callFrame(int index) 485 v8::Local<v8::Value> callFrameValue;
498 { 486 if (!callFramesArray->Get(debuggerContext(), i).ToLocal(&callFrameValue) )
499 if (!m_isolate->InContext()) 487 return JavaScriptCallFrames();
500 return nullptr; 488 if (!callFrameValue->IsObject())
501 v8::HandleScope handleScope(m_isolate); 489 return JavaScriptCallFrames();
502 490 v8::Local<v8::Object> callFrameObject = callFrameValue.As<v8::Object>();
503 v8::Local<v8::Value> currentCallFrameV8; 491 callFrames.append(JavaScriptCallFrame::create(debuggerContext(), v8::Loc al<v8::Object>::Cast(callFrameObject)));
504 if (m_executionState.IsEmpty()) {
505 v8::Local<v8::Function> currentCallFrameFunction = v8::Local<v8::Functio n>::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("currentCallF rameByIndex")));
506 currentCallFrameV8 = v8::Debug::Call(debuggerContext(), currentCallFrame Function, v8::Integer::New(m_isolate, index)).ToLocalChecked();
507 } else {
508 v8::Local<v8::Value> argv[] = { m_executionState, v8::Integer::New(m_iso late, index) };
509 currentCallFrameV8 = callDebuggerMethod("currentCallFrameByIndex", WTF_A RRAY_LENGTH(argv), argv).ToLocalChecked();
510 } 492 }
511 ASSERT(!currentCallFrameV8.IsEmpty()); 493 return callFrames;
512 if (!currentCallFrameV8->IsObject())
513 return nullptr;
514 return JavaScriptCallFrame::create(debuggerContext(), v8::Local<v8::Object>: :Cast(currentCallFrameV8));
515 } 494 }
516 495
517 static V8DebuggerImpl* toV8DebuggerImpl(v8::Local<v8::Value> data) 496 static V8DebuggerImpl* toV8DebuggerImpl(v8::Local<v8::Value> data)
518 { 497 {
519 void* p = v8::Local<v8::External>::Cast(data)->Value(); 498 void* p = v8::Local<v8::External>::Cast(data)->Value();
520 return static_cast<V8DebuggerImpl*>(p); 499 return static_cast<V8DebuggerImpl*>(p);
521 } 500 }
522 501
523 void V8DebuggerImpl::breakProgramCallback(const v8::FunctionCallbackInfo<v8::Val ue>& info) 502 void V8DebuggerImpl::breakProgramCallback(const v8::FunctionCallbackInfo<v8::Val ue>& info)
524 { 503 {
(...skipping 20 matching lines...) Expand all
545 breakpointIds.resize(hitBreakpointNumbers->Length()); 524 breakpointIds.resize(hitBreakpointNumbers->Length());
546 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) { 525 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) {
547 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get (i); 526 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get (i);
548 ASSERT(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt3 2()); 527 ASSERT(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt3 2());
549 breakpointIds[i] = String16::number(hitBreakpointNumber->Int32Value( )); 528 breakpointIds[i] = String16::number(hitBreakpointNumber->Int32Value( ));
550 } 529 }
551 } 530 }
552 531
553 m_pausedContext = pausedContext; 532 m_pausedContext = pausedContext;
554 m_executionState = executionState; 533 m_executionState = executionState;
555 V8DebuggerAgentImpl::SkipPauseRequest result = agent->didPause(pausedContext , currentCallFrames(), exception, breakpointIds, isPromiseRejection); 534 V8DebuggerAgentImpl::SkipPauseRequest result = agent->didPause(pausedContext , exception, breakpointIds, isPromiseRejection);
556 if (result == V8DebuggerAgentImpl::RequestNoSkip) { 535 if (result == V8DebuggerAgentImpl::RequestNoSkip) {
557 m_runningNestedMessageLoop = true; 536 m_runningNestedMessageLoop = true;
558 int groupId = getGroupId(pausedContext); 537 int groupId = getGroupId(pausedContext);
559 ASSERT(groupId); 538 ASSERT(groupId);
560 m_client->runMessageLoopOnPause(groupId); 539 m_client->runMessageLoopOnPause(groupId);
561 // The agent may have been removed in the nested loop. 540 // The agent may have been removed in the nested loop.
562 agent = getDebuggerAgentForContext(pausedContext); 541 agent = getDebuggerAgentForContext(pausedContext);
563 if (agent) 542 if (agent)
564 agent->didContinue(); 543 agent->didContinue();
565 m_runningNestedMessageLoop = false; 544 m_runningNestedMessageLoop = false;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 } 815 }
837 816
838 v8::Local<v8::Context> V8DebuggerImpl::regexContext() 817 v8::Local<v8::Context> V8DebuggerImpl::regexContext()
839 { 818 {
840 if (m_regexContext.IsEmpty()) 819 if (m_regexContext.IsEmpty())
841 m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate)); 820 m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate));
842 return m_regexContext.Get(m_isolate); 821 return m_regexContext.Get(m_isolate);
843 } 822 }
844 823
845 } // namespace blink 824 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698