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

Side by Side Diff: base/trace_event/heap_profiler_allocation_context_tracker.h

Issue 1675183006: tracing: add dump provider for malloc heap profiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shim_layer_linux
Patch Set: ssid review Created 4 years, 9 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
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 #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_ 5 #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_
6 #define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_ 6 #define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/atomicops.h" 10 #include "base/atomicops.h"
(...skipping 25 matching lines...) Expand all
36 if (subtle::NoBarrier_Load(&capture_enabled_) == 0) 36 if (subtle::NoBarrier_Load(&capture_enabled_) == 0)
37 return false; 37 return false;
38 38
39 // In the slow path, an acquire load is required to pair with the release 39 // In the slow path, an acquire load is required to pair with the release
40 // store in |SetCaptureEnabled|. This is to ensure that the TLS slot for 40 // store in |SetCaptureEnabled|. This is to ensure that the TLS slot for
41 // the thread-local allocation context tracker has been initialized if 41 // the thread-local allocation context tracker has been initialized if
42 // |capture_enabled| returns true. 42 // |capture_enabled| returns true.
43 return subtle::Acquire_Load(&capture_enabled_) != 0; 43 return subtle::Acquire_Load(&capture_enabled_) != 0;
44 } 44 }
45 45
46 // Returns the thread-local instance, creating one if necessary. Returns
47 // always a valid instance, unless it is called re-entrantly, in which case
48 // returns nullptr in the nested calls.
49 static AllocationContextTracker* GetInstanceForCurrentThread();
50
46 // Pushes a frame onto the thread-local pseudo stack. 51 // Pushes a frame onto the thread-local pseudo stack.
47 static void PushPseudoStackFrame(StackFrame frame); 52 void PushPseudoStackFrame(StackFrame frame);
48 53
49 // Pops a frame from the thread-local pseudo stack. 54 // Pops a frame from the thread-local pseudo stack.
50 static void PopPseudoStackFrame(StackFrame frame); 55 void PopPseudoStackFrame(StackFrame frame);
51 56
52 // Returns a snapshot of the current thread-local context. 57 // Returns a snapshot of the current thread-local context.
53 static AllocationContext GetContextSnapshot(); 58 AllocationContext GetContextSnapshot();
54 59
55 ~AllocationContextTracker(); 60 ~AllocationContextTracker();
56 61
57 private: 62 private:
58 AllocationContextTracker(); 63 AllocationContextTracker();
59 64
60 static AllocationContextTracker* GetThreadLocalTracker();
61
62 static subtle::Atomic32 capture_enabled_; 65 static subtle::Atomic32 capture_enabled_;
63 66
64 // The pseudo stack where frames are |TRACE_EVENT| names. 67 // The pseudo stack where frames are |TRACE_EVENT| names.
65 std::vector<StackFrame> pseudo_stack_; 68 std::vector<StackFrame> pseudo_stack_;
66 69
67 DISALLOW_COPY_AND_ASSIGN(AllocationContextTracker); 70 DISALLOW_COPY_AND_ASSIGN(AllocationContextTracker);
68 }; 71 };
69 72
70 } // namespace trace_event 73 } // namespace trace_event
71 } // namespace base 74 } // namespace base
72 75
73 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_ 76 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698