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

Unified 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: production version 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 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 9c9a3132abab1e395a94d5632dc253845f43efa4..83912ce3cc232434fa2c937d9e21a958152b9c61 100644
--- a/base/trace_event/heap_profiler_allocation_context_tracker.h
+++ b/base/trace_event/heap_profiler_allocation_context_tracker.h
@@ -23,11 +23,23 @@ namespace trace_event {
// details.
class BASE_EXPORT AllocationContextTracker {
public:
+ enum InitializationState { kNotInitialized = 0, kInitializing, kInitialized };
+
// 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);
+ // Exposes the initialization state of the tracker. This is to avoid
+ // re-entrancy in the malloc heap profiler, that will lazy initialize the
petrcermak 2016/03/11 11:09:23 nit: s/that/which/ (you can't have "that" after a
petrcermak 2016/03/11 11:09:23 nit: s/lazy/lazily/
Primiano Tucci (use gerrit) 2016/03/11 13:57:57 Done.
Primiano Tucci (use gerrit) 2016/03/11 13:57:57 Done.
+ // thread-local context trackes on the first malloc seen, causing a nested
petrcermak 2016/03/11 11:09:23 s/trackes/trackers/
petrcermak 2016/03/11 11:09:23 supernit: wouldn't "first encountered malloc" read
Primiano Tucci (use gerrit) 2016/03/11 13:57:57 Done.
Primiano Tucci (use gerrit) 2016/03/11 13:57:57 actually was "tracker" , just typoed r/s
+ // allocation.
+ static InitializationState GetStateForCurrentThread();
+
+ // Enforces the initialization of the tracker. Subsequent calls to the other
+ // methods of this class are supposed to not cause any further malloc/new.
+ static AllocationContextTracker* InitializeForCurrentThread();
+
// Returns whether capturing allocation context is enabled globally.
inline static bool capture_enabled() {
// A little lag after heap profiling is enabled or disabled is fine, it is

Powered by Google App Engine
This is Rietveld 408576698