[tracing] Non-functional refactor of memory dump arg names
This CL is just cleaning up the inconsistencies accumulated w.r.t. of names used in the TraceConfig vs enum names in the codebase. Also this simplifies the complex and unnecessary wrapping in of the level of details argument in the RequestGlobalMemoryDump() API. BUG= TBR=jochen@chromium.org,reed@google.com Review URL: https://codereview.chromium.org/1337943003 Cr-Commit-Position: refs/heads/master@{#348715}
This commit is contained in:
base/trace_event
java_heap_dump_provider_android_unittest.ccmemory_allocator_dump_unittest.ccmemory_dump_manager.ccmemory_dump_manager.hmemory_dump_manager_unittest.ccmemory_dump_provider.hmemory_dump_request_args.ccmemory_dump_request_args.hprocess_memory_dump.hprocess_memory_maps_dump_provider.ccprocess_memory_maps_dump_provider_unittest.ccprocess_memory_totals_dump_provider_unittest.cctrace_config.cctrace_config.htrace_config_unittest.ccwinheap_dump_provider_win_unittest.cc
components/tracing
content
browser
child
gin
skia/ext
@@ -13,7 +13,7 @@ namespace trace_event {
|
|||||||
TEST(JavaHeapDumpProviderTest, JavaHeapDump) {
|
TEST(JavaHeapDumpProviderTest, JavaHeapDump) {
|
||||||
auto jhdp = JavaHeapDumpProvider::GetInstance();
|
auto jhdp = JavaHeapDumpProvider::GetInstance();
|
||||||
scoped_ptr<ProcessMemoryDump> pmd(new ProcessMemoryDump(nullptr));
|
scoped_ptr<ProcessMemoryDump> pmd(new ProcessMemoryDump(nullptr));
|
||||||
MemoryDumpArgs dump_args = {MemoryDumpArgs::LevelOfDetail::HIGH};
|
MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED};
|
||||||
|
|
||||||
jhdp->OnMemoryDump(dump_args, pmd.get());
|
jhdp->OnMemoryDump(dump_args, pmd.get());
|
||||||
}
|
}
|
||||||
|
@@ -126,7 +126,7 @@ TEST(MemoryAllocatorDumpTest, GuidGeneration) {
|
|||||||
TEST(MemoryAllocatorDumpTest, DumpIntoProcessMemoryDump) {
|
TEST(MemoryAllocatorDumpTest, DumpIntoProcessMemoryDump) {
|
||||||
FakeMemoryAllocatorDumpProvider fmadp;
|
FakeMemoryAllocatorDumpProvider fmadp;
|
||||||
ProcessMemoryDump pmd(make_scoped_refptr(new MemoryDumpSessionState()));
|
ProcessMemoryDump pmd(make_scoped_refptr(new MemoryDumpSessionState()));
|
||||||
MemoryDumpArgs dump_args = {MemoryDumpArgs::LevelOfDetail::HIGH};
|
MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED};
|
||||||
|
|
||||||
fmadp.OnMemoryDump(dump_args, &pmd);
|
fmadp.OnMemoryDump(dump_args, &pmd);
|
||||||
|
|
||||||
|
@@ -48,21 +48,20 @@ uint32 g_heavy_dumps_rate = 0;
|
|||||||
MemoryDumpManager* g_instance_for_testing = nullptr;
|
MemoryDumpManager* g_instance_for_testing = nullptr;
|
||||||
|
|
||||||
void RequestPeriodicGlobalDump() {
|
void RequestPeriodicGlobalDump() {
|
||||||
MemoryDumpArgs::LevelOfDetail dump_level_of_detail;
|
MemoryDumpLevelOfDetail level_of_detail;
|
||||||
if (g_heavy_dumps_rate == 0) {
|
if (g_heavy_dumps_rate == 0) {
|
||||||
dump_level_of_detail = MemoryDumpArgs::LevelOfDetail::LOW;
|
level_of_detail = MemoryDumpLevelOfDetail::LIGHT;
|
||||||
} else {
|
} else {
|
||||||
dump_level_of_detail = g_periodic_dumps_count == 0
|
level_of_detail = g_periodic_dumps_count == 0
|
||||||
? MemoryDumpArgs::LevelOfDetail::HIGH
|
? MemoryDumpLevelOfDetail::DETAILED
|
||||||
: MemoryDumpArgs::LevelOfDetail::LOW;
|
: MemoryDumpLevelOfDetail::LIGHT;
|
||||||
|
|
||||||
if (++g_periodic_dumps_count == g_heavy_dumps_rate)
|
if (++g_periodic_dumps_count == g_heavy_dumps_rate)
|
||||||
g_periodic_dumps_count = 0;
|
g_periodic_dumps_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryDumpArgs dump_args = {dump_level_of_detail};
|
|
||||||
MemoryDumpManager::GetInstance()->RequestGlobalDump(
|
MemoryDumpManager::GetInstance()->RequestGlobalDump(
|
||||||
MemoryDumpType::PERIODIC_INTERVAL, dump_args);
|
MemoryDumpType::PERIODIC_INTERVAL, level_of_detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@@ -204,9 +203,10 @@ void MemoryDumpManager::UnregisterDumpProvider(MemoryDumpProvider* mdp) {
|
|||||||
mdp_iter->unregistered = true;
|
mdp_iter->unregistered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryDumpManager::RequestGlobalDump(MemoryDumpType dump_type,
|
void MemoryDumpManager::RequestGlobalDump(
|
||||||
const MemoryDumpArgs& dump_args,
|
MemoryDumpType dump_type,
|
||||||
const MemoryDumpCallback& callback) {
|
MemoryDumpLevelOfDetail level_of_detail,
|
||||||
|
const MemoryDumpCallback& callback) {
|
||||||
// Bail out immediately if tracing is not enabled at all.
|
// Bail out immediately if tracing is not enabled at all.
|
||||||
if (!UNLIKELY(subtle::NoBarrier_Load(&memory_tracing_enabled_))) {
|
if (!UNLIKELY(subtle::NoBarrier_Load(&memory_tracing_enabled_))) {
|
||||||
if (!callback.is_null())
|
if (!callback.is_null())
|
||||||
@@ -230,13 +230,14 @@ void MemoryDumpManager::RequestGlobalDump(MemoryDumpType dump_type,
|
|||||||
|
|
||||||
// The delegate will coordinate the IPC broadcast and at some point invoke
|
// The delegate will coordinate the IPC broadcast and at some point invoke
|
||||||
// CreateProcessDump() to get a dump for the current process.
|
// CreateProcessDump() to get a dump for the current process.
|
||||||
MemoryDumpRequestArgs args = {guid, dump_type, dump_args};
|
MemoryDumpRequestArgs args = {guid, dump_type, level_of_detail};
|
||||||
delegate->RequestGlobalMemoryDump(args, callback);
|
delegate->RequestGlobalMemoryDump(args, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryDumpManager::RequestGlobalDump(MemoryDumpType dump_type,
|
void MemoryDumpManager::RequestGlobalDump(
|
||||||
const MemoryDumpArgs& dump_args) {
|
MemoryDumpType dump_type,
|
||||||
RequestGlobalDump(dump_type, dump_args, MemoryDumpCallback());
|
MemoryDumpLevelOfDetail level_of_detail) {
|
||||||
|
RequestGlobalDump(dump_type, level_of_detail, MemoryDumpCallback());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryDumpManager::CreateProcessDump(const MemoryDumpRequestArgs& args,
|
void MemoryDumpManager::CreateProcessDump(const MemoryDumpRequestArgs& args,
|
||||||
@@ -319,8 +320,9 @@ void MemoryDumpManager::ContinueAsyncProcessDump(
|
|||||||
bool dump_successful = false;
|
bool dump_successful = false;
|
||||||
|
|
||||||
if (!skip_dump) {
|
if (!skip_dump) {
|
||||||
dump_successful = mdp->OnMemoryDump(pmd_async_state->req_args.dump_args,
|
MemoryDumpArgs args = {pmd_async_state->req_args.level_of_detail};
|
||||||
&pmd_async_state->process_memory_dump);
|
dump_successful =
|
||||||
|
mdp->OnMemoryDump(args, &pmd_async_state->process_memory_dump);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -448,7 +450,7 @@ void MemoryDumpManager::OnTraceLogEnabled() {
|
|||||||
DCHECK_LE(config_list.size(), 2u);
|
DCHECK_LE(config_list.size(), 2u);
|
||||||
for (const TraceConfig::MemoryDumpTriggerConfig& config : config_list) {
|
for (const TraceConfig::MemoryDumpTriggerConfig& config : config_list) {
|
||||||
DCHECK(config.periodic_interval_ms);
|
DCHECK(config.periodic_interval_ms);
|
||||||
if (config.level_of_detail == MemoryDumpArgs::LevelOfDetail::HIGH)
|
if (config.level_of_detail == MemoryDumpLevelOfDetail::DETAILED)
|
||||||
heavy_dump_period_ms = config.periodic_interval_ms;
|
heavy_dump_period_ms = config.periodic_interval_ms;
|
||||||
min_timer_period_ms =
|
min_timer_period_ms =
|
||||||
std::min(min_timer_period_ms, config.periodic_interval_ms);
|
std::min(min_timer_period_ms, config.periodic_interval_ms);
|
||||||
|
@@ -67,18 +67,17 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver {
|
|||||||
|
|
||||||
// Requests a memory dump. The dump might happen or not depending on the
|
// Requests a memory dump. The dump might happen or not depending on the
|
||||||
// filters and categories specified when enabling tracing.
|
// filters and categories specified when enabling tracing.
|
||||||
// The |dump_args| is used to specify the dump's level of detail.
|
|
||||||
// The optional |callback| is executed asynchronously, on an arbitrary thread,
|
// The optional |callback| is executed asynchronously, on an arbitrary thread,
|
||||||
// to notify about the completion of the global dump (i.e. after all the
|
// to notify about the completion of the global dump (i.e. after all the
|
||||||
// processes have dumped) and its success (true iff all the dumps were
|
// processes have dumped) and its success (true iff all the dumps were
|
||||||
// successful).
|
// successful).
|
||||||
void RequestGlobalDump(MemoryDumpType dump_type,
|
void RequestGlobalDump(MemoryDumpType dump_type,
|
||||||
const MemoryDumpArgs& dump_args,
|
MemoryDumpLevelOfDetail level_of_detail,
|
||||||
const MemoryDumpCallback& callback);
|
const MemoryDumpCallback& callback);
|
||||||
|
|
||||||
// Same as above (still asynchronous), but without callback.
|
// Same as above (still asynchronous), but without callback.
|
||||||
void RequestGlobalDump(MemoryDumpType dump_type,
|
void RequestGlobalDump(MemoryDumpType dump_type,
|
||||||
const MemoryDumpArgs& dump_args);
|
MemoryDumpLevelOfDetail level_of_detail);
|
||||||
|
|
||||||
// TraceLog::EnabledStateObserver implementation.
|
// TraceLog::EnabledStateObserver implementation.
|
||||||
void OnTraceLogEnabled() override;
|
void OnTraceLogEnabled() override;
|
||||||
|
@@ -27,27 +27,14 @@ using testing::Return;
|
|||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
namespace trace_event {
|
namespace trace_event {
|
||||||
namespace {
|
|
||||||
MemoryDumpArgs g_high_detail_args = {MemoryDumpArgs::LevelOfDetail::HIGH};
|
|
||||||
MemoryDumpArgs g_low_detail_args = {MemoryDumpArgs::LevelOfDetail::LOW};
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
// GTest matchers for MemoryDumpRequestArgs arguments.
|
// GTest matchers for MemoryDumpRequestArgs arguments.
|
||||||
MATCHER(IsHighDetail, "") {
|
MATCHER(IsDetailedDump, "") {
|
||||||
return arg.level_of_detail == MemoryDumpArgs::LevelOfDetail::HIGH;
|
return arg.level_of_detail == MemoryDumpLevelOfDetail::DETAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
MATCHER(IsLowDetail, "") {
|
MATCHER(IsLightDump, "") {
|
||||||
return arg.level_of_detail == MemoryDumpArgs::LevelOfDetail::LOW;
|
return arg.level_of_detail == MemoryDumpLevelOfDetail::LIGHT;
|
||||||
}
|
|
||||||
|
|
||||||
// GTest matchers for MemoryDumpArgs arguments.
|
|
||||||
MATCHER(IsHighDetailArgs, "") {
|
|
||||||
return arg.dump_args.level_of_detail == MemoryDumpArgs::LevelOfDetail::HIGH;
|
|
||||||
}
|
|
||||||
|
|
||||||
MATCHER(IsLowDetailArgs, "") {
|
|
||||||
return arg.dump_args.level_of_detail == MemoryDumpArgs::LevelOfDetail::LOW;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Testing MemoryDumpManagerDelegate which, by default, short-circuits dump
|
// Testing MemoryDumpManagerDelegate which, by default, short-circuits dump
|
||||||
@@ -151,7 +138,7 @@ TEST_F(MemoryDumpManagerTest, SingleDumper) {
|
|||||||
EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(0);
|
EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(0);
|
||||||
EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
|
EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args);
|
MemoryDumpLevelOfDetail::DETAILED);
|
||||||
DisableTracing();
|
DisableTracing();
|
||||||
|
|
||||||
// Now repeat enabling the memory category and check that the dumper is
|
// Now repeat enabling the memory category and check that the dumper is
|
||||||
@@ -161,7 +148,7 @@ TEST_F(MemoryDumpManagerTest, SingleDumper) {
|
|||||||
EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(3).WillRepeatedly(Return(true));
|
EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(3).WillRepeatedly(Return(true));
|
||||||
for (int i = 0; i < 3; ++i)
|
for (int i = 0; i < 3; ++i)
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args);
|
MemoryDumpLevelOfDetail::DETAILED);
|
||||||
DisableTracing();
|
DisableTracing();
|
||||||
|
|
||||||
mdm_->UnregisterDumpProvider(&mdp);
|
mdm_->UnregisterDumpProvider(&mdp);
|
||||||
@@ -172,7 +159,7 @@ TEST_F(MemoryDumpManagerTest, SingleDumper) {
|
|||||||
EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1);
|
EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1);
|
||||||
EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
|
EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args);
|
MemoryDumpLevelOfDetail::DETAILED);
|
||||||
TraceLog::GetInstance()->SetDisabled();
|
TraceLog::GetInstance()->SetDisabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,9 +172,9 @@ TEST_F(MemoryDumpManagerTest, CheckMemoryDumpArgs) {
|
|||||||
mdm_->RegisterDumpProvider(&mdp);
|
mdm_->RegisterDumpProvider(&mdp);
|
||||||
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
|
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
|
||||||
EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1);
|
EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1);
|
||||||
EXPECT_CALL(mdp, OnMemoryDump(IsHighDetail(), _)).WillOnce(Return(true));
|
EXPECT_CALL(mdp, OnMemoryDump(IsDetailedDump(), _)).WillOnce(Return(true));
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args);
|
MemoryDumpLevelOfDetail::DETAILED);
|
||||||
DisableTracing();
|
DisableTracing();
|
||||||
mdm_->UnregisterDumpProvider(&mdp);
|
mdm_->UnregisterDumpProvider(&mdp);
|
||||||
|
|
||||||
@@ -196,9 +183,9 @@ TEST_F(MemoryDumpManagerTest, CheckMemoryDumpArgs) {
|
|||||||
mdm_->RegisterDumpProvider(&mdp);
|
mdm_->RegisterDumpProvider(&mdp);
|
||||||
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
|
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
|
||||||
EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1);
|
EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1);
|
||||||
EXPECT_CALL(mdp, OnMemoryDump(IsLowDetail(), _)).WillOnce(Return(true));
|
EXPECT_CALL(mdp, OnMemoryDump(IsLightDump(), _)).WillOnce(Return(true));
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_low_detail_args);
|
MemoryDumpLevelOfDetail::LIGHT);
|
||||||
DisableTracing();
|
DisableTracing();
|
||||||
mdm_->UnregisterDumpProvider(&mdp);
|
mdm_->UnregisterDumpProvider(&mdp);
|
||||||
}
|
}
|
||||||
@@ -231,7 +218,7 @@ TEST_F(MemoryDumpManagerTest, SharedSessionState) {
|
|||||||
|
|
||||||
for (int i = 0; i < 2; ++i)
|
for (int i = 0; i < 2; ++i)
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args);
|
MemoryDumpLevelOfDetail::DETAILED);
|
||||||
|
|
||||||
DisableTracing();
|
DisableTracing();
|
||||||
}
|
}
|
||||||
@@ -249,7 +236,7 @@ TEST_F(MemoryDumpManagerTest, MultipleDumpers) {
|
|||||||
EXPECT_CALL(mdp1, OnMemoryDump(_, _)).WillOnce(Return(true));
|
EXPECT_CALL(mdp1, OnMemoryDump(_, _)).WillOnce(Return(true));
|
||||||
EXPECT_CALL(mdp2, OnMemoryDump(_, _)).Times(0);
|
EXPECT_CALL(mdp2, OnMemoryDump(_, _)).Times(0);
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args);
|
MemoryDumpLevelOfDetail::DETAILED);
|
||||||
DisableTracing();
|
DisableTracing();
|
||||||
|
|
||||||
// Invert: enable mdp1 and disable mdp2.
|
// Invert: enable mdp1 and disable mdp2.
|
||||||
@@ -260,7 +247,7 @@ TEST_F(MemoryDumpManagerTest, MultipleDumpers) {
|
|||||||
EXPECT_CALL(mdp1, OnMemoryDump(_, _)).Times(0);
|
EXPECT_CALL(mdp1, OnMemoryDump(_, _)).Times(0);
|
||||||
EXPECT_CALL(mdp2, OnMemoryDump(_, _)).WillOnce(Return(true));
|
EXPECT_CALL(mdp2, OnMemoryDump(_, _)).WillOnce(Return(true));
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args);
|
MemoryDumpLevelOfDetail::DETAILED);
|
||||||
DisableTracing();
|
DisableTracing();
|
||||||
|
|
||||||
// Enable both mdp1 and mdp2.
|
// Enable both mdp1 and mdp2.
|
||||||
@@ -270,7 +257,7 @@ TEST_F(MemoryDumpManagerTest, MultipleDumpers) {
|
|||||||
EXPECT_CALL(mdp1, OnMemoryDump(_, _)).WillOnce(Return(true));
|
EXPECT_CALL(mdp1, OnMemoryDump(_, _)).WillOnce(Return(true));
|
||||||
EXPECT_CALL(mdp2, OnMemoryDump(_, _)).WillOnce(Return(true));
|
EXPECT_CALL(mdp2, OnMemoryDump(_, _)).WillOnce(Return(true));
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args);
|
MemoryDumpLevelOfDetail::DETAILED);
|
||||||
DisableTracing();
|
DisableTracing();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +274,7 @@ TEST_F(MemoryDumpManagerTest, RegistrationConsistency) {
|
|||||||
EXPECT_CALL(mdp, OnMemoryDump(_, _)).WillOnce(Return(true));
|
EXPECT_CALL(mdp, OnMemoryDump(_, _)).WillOnce(Return(true));
|
||||||
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
|
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args);
|
MemoryDumpLevelOfDetail::DETAILED);
|
||||||
DisableTracing();
|
DisableTracing();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,7 +285,7 @@ TEST_F(MemoryDumpManagerTest, RegistrationConsistency) {
|
|||||||
EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
|
EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
|
||||||
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
|
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args);
|
MemoryDumpLevelOfDetail::DETAILED);
|
||||||
DisableTracing();
|
DisableTracing();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +297,7 @@ TEST_F(MemoryDumpManagerTest, RegistrationConsistency) {
|
|||||||
EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
|
EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
|
||||||
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
|
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args);
|
MemoryDumpLevelOfDetail::DETAILED);
|
||||||
DisableTracing();
|
DisableTracing();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,7 +310,7 @@ TEST_F(MemoryDumpManagerTest, RegistrationConsistency) {
|
|||||||
EXPECT_CALL(mdp, OnMemoryDump(_, _)).WillOnce(Return(true));
|
EXPECT_CALL(mdp, OnMemoryDump(_, _)).WillOnce(Return(true));
|
||||||
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
|
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args);
|
MemoryDumpLevelOfDetail::DETAILED);
|
||||||
DisableTracing();
|
DisableTracing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -370,7 +357,7 @@ TEST_F(MemoryDumpManagerTest, RespectTaskRunnerAffinity) {
|
|||||||
MessageLoop::current()->task_runner(), run_loop.QuitClosure());
|
MessageLoop::current()->task_runner(), run_loop.QuitClosure());
|
||||||
EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1);
|
EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1);
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args, callback);
|
MemoryDumpLevelOfDetail::DETAILED, callback);
|
||||||
// This nested message loop (|run_loop|) will quit if and only if the
|
// This nested message loop (|run_loop|) will quit if and only if the
|
||||||
// |callback| passed to RequestGlobalDump() is invoked.
|
// |callback| passed to RequestGlobalDump() is invoked.
|
||||||
run_loop.Run();
|
run_loop.Run();
|
||||||
@@ -425,7 +412,7 @@ TEST_F(MemoryDumpManagerTest, DisableFailingDumpers) {
|
|||||||
|
|
||||||
for (int i = 0; i < kNumDumps; i++) {
|
for (int i = 0; i < kNumDumps; i++) {
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args);
|
MemoryDumpLevelOfDetail::DETAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
DisableTracing();
|
DisableTracing();
|
||||||
@@ -461,7 +448,7 @@ TEST_F(MemoryDumpManagerTest, RegisterDumperWhileDumping) {
|
|||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args);
|
MemoryDumpLevelOfDetail::DETAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
DisableTracing();
|
DisableTracing();
|
||||||
@@ -497,7 +484,7 @@ TEST_F(MemoryDumpManagerTest, UnregisterDumperWhileDumping) {
|
|||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args);
|
MemoryDumpLevelOfDetail::DETAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
DisableTracing();
|
DisableTracing();
|
||||||
@@ -550,7 +537,7 @@ TEST_F(MemoryDumpManagerTest, UnregisterDumperFromThreadWhileDumping) {
|
|||||||
|
|
||||||
EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1);
|
EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1);
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args, callback);
|
MemoryDumpLevelOfDetail::DETAILED, callback);
|
||||||
|
|
||||||
run_loop.Run();
|
run_loop.Run();
|
||||||
|
|
||||||
@@ -577,7 +564,7 @@ TEST_F(MemoryDumpManagerTest, CallbackCalledOnFailure) {
|
|||||||
Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this),
|
Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this),
|
||||||
MessageLoop::current()->task_runner(), run_loop.QuitClosure());
|
MessageLoop::current()->task_runner(), run_loop.QuitClosure());
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args, callback);
|
MemoryDumpLevelOfDetail::DETAILED, callback);
|
||||||
run_loop.Run();
|
run_loop.Run();
|
||||||
}
|
}
|
||||||
EXPECT_FALSE(last_callback_success_);
|
EXPECT_FALSE(last_callback_success_);
|
||||||
@@ -600,7 +587,7 @@ TEST_F(MemoryDumpManagerTest, InitializedAfterStartOfTracing) {
|
|||||||
Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this),
|
Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this),
|
||||||
MessageLoop::current()->task_runner(), run_loop.QuitClosure());
|
MessageLoop::current()->task_runner(), run_loop.QuitClosure());
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args, callback);
|
MemoryDumpLevelOfDetail::DETAILED, callback);
|
||||||
run_loop.Run();
|
run_loop.Run();
|
||||||
EXPECT_FALSE(last_callback_success_);
|
EXPECT_FALSE(last_callback_success_);
|
||||||
}
|
}
|
||||||
@@ -616,7 +603,7 @@ TEST_F(MemoryDumpManagerTest, InitializedAfterStartOfTracing) {
|
|||||||
Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this),
|
Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this),
|
||||||
MessageLoop::current()->task_runner(), run_loop.QuitClosure());
|
MessageLoop::current()->task_runner(), run_loop.QuitClosure());
|
||||||
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
g_high_detail_args, callback);
|
MemoryDumpLevelOfDetail::DETAILED, callback);
|
||||||
run_loop.Run();
|
run_loop.Run();
|
||||||
EXPECT_TRUE(last_callback_success_);
|
EXPECT_TRUE(last_callback_success_);
|
||||||
}
|
}
|
||||||
@@ -693,13 +680,13 @@ TEST_F(MemoryDumpManagerTest, TraceConfigExpectationsWhenIsCoordinator) {
|
|||||||
const int kHeavyDumpPeriodMs = kHeavyDumpRate * kLightDumpPeriodMs;
|
const int kHeavyDumpPeriodMs = kHeavyDumpRate * kLightDumpPeriodMs;
|
||||||
// The expected sequence with light=1ms, heavy=5ms is H,L,L,L,L,H,...
|
// The expected sequence with light=1ms, heavy=5ms is H,L,L,L,L,H,...
|
||||||
testing::InSequence sequence;
|
testing::InSequence sequence;
|
||||||
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsHighDetailArgs(), _));
|
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsDetailedDump(), _));
|
||||||
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLowDetailArgs(), _))
|
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLightDump(), _))
|
||||||
.Times(kHeavyDumpRate - 1);
|
.Times(kHeavyDumpRate - 1);
|
||||||
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsHighDetailArgs(), _));
|
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsDetailedDump(), _));
|
||||||
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLowDetailArgs(), _))
|
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLightDump(), _))
|
||||||
.Times(kHeavyDumpRate - 2);
|
.Times(kHeavyDumpRate - 2);
|
||||||
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLowDetailArgs(), _))
|
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLightDump(), _))
|
||||||
.WillOnce(Invoke([quit_closure](const MemoryDumpRequestArgs& args,
|
.WillOnce(Invoke([quit_closure](const MemoryDumpRequestArgs& args,
|
||||||
const MemoryDumpCallback& callback) {
|
const MemoryDumpCallback& callback) {
|
||||||
ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure);
|
ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure);
|
||||||
|
@@ -7,23 +7,17 @@
|
|||||||
|
|
||||||
#include "base/base_export.h"
|
#include "base/base_export.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
|
#include "base/trace_event/memory_dump_request_args.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
namespace trace_event {
|
namespace trace_event {
|
||||||
|
|
||||||
class ProcessMemoryDump;
|
class ProcessMemoryDump;
|
||||||
|
|
||||||
// Contains information about the type of memory dump the MemoryDumpProvider
|
// Args passed to OnMemoryDump(). This is to avoid rewriting all the subclasses
|
||||||
// should generate on dump request. This is to control the size of dumps
|
// in the codebase when extending the MemoryDumpProvider API.
|
||||||
// generated.
|
|
||||||
struct MemoryDumpArgs {
|
struct MemoryDumpArgs {
|
||||||
enum class LevelOfDetail {
|
MemoryDumpLevelOfDetail level_of_detail;
|
||||||
LOW,
|
|
||||||
HIGH,
|
|
||||||
LAST = HIGH // For IPC Macros.
|
|
||||||
};
|
|
||||||
|
|
||||||
LevelOfDetail level_of_detail;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// The contract interface that memory dump providers must implement.
|
// The contract interface that memory dump providers must implement.
|
||||||
|
@@ -10,20 +10,41 @@ namespace base {
|
|||||||
namespace trace_event {
|
namespace trace_event {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
const char* MemoryDumpTypeToString(
|
const char* MemoryDumpTypeToString(const MemoryDumpType& dump_type) {
|
||||||
const MemoryDumpType& dump_type) {
|
|
||||||
switch (dump_type) {
|
switch (dump_type) {
|
||||||
case MemoryDumpType::TASK_BEGIN:
|
case MemoryDumpType::TASK_BEGIN:
|
||||||
return "TASK_BEGIN";
|
return "task_begin";
|
||||||
case MemoryDumpType::TASK_END:
|
case MemoryDumpType::TASK_END:
|
||||||
return "TASK_END";
|
return "task_end";
|
||||||
case MemoryDumpType::PERIODIC_INTERVAL:
|
case MemoryDumpType::PERIODIC_INTERVAL:
|
||||||
return "PERIODIC_INTERVAL";
|
return "periodic_interval";
|
||||||
case MemoryDumpType::EXPLICITLY_TRIGGERED:
|
case MemoryDumpType::EXPLICITLY_TRIGGERED:
|
||||||
return "EXPLICITLY_TRIGGERED";
|
return "explicitly_triggered";
|
||||||
}
|
}
|
||||||
NOTREACHED();
|
NOTREACHED();
|
||||||
return "UNKNOWN";
|
return "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* MemoryDumpLevelOfDetailToString(
|
||||||
|
const MemoryDumpLevelOfDetail& level_of_detail) {
|
||||||
|
switch (level_of_detail) {
|
||||||
|
case MemoryDumpLevelOfDetail::LIGHT:
|
||||||
|
return "light";
|
||||||
|
case MemoryDumpLevelOfDetail::DETAILED:
|
||||||
|
return "detailed";
|
||||||
|
}
|
||||||
|
NOTREACHED();
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryDumpLevelOfDetail StringToMemoryDumpLevelOfDetail(
|
||||||
|
const std::string& str) {
|
||||||
|
if (str == "light")
|
||||||
|
return MemoryDumpLevelOfDetail::LIGHT;
|
||||||
|
if (str == "detailed")
|
||||||
|
return MemoryDumpLevelOfDetail::DETAILED;
|
||||||
|
NOTREACHED();
|
||||||
|
return MemoryDumpLevelOfDetail::LAST;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace trace_event
|
} // namespace trace_event
|
||||||
|
@@ -8,9 +8,10 @@
|
|||||||
// This file defines the types and structs used to issue memory dump requests.
|
// This file defines the types and structs used to issue memory dump requests.
|
||||||
// These are also used in the IPCs for coordinating inter-process memory dumps.
|
// These are also used in the IPCs for coordinating inter-process memory dumps.
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "base/base_export.h"
|
#include "base/base_export.h"
|
||||||
#include "base/callback.h"
|
#include "base/callback.h"
|
||||||
#include "base/trace_event/memory_dump_provider.h"
|
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
namespace trace_event {
|
namespace trace_event {
|
||||||
@@ -25,11 +26,18 @@ enum class MemoryDumpType {
|
|||||||
LAST = EXPLICITLY_TRIGGERED // For IPC macros.
|
LAST = EXPLICITLY_TRIGGERED // For IPC macros.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Returns the name in string for the dump type given.
|
// Tells the MemoryDumpProvider(s) how much detailed their dumps should be.
|
||||||
BASE_EXPORT const char* MemoryDumpTypeToString(const MemoryDumpType& dump_type);
|
// MemoryDumpProvider instances must guarantee that level of detail does not
|
||||||
|
// affect the total size reported in the root node, but only the granularity of
|
||||||
using MemoryDumpCallback = Callback<void(uint64 dump_guid, bool success)>;
|
// the child MemoryAllocatorDump(s).
|
||||||
|
enum class MemoryDumpLevelOfDetail {
|
||||||
|
LIGHT, // Few entries, typically a fixed number, per dump.
|
||||||
|
DETAILED, // Unrestricted amount of entries per dump.
|
||||||
|
LAST = DETAILED // For IPC Macros.
|
||||||
|
};
|
||||||
|
|
||||||
|
// Initial request arguments for a global memory dump. (see
|
||||||
|
// MemoryDumpManager::RequestGlobalMemoryDump()).
|
||||||
struct BASE_EXPORT MemoryDumpRequestArgs {
|
struct BASE_EXPORT MemoryDumpRequestArgs {
|
||||||
// Globally unique identifier. In multi-process dumps, all processes issue a
|
// Globally unique identifier. In multi-process dumps, all processes issue a
|
||||||
// local dump with the same guid. This allows the trace importers to
|
// local dump with the same guid. This allows the trace importers to
|
||||||
@@ -37,10 +45,19 @@ struct BASE_EXPORT MemoryDumpRequestArgs {
|
|||||||
uint64 dump_guid;
|
uint64 dump_guid;
|
||||||
|
|
||||||
MemoryDumpType dump_type;
|
MemoryDumpType dump_type;
|
||||||
|
MemoryDumpLevelOfDetail level_of_detail;
|
||||||
MemoryDumpArgs dump_args;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using MemoryDumpCallback = Callback<void(uint64 dump_guid, bool success)>;
|
||||||
|
|
||||||
|
BASE_EXPORT const char* MemoryDumpTypeToString(const MemoryDumpType& dump_type);
|
||||||
|
|
||||||
|
BASE_EXPORT const char* MemoryDumpLevelOfDetailToString(
|
||||||
|
const MemoryDumpLevelOfDetail& level_of_detail);
|
||||||
|
|
||||||
|
BASE_EXPORT MemoryDumpLevelOfDetail
|
||||||
|
StringToMemoryDumpLevelOfDetail(const std::string& str);
|
||||||
|
|
||||||
} // namespace trace_event
|
} // namespace trace_event
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
||||||
|
@@ -25,12 +25,8 @@ class ConvertableToTraceFormat;
|
|||||||
class MemoryDumpManager;
|
class MemoryDumpManager;
|
||||||
class MemoryDumpSessionState;
|
class MemoryDumpSessionState;
|
||||||
|
|
||||||
// ProcessMemoryDump is as a strongly typed container which enforces the data
|
// ProcessMemoryDump is as a strongly typed container which holds the dumps
|
||||||
// model for each memory dump and holds the dumps produced by the
|
// produced by the MemoryDumpProvider(s) for a specific process.
|
||||||
// MemoryDumpProvider(s) for a specific process.
|
|
||||||
// At trace generation time (i.e. when AsValue() is called), ProcessMemoryDump
|
|
||||||
// will compose a key-value dictionary of the various dumps obtained at trace
|
|
||||||
// dump point time.
|
|
||||||
class BASE_EXPORT ProcessMemoryDump {
|
class BASE_EXPORT ProcessMemoryDump {
|
||||||
public:
|
public:
|
||||||
struct MemoryAllocatorDumpEdge {
|
struct MemoryAllocatorDumpEdge {
|
||||||
|
@@ -168,7 +168,7 @@ ProcessMemoryMapsDumpProvider::~ProcessMemoryMapsDumpProvider() {
|
|||||||
bool ProcessMemoryMapsDumpProvider::OnMemoryDump(const MemoryDumpArgs& args,
|
bool ProcessMemoryMapsDumpProvider::OnMemoryDump(const MemoryDumpArgs& args,
|
||||||
ProcessMemoryDump* pmd) {
|
ProcessMemoryDump* pmd) {
|
||||||
// Snapshot of memory maps is not taken for light dump requests.
|
// Snapshot of memory maps is not taken for light dump requests.
|
||||||
if (args.level_of_detail == MemoryDumpArgs::LevelOfDetail::LOW)
|
if (args.level_of_detail == MemoryDumpLevelOfDetail::LIGHT)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
uint32 res = 0;
|
uint32 res = 0;
|
||||||
|
@@ -110,7 +110,7 @@ TEST(ProcessMemoryMapsDumpProviderTest, ParseProcSmaps) {
|
|||||||
const uint32 kProtR = ProcessMemoryMaps::VMRegion::kProtectionFlagsRead;
|
const uint32 kProtR = ProcessMemoryMaps::VMRegion::kProtectionFlagsRead;
|
||||||
const uint32 kProtW = ProcessMemoryMaps::VMRegion::kProtectionFlagsWrite;
|
const uint32 kProtW = ProcessMemoryMaps::VMRegion::kProtectionFlagsWrite;
|
||||||
const uint32 kProtX = ProcessMemoryMaps::VMRegion::kProtectionFlagsExec;
|
const uint32 kProtX = ProcessMemoryMaps::VMRegion::kProtectionFlagsExec;
|
||||||
const MemoryDumpArgs dump_args = {MemoryDumpArgs::LevelOfDetail::HIGH};
|
const MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED};
|
||||||
|
|
||||||
auto pmmdp = ProcessMemoryMapsDumpProvider::GetInstance();
|
auto pmmdp = ProcessMemoryMapsDumpProvider::GetInstance();
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ namespace base {
|
|||||||
namespace trace_event {
|
namespace trace_event {
|
||||||
|
|
||||||
TEST(ProcessMemoryTotalsDumpProviderTest, DumpRSS) {
|
TEST(ProcessMemoryTotalsDumpProviderTest, DumpRSS) {
|
||||||
const MemoryDumpArgs high_detail_args = {MemoryDumpArgs::LevelOfDetail::HIGH};
|
const MemoryDumpArgs high_detail_args = {MemoryDumpLevelOfDetail::DETAILED};
|
||||||
auto pmtdp = ProcessMemoryTotalsDumpProvider::GetInstance();
|
auto pmtdp = ProcessMemoryTotalsDumpProvider::GetInstance();
|
||||||
scoped_ptr<ProcessMemoryDump> pmd_before(new ProcessMemoryDump(nullptr));
|
scoped_ptr<ProcessMemoryDump> pmd_before(new ProcessMemoryDump(nullptr));
|
||||||
scoped_ptr<ProcessMemoryDump> pmd_after(new ProcessMemoryDump(nullptr));
|
scoped_ptr<ProcessMemoryDump> pmd_after(new ProcessMemoryDump(nullptr));
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#include "base/strings/string_tokenizer.h"
|
#include "base/strings/string_tokenizer.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "base/trace_event/memory_dump_manager.h"
|
#include "base/trace_event/memory_dump_manager.h"
|
||||||
|
#include "base/trace_event/memory_dump_request_args.h"
|
||||||
#include "base/trace_event/trace_event.h"
|
#include "base/trace_event/trace_event.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
@@ -44,16 +45,14 @@ const char kMemoryDumpConfigParam[] = "memory_dump_config";
|
|||||||
const char kTriggersParam[] = "triggers";
|
const char kTriggersParam[] = "triggers";
|
||||||
const char kPeriodicIntervalParam[] = "periodic_interval_ms";
|
const char kPeriodicIntervalParam[] = "periodic_interval_ms";
|
||||||
const char kModeParam[] = "mode";
|
const char kModeParam[] = "mode";
|
||||||
const char kDetailedParam[] = "detailed";
|
|
||||||
const char kLightParam[] = "light";
|
|
||||||
|
|
||||||
// Default configuration of memory dumps.
|
// Default configuration of memory dumps.
|
||||||
const TraceConfig::MemoryDumpTriggerConfig kDefaultHeavyMemoryDumpTrigger = {
|
const TraceConfig::MemoryDumpTriggerConfig kDefaultHeavyMemoryDumpTrigger = {
|
||||||
2000, // periodic_interval_ms
|
2000, // periodic_interval_ms
|
||||||
MemoryDumpArgs::LevelOfDetail::HIGH};
|
MemoryDumpLevelOfDetail::DETAILED};
|
||||||
const TraceConfig::MemoryDumpTriggerConfig kDefaultLightMemoryDumpTrigger = {
|
const TraceConfig::MemoryDumpTriggerConfig kDefaultLightMemoryDumpTrigger = {
|
||||||
250, // periodic_interval_ms
|
250, // periodic_interval_ms
|
||||||
MemoryDumpArgs::LevelOfDetail::LOW};
|
MemoryDumpLevelOfDetail::LIGHT};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@@ -465,7 +464,6 @@ void TraceConfig::SetMemoryDumpConfig(
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
MemoryDumpTriggerConfig dump_config;
|
MemoryDumpTriggerConfig dump_config;
|
||||||
std::string dump_type;
|
|
||||||
int interval = 0;
|
int interval = 0;
|
||||||
|
|
||||||
if (!trigger->GetInteger(kPeriodicIntervalParam, &interval)) {
|
if (!trigger->GetInteger(kPeriodicIntervalParam, &interval)) {
|
||||||
@@ -473,14 +471,10 @@ void TraceConfig::SetMemoryDumpConfig(
|
|||||||
}
|
}
|
||||||
DCHECK_GT(interval, 0);
|
DCHECK_GT(interval, 0);
|
||||||
dump_config.periodic_interval_ms = static_cast<uint32>(interval);
|
dump_config.periodic_interval_ms = static_cast<uint32>(interval);
|
||||||
dump_config.level_of_detail = MemoryDumpArgs::LevelOfDetail::LOW;
|
std::string level_of_detail_str;
|
||||||
|
trigger->GetString(kModeParam, &level_of_detail_str);
|
||||||
if (trigger->GetString(kModeParam, &dump_type)) {
|
dump_config.level_of_detail =
|
||||||
if (dump_type == kDetailedParam) {
|
StringToMemoryDumpLevelOfDetail(level_of_detail_str);
|
||||||
dump_config.level_of_detail = MemoryDumpArgs::LevelOfDetail::HIGH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
memory_dump_config_.push_back(dump_config);
|
memory_dump_config_.push_back(dump_config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -541,17 +535,8 @@ void TraceConfig::ToDict(base::DictionaryValue& dict) const {
|
|||||||
new base::DictionaryValue());
|
new base::DictionaryValue());
|
||||||
trigger_dict->SetInteger(kPeriodicIntervalParam,
|
trigger_dict->SetInteger(kPeriodicIntervalParam,
|
||||||
static_cast<int>(config.periodic_interval_ms));
|
static_cast<int>(config.periodic_interval_ms));
|
||||||
|
trigger_dict->SetString(
|
||||||
switch (config.level_of_detail) {
|
kModeParam, MemoryDumpLevelOfDetailToString(config.level_of_detail));
|
||||||
case MemoryDumpArgs::LevelOfDetail::LOW:
|
|
||||||
trigger_dict->SetString(kModeParam, kLightParam);
|
|
||||||
break;
|
|
||||||
case MemoryDumpArgs::LevelOfDetail::HIGH:
|
|
||||||
trigger_dict->SetString(kModeParam, kDetailedParam);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
NOTREACHED();
|
|
||||||
}
|
|
||||||
triggers_list->Append(trigger_dict.Pass());
|
triggers_list->Append(trigger_dict.Pass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include "base/base_export.h"
|
#include "base/base_export.h"
|
||||||
#include "base/gtest_prod_util.h"
|
#include "base/gtest_prod_util.h"
|
||||||
#include "base/trace_event/memory_dump_provider.h"
|
#include "base/trace_event/memory_dump_request_args.h"
|
||||||
#include "base/values.h"
|
#include "base/values.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
@@ -40,7 +40,7 @@ class BASE_EXPORT TraceConfig {
|
|||||||
// "memory-infra" category is enabled.
|
// "memory-infra" category is enabled.
|
||||||
struct MemoryDumpTriggerConfig {
|
struct MemoryDumpTriggerConfig {
|
||||||
uint32 periodic_interval_ms;
|
uint32 periodic_interval_ms;
|
||||||
MemoryDumpArgs::LevelOfDetail level_of_detail;
|
MemoryDumpLevelOfDetail level_of_detail;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<MemoryDumpTriggerConfig> MemoryDumpConfig;
|
typedef std::vector<MemoryDumpTriggerConfig> MemoryDumpConfig;
|
||||||
|
@@ -498,11 +498,11 @@ TEST(TraceConfigTest, TraceConfigFromMemoryConfigString) {
|
|||||||
EXPECT_EQ(2u, tc.memory_dump_config_.size());
|
EXPECT_EQ(2u, tc.memory_dump_config_.size());
|
||||||
|
|
||||||
EXPECT_EQ(200u, tc.memory_dump_config_[0].periodic_interval_ms);
|
EXPECT_EQ(200u, tc.memory_dump_config_[0].periodic_interval_ms);
|
||||||
EXPECT_EQ(MemoryDumpArgs::LevelOfDetail::LOW,
|
EXPECT_EQ(MemoryDumpLevelOfDetail::LIGHT,
|
||||||
tc.memory_dump_config_[0].level_of_detail);
|
tc.memory_dump_config_[0].level_of_detail);
|
||||||
|
|
||||||
EXPECT_EQ(2000u, tc.memory_dump_config_[1].periodic_interval_ms);
|
EXPECT_EQ(2000u, tc.memory_dump_config_[1].periodic_interval_ms);
|
||||||
EXPECT_EQ(MemoryDumpArgs::LevelOfDetail::HIGH,
|
EXPECT_EQ(MemoryDumpLevelOfDetail::DETAILED,
|
||||||
tc.memory_dump_config_[1].level_of_detail);
|
tc.memory_dump_config_[1].level_of_detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@ namespace trace_event {
|
|||||||
|
|
||||||
TEST(WinHeapDumpProviderTest, OnMemoryDump) {
|
TEST(WinHeapDumpProviderTest, OnMemoryDump) {
|
||||||
ProcessMemoryDump pmd(make_scoped_refptr(new MemoryDumpSessionState()));
|
ProcessMemoryDump pmd(make_scoped_refptr(new MemoryDumpSessionState()));
|
||||||
MemoryDumpArgs dump_args = {MemoryDumpArgs::LevelOfDetail::HIGH};
|
MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED};
|
||||||
|
|
||||||
WinHeapDumpProvider* winheap_dump_provider =
|
WinHeapDumpProvider* winheap_dump_provider =
|
||||||
WinHeapDumpProvider::GetInstance();
|
WinHeapDumpProvider::GetInstance();
|
||||||
|
@@ -29,16 +29,15 @@ IPC_STRUCT_TRAITS_END()
|
|||||||
IPC_STRUCT_TRAITS_BEGIN(base::trace_event::MemoryDumpRequestArgs)
|
IPC_STRUCT_TRAITS_BEGIN(base::trace_event::MemoryDumpRequestArgs)
|
||||||
IPC_STRUCT_TRAITS_MEMBER(dump_guid)
|
IPC_STRUCT_TRAITS_MEMBER(dump_guid)
|
||||||
IPC_STRUCT_TRAITS_MEMBER(dump_type)
|
IPC_STRUCT_TRAITS_MEMBER(dump_type)
|
||||||
IPC_STRUCT_TRAITS_MEMBER(dump_args)
|
IPC_STRUCT_TRAITS_MEMBER(level_of_detail)
|
||||||
IPC_STRUCT_TRAITS_END()
|
IPC_STRUCT_TRAITS_END()
|
||||||
|
|
||||||
IPC_STRUCT_TRAITS_BEGIN(base::trace_event::MemoryDumpArgs)
|
IPC_STRUCT_TRAITS_BEGIN(base::trace_event::MemoryDumpArgs)
|
||||||
IPC_STRUCT_TRAITS_MEMBER(level_of_detail)
|
IPC_STRUCT_TRAITS_MEMBER(level_of_detail)
|
||||||
IPC_STRUCT_TRAITS_END()
|
IPC_STRUCT_TRAITS_END()
|
||||||
|
|
||||||
IPC_ENUM_TRAITS_MAX_VALUE(
|
IPC_ENUM_TRAITS_MAX_VALUE(base::trace_event::MemoryDumpLevelOfDetail,
|
||||||
base::trace_event::MemoryDumpArgs::LevelOfDetail,
|
base::trace_event::MemoryDumpLevelOfDetail::LAST)
|
||||||
base::trace_event::MemoryDumpArgs::LevelOfDetail::LAST)
|
|
||||||
|
|
||||||
IPC_ENUM_TRAITS_MAX_VALUE(
|
IPC_ENUM_TRAITS_MAX_VALUE(
|
||||||
base::trace_event::MemoryDumpType,
|
base::trace_event::MemoryDumpType,
|
||||||
|
@@ -211,10 +211,9 @@ Response TracingHandler::RequestMemoryDump(DevToolsCommandId command_id) {
|
|||||||
if (!IsRecording())
|
if (!IsRecording())
|
||||||
return Response::InternalError("Tracing is not started");
|
return Response::InternalError("Tracing is not started");
|
||||||
|
|
||||||
base::trace_event::MemoryDumpArgs dump_args = {
|
|
||||||
base::trace_event::MemoryDumpArgs::LevelOfDetail::HIGH};
|
|
||||||
base::trace_event::MemoryDumpManager::GetInstance()->RequestGlobalDump(
|
base::trace_event::MemoryDumpManager::GetInstance()->RequestGlobalDump(
|
||||||
base::trace_event::MemoryDumpType::EXPLICITLY_TRIGGERED, dump_args,
|
base::trace_event::MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
|
base::trace_event::MemoryDumpLevelOfDetail::DETAILED,
|
||||||
base::Bind(&TracingHandler::OnMemoryDumpFinished,
|
base::Bind(&TracingHandler::OnMemoryDumpFinished,
|
||||||
weak_factory_.GetWeakPtr(), command_id));
|
weak_factory_.GetWeakPtr(), command_id));
|
||||||
return Response::OK();
|
return Response::OK();
|
||||||
|
@@ -38,9 +38,9 @@ class MockDumpProvider : public base::trace_event::MemoryDumpProvider {
|
|||||||
class MemoryTracingTest : public ContentBrowserTest {
|
class MemoryTracingTest : public ContentBrowserTest {
|
||||||
public:
|
public:
|
||||||
void DoRequestGlobalDump(const base::trace_event::MemoryDumpCallback& cb) {
|
void DoRequestGlobalDump(const base::trace_event::MemoryDumpCallback& cb) {
|
||||||
MemoryDumpArgs dump_args = { MemoryDumpArgs::LevelOfDetail::HIGH };
|
|
||||||
MemoryDumpManager::GetInstance()->RequestGlobalDump(
|
MemoryDumpManager::GetInstance()->RequestGlobalDump(
|
||||||
MemoryDumpType::EXPLICITLY_TRIGGERED, dump_args, cb);
|
MemoryDumpType::EXPLICITLY_TRIGGERED,
|
||||||
|
base::trace_event::MemoryDumpLevelOfDetail::DETAILED, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used as callback argument for MemoryDumpManager::RequestGlobalDump():
|
// Used as callback argument for MemoryDumpManager::RequestGlobalDump():
|
||||||
|
@@ -23,11 +23,13 @@ bool WebMemoryDumpProviderAdapter::OnMemoryDump(
|
|||||||
base::trace_event::ProcessMemoryDump* pmd) {
|
base::trace_event::ProcessMemoryDump* pmd) {
|
||||||
blink::WebMemoryDumpLevelOfDetail level;
|
blink::WebMemoryDumpLevelOfDetail level;
|
||||||
switch (args.level_of_detail) {
|
switch (args.level_of_detail) {
|
||||||
case base::trace_event::MemoryDumpArgs::LevelOfDetail::LOW:
|
case base::trace_event::MemoryDumpLevelOfDetail::LIGHT:
|
||||||
level = blink::WebMemoryDumpLevelOfDetail::Low;
|
// TODO(primiano): switch to actual constant once the corresponding
|
||||||
|
// rename lands in blink and rolls.
|
||||||
|
level = static_cast<blink::WebMemoryDumpLevelOfDetail>(0);
|
||||||
break;
|
break;
|
||||||
case base::trace_event::MemoryDumpArgs::LevelOfDetail::HIGH:
|
case base::trace_event::MemoryDumpLevelOfDetail::DETAILED:
|
||||||
level = blink::WebMemoryDumpLevelOfDetail::High;
|
level = static_cast<blink::WebMemoryDumpLevelOfDetail>(1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
NOTREACHED();
|
NOTREACHED();
|
||||||
|
@@ -104,8 +104,7 @@ void V8IsolateMemoryDumpProvider::DumpHeapStatistics(
|
|||||||
heap_statistics.total_heap_size() - known_spaces_size);
|
heap_statistics.total_heap_size() - known_spaces_size);
|
||||||
|
|
||||||
// If light dump is requested, then object statistics are not dumped
|
// If light dump is requested, then object statistics are not dumped
|
||||||
if (args.level_of_detail ==
|
if (args.level_of_detail == base::trace_event::MemoryDumpLevelOfDetail::LIGHT)
|
||||||
base::trace_event::MemoryDumpArgs::LevelOfDetail::LOW)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Dump statistics of the heap's live objects from last GC.
|
// Dump statistics of the heap's live objects from last GC.
|
||||||
|
@@ -24,7 +24,7 @@ TEST_F(V8MemoryDumpProviderTest, DumpStatistics) {
|
|||||||
scoped_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump(
|
scoped_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump(
|
||||||
new base::trace_event::ProcessMemoryDump(nullptr));
|
new base::trace_event::ProcessMemoryDump(nullptr));
|
||||||
base::trace_event::MemoryDumpArgs dump_args = {
|
base::trace_event::MemoryDumpArgs dump_args = {
|
||||||
base::trace_event::MemoryDumpArgs::LevelOfDetail::HIGH};
|
base::trace_event::MemoryDumpLevelOfDetail::DETAILED};
|
||||||
instance_->isolate_memory_dump_provider_for_testing()->OnMemoryDump(
|
instance_->isolate_memory_dump_provider_for_testing()->OnMemoryDump(
|
||||||
dump_args, process_memory_dump.get());
|
dump_args, process_memory_dump.get());
|
||||||
const base::trace_event::ProcessMemoryDump::AllocatorDumpsMap&
|
const base::trace_event::ProcessMemoryDump::AllocatorDumpsMap&
|
||||||
|
@@ -13,7 +13,7 @@ TEST(SkiaMemoryDumpProviderTest, OnMemoryDump) {
|
|||||||
scoped_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump(
|
scoped_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump(
|
||||||
new base::trace_event::ProcessMemoryDump(nullptr));
|
new base::trace_event::ProcessMemoryDump(nullptr));
|
||||||
base::trace_event::MemoryDumpArgs dump_args = {
|
base::trace_event::MemoryDumpArgs dump_args = {
|
||||||
base::trace_event::MemoryDumpArgs::LevelOfDetail::HIGH};
|
base::trace_event::MemoryDumpLevelOfDetail::DETAILED};
|
||||||
SkiaMemoryDumpProvider::GetInstance()->OnMemoryDump(
|
SkiaMemoryDumpProvider::GetInstance()->OnMemoryDump(
|
||||||
dump_args, process_memory_dump.get());
|
dump_args, process_memory_dump.get());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user