diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2021-05-14 17:04:40 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2021-05-14 17:04:40 +0000 |
commit | f061f8d046c3f51eeec9892c06edd450b1ee131f (patch) | |
tree | 5a89086a96b77c70f08b5e2239ce8ba48bf0459d | |
parent | 760224b9184b439f19ba3fa10e47a5fa68e76764 (diff) | |
parent | 9ce26a8dc26c1aed923dec621cad0dd24c2ed836 (diff) | |
download | perfetto-f061f8d046c3f51eeec9892c06edd450b1ee131f.tar.gz |
Merge "Do not add libc.malloc if all_heaps is set."
-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 |