diff options
author | primiano <primiano@chromium.org> | 2015-11-02 08:43:28 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-02 16:44:08 +0000 |
commit | 252503f31e82b5bcfde4c35930e61685a71d5d9a (patch) | |
tree | 722bebe61d93beebed6ed915ca4dbdec69cd7dda /base | |
parent | 97585a9ddc05519be5acdef4bcbb51a0b6bcb848 (diff) | |
download | chromium_src-252503f31e82b5bcfde4c35930e61685a71d5d9a.zip chromium_src-252503f31e82b5bcfde4c35930e61685a71d5d9a.tar.gz chromium_src-252503f31e82b5bcfde4c35930e61685a71d5d9a.tar.bz2 |
[tracing] heap-profiler: Use explicit ConvertableToTraceFormat cast
crrev.com/1427063002 introduced a new overload to the
TRACE_EVENT_API_ADD_METADATA_EVENT api which takes a generic template
as argument. This causes the heap-profiler code in
memory_dump_manager.cc to prefer picking the bool cast operator of
scoped_refptr<DerivedClassWhichExtendsConvertable> rather than
the upcast operator to scoped_refptr<Convertable>.
In practical terms this means that invoking
TRACE_EVENT_API_ADD_METADATA_EVENT("name", scoped_refptr<Derived>)
expands to TRACE_EVENT_API_ADD_METADATA_EVENT("name", true) and does
not invoke the AppendAsTraceFormat() virtual method.
Using the explicit scoped_refptr<Convertable> when invoking the
TRACE_EVENT_API_ADD_METADATA_EVENT to fix the situation.
BUG=542702,524631
Review URL: https://codereview.chromium.org/1429883003
Cr-Commit-Position: refs/heads/master@{#357373}
Diffstat (limited to 'base')
-rw-r--r-- | base/trace_event/memory_dump_manager.cc | 5 | ||||
-rw-r--r-- | base/trace_event/memory_profiler_allocation_context.h | 5 |
2 files changed, 7 insertions, 3 deletions
diff --git a/base/trace_event/memory_dump_manager.cc b/base/trace_event/memory_dump_manager.cc index d939eea..0091442 100644 --- a/base/trace_event/memory_dump_manager.cc +++ b/base/trace_event/memory_dump_manager.cc @@ -479,8 +479,9 @@ void MemoryDumpManager::OnTraceLogEnabled() { // If heap profiling is enabled, the stack frame deduplicator will be in // use. Add a metadata event to write its frames. stack_frame_deduplicator = new StackFrameDeduplicator; - TRACE_EVENT_API_ADD_METADATA_EVENT("stackFrames", "stackFrames", - stack_frame_deduplicator); + TRACE_EVENT_API_ADD_METADATA_EVENT( + "stackFrames", "stackFrames", + scoped_refptr<ConvertableToTraceFormat>(stack_frame_deduplicator)); } session_state_ = new MemoryDumpSessionState(stack_frame_deduplicator); diff --git a/base/trace_event/memory_profiler_allocation_context.h b/base/trace_event/memory_profiler_allocation_context.h index 4e08c50..31c134d 100644 --- a/base/trace_event/memory_profiler_allocation_context.h +++ b/base/trace_event/memory_profiler_allocation_context.h @@ -49,7 +49,10 @@ class BASE_EXPORT AllocationStack { return; // Assert that pushes and pops are nested correctly. - DCHECK_EQ(frame, stack_.back()); + // This DCHECK can be hit if some TRACE_EVENT macro is unbalanced + // (a TRACE_EVENT_END* call without a corresponding TRACE_EVENT_BEGIN). + DCHECK_EQ(frame, stack_.back()) + << "Encountered an unmatched TRACE_EVENT_END"; stack_.pop_back(); } |