本文整理汇总了C++中v8::Handle::GetStackTrace方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::GetStackTrace方法的具体用法?C++ Handle::GetStackTrace怎么用?C++ Handle::GetStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类v8::Handle
的用法示例。
在下文中一共展示了Handle::GetStackTrace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: consoleMessage
void V8ConsoleMessage::handler(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data)
{
// Use the frame where JavaScript is called from.
Frame* frame = V8Proxy::retrieveFrameForEnteredContext();
if (!frame)
return;
Page* page = frame->page();
if (!page)
return;
v8::Handle<v8::String> errorMessageString = message->Get();
ASSERT(!errorMessageString.IsEmpty());
String errorMessage = toWebCoreString(errorMessageString);
v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace();
RefPtr<ScriptCallStack> callStack;
// Currently stack trace is only collected when inspector is open.
if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0)
callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallStackSizeToCapture);
v8::Handle<v8::Value> resourceName = message->GetScriptResourceName();
bool useURL = resourceName.IsEmpty() || !resourceName->IsString();
String resourceNameString = useURL ? frame->document()->url() : toWebCoreString(resourceName);
V8ConsoleMessage consoleMessage(errorMessage, resourceNameString, message->GetLineNumber());
consoleMessage.dispatchNow(page, callStack);
}
示例2: messageHandlerInMainThread
static void messageHandlerInMainThread(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data)
{
DOMWindow* firstWindow = firstDOMWindow();
if (!firstWindow->isCurrentlyDisplayedInFrame())
return;
String errorMessage = toWebCoreString(message->Get());
v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace();
RefPtr<ScriptCallStack> callStack;
// Currently stack trace is only collected when inspector is open.
if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0)
callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallStackSizeToCapture);
v8::Handle<v8::Value> resourceName = message->GetScriptResourceName();
bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsString();
String resource = shouldUseDocumentURL ? firstWindow->document()->url() : toWebCoreString(resourceName);
RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, resource, message->GetLineNumber(), message->GetStartColumn());
// messageHandlerInMainThread can be called while we're creating a new context.
// Since we cannot create a wrapper in the intermediate timing, we need to skip
// creating a wrapper for |event|.
DOMWrapperWorld* world = DOMWrapperWorld::current();
Frame* frame = firstWindow->document()->frame();
if (world && frame && frame->script()->existingWindowShell(world)) {
v8::Local<v8::Value> wrappedEvent = toV8(event.get(), v8::Handle<v8::Object>(), v8::Isolate::GetCurrent());
if (!wrappedEvent.IsEmpty()) {
ASSERT(wrappedEvent->IsObject());
v8::Local<v8::Object>::Cast(wrappedEvent)->SetHiddenValue(V8HiddenPropertyName::error(), data);
}
}
AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCrossOrigin : NotSharableCrossOrigin;
firstWindow->document()->reportException(event.release(), callStack, corsStatus);
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:34,代码来源:V8Initializer.cpp
示例3: messageHandlerInMainThread
static void messageHandlerInMainThread(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data)
{
ASSERT(isMainThread());
// It's possible that messageHandlerInMainThread() is invoked while we're initializing a window.
// In that half-baked situation, we don't have a valid context nor a valid world,
// so just return immediately.
if (DOMWrapperWorld::windowIsBeingInitialized())
return;
v8::Isolate* isolate = v8::Isolate::GetCurrent();
// If called during context initialization, there will be no entered window.
LocalDOMWindow* enteredWindow = enteredDOMWindow(isolate);
if (!enteredWindow)
return;
String errorMessage = toCoreString(message->Get());
v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace();
RefPtr<ScriptCallStack> callStack = nullptr;
int scriptId = message->GetScriptOrigin().ScriptID()->Value();
// Currently stack trace is only collected when inspector is open.
if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) {
callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallStackSizeToCapture, isolate);
bool success = false;
int topScriptId = callStack->at(0).scriptId().toInt(&success);
if (success && topScriptId == scriptId)
scriptId = 0;
} else {
Vector<ScriptCallFrame> callFrames;
callStack = ScriptCallStack::create(callFrames);
}
v8::Handle<v8::Value> resourceName = message->GetScriptOrigin().ResourceName();
bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsString();
String resource = shouldUseDocumentURL ? enteredWindow->document()->url() : toCoreString(resourceName.As<v8::String>());
ScriptState* scriptState = ScriptState::current(isolate);
RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, resource, message->GetLineNumber(), message->GetStartColumn() + 1, &scriptState->world());
if (V8DOMWrapper::isDOMWrapper(data)) {
v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(data);
const WrapperTypeInfo* type = toWrapperTypeInfo(obj);
if (V8DOMException::wrapperTypeInfo.isSubclass(type)) {
DOMException* exception = V8DOMException::toNative(obj);
if (exception && !exception->messageForConsole().isEmpty())
event->setUnsanitizedMessage("Uncaught " + exception->toStringForConsole());
}
}
// This method might be called while we're creating a new context. In this case, we
// avoid storing the exception object, as we can't create a wrapper during context creation.
// FIXME: Can we even get here during initialization now that we bail out when GetEntered returns an empty handle?
LocalFrame* frame = enteredWindow->document()->frame();
if (frame && frame->script().existingWindowProxy(scriptState->world())) {
V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, scriptState->context()->Global(), isolate);
}
enteredWindow->document()->reportException(event.release(), scriptId, callStack);
}
示例4: reportUncaughtException
static void reportUncaughtException(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data)
{
DOMWindow* firstWindow = firstDOMWindow(BindingState::instance());
if (!firstWindow->isCurrentlyDisplayedInFrame())
return;
String errorMessage = toWebCoreString(message->Get());
v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace();
RefPtr<ScriptCallStack> callStack;
// Currently stack trace is only collected when inspector is open.
if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0)
callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallStackSizeToCapture);
v8::Handle<v8::Value> resourceName = message->GetScriptResourceName();
bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsString();
String resource = shouldUseDocumentURL ? firstWindow->document()->url() : toWebCoreString(resourceName);
firstWindow->document()->reportException(errorMessage, message->GetLineNumber(), resource, callStack);
}