OLD | NEW |
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/V8Debugger.h" | 5 #include "src/inspector/V8Debugger.h" |
6 | 6 |
7 #include "src/inspector/DebuggerScript.h" | 7 #include "src/inspector/DebuggerScript.h" |
8 #include "src/inspector/ScriptBreakpoint.h" | 8 #include "src/inspector/ScriptBreakpoint.h" |
9 #include "src/inspector/StringUtil.h" | 9 #include "src/inspector/StringUtil.h" |
10 #include "src/inspector/V8DebuggerAgentImpl.h" | 10 #include "src/inspector/V8DebuggerAgentImpl.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 } | 371 } |
372 return true; | 372 return true; |
373 } | 373 } |
374 // Compile error. | 374 // Compile error. |
375 case 1: { | 375 case 1: { |
376 *exceptionDetails = | 376 *exceptionDetails = |
377 protocol::Runtime::ExceptionDetails::create() | 377 protocol::Runtime::ExceptionDetails::create() |
378 .setExceptionId(m_inspector->nextExceptionId()) | 378 .setExceptionId(m_inspector->nextExceptionId()) |
379 .setText(toProtocolStringWithTypeCheck(resultTuple->Get(2))) | 379 .setText(toProtocolStringWithTypeCheck(resultTuple->Get(2))) |
380 .setLineNumber( | 380 .setLineNumber( |
381 static_cast<int>( | 381 resultTuple->Get(3)->ToInteger(m_isolate)->Value() - 1) |
382 resultTuple->Get(3)->ToInteger(m_isolate)->Value()) - | |
383 1) | |
384 .setColumnNumber( | 382 .setColumnNumber( |
385 static_cast<int>( | 383 resultTuple->Get(4)->ToInteger(m_isolate)->Value() - 1) |
386 resultTuple->Get(4)->ToInteger(m_isolate)->Value()) - | |
387 1) | |
388 .build(); | 384 .build(); |
389 return false; | 385 return false; |
390 } | 386 } |
391 } | 387 } |
392 *error = "Unknown error."; | 388 *error = "Unknown error."; |
393 return false; | 389 return false; |
394 } | 390 } |
395 | 391 |
396 JavaScriptCallFrames V8Debugger::currentCallFrames(int limit) { | 392 JavaScriptCallFrames V8Debugger::currentCallFrames(int limit) { |
397 if (!m_isolate->InContext()) return JavaScriptCallFrames(); | 393 if (!m_isolate->InContext()) return JavaScriptCallFrames(); |
(...skipping 11 matching lines...) Expand all Loading... |
409 v8::Integer::New(m_isolate, limit)}; | 405 v8::Integer::New(m_isolate, limit)}; |
410 currentCallFramesV8 = | 406 currentCallFramesV8 = |
411 callDebuggerMethod("currentCallFrames", V8_INSPECTOR_ARRAY_LENGTH(argv), | 407 callDebuggerMethod("currentCallFrames", V8_INSPECTOR_ARRAY_LENGTH(argv), |
412 argv) | 408 argv) |
413 .ToLocalChecked(); | 409 .ToLocalChecked(); |
414 } | 410 } |
415 DCHECK(!currentCallFramesV8.IsEmpty()); | 411 DCHECK(!currentCallFramesV8.IsEmpty()); |
416 if (!currentCallFramesV8->IsArray()) return JavaScriptCallFrames(); | 412 if (!currentCallFramesV8->IsArray()) return JavaScriptCallFrames(); |
417 v8::Local<v8::Array> callFramesArray = currentCallFramesV8.As<v8::Array>(); | 413 v8::Local<v8::Array> callFramesArray = currentCallFramesV8.As<v8::Array>(); |
418 JavaScriptCallFrames callFrames; | 414 JavaScriptCallFrames callFrames; |
419 for (uint32_t i = 0; i < callFramesArray->Length(); ++i) { | 415 for (size_t i = 0; i < callFramesArray->Length(); ++i) { |
420 v8::Local<v8::Value> callFrameValue; | 416 v8::Local<v8::Value> callFrameValue; |
421 if (!callFramesArray->Get(debuggerContext(), i).ToLocal(&callFrameValue)) | 417 if (!callFramesArray->Get(debuggerContext(), i).ToLocal(&callFrameValue)) |
422 return JavaScriptCallFrames(); | 418 return JavaScriptCallFrames(); |
423 if (!callFrameValue->IsObject()) return JavaScriptCallFrames(); | 419 if (!callFrameValue->IsObject()) return JavaScriptCallFrames(); |
424 v8::Local<v8::Object> callFrameObject = callFrameValue.As<v8::Object>(); | 420 v8::Local<v8::Object> callFrameObject = callFrameValue.As<v8::Object>(); |
425 callFrames.push_back(JavaScriptCallFrame::create( | 421 callFrames.push_back(JavaScriptCallFrame::create( |
426 debuggerContext(), v8::Local<v8::Object>::Cast(callFrameObject))); | 422 debuggerContext(), v8::Local<v8::Object>::Cast(callFrameObject))); |
427 } | 423 } |
428 return callFrames; | 424 return callFrames; |
429 } | 425 } |
(...skipping 25 matching lines...) Expand all Loading... |
455 // Don't allow nested breaks. | 451 // Don't allow nested breaks. |
456 if (m_runningNestedMessageLoop) return; | 452 if (m_runningNestedMessageLoop) return; |
457 | 453 |
458 V8DebuggerAgentImpl* agent = | 454 V8DebuggerAgentImpl* agent = |
459 m_inspector->enabledDebuggerAgentForGroup(getGroupId(pausedContext)); | 455 m_inspector->enabledDebuggerAgentForGroup(getGroupId(pausedContext)); |
460 if (!agent) return; | 456 if (!agent) return; |
461 | 457 |
462 std::vector<String16> breakpointIds; | 458 std::vector<String16> breakpointIds; |
463 if (!hitBreakpointNumbers.IsEmpty()) { | 459 if (!hitBreakpointNumbers.IsEmpty()) { |
464 breakpointIds.reserve(hitBreakpointNumbers->Length()); | 460 breakpointIds.reserve(hitBreakpointNumbers->Length()); |
465 for (uint32_t i = 0; i < hitBreakpointNumbers->Length(); i++) { | 461 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) { |
466 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get(i); | 462 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get(i); |
467 DCHECK(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt32()); | 463 DCHECK(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt32()); |
468 breakpointIds.push_back( | 464 breakpointIds.push_back( |
469 String16::fromInteger(hitBreakpointNumber->Int32Value())); | 465 String16::fromInteger(hitBreakpointNumber->Int32Value())); |
470 } | 466 } |
471 } | 467 } |
472 | 468 |
473 m_pausedContext = pausedContext; | 469 m_pausedContext = pausedContext; |
474 m_executionState = executionState; | 470 m_executionState = executionState; |
475 V8DebuggerAgentImpl::SkipPauseRequest result = agent->didPause( | 471 V8DebuggerAgentImpl::SkipPauseRequest result = agent->didPause( |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 | 572 |
577 void V8Debugger::handleV8AsyncTaskEvent(v8::Local<v8::Context> context, | 573 void V8Debugger::handleV8AsyncTaskEvent(v8::Local<v8::Context> context, |
578 v8::Local<v8::Object> executionState, | 574 v8::Local<v8::Object> executionState, |
579 v8::Local<v8::Object> eventData) { | 575 v8::Local<v8::Object> eventData) { |
580 if (!m_maxAsyncCallStackDepth) return; | 576 if (!m_maxAsyncCallStackDepth) return; |
581 | 577 |
582 String16 type = toProtocolStringWithTypeCheck( | 578 String16 type = toProtocolStringWithTypeCheck( |
583 callInternalGetterFunction(eventData, "type")); | 579 callInternalGetterFunction(eventData, "type")); |
584 String16 name = toProtocolStringWithTypeCheck( | 580 String16 name = toProtocolStringWithTypeCheck( |
585 callInternalGetterFunction(eventData, "name")); | 581 callInternalGetterFunction(eventData, "name")); |
586 int id = static_cast<int>(callInternalGetterFunction(eventData, "id") | 582 int id = callInternalGetterFunction(eventData, "id") |
587 ->ToInteger(m_isolate) | 583 ->ToInteger(m_isolate) |
588 ->Value()); | 584 ->Value(); |
589 // The scopes for the ids are defined by the eventData.name namespaces. There | 585 // The scopes for the ids are defined by the eventData.name namespaces. There |
590 // are currently two namespaces: "Object." and "Promise.". | 586 // are currently two namespaces: "Object." and "Promise.". |
591 void* ptr = reinterpret_cast<void*>(id * 4 + (name[0] == 'P' ? 2 : 0) + 1); | 587 void* ptr = reinterpret_cast<void*>(id * 4 + (name[0] == 'P' ? 2 : 0) + 1); |
592 if (type == v8AsyncTaskEventEnqueue) | 588 if (type == v8AsyncTaskEventEnqueue) |
593 asyncTaskScheduled(name, ptr, false); | 589 asyncTaskScheduled(name, ptr, false); |
594 else if (type == v8AsyncTaskEventWillHandle) | 590 else if (type == v8AsyncTaskEventWillHandle) |
595 asyncTaskStarted(ptr); | 591 asyncTaskStarted(ptr); |
596 else if (type == v8AsyncTaskEventDidHandle) | 592 else if (type == v8AsyncTaskEventDidHandle) |
597 asyncTaskFinished(ptr); | 593 asyncTaskFinished(ptr); |
598 else | 594 else |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 | 907 |
912 size_t stackSize = | 908 size_t stackSize = |
913 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; | 909 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; |
914 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) | 910 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) |
915 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; | 911 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; |
916 | 912 |
917 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); | 913 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
918 } | 914 } |
919 | 915 |
920 } // namespace v8_inspector | 916 } // namespace v8_inspector |
OLD | NEW |