Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: base/trace_event/trace_log.cc

Issue 2256913003: Tracing: Add more DCHECKS to get more info on recent test flakiness (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed one Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium 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 "base/trace_event/trace_log.h" 5 #include "base/trace_event/trace_log.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 // Use this function instead of TraceEventHandle constructor to keep the 168 // Use this function instead of TraceEventHandle constructor to keep the
169 // overhead of ScopedTracer (trace_event.h) constructor minimum. 169 // overhead of ScopedTracer (trace_event.h) constructor minimum.
170 void MakeHandle(uint32_t chunk_seq, 170 void MakeHandle(uint32_t chunk_seq,
171 size_t chunk_index, 171 size_t chunk_index,
172 size_t event_index, 172 size_t event_index,
173 TraceEventHandle* handle) { 173 TraceEventHandle* handle) {
174 DCHECK(chunk_seq); 174 DCHECK(chunk_seq);
175 DCHECK(chunk_index <= TraceBufferChunk::kMaxChunkIndex); 175 DCHECK(chunk_index <= TraceBufferChunk::kMaxChunkIndex);
176 DCHECK(event_index < TraceBufferChunk::kTraceBufferChunkSize); 176 DCHECK(event_index < TraceBufferChunk::kTraceBufferChunkSize);
177 DCHECK(chunk_index <= std::numeric_limits<uint16_t>::max());
177 handle->chunk_seq = chunk_seq; 178 handle->chunk_seq = chunk_seq;
178 handle->chunk_index = static_cast<uint16_t>(chunk_index); 179 handle->chunk_index = static_cast<uint16_t>(chunk_index);
179 handle->event_index = static_cast<uint16_t>(event_index); 180 handle->event_index = static_cast<uint16_t>(event_index);
180 } 181 }
181 182
182 } // namespace 183 } // namespace
183 184
184 // A helper class that allows the lock to be acquired in the middle of the scope 185 // A helper class that allows the lock to be acquired in the middle of the scope
185 // and unlocks at the end of scope if locked. 186 // and unlocks at the end of scope if locked.
186 class TraceLog::OptionalAutoLock { 187 class TraceLog::OptionalAutoLock {
(...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 1602
1602 TraceEvent* TraceLog::GetEventByHandle(TraceEventHandle handle) { 1603 TraceEvent* TraceLog::GetEventByHandle(TraceEventHandle handle) {
1603 return GetEventByHandleInternal(handle, NULL); 1604 return GetEventByHandleInternal(handle, NULL);
1604 } 1605 }
1605 1606
1606 TraceEvent* TraceLog::GetEventByHandleInternal(TraceEventHandle handle, 1607 TraceEvent* TraceLog::GetEventByHandleInternal(TraceEventHandle handle,
1607 OptionalAutoLock* lock) { 1608 OptionalAutoLock* lock) {
1608 if (!handle.chunk_seq) 1609 if (!handle.chunk_seq)
1609 return NULL; 1610 return NULL;
1610 1611
1612 DCHECK(handle.chunk_seq);
1613 DCHECK(handle.chunk_index <= TraceBufferChunk::kMaxChunkIndex);
1614 DCHECK(handle.event_index < TraceBufferChunk::kTraceBufferChunkSize);
1615
1611 if (thread_local_event_buffer_.Get()) { 1616 if (thread_local_event_buffer_.Get()) {
1612 TraceEvent* trace_event = 1617 TraceEvent* trace_event =
1613 thread_local_event_buffer_.Get()->GetEventByHandle(handle); 1618 thread_local_event_buffer_.Get()->GetEventByHandle(handle);
1614 if (trace_event) 1619 if (trace_event)
1615 return trace_event; 1620 return trace_event;
1616 } 1621 }
1617 1622
1618 // The event has been out-of-control of the thread local buffer. 1623 // The event has been out-of-control of the thread local buffer.
1619 // Try to get the event from the main buffer with a lock. 1624 // Try to get the event from the main buffer with a lock.
1620 if (lock) 1625 if (lock)
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 } 1784 }
1780 1785
1781 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 1786 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
1782 if (*category_group_enabled_) { 1787 if (*category_group_enabled_) {
1783 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, 1788 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_,
1784 event_handle_); 1789 event_handle_);
1785 } 1790 }
1786 } 1791 }
1787 1792
1788 } // namespace trace_event_internal 1793 } // namespace trace_event_internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698