diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2021-05-14 18:19:39 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-05-14 18:19:39 +0000 |
commit | f1603603a1901086849a537ca30a8163ff6837a9 (patch) | |
tree | bf73d7f6bf69267f9c2af63655f6b120eddd5590 | |
parent | 0bbec4577d6f55a46e5386c583c6466977408670 (diff) | |
parent | d717df3e4babd8ffd8abea12c83545c3b966f5b8 (diff) | |
download | perfetto-f1603603a1901086849a537ca30a8163ff6837a9.tar.gz |
Merge "Do not add libc.malloc if all_heaps is set." am: f061f8d046 am: 59cd7d1aa7 am: d717df3e4b
Original change: https://android-review.googlesource.com/c/platform/external/perfetto/+/1708474
Change-Id: Ic17fd3d5d4f5939deeffaa7623fc213a5c3c03bb
-rw-r--r-- | src/profiling/memory/heapprofd_producer.cc | 2 | ||||
-rw-r--r-- | src/profiling/memory/heapprofd_producer_unittest.cc | 24 |
2 files changed, 25 insertions, 1 deletions
diff --git a/src/profiling/memory/heapprofd_producer.cc b/src/profiling/memory/heapprofd_producer.cc index 16da1faa6..3403d3773 100644 --- a/src/profiling/memory/heapprofd_producer.cc +++ b/src/profiling/memory/heapprofd_producer.cc @@ -152,7 +152,7 @@ bool HeapprofdConfigToClientConfiguration( std::vector<std::string> heaps = heapprofd_config.heaps(); std::vector<uint64_t> heap_intervals = heapprofd_config.heap_sampling_intervals(); - if (heaps.empty()) { + if (heaps.empty() && !cli_config->all_heaps) { heaps.push_back("libc.malloc"); } diff --git a/src/profiling/memory/heapprofd_producer_unittest.cc b/src/profiling/memory/heapprofd_producer_unittest.cc index 8a751451a..b1ee3f8a6 100644 --- a/src/profiling/memory/heapprofd_producer_unittest.cc +++ b/src/profiling/memory/heapprofd_producer_unittest.cc @@ -202,5 +202,29 @@ TEST(HeapprofdConfigToClientConfigurationTest, AdaptiveSamplingWithMax) { 4 * 4096u); } +TEST(HeapprofdConfigToClientConfigurationTest, AllHeaps) { + HeapprofdConfig cfg; + cfg.set_all_heaps(true); + cfg.set_sampling_interval_bytes(4096); + ClientConfiguration cli_config; + ASSERT_TRUE(HeapprofdConfigToClientConfiguration(cfg, &cli_config)); + EXPECT_EQ(cli_config.num_heaps, 0u); + EXPECT_EQ(cli_config.default_interval, 4096u); +} + +TEST(HeapprofdConfigToClientConfigurationTest, AllHeapsAndExplicit) { + HeapprofdConfig cfg; + cfg.set_all_heaps(true); + cfg.set_sampling_interval_bytes(4096); + cfg.add_heaps("foo"); + cfg.add_heap_sampling_intervals(1024u); + ClientConfiguration cli_config; + ASSERT_TRUE(HeapprofdConfigToClientConfiguration(cfg, &cli_config)); + EXPECT_EQ(cli_config.num_heaps, 1u); + EXPECT_STREQ(cli_config.heaps[0].name, "foo"); + EXPECT_EQ(cli_config.heaps[0].interval, 1024u); + EXPECT_EQ(cli_config.default_interval, 4096u); +} + } // namespace profiling } // namespace perfetto |