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

Side by Side Diff: src/inspector/v8-debugger.cc

Issue 2738503006: [inspector] don't make v8::debug::Call for breakProgram. (Closed)
Patch Set: addressed comments Created 3 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
« no previous file with comments | « src/inspector/v8-debugger.h ('k') | src/inspector/v8-debugger-agent-impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "src/inspector/v8-debugger.h" 5 #include "src/inspector/v8-debugger.h"
6 6
7 #include "src/inspector/debugger-script.h" 7 #include "src/inspector/debugger-script.h"
8 #include "src/inspector/inspected-context.h" 8 #include "src/inspector/inspected-context.h"
9 #include "src/inspector/protocol/Protocol.h" 9 #include "src/inspector/protocol/Protocol.h"
10 #include "src/inspector/script-breakpoint.h" 10 #include "src/inspector/script-breakpoint.h"
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 338
339 bool V8Debugger::canBreakProgram() { 339 bool V8Debugger::canBreakProgram() {
340 if (!m_breakpointsActivated) return false; 340 if (!m_breakpointsActivated) return false;
341 return !v8::debug::AllFramesOnStackAreBlackboxed(m_isolate); 341 return !v8::debug::AllFramesOnStackAreBlackboxed(m_isolate);
342 } 342 }
343 343
344 void V8Debugger::breakProgram() { 344 void V8Debugger::breakProgram() {
345 // Don't allow nested breaks. 345 // Don't allow nested breaks.
346 if (isPaused()) return; 346 if (isPaused()) return;
347 if (!canBreakProgram()) return; 347 if (!canBreakProgram()) return;
348 348 v8::debug::BreakRightNow(m_isolate);
349 v8::HandleScope scope(m_isolate);
350 v8::Local<v8::Function> breakFunction;
351 if (!v8::Function::New(m_isolate->GetCurrentContext(),
352 &V8Debugger::breakProgramCallback,
353 v8::External::New(m_isolate, this), 0,
354 v8::ConstructorBehavior::kThrow)
355 .ToLocal(&breakFunction))
356 return;
357 v8::debug::Call(debuggerContext(), breakFunction).ToLocalChecked();
358 } 349 }
359 350
360 void V8Debugger::continueProgram() { 351 void V8Debugger::continueProgram() {
361 if (isPaused()) m_inspector->client()->quitMessageLoopOnPause(); 352 if (isPaused()) m_inspector->client()->quitMessageLoopOnPause();
362 m_pausedContext.Clear(); 353 m_pausedContext.Clear();
363 m_executionState.Clear(); 354 m_executionState.Clear();
364 } 355 }
365 356
366 void V8Debugger::stepIntoStatement() { 357 void V8Debugger::stepIntoStatement() {
367 DCHECK(isPaused()); 358 DCHECK(isPaused());
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 if (!callFramesArray->Get(debuggerContext(), i).ToLocal(&callFrameValue)) 489 if (!callFramesArray->Get(debuggerContext(), i).ToLocal(&callFrameValue))
499 return JavaScriptCallFrames(); 490 return JavaScriptCallFrames();
500 if (!callFrameValue->IsObject()) return JavaScriptCallFrames(); 491 if (!callFrameValue->IsObject()) return JavaScriptCallFrames();
501 v8::Local<v8::Object> callFrameObject = callFrameValue.As<v8::Object>(); 492 v8::Local<v8::Object> callFrameObject = callFrameValue.As<v8::Object>();
502 callFrames.push_back(JavaScriptCallFrame::create( 493 callFrames.push_back(JavaScriptCallFrame::create(
503 debuggerContext(), v8::Local<v8::Object>::Cast(callFrameObject))); 494 debuggerContext(), v8::Local<v8::Object>::Cast(callFrameObject)));
504 } 495 }
505 return callFrames; 496 return callFrames;
506 } 497 }
507 498
508 static V8Debugger* toV8Debugger(v8::Local<v8::Value> data) {
509 void* p = v8::Local<v8::External>::Cast(data)->Value();
510 return static_cast<V8Debugger*>(p);
511 }
512
513 void V8Debugger::breakProgramCallback(
514 const v8::FunctionCallbackInfo<v8::Value>& info) {
515 DCHECK_EQ(info.Length(), 2);
516 V8Debugger* thisPtr = toV8Debugger(info.Data());
517 if (!thisPtr->enabled()) return;
518 v8::Local<v8::Context> pausedContext =
519 thisPtr->m_isolate->GetCurrentContext();
520 v8::Local<v8::Value> exception;
521 v8::Local<v8::Array> hitBreakpoints;
522 thisPtr->handleProgramBreak(pausedContext,
523 v8::Local<v8::Object>::Cast(info[0]), exception,
524 hitBreakpoints);
525 }
526
527 void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext, 499 void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext,
528 v8::Local<v8::Object> executionState, 500 v8::Local<v8::Object> executionState,
529 v8::Local<v8::Value> exception, 501 v8::Local<v8::Value> exception,
530 v8::Local<v8::Array> hitBreakpointNumbers, 502 v8::Local<v8::Array> hitBreakpointNumbers,
531 bool isPromiseRejection, bool isUncaught) { 503 bool isPromiseRejection, bool isUncaught) {
532 // Don't allow nested breaks. 504 // Don't allow nested breaks.
533 if (isPaused()) return; 505 if (isPaused()) return;
534 506
535 V8DebuggerAgentImpl* agent = m_inspector->enabledDebuggerAgentForGroup( 507 V8DebuggerAgentImpl* agent = m_inspector->enabledDebuggerAgentForGroup(
536 m_inspector->contextGroupId(pausedContext)); 508 m_inspector->contextGroupId(pausedContext));
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 972
1001 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); 973 return V8StackTraceImpl::capture(this, contextGroupId, stackSize);
1002 } 974 }
1003 975
1004 int V8Debugger::currentContextGroupId() { 976 int V8Debugger::currentContextGroupId() {
1005 if (!m_isolate->InContext()) return 0; 977 if (!m_isolate->InContext()) return 0;
1006 return m_inspector->contextGroupId(m_isolate->GetCurrentContext()); 978 return m_inspector->contextGroupId(m_isolate->GetCurrentContext());
1007 } 979 }
1008 980
1009 } // namespace v8_inspector 981 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/v8-debugger.h ('k') | src/inspector/v8-debugger-agent-impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698