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

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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 void V8DebuggerImpl::clearStepping() 389 void V8DebuggerImpl::clearStepping()
390 { 390 {
391 ASSERT(enabled()); 391 ASSERT(enabled());
392 v8::HandleScope scope(m_isolate); 392 v8::HandleScope scope(m_isolate);
393 v8::Context::Scope contextScope(debuggerContext()); 393 v8::Context::Scope contextScope(debuggerContext());
394 394
395 v8::Local<v8::Value> argv[] = { v8::Undefined(m_isolate) }; 395 v8::Local<v8::Value> argv[] = { v8::Undefined(m_isolate) };
396 callDebuggerMethod("clearStepping", 0, argv); 396 callDebuggerMethod("clearStepping", 0, argv);
397 } 397 }
398 398
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) 399 bool V8DebuggerImpl::setScriptSource(const String16& sourceID, const String16& n ewContent, bool preview, ErrorString* error, Maybe<protocol::Debugger::SetScript SourceError>* errorData, Vector<OwnPtr<JavaScriptCallFrame>>* newCallFrames, May be<bool>* stackChanged)
400 { 400 {
401 class EnableLiveEditScope { 401 class EnableLiveEditScope {
402 public: 402 public:
403 explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate) 403 explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate)
404 { 404 {
405 v8::Debug::SetLiveEditEnabled(m_isolate, true); 405 v8::Debug::SetLiveEditEnabled(m_isolate, true);
406 inLiveEditScope = true; 406 inLiveEditScope = true;
407 } 407 }
408 ~EnableLiveEditScope() 408 ~EnableLiveEditScope()
409 { 409 {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 .setMessage(toProtocolStringWithTypeCheck(resultTuple->Get(2))) 458 .setMessage(toProtocolStringWithTypeCheck(resultTuple->Get(2)))
459 .setLineNumber(resultTuple->Get(3)->ToInteger(m_isolate)->Value( )) 459 .setLineNumber(resultTuple->Get(3)->ToInteger(m_isolate)->Value( ))
460 .setColumnNumber(resultTuple->Get(4)->ToInteger(m_isolate)->Valu e()).build(); 460 .setColumnNumber(resultTuple->Get(4)->ToInteger(m_isolate)->Valu e()).build();
461 return false; 461 return false;
462 } 462 }
463 } 463 }
464 *error = "Unknown error."; 464 *error = "Unknown error.";
465 return false; 465 return false;
466 } 466 }
467 467
468 int V8DebuggerImpl::frameCount() 468 Vector<OwnPtr<JavaScriptCallFrame>> 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 { 469 {
481 if (!m_isolate->InContext()) 470 if (!m_isolate->InContext())
482 return nullptr; 471 return Vector<OwnPtr<JavaScriptCallFrame>>();
483 v8::Local<v8::Value> currentCallFrameV8; 472 v8::Local<v8::Value> currentCallFramesV8;
484 if (m_executionState.IsEmpty()) { 473 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"))); 474 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(); 475 currentCallFramesV8 = v8::Debug::Call(debuggerContext(), currentCallFram esFunction, v8::Integer::New(m_isolate, limit)).ToLocalChecked();
487 } else { 476 } else {
488 v8::Local<v8::Value> argv[] = { m_executionState }; 477 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(); 478 currentCallFramesV8 = callDebuggerMethod("currentCallFrames", WTF_ARRAY_ LENGTH(argv), argv).ToLocalChecked();
490 } 479 }
491 ASSERT(!currentCallFrameV8.IsEmpty()); 480 ASSERT(!currentCallFramesV8.IsEmpty());
492 if (!currentCallFrameV8->IsObject()) 481 if (!currentCallFramesV8->IsArray())
493 return nullptr; 482 return Vector<OwnPtr<JavaScriptCallFrame>>();
dgozman 2016/03/26 01:48:24 Let's introduce JavaScriptCallFrames type.
kozy 2016/03/26 02:00:42 Done.
494 return JavaScriptCallFrame::create(debuggerContext(), v8::Local<v8::Object>: :Cast(currentCallFrameV8)); 483 v8::Local<v8::Array> callFramesArray = currentCallFramesV8.As<v8::Array>();
495 } 484 Vector<OwnPtr<JavaScriptCallFrame>> callFrames;
496 485 for (size_t i = 0; i < callFramesArray->Length(); ++i) {
497 PassOwnPtr<JavaScriptCallFrame> V8DebuggerImpl::callFrame(int index) 486 v8::Local<v8::Value> callFrameValue;
498 { 487 if (!callFramesArray->Get(debuggerContext(), i).ToLocal(&callFrameValue) )
499 if (!m_isolate->InContext()) 488 return Vector<OwnPtr<JavaScriptCallFrame>>();
500 return nullptr; 489 if (!callFrameValue->IsObject())
501 v8::HandleScope handleScope(m_isolate); 490 return Vector<OwnPtr<JavaScriptCallFrame>>();
502 491 v8::Local<v8::Object> callFrameObject = callFrameValue.As<v8::Object>();
503 v8::Local<v8::Value> currentCallFrameV8; 492 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 } 493 }
511 ASSERT(!currentCallFrameV8.IsEmpty()); 494 return callFrames;
512 if (!currentCallFrameV8->IsObject())
513 return nullptr;
514 return JavaScriptCallFrame::create(debuggerContext(), v8::Local<v8::Object>: :Cast(currentCallFrameV8));
515 } 495 }
516 496
517 static V8DebuggerImpl* toV8DebuggerImpl(v8::Local<v8::Value> data) 497 static V8DebuggerImpl* toV8DebuggerImpl(v8::Local<v8::Value> data)
518 { 498 {
519 void* p = v8::Local<v8::External>::Cast(data)->Value(); 499 void* p = v8::Local<v8::External>::Cast(data)->Value();
520 return static_cast<V8DebuggerImpl*>(p); 500 return static_cast<V8DebuggerImpl*>(p);
521 } 501 }
522 502
523 void V8DebuggerImpl::breakProgramCallback(const v8::FunctionCallbackInfo<v8::Val ue>& info) 503 void V8DebuggerImpl::breakProgramCallback(const v8::FunctionCallbackInfo<v8::Val ue>& info)
524 { 504 {
(...skipping 20 matching lines...) Expand all
545 breakpointIds.resize(hitBreakpointNumbers->Length()); 525 breakpointIds.resize(hitBreakpointNumbers->Length());
546 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) { 526 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) {
547 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get (i); 527 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get (i);
548 ASSERT(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt3 2()); 528 ASSERT(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt3 2());
549 breakpointIds[i] = String16::number(hitBreakpointNumber->Int32Value( )); 529 breakpointIds[i] = String16::number(hitBreakpointNumber->Int32Value( ));
550 } 530 }
551 } 531 }
552 532
553 m_pausedContext = pausedContext; 533 m_pausedContext = pausedContext;
554 m_executionState = executionState; 534 m_executionState = executionState;
555 V8DebuggerAgentImpl::SkipPauseRequest result = agent->didPause(pausedContext , currentCallFrames(), exception, breakpointIds, isPromiseRejection); 535 V8DebuggerAgentImpl::SkipPauseRequest result = agent->didPause(pausedContext , exception, breakpointIds, isPromiseRejection);
556 if (result == V8DebuggerAgentImpl::RequestNoSkip) { 536 if (result == V8DebuggerAgentImpl::RequestNoSkip) {
557 m_runningNestedMessageLoop = true; 537 m_runningNestedMessageLoop = true;
558 int groupId = getGroupId(pausedContext); 538 int groupId = getGroupId(pausedContext);
559 ASSERT(groupId); 539 ASSERT(groupId);
560 m_client->runMessageLoopOnPause(groupId); 540 m_client->runMessageLoopOnPause(groupId);
561 // The agent may have been removed in the nested loop. 541 // The agent may have been removed in the nested loop.
562 agent = getDebuggerAgentForContext(pausedContext); 542 agent = getDebuggerAgentForContext(pausedContext);
563 if (agent) 543 if (agent)
564 agent->didContinue(); 544 agent->didContinue();
565 m_runningNestedMessageLoop = false; 545 m_runningNestedMessageLoop = false;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 } 816 }
837 817
838 v8::Local<v8::Context> V8DebuggerImpl::regexContext() 818 v8::Local<v8::Context> V8DebuggerImpl::regexContext()
839 { 819 {
840 if (m_regexContext.IsEmpty()) 820 if (m_regexContext.IsEmpty())
841 m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate)); 821 m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate));
842 return m_regexContext.Get(m_isolate); 822 return m_regexContext.Get(m_isolate);
843 } 823 }
844 824
845 } // namespace blink 825 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698