Index: base/trace_event/memory_dump_manager.cc |
diff --git a/base/trace_event/memory_dump_manager.cc b/base/trace_event/memory_dump_manager.cc |
index 3430169630f6e172a0ed1417f30b3c50e43a9731..83584c53104591291ec86a79c58043616188be13 100644 |
--- a/base/trace_event/memory_dump_manager.cc |
+++ b/base/trace_event/memory_dump_manager.cc |
@@ -15,7 +15,27 @@ namespace base { |
namespace trace_event { |
namespace { |
+ |
MemoryDumpManager* g_instance_for_testing = nullptr; |
+const int kTraceEventNumArgs = 1; |
+const char* kTraceEventArgNames[] = {"dumps"}; |
+const unsigned char kTraceEventArgTypes[] = {TRACE_VALUE_TYPE_CONVERTABLE}; |
+uint64 g_next_guid = 0; |
+ |
+const char* DumpPointTypeToString(const DumpPointType& type) { |
+ switch (type) { |
+ case DumpPointType::TASK_BEGIN: |
+ return "TASK_BEGIN"; |
+ case DumpPointType::TASK_END: |
+ return "TASK_END"; |
+ case DumpPointType::PERIODIC_INTERVAL: |
+ return "PERIODIC_INTERVAL"; |
+ case DumpPointType::EXPLICITLY_TRIGGERED: |
+ return "EXPLICITLY_TRIGGERED"; |
+ } |
+ NOTREACHED(); |
+ return "UNKNOWN"; |
+} |
} |
// TODO(primiano): this should be smarter and should do something similar to |
@@ -82,7 +102,7 @@ void MemoryDumpManager::RequestDumpPoint(DumpPointType type) { |
if (!UNLIKELY(subtle::NoBarrier_Load(&memory_tracing_enabled_))) |
return; |
- CreateLocalDumpPoint(); |
+ CreateLocalDumpPoint(type); |
} |
void MemoryDumpManager::BroadcastDumpRequest() { |
@@ -90,7 +110,7 @@ void MemoryDumpManager::BroadcastDumpRequest() { |
} |
// Creates a dump point for the current process and appends it to the trace. |
-void MemoryDumpManager::CreateLocalDumpPoint() { |
+void MemoryDumpManager::CreateLocalDumpPoint(DumpPointType type) { |
AutoLock lock(lock_); |
bool did_any_provider_dump = false; |
scoped_ptr<ProcessMemoryDump> pmd(new ProcessMemoryDump()); |
@@ -114,9 +134,16 @@ void MemoryDumpManager::CreateLocalDumpPoint() { |
if (!did_any_provider_dump) |
return; |
picksi
2015/02/26 17:58:04
[Without thinking too deeply about this...] Does t
Primiano Tucci (use gerrit)
2015/03/01 11:32:28
Done. Turns out I needed to change the g_next_guid
|
- scoped_refptr<TracedValue> value(new TracedValue()); |
- pmd->AsValueInto(value.get()); |
- // TODO(primiano): add the dump point to the trace at this point. |
+ scoped_refptr<ConvertableToTraceFormat> event_value(new TracedValue()); |
+ pmd->AsValueInto(static_cast<TracedValue*>(event_value.get())); |
+ const char* const event_name = DumpPointTypeToString(type); |
+ const uint64 event_guid = ++g_next_guid; |
nduca
2015/02/26 17:26:29
i think you need TRACE_ID_DONT_MANGLE -- see trace
Primiano Tucci (use gerrit)
2015/03/01 11:32:28
Right.
FTR: the rationale here is that we don't wa
|
+ |
+ TRACE_EVENT_API_ADD_TRACE_EVENT( |
dsinclair
2015/02/26 17:54:54
I'm not sure if want to leak this out of trace_eve
Primiano Tucci (use gerrit)
2015/03/01 11:32:28
Oh, I though that was meant to be part of the publ
|
+ TRACE_EVENT_PHASE_MEMORY_DUMP, |
+ TraceLog::GetCategoryGroupEnabled(kTraceCategory), event_name, event_guid, |
+ kTraceEventNumArgs, kTraceEventArgNames, kTraceEventArgTypes, NULL, |
picksi
2015/02/26 17:58:04
It would make this code clearer if the NULL was a
Primiano Tucci (use gerrit)
2015/03/01 11:32:28
Makes sense making it explicit. IIRC in chromium w
|
+ &event_value, TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_MANGLE_ID); |
} |
void MemoryDumpManager::OnTraceLogEnabled() { |