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

Unified Diff: base/trace_event/heap_profiler_allocation_context_tracker.h

Issue 1839503002: [tracing] Add native allocation tracing mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add type to StackFrame; format thread name Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: base/trace_event/heap_profiler_allocation_context_tracker.h
diff --git a/base/trace_event/heap_profiler_allocation_context_tracker.h b/base/trace_event/heap_profiler_allocation_context_tracker.h
index d6133323bfb3d8f88f4331f6c718582c5611b3ee..202bd8914b9964facce371f12a8a7abf26307d8d 100644
--- a/base/trace_event/heap_profiler_allocation_context_tracker.h
+++ b/base/trace_event/heap_profiler_allocation_context_tracker.h
@@ -23,24 +23,29 @@ namespace trace_event {
// details.
class BASE_EXPORT AllocationContextTracker {
public:
- // Globally enables capturing allocation context.
- // TODO(ruuda): Should this be replaced by |EnableCapturing| in the future?
- // Or at least have something that guards agains enable -> disable -> enable?
- static void SetCaptureEnabled(bool enabled);
+ enum CaptureMode {
Primiano Tucci (use gerrit) 2016/04/07 15:51:56 enum class CaptureMode { DISABLED, PSEUDO_STACK, N
Dmitry Skiba 2016/04/12 18:22:11 Done.
+ DONT_CAPTURE = 0, // must be 0
+ CAPTURE_PSEUDO_STACK,
+ CAPTURE_NATIVE_STACK
+ };
+
+ // Globally sets capturing mode.
+ // TODO: How to guards against CAPTURE_* -> DONT_CAPTURE -> CAPTURE_*?
Primiano Tucci (use gerrit) 2016/04/07 15:51:56 TODO want always a name ;) you can put mine if you
Dmitry Skiba 2016/04/12 18:22:11 Done.
+ static void SetCaptureMode(CaptureMode mode);
// Returns whether capturing allocation context is enabled globally.
inline static bool capture_enabled() {
Primiano Tucci (use gerrit) 2016/04/07 15:51:56 Hmm I think you want to expose the capture mode he
Dmitry Skiba 2016/04/12 18:22:11 Yes, this is intended. I want us to still maintain
// A little lag after heap profiling is enabled or disabled is fine, it is
// more important that the check is as cheap as possible when capturing is
// not enabled, so do not issue a memory barrier in the fast path.
- if (subtle::NoBarrier_Load(&capture_enabled_) == 0)
+ if (subtle::NoBarrier_Load(&capture_mode_) == DONT_CAPTURE)
return false;
// In the slow path, an acquire load is required to pair with the release
- // store in |SetCaptureEnabled|. This is to ensure that the TLS slot for
+ // store in |SetCaptureMode|. This is to ensure that the TLS slot for
// the thread-local allocation context tracker has been initialized if
// |capture_enabled| returns true.
- return subtle::Acquire_Load(&capture_enabled_) != 0;
+ return subtle::Acquire_Load(&capture_mode_) != DONT_CAPTURE;
}
// Returns the thread-local instance, creating one if necessary. Returns
@@ -53,10 +58,11 @@ class BASE_EXPORT AllocationContextTracker {
static void SetCurrentThreadName(const char* name);
// Pushes a frame onto the thread-local pseudo stack.
+ void PushPseudoStackFrame(const char* frame_symbol_value);
Primiano Tucci (use gerrit) 2016/04/07 15:51:56 s/frame_symbol_value/trace_event_name/ :) it makes
Dmitry Skiba 2016/04/12 18:22:11 Done.
void PushPseudoStackFrame(StackFrame frame);
Primiano Tucci (use gerrit) 2016/04/07 15:51:56 Do we really need both versions here? It seem that
Dmitry Skiba 2016/04/12 18:22:11 Done.
// Pops a frame from the thread-local pseudo stack.
- void PopPseudoStackFrame(StackFrame frame);
+ void PopPseudoStackFrame(const void* frame_value);
// Push and pop current task's context. A stack is used to support nested
// tasks and the top of the stack will be used in allocation context.
@@ -71,7 +77,7 @@ class BASE_EXPORT AllocationContextTracker {
private:
AllocationContextTracker();
- static subtle::Atomic32 capture_enabled_;
+ static subtle::Atomic32 capture_mode_;
// The pseudo stack where frames are |TRACE_EVENT| names.
std::vector<StackFrame> pseudo_stack_;

Powered by Google App Engine
This is Rietveld 408576698