Edit

kc3-lang/angle/src/common/event_tracer.cpp

Branch :

  • Show log

    Commit

  • Author : Oystein Eftevaag
    Date : 2018-06-29 10:49:38
    Hash : 33e72d99
    Message : Removed an assert about addTraceEvent not returning empty handles. There are several codepaths where this is the expected result: * Other threads disabling the category in question. * The TraceBuffer being fill and no new chunks available. * Perfetto being active as the tracing backend. In all cases, the single use of a handle to a TraceEvent is TraceLog::UpdateTraceEventDuration which handles the above cases correctly. BUG=844421 Change-Id: Ieaf3aa5c913cee8c51cfea637907d5bc3b560ceb Reviewed-on: https://chromium-review.googlesource.com/1120841 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>

  • src/common/event_tracer.cpp
  • // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    
    #include "common/event_tracer.h"
    
    #include "common/debug.h"
    
    namespace angle
    {
    
    const unsigned char *GetTraceCategoryEnabledFlag(const char *name)
    {
        auto *platform = ANGLEPlatformCurrent();
        ASSERT(platform);
    
        const unsigned char *categoryEnabledFlag =
            platform->getTraceCategoryEnabledFlag(platform, name);
        if (categoryEnabledFlag != nullptr)
        {
            return categoryEnabledFlag;
        }
    
        static unsigned char disabled = 0;
        return &disabled;
    }
    
    angle::TraceEventHandle AddTraceEvent(char phase,
                                          const unsigned char *categoryGroupEnabled,
                                          const char *name,
                                          unsigned long long id,
                                          int numArgs,
                                          const char **argNames,
                                          const unsigned char *argTypes,
                                          const unsigned long long *argValues,
                                          unsigned char flags)
    {
        auto *platform = ANGLEPlatformCurrent();
        ASSERT(platform);
    
        double timestamp = platform->monotonicallyIncreasingTime(platform);
    
        if (timestamp != 0)
        {
            angle::TraceEventHandle handle =
                platform->addTraceEvent(platform, phase, categoryGroupEnabled, name, id, timestamp,
                                        numArgs, argNames, argTypes, argValues, flags);
            return handle;
        }
    
        return static_cast<angle::TraceEventHandle>(0);
    }
    
    }  // namespace angle