コード例 #1
0
void InspectorConsoleAgent::count(JSC::ExecState* state, PassRefPtr<ScriptArguments> arguments)
{
    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state, ScriptCallStack::maxCallStackSizeToCapture));

    String title;
    String identifier;
    if (!arguments->argumentCount()) {
        // '@' prefix for engine generated labels.
        title = ASCIILiteral("Global");
        identifier = makeString('@', title);
    } else {
        // '#' prefix for user labels.
        arguments->getFirstArgumentAsString(title);
        identifier = makeString('#', title);
    }

    auto result = m_counts.add(identifier, 1);
    if (!result.isNewEntry)
        result.iterator->value += 1;

    // FIXME: Web Inspector should have a better UI for counters, but for now we just log an updated counter value.

    String message = makeString(title, ": ", String::number(result.iterator->value));
    addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Log, MessageLevel::Debug, message, callStack));
}
コード例 #2
0
void ConsoleBase::timeEnd(ScriptState* scriptState, const String& title)
{
    TRACE_EVENT_COPY_ASYNC_END0("blink.console", title.utf8().data(), this);

    // Follow Firebug's behavior of requiring a title that is not null or
    // undefined for timing functions
    if (title.isNull())
        return;

    HashMap<String, double>::iterator it = m_times.find(title);
    if (it == m_times.end())
        return;

    double startTime = it->value;
    m_times.remove(it);

    double elapsed = monotonicallyIncreasingTime() - startTime;
    String message = title + String::format(": %.3fms", elapsed * 1000);

    RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(ConsoleAPIMessageSource, DebugMessageLevel, message);
    consoleMessage->setType(TimeEndMessageType);
    consoleMessage->setScriptState(scriptState);
    consoleMessage->setCallStack(createScriptCallStackForConsole(1));
    reportMessageToConsole(consoleMessage.release());
}
コード例 #3
0
void InspectorConsoleAgent::count(JSC::ExecState* state, PassRefPtr<ScriptArguments> arguments)
{
    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state, ScriptCallStack::maxCallStackSizeToCapture));
    const ScriptCallFrame& lastCaller = callStack->at(0);
    // Follow Firebug's behavior of counting with null and undefined title in
    // the same bucket as no argument
    String title;
    arguments->getFirstArgumentAsString(title);
    String identifier = title + '@' + lastCaller.sourceURL() + ':' + String::number(lastCaller.lineNumber());

    HashMap<String, unsigned>::iterator it = m_counts.find(identifier);
    int count;
    if (it == m_counts.end())
        count = 1;
    else {
        count = it->value + 1;
        m_counts.remove(it);
    }

    m_counts.add(identifier, count);

    String message;
    if (title.isEmpty())
        message = "<no label>: " + String::number(count);
    else
        message = title + ": " + String::number(count);

    addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Log, MessageLevel::Debug, message, callStack));
}
コード例 #4
0
void InspectorConsoleAgent::consoleCount(ScriptState* state, PassRefPtr<ScriptArguments> arguments)
{
    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole());
    const ScriptCallFrame& lastCaller = callStack->at(0);
    // Follow Firebug's behavior of counting with null and undefined title in
    // the same bucket as no argument
    String title;
    arguments->getFirstArgumentAsString(title);
    String identifier = title.isEmpty() ? String(lastCaller.sourceURL() + ':' + String::number(lastCaller.lineNumber()))
                                        : String(title + '@');

    HashMap<String, unsigned>::iterator it = m_counts.find(identifier);
    int count;
    if (it == m_counts.end())
        count = 1;
    else {
        count = it->value + 1;
        m_counts.remove(it);
    }

    m_counts.add(identifier, count);

    String message = title + ": " + String::number(count);
    addMessageToConsole(ConsoleAPIMessageSource, LogMessageType, DebugMessageLevel, message, callStack);
}
コード例 #5
0
ファイル: Console.cpp プロジェクト: kcomkar/webkit
void Console::timeEnd(ScriptState* state, const String& title)
{
#if PLATFORM(CHROMIUM)
    TRACE_EVENT_COPY_ASYNC_END0("webkit", title.utf8().data(), this);
#endif
    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state));
    InspectorInstrumentation::stopConsoleTiming(m_frame, title, callStack.release());
}
コード例 #6
0
ファイル: Console.cpp プロジェクト: boska/webkit
static void internalAddMessage(Page* page, MessageType type, MessageLevel level, JSC::ExecState* state, PassRefPtr<ScriptArguments> prpArguments, bool acceptNoArguments = false, bool printTrace = false)
{
    RefPtr<ScriptArguments> arguments = prpArguments;

    if (!page)
        return;

    if (!acceptNoArguments && !arguments->argumentCount())
        return;

    size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture : 1;
    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state, stackSize));
    const ScriptCallFrame& lastCaller = callStack->at(0);

    String message;
    bool gotMessage = arguments->getFirstArgumentAsString(message);
    InspectorInstrumentation::addMessageToConsole(page, MessageSource::ConsoleAPI, type, level, message, state, arguments);

    if (page->settings().privateBrowsingEnabled())
        return;

    if (gotMessage)
        page->chrome().client().addMessageToConsole(MessageSource::ConsoleAPI, type, level, message, lastCaller.lineNumber(), lastCaller.columnNumber(), lastCaller.sourceURL());

    if (!page->settings().logsPageMessagesToSystemConsoleEnabled() && !PageConsole::shouldPrintExceptions())
        return;

    PageConsole::printSourceURLAndPosition(lastCaller.sourceURL(), lastCaller.lineNumber());

    printf(": ");

    PageConsole::printMessageSourceAndLevelPrefix(MessageSource::ConsoleAPI, level, printTrace);

    for (size_t i = 0; i < arguments->argumentCount(); ++i) {
        String argAsString = arguments->argumentAt(i).toString(arguments->globalState());
        printf(" %s", argAsString.utf8().data());
    }

    printf("\n");

    if (!printTrace)
        return;

    for (size_t i = 0; i < callStack->size(); ++i) {
        const ScriptCallFrame& callFrame = callStack->at(i);

        String functionName = String(callFrame.functionName());
        if (functionName.isEmpty())
            functionName = ASCIILiteral("(unknown)");

        printf("%lu: %s (", static_cast<unsigned long>(i), functionName.utf8().data());

        PageConsole::printSourceURLAndPosition(callFrame.sourceURL(), callFrame.lineNumber());

        printf(")\n");
    }
}
コード例 #7
0
ファイル: JSConsoleClient.cpp プロジェクト: CannedFish/webkit
void JSConsoleClient::profile(JSC::ExecState* exec, const String& title)
{
    if (!m_profilerAgent->enabled())
        return;

    String resolvedTitle = m_profilerAgent->startProfiling(title);

    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(exec, 1));
    m_consoleAgent->addMessageToConsole(MessageSource::ConsoleAPI, MessageType::Profile, MessageLevel::Debug, resolvedTitle, callStack);
}
コード例 #8
0
ファイル: JSConsoleClient.cpp プロジェクト: CannedFish/webkit
void JSConsoleClient::profileEnd(JSC::ExecState* exec, const String& title)
{
    if (!m_profilerAgent->enabled())
        return;

    RefPtr<JSC::Profile> profile = m_profilerAgent->stopProfiling(title);
    if (!profile)
        return;

    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(exec, 1));
    String message = makeString(profile->title(), '#', String::number(profile->uid()));
    m_consoleAgent->addMessageToConsole(MessageSource::ConsoleAPI, MessageType::Profile, MessageLevel::Debug, message, callStack);
}
コード例 #9
0
void InspectorConsoleAgent::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, ScriptState* state, PassRefPtr<ScriptArguments> arguments, unsigned long requestIdentifier)
{
    if (!developerExtrasEnabled())
        return;

    if (type == ClearMessageType) {
        ErrorString error;
        clearMessages(&error);
    }

    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state));
    addConsoleMessage(adoptPtr(new ConsoleMessage(source, type, level, message, arguments, callStack.release(), requestIdentifier)));
}
コード例 #10
0
void InspectorConsoleAgent::consoleCount(ScriptState* scriptState, PassRefPtrWillBeRawPtr<ScriptArguments> arguments)
{
    RefPtrWillBeRawPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(scriptState));
    const ScriptCallFrame& lastCaller = callStack->at(0);
    // Follow Firebug's behavior of counting with null and undefined title in
    // the same bucket as no argument
    String title;
    arguments->getFirstArgumentAsString(title);
    String identifier = title.isEmpty() ? String(lastCaller.sourceURL() + ':' + String::number(lastCaller.lineNumber()))
                                        : String(title + '@');

    HashCountedSet<String>::AddResult result = m_counts.add(identifier);
    String message = title + ": " + String::number(result.storedValue->value);
    addMessageToConsole(ConsoleAPIMessageSource, LogMessageType, DebugMessageLevel, message, callStack.get());
}
コード例 #11
0
ファイル: Console.cpp プロジェクト: boska/webkit
void Console::profileEnd(JSC::ExecState* state, const String& title)
{
    Page* page = this->page();
    if (!page)
        return;

    if (!InspectorInstrumentation::profilerEnabled(page))
        return;

    RefPtr<ScriptProfile> profile = ScriptProfiler::stop(state, title);
    if (!profile)
        return;

    m_profiles.append(profile);
    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state, 1));
    InspectorInstrumentation::addProfile(page, profile, callStack);
}
コード例 #12
0
void ConsoleMessage::autogenerateMetadata(JSC::ExecState* state)
{
    if (!state)
        return;

    if (m_type == MessageType::EndGroup)
        return;

    // FIXME: Should this really be using "for console" in the generic ConsoleMessage autogeneration? This can skip the first frame.
    m_callStack = createScriptCallStackForConsole(state, ScriptCallStack::maxCallStackSizeToCapture);

    if (const ScriptCallFrame* frame = m_callStack->firstNonNativeCallFrame()) {
        m_url = frame->sourceURL();
        m_line = frame->lineNumber();
        m_column = frame->columnNumber();
        return;
    }
}
コード例 #13
0
void ConsoleBase::internalAddMessage(MessageType type, MessageLevel level, ScriptState* scriptState, PassRefPtrWillBeRawPtr<ScriptArguments> scriptArguments, bool acceptNoArguments, bool printTrace)
{
    RefPtrWillBeRawPtr<ScriptArguments> arguments = scriptArguments;
    if (!acceptNoArguments && (!arguments || !arguments->argumentCount()))
        return;

    String message;
    bool gotStringMessage = arguments ? arguments->getFirstArgumentAsString(message) : false;

    RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(ConsoleAPIMessageSource, level, gotStringMessage? message : String());
    consoleMessage->setType(type);
    consoleMessage->setScriptState(scriptState);
    consoleMessage->setScriptArguments(arguments);

    size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture : 1;
    consoleMessage->setCallStack(createScriptCallStackForConsole(stackSize));
    reportMessageToConsole(consoleMessage.release());
}
コード例 #14
0
ファイル: ConsoleMessage.cpp プロジェクト: domenic/mojo
void ConsoleMessage::collectCallStack()
{
    if (m_type == EndGroupMessageType)
        return;

    if (!m_callStack || m_source == ConsoleAPIMessageSource)
        m_callStack = createScriptCallStackForConsole(ScriptCallStack::maxCallStackSizeToCapture, true);

    if (m_callStack && m_callStack->size() && !m_scriptId) {
        const ScriptCallFrame& frame = m_callStack->at(0);
        m_url = frame.sourceURL();
        m_lineNumber = frame.lineNumber();
        m_columnNumber = frame.columnNumber();
        return;
    }

    m_callStack.clear();
}
コード例 #15
0
ファイル: ConsoleBase.cpp プロジェクト: jeremyroman/blink
void ConsoleBase::internalAddMessage(MessageType type, MessageLevel level, ScriptState* state, PassRefPtr<ScriptArguments> scriptArguments, bool acceptNoArguments, bool printTrace)
{
    if (!context())
        return;

    RefPtr<ScriptArguments> arguments = scriptArguments;
    if (!acceptNoArguments && !arguments->argumentCount())
        return;

    size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture : 1;
    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(stackSize));

    String message;
    bool gotStringMessage = arguments->getFirstArgumentAsString(message);
    InspectorInstrumentation::addMessageToConsole(context(), ConsoleAPIMessageSource, type, level, message, state, arguments);
    if (gotStringMessage)
        reportMessageToClient(level, message, callStack);
}
コード例 #16
0
void ConsoleClient::printConsoleMessageWithArguments(MessageSource source, MessageType type, MessageLevel level, JSC::ExecState* exec, RefPtr<ScriptArguments>&& arguments)
{
    bool isTraceMessage = type == MessageType::Trace;
    size_t stackSize = isTraceMessage ? ScriptCallStack::maxCallStackSizeToCapture : 1;
    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(exec, stackSize));
    const ScriptCallFrame& lastCaller = callStack->at(0);

    StringBuilder builder;

    if (!lastCaller.sourceURL().isEmpty()) {
        appendURLAndPosition(builder, lastCaller.sourceURL(), lastCaller.lineNumber(), lastCaller.columnNumber());
        builder.appendLiteral(": ");
    }

    appendMessagePrefix(builder, source, type, level);
    for (size_t i = 0; i < arguments->argumentCount(); ++i) {
        String argAsString = arguments->argumentAt(i).toString(arguments->globalState());
        builder.append(' ');
        builder.append(argAsString.utf8().data());
    }

    WTFLogAlways("%s", builder.toString().utf8().data());

    if (isTraceMessage) {
        for (size_t i = 0; i < callStack->size(); ++i) {
            const ScriptCallFrame& callFrame = callStack->at(i);
            String functionName = String(callFrame.functionName());
            if (functionName.isEmpty())
                functionName = ASCIILiteral("(unknown)");

            StringBuilder callFrameBuilder;
            callFrameBuilder.appendNumber(i);
            callFrameBuilder.appendLiteral(": ");
            callFrameBuilder.append(functionName);
            callFrameBuilder.append('(');
            appendURLAndPosition(callFrameBuilder, callFrame.sourceURL(), callFrame.lineNumber(), callFrame.columnNumber());
            callFrameBuilder.append(')');

            WTFLogAlways("%s", callFrameBuilder.toString().utf8().data());
        }
    }
}
コード例 #17
0
ファイル: Console.cpp プロジェクト: boska/webkit
void Console::profile(JSC::ExecState* state, const String& title)
{
    Page* page = this->page();
    if (!page)
        return;

    // FIXME: log a console message when profiling is disabled.
    if (!InspectorInstrumentation::profilerEnabled(page))
        return;

    String resolvedTitle = title;
    if (title.isNull()) // no title so give it the next user initiated profile title.
        resolvedTitle = InspectorInstrumentation::getCurrentUserInitiatedProfileName(page, true);

    ScriptProfiler::start(state, resolvedTitle);

    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state, 1));
    const ScriptCallFrame& lastCaller = callStack->at(0);
    InspectorInstrumentation::addStartProfilingMessageToConsole(page, resolvedTitle, lastCaller.lineNumber(), lastCaller.columnNumber(), lastCaller.sourceURL());
}
コード例 #18
0
void PageConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel level, JSC::ExecState* exec, PassRefPtr<Inspector::ScriptArguments> prpArguments)
{
    RefPtr<ScriptArguments> arguments = prpArguments;

    String message;
    bool gotMessage = arguments->getFirstArgumentAsString(message);
    InspectorInstrumentation::addMessageToConsole(&m_page, MessageSource::ConsoleAPI, type, level, message, exec, arguments);

    if (m_page.usesEphemeralSession())
        return;

    if (gotMessage) {
        size_t stackSize = type == MessageType::Trace ? ScriptCallStack::maxCallStackSizeToCapture : 1;
        RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(exec, stackSize));
        const ScriptCallFrame& lastCaller = callStack->at(0);
        m_page.chrome().client().addMessageToConsole(MessageSource::ConsoleAPI, type, level, message, lastCaller.lineNumber(), lastCaller.columnNumber(), lastCaller.sourceURL());
    }

    if (m_page.settings().logsPageMessagesToSystemConsoleEnabled() || PageConsoleClient::shouldPrintExceptions())
        ConsoleClient::printConsoleMessageWithArguments(MessageSource::ConsoleAPI, type, level, exec, arguments.release());
}
コード例 #19
0
ファイル: ConsoleMessage.cpp プロジェクト: jiezh/h5vcc
void ConsoleMessage::autogenerateMetadata(bool canGenerateCallStack, ScriptState* state)
{
    if (m_type == EndGroupMessageType)
        return;

    if (state)
        m_callStack = createScriptCallStackForConsole(state);
    else if (canGenerateCallStack)
        m_callStack = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, true);
    else
        return;

    if (m_callStack && m_callStack->size()) {
        const ScriptCallFrame& frame = m_callStack->at(0);
        m_url = frame.sourceURL();
        m_line = frame.lineNumber();
        return;
    }

    m_callStack.clear();
}
コード例 #20
0
void JSGlobalObjectConsoleClient::timeEnd(ExecState* exec, const String& title)
{
    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(exec, 1));
    m_consoleAgent->stopTiming(title, WTF::move(callStack));
}
コード例 #21
0
PassRefPtr<ScriptCallStack> createScriptCallStack(ScriptState*, size_t maxStackSize)
{
    return createScriptCallStackForConsole(maxStackSize);
}
コード例 #22
0
PassRefPtr<ScriptCallStack> createScriptCallStackForConsole(ScriptState*)
{
    return createScriptCallStackForConsole();
}
コード例 #23
0
ファイル: Console.cpp プロジェクト: ZeusbaseWeb/webkit
void Console::timeEnd(JSC::ExecState* state, const String& title)
{
    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state));
    InspectorInstrumentation::stopConsoleTiming(m_frame, title, callStack.release());
}
コード例 #24
0
ファイル: JSConsoleClient.cpp プロジェクト: CannedFish/webkit
void JSConsoleClient::timeEnd(ExecState* exec, const String& title)
{
    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(exec, 1));
    m_consoleAgent->stopTiming(title, callStack.release());
}
コード例 #25
0
void PageConsoleClient::timeEnd(JSC::ExecState* exec, const String& title)
{
    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(exec, 1));
    InspectorInstrumentation::stopConsoleTiming(&m_page.mainFrame(), title, callStack.release());
}