コード例 #1
0
v8::Local<v8::Object> JavaScriptCallFrame::createExceptionDetails(v8::Isolate* isolate, v8::Local<v8::Message> message)
{
    v8::Local<v8::Object> exceptionDetails = v8::Object::New(isolate);
    exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "text"), message->Get());
    exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "url"), message->GetScriptOrigin().ResourceName());
    exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "scriptId"), v8::Integer::New(isolate, message->GetScriptOrigin().ScriptID()->Value()));
    exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "line"), v8::Integer::New(isolate, message->GetLineNumber()));
    exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "column"), v8::Integer::New(isolate, message->GetStartColumn()));
    if (!message->GetStackTrace().IsEmpty())
        exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), message->GetStackTrace()->AsArray());
    else
        exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), v8::Undefined(isolate));
    return exceptionDetails;
}
コード例 #2
0
ファイル: InjectedScript.cpp プロジェクト: ben-page/node
std::unique_ptr<protocol::Runtime::ExceptionDetails> InjectedScript::createExceptionDetails(v8::Local<v8::Message> message)
{
    std::unique_ptr<protocol::Runtime::ExceptionDetails> exceptionDetailsObject = protocol::Runtime::ExceptionDetails::create()
        .setText(toProtocolString(message->Get()))
        .setScriptId(String16::fromInteger(message->GetScriptOrigin().ScriptID()->Value()))
        .setLineNumber(message->GetLineNumber(m_context->context()).FromMaybe(1) - 1)
        .setColumnNumber(message->GetStartColumn(m_context->context()).FromMaybe(0))
        .build();

    v8::Local<v8::StackTrace> stackTrace = message->GetStackTrace();
    if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0)
        exceptionDetailsObject->setStackTrace(m_context->inspector()->debugger()->createStackTrace(stackTrace)->buildInspectorObjectImpl());
    return exceptionDetailsObject;
}
コード例 #3
0
ファイル: V8Initializer.cpp プロジェクト: techtonik/chromium
static PassRefPtrWillBeRawPtr<ScriptCallStack> extractCallStack(v8::Isolate* isolate, v8::Local<v8::Message> message, int* const scriptId)
{
    v8::Local<v8::StackTrace> stackTrace = message->GetStackTrace();
    RefPtrWillBeRawPtr<ScriptCallStack> callStack = nullptr;
    *scriptId = message->GetScriptOrigin().ScriptID()->Value();
    // Currently stack trace is only collected when inspector is open.
    if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) {
        callStack = createScriptCallStack(isolate, stackTrace, ScriptCallStack::maxCallStackSizeToCapture);
        bool success = false;
        int topScriptId = callStack->at(0).scriptId().toInt(&success);
        if (success && topScriptId == *scriptId)
            *scriptId = 0;
    }
    return callStack.release();
}
コード例 #4
0
ファイル: SourceLocation.cpp プロジェクト: mirror/chromium
// static
std::unique_ptr<SourceLocation> SourceLocation::fromMessage(
    v8::Isolate* isolate,
    v8::Local<v8::Message> message,
    ExecutionContext* executionContext) {
  v8::Local<v8::StackTrace> stack = message->GetStackTrace();
  std::unique_ptr<v8_inspector::V8StackTrace> stackTrace = nullptr;
  V8PerIsolateData* data = V8PerIsolateData::from(isolate);
  if (data && data->threadDebugger())
    stackTrace = data->threadDebugger()->v8Inspector()->createStackTrace(stack);

  int scriptId = message->GetScriptOrigin().ScriptID()->Value();
  if (!stack.IsEmpty() && stack->GetFrameCount() > 0) {
    int topScriptId = stack->GetFrame(0)->GetScriptId();
    if (topScriptId == scriptId)
      scriptId = 0;
  }

  int lineNumber = 0;
  int columnNumber = 0;
  if (v8Call(message->GetLineNumber(isolate->GetCurrentContext()),
             lineNumber) &&
      v8Call(message->GetStartColumn(isolate->GetCurrentContext()),
             columnNumber))
    ++columnNumber;

  if ((!scriptId || !lineNumber) && stackTrace && !stackTrace->isEmpty())
    return SourceLocation::createFromNonEmptyV8StackTrace(std::move(stackTrace),
                                                          0);

  String url = toCoreStringWithUndefinedOrNullCheck(
      message->GetScriptOrigin().ResourceName());
  if (url.isNull())
    url = executionContext->url();
  return SourceLocation::create(url, lineNumber, columnNumber,
                                std::move(stackTrace), scriptId);
}