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

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()
469 { 469 {
470 ASSERT(isPaused()); 470 Vector<OwnPtr<JavaScriptCallFrame>> callFrames;
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 {
481 if (!m_isolate->InContext()) 471 if (!m_isolate->InContext())
482 return nullptr; 472 return callFrames;
dgozman 2016/03/26 00:49:21 Let's be explicit.
kozy 2016/03/26 01:11:17 Done.
483 v8::Local<v8::Value> currentCallFrameV8; 473 v8::Local<v8::Value> currentCallFramesV8;
484 if (m_executionState.IsEmpty()) { 474 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"))); 475 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(); 476 currentCallFramesV8 = v8::Debug::Call(debuggerContext(), currentCallFram esFunction).ToLocalChecked();
487 } else { 477 } else {
488 v8::Local<v8::Value> argv[] = { m_executionState }; 478 v8::Local<v8::Value> argv[] = { m_executionState };
489 currentCallFrameV8 = callDebuggerMethod("currentCallFrame", WTF_ARRAY_LE NGTH(argv), argv).ToLocalChecked(); 479 currentCallFramesV8 = callDebuggerMethod("currentCallFrames", WTF_ARRAY_ LENGTH(argv), argv).ToLocalChecked();
490 } 480 }
491 ASSERT(!currentCallFrameV8.IsEmpty()); 481 ASSERT(!currentCallFramesV8.IsEmpty());
492 if (!currentCallFrameV8->IsObject()) 482 if (!currentCallFramesV8->IsArray())
493 return nullptr; 483 return callFrames;
dgozman 2016/03/26 00:49:21 Let's be explicit.
kozy 2016/03/26 01:11:17 Done.
494 return JavaScriptCallFrame::create(debuggerContext(), v8::Local<v8::Object>: :Cast(currentCallFrameV8)); 484 v8::Local<v8::Array> callFramesArray = currentCallFramesV8.As<v8::Array>();
495 } 485 for (size_t i = 0; i < callFramesArray->Length(); ++i) {
496 486 v8::Local<v8::Value> callFrameValue;
497 PassOwnPtr<JavaScriptCallFrame> V8DebuggerImpl::callFrame(int index) 487 if (!callFramesArray->Get(debuggerContext(), i).ToLocal(&callFrameValue) )
498 { 488 return Vector<OwnPtr<JavaScriptCallFrame>>();
499 if (!m_isolate->InContext()) 489 if (!callFrameValue->IsObject())
500 return nullptr; 490 return Vector<OwnPtr<JavaScriptCallFrame>>();
501 v8::HandleScope handleScope(m_isolate); 491 v8::Local<v8::Object> callFrameObject = callFrameValue.As<v8::Object>();
502 492 callFrames.append(JavaScriptCallFrame::create(debuggerContext(), v8::Loc al<v8::Object>::Cast(callFrameObject)));
503 v8::Local<v8::Value> currentCallFrameV8;
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 311 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