| OLD | NEW |
| 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 #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_STACK_FRAME_DEDUPLICATOR_H_ | 5 #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_STACK_FRAME_DEDUPLICATOR_H_ |
| 6 #define BASE_TRACE_EVENT_HEAP_PROFILER_STACK_FRAME_DEDUPLICATOR_H_ | 6 #define BASE_TRACE_EVENT_HEAP_PROFILER_STACK_FRAME_DEDUPLICATOR_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // parent frame (when it is at the bottom of the call stack). | 40 // parent frame (when it is at the bottom of the call stack). |
| 41 int parent_frame_index; | 41 int parent_frame_index; |
| 42 | 42 |
| 43 // Indices into |frames_| of frames called from the current frame. | 43 // Indices into |frames_| of frames called from the current frame. |
| 44 std::map<StackFrame, int> children; | 44 std::map<StackFrame, int> children; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 using ConstIterator = std::vector<FrameNode>::const_iterator; | 47 using ConstIterator = std::vector<FrameNode>::const_iterator; |
| 48 | 48 |
| 49 StackFrameDeduplicator(); | 49 StackFrameDeduplicator(); |
| 50 ~StackFrameDeduplicator() override; |
| 50 | 51 |
| 51 // Inserts a backtrace where |beginFrame| is a pointer to the bottom frame | 52 // Inserts a backtrace where |beginFrame| is a pointer to the bottom frame |
| 52 // (e.g. main) and |endFrame| is a pointer past the top frame (most recently | 53 // (e.g. main) and |endFrame| is a pointer past the top frame (most recently |
| 53 // called function), and returns the index of its leaf node in |frames_|. | 54 // called function), and returns the index of its leaf node in |frames_|. |
| 54 // Returns -1 if the backtrace is empty. | 55 // Returns -1 if the backtrace is empty. |
| 55 int Insert(const StackFrame* beginFrame, const StackFrame* endFrame); | 56 int Insert(const StackFrame* beginFrame, const StackFrame* endFrame); |
| 56 | 57 |
| 57 // Iterators over the frame nodes in the call tree. | 58 // Iterators over the frame nodes in the call tree. |
| 58 ConstIterator begin() const { return frames_.begin(); } | 59 ConstIterator begin() const { return frames_.begin(); } |
| 59 ConstIterator end() const { return frames_.end(); } | 60 ConstIterator end() const { return frames_.end(); } |
| 60 | 61 |
| 61 // Writes the |stackFrames| dictionary as defined in https://goo.gl/GerkV8 to | 62 // Writes the |stackFrames| dictionary as defined in https://goo.gl/GerkV8 to |
| 62 // the trace log. | 63 // the trace log. |
| 63 void AppendAsTraceFormat(std::string* out) const override; | 64 void AppendAsTraceFormat(std::string* out) const override; |
| 64 | 65 |
| 65 // Estimates memory overhead including |sizeof(StackFrameDeduplicator)|. | 66 // Estimates memory overhead including |sizeof(StackFrameDeduplicator)|. |
| 66 void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead) override; | 67 void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead) override; |
| 67 | 68 |
| 68 private: | 69 private: |
| 69 ~StackFrameDeduplicator() override; | |
| 70 | |
| 71 std::map<StackFrame, int> roots_; | 70 std::map<StackFrame, int> roots_; |
| 72 std::vector<FrameNode> frames_; | 71 std::vector<FrameNode> frames_; |
| 73 | 72 |
| 74 DISALLOW_COPY_AND_ASSIGN(StackFrameDeduplicator); | 73 DISALLOW_COPY_AND_ASSIGN(StackFrameDeduplicator); |
| 75 }; | 74 }; |
| 76 | 75 |
| 77 } // namespace trace_event | 76 } // namespace trace_event |
| 78 } // namespace base | 77 } // namespace base |
| 79 | 78 |
| 80 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_STACK_FRAME_DEDUPLICATOR_H_ | 79 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_STACK_FRAME_DEDUPLICATOR_H_ |
| OLD | NEW |