Merge "Add NullTraceWriter"
diff --git a/include/perfetto/tracing/core/service.h b/include/perfetto/tracing/core/service.h
index ab8d475..ed810ec 100644
--- a/include/perfetto/tracing/core/service.h
+++ b/include/perfetto/tracing/core/service.h
@@ -146,6 +146,7 @@
   virtual std::unique_ptr<ProducerEndpoint> ConnectProducer(
       Producer*,
       uid_t uid,
+      const std::string& name,
       size_t shared_memory_size_hint_bytes = 0) = 0;
 
   // Coonects a Consumer instance and obtains a ConsumerEndpoint, which is
diff --git a/include/perfetto/tracing/ipc/producer_ipc_client.h b/include/perfetto/tracing/ipc/producer_ipc_client.h
index caa1aa7..fb66c71 100644
--- a/include/perfetto/tracing/ipc/producer_ipc_client.h
+++ b/include/perfetto/tracing/ipc/producer_ipc_client.h
@@ -41,8 +41,11 @@
   // callbacks invoked on the Producer interface: no more Producer callbacks are
   // invoked immediately after its destruction and any pending callback will be
   // dropped.
-  static std::unique_ptr<Service::ProducerEndpoint>
-  Connect(const char* service_sock_name, Producer*, base::TaskRunner*);
+  static std::unique_ptr<Service::ProducerEndpoint> Connect(
+      const char* service_sock_name,
+      Producer*,
+      const std::string& producer_name,
+      base::TaskRunner*);
 
  protected:
   ProducerIPCClient() = delete;
diff --git a/perfetto.rc b/perfetto.rc
index 65256a9..23abaf2 100644
--- a/perfetto.rc
+++ b/perfetto.rc
@@ -31,6 +31,7 @@
     # unexpectedly.
     onrestart exec_background - nobody shell -- /system/bin/traced_probes --cleanup-after-crash
     file /dev/kmsg w
+    capabilities DAC_READ_SEARCH
 
 on property:sys.traced.enable_override=1
     setprop persist.traced.enable 1
diff --git a/protos/perfetto/config/perfetto_config.proto b/protos/perfetto/config/perfetto_config.proto
index 3984b9e..e149b49 100644
--- a/protos/perfetto/config/perfetto_config.proto
+++ b/protos/perfetto/config/perfetto_config.proto
@@ -162,8 +162,6 @@
 
   message ProducerConfig {
     // Identifies the producer for which this config is for.
-    // TODO: Current behaviour just uses the first producer config,
-    // regardless of name.
     optional string producer_name = 1;
 
     // Specifies the preferred size of the shared memory buffer. If the size is
diff --git a/protos/perfetto/config/trace_config.proto b/protos/perfetto/config/trace_config.proto
index 2c3c481..c5d057a 100644
--- a/protos/perfetto/config/trace_config.proto
+++ b/protos/perfetto/config/trace_config.proto
@@ -84,8 +84,6 @@
 
   message ProducerConfig {
     // Identifies the producer for which this config is for.
-    // TODO(taylori): Current behaviour just uses the first producer config,
-    // regardless of name.
     optional string producer_name = 1;
 
     // Specifies the preferred size of the shared memory buffer. If the size is
diff --git a/src/ftrace_reader/ftrace_config_muxer.cc b/src/ftrace_reader/ftrace_config_muxer.cc
index 3642b24..641bd28 100644
--- a/src/ftrace_reader/ftrace_config_muxer.cc
+++ b/src/ftrace_reader/ftrace_config_muxer.cc
@@ -262,6 +262,8 @@
     if (ftrace_->EnableEvent(event->group, event->name)) {
       current_state_.ftrace_events.insert(name);
       *actual.add_ftrace_events() = name;
+    } else {
+      PERFETTO_DPLOG("Failed to enable %s.", name.c_str());
     }
   }
 
diff --git a/src/protozero/scattered_stream_writer.cc b/src/protozero/scattered_stream_writer.cc
index 8605e69..305fe0f 100644
--- a/src/protozero/scattered_stream_writer.cc
+++ b/src/protozero/scattered_stream_writer.cc
@@ -65,7 +65,7 @@
   }
   uint8_t* begin = write_ptr_;
   write_ptr_ += size;
-#ifndef NDEBUG
+#if PERFETTO_DCHECK_IS_ON()
   memset(begin, 0, size);
 #endif
   return begin;
diff --git a/src/traced/probes/filesystem/inode_file_data_source.cc b/src/traced/probes/filesystem/inode_file_data_source.cc
index 2f5c590..3186b3f 100644
--- a/src/traced/probes/filesystem/inode_file_data_source.cc
+++ b/src/traced/probes/filesystem/inode_file_data_source.cc
@@ -48,38 +48,41 @@
     directory += "/";
     if (!dir)
       continue;
+
+    struct stat buf;
+    if (lstat(directory.c_str(), &buf) != 0) {
+      PERFETTO_DPLOG("lstat %s", directory.c_str());
+      continue;
+    }
+    if (S_ISLNK(buf.st_mode))
+      continue;
+
+    BlockDeviceID block_device_id = buf.st_dev;
+
     while ((entry = readdir(dir.get())) != nullptr) {
       std::string filename = entry->d_name;
       if (filename == "." || filename == "..")
         continue;
       std::string filepath = directory + filename;
 
-      struct stat buf;
-      if (lstat(filepath.c_str(), &buf) != 0)
-        continue;
-
-      // This might happen on filesystems that do not return
-      // information in entry->d_type.
-      if (S_ISLNK(buf.st_mode))
-        continue;
-
       Inode inode_number = entry->d_ino;
-      BlockDeviceID block_device_id = buf.st_dev;
 
       protos::pbzero::InodeFileMap_Entry_Type type =
           protos::pbzero::InodeFileMap_Entry_Type_UNKNOWN;
       // Readdir and stat not guaranteed to have directory info for all systems
-      if (entry->d_type == DT_DIR || S_ISDIR(buf.st_mode)) {
+      if (entry->d_type == DT_DIR) {
         // Continue iterating through files if current entry is a directory
         queue.push_back(filepath);
         type = protos::pbzero::InodeFileMap_Entry_Type_DIRECTORY;
-      } else if (entry->d_type == DT_REG || S_ISREG(buf.st_mode)) {
+      } else if (entry->d_type == DT_REG) {
         type = protos::pbzero::InodeFileMap_Entry_Type_FILE;
       }
 
       if (!fn(block_device_id, inode_number, filepath, type))
         return;
     }
+    if (errno != 0)
+      PERFETTO_DPLOG("readdir %s", directory.c_str());
   }
 }
 
diff --git a/src/traced/probes/probes_producer.cc b/src/traced/probes/probes_producer.cc
index 14d919d..5d29fd9 100644
--- a/src/traced/probes/probes_producer.cc
+++ b/src/traced/probes/probes_producer.cc
@@ -240,7 +240,8 @@
 void ProbesProducer::Connect() {
   PERFETTO_DCHECK(state_ == kNotConnected);
   state_ = kConnecting;
-  endpoint_ = ProducerIPCClient::Connect(socket_name_, this, task_runner_);
+  endpoint_ = ProducerIPCClient::Connect(
+      socket_name_, this, "com.google.perfetto.traced_probes", task_runner_);
 }
 
 void ProbesProducer::IncreaseConnectionBackoff() {
diff --git a/src/tracing/core/service_impl.cc b/src/tracing/core/service_impl.cc
index 1d3acef..04612ee 100644
--- a/src/tracing/core/service_impl.cc
+++ b/src/tracing/core/service_impl.cc
@@ -91,6 +91,7 @@
 std::unique_ptr<Service::ProducerEndpoint> ServiceImpl::ConnectProducer(
     Producer* producer,
     uid_t uid,
+    const std::string& producer_name,
     size_t shared_memory_size_hint_bytes) {
   PERFETTO_DCHECK_THREAD(thread_checker_);
 
@@ -107,8 +108,8 @@
   const ProducerID id = GetNextProducerID();
   PERFETTO_DLOG("Producer %" PRIu16 " connected", id);
 
-  std::unique_ptr<ProducerEndpointImpl> endpoint(
-      new ProducerEndpointImpl(id, uid, this, task_runner_, producer));
+  std::unique_ptr<ProducerEndpointImpl> endpoint(new ProducerEndpointImpl(
+      id, uid, this, task_runner_, producer, producer_name));
   auto it_and_inserted = producers_.emplace(id, endpoint.get());
   PERFETTO_DCHECK(it_and_inserted.second);
   shared_memory_size_hint_bytes_ = shared_memory_size_hint_bytes;
@@ -226,7 +227,6 @@
   // though, because this assumes that each tracing session creates at most one
   // data source instance in each Producer, and each data source has only one
   // TraceWriter.
-  // TODO(taylori): Handle multiple producers/producer_configs.
   // auto first_producer_config = cfg.producers()[0];
   // if (tracing_sessions_.size() >=
   //     (kDefaultShmSize / first_producer_config.page_size_kb() / 2)) {
@@ -309,8 +309,18 @@
   for (const TraceConfig::DataSource& cfg_data_source : cfg.data_sources()) {
     // Scan all the registered data sources with a matching name.
     auto range = data_sources_.equal_range(cfg_data_source.config().name());
-    for (auto it = range.first; it != range.second; it++)
-      CreateDataSourceInstance(cfg_data_source, it->second, tracing_session);
+    for (auto it = range.first; it != range.second; it++) {
+      TraceConfig::ProducerConfig producer_config;
+      for (auto& config : cfg.producers()) {
+        if (GetProducer(it->second.producer_id)->name_ ==
+            config.producer_name()) {
+          producer_config = config;
+          break;
+        }
+      }
+      CreateDataSourceInstance(cfg_data_source, producer_config, it->second,
+                               tracing_session);
+    }
   }
 
   // Trigger delayed task if the trace is time limited.
@@ -625,11 +635,18 @@
 
   for (auto& iter : tracing_sessions_) {
     TracingSession& tracing_session = iter.second;
+    TraceConfig::ProducerConfig producer_config;
+    for (auto& config : tracing_session.config.producers()) {
+      if (producer->name_ == config.producer_name()) {
+        producer_config = config;
+        break;
+      }
+    }
     for (const TraceConfig::DataSource& cfg_data_source :
          tracing_session.config.data_sources()) {
       if (cfg_data_source.config().name() == desc.name())
-        CreateDataSourceInstance(cfg_data_source, reg_ds->second,
-                                 &tracing_session);
+        CreateDataSourceInstance(cfg_data_source, producer_config,
+                                 reg_ds->second, &tracing_session);
     }
   }
 }
@@ -668,6 +685,7 @@
 
 void ServiceImpl::CreateDataSourceInstance(
     const TraceConfig::DataSource& cfg_data_source,
+    const TraceConfig::ProducerConfig& producer_config,
     const RegisteredDataSource& data_source,
     TracingSession* tracing_session) {
   PERFETTO_DCHECK_THREAD(thread_checker_);
@@ -709,14 +727,14 @@
   PERFETTO_DLOG("Starting data source %s with target buffer %" PRIu16,
                 ds_config.name().c_str(), global_id);
   if (!producer->shared_memory()) {
-    // TODO(taylori): Handle multiple producers/producer configs.
-    producer->shared_buffer_page_size_kb_ =
-        std::min((tracing_session->GetDesiredPageSizeKb() == 0)
-                     ? kDefaultShmPageSizeKb
-                     : tracing_session->GetDesiredPageSizeKb(),
-                 kMaxShmPageSizeKb);
+    producer->shared_buffer_page_size_kb_ = std::min<size_t>(
+        (producer_config.page_size_kb() == 0) ? kDefaultShmPageSizeKb
+                                              : producer_config.page_size_kb(),
+        kMaxShmPageSizeKb);
+
     size_t shm_size =
-        std::min(tracing_session->GetDesiredShmSizeKb() * 1024, kMaxShmSize);
+        std::min<size_t>(producer_config.shm_size_kb() * 1024, kMaxShmSize);
+
     if (shm_size % base::kPageSize || shm_size < base::kPageSize)
       shm_size = std::min(shared_memory_size_hint_bytes_, kMaxShmSize);
     if (shm_size % base::kPageSize || shm_size < base::kPageSize ||
@@ -1003,12 +1021,14 @@
     uid_t uid,
     ServiceImpl* service,
     base::TaskRunner* task_runner,
-    Producer* producer)
+    Producer* producer,
+    const std::string& producer_name)
     : id_(id),
       uid_(uid),
       service_(service),
       task_runner_(task_runner),
-      producer_(producer) {
+      producer_(producer),
+      name_(producer_name) {
   // TODO(primiano): make the page-size for the SHM dynamic and find a way to
   // communicate that to the Producer (add a field to the
   // InitializeConnectionResponse IPC).
@@ -1131,18 +1151,4 @@
                                             const TraceConfig& new_config)
     : consumer(consumer_ptr), config(new_config) {}
 
-size_t ServiceImpl::TracingSession::GetDesiredShmSizeKb() {
-  if (config.producers_size() == 0)
-    return 0;
-  // TODO(taylori): Handle multiple producers/producer configs.
-  return config.producers()[0].shm_size_kb();
-}
-
-size_t ServiceImpl::TracingSession::GetDesiredPageSizeKb() {
-  if (config.producers_size() == 0)
-    return 0;
-  // TODO(taylori): Handle multiple producers/producer configs.
-  return config.producers()[0].page_size_kb();
-}
-
 }  // namespace perfetto
diff --git a/src/tracing/core/service_impl.h b/src/tracing/core/service_impl.h
index ce76ac7..4f7428c 100644
--- a/src/tracing/core/service_impl.h
+++ b/src/tracing/core/service_impl.h
@@ -60,7 +60,8 @@
                          uid_t uid,
                          ServiceImpl*,
                          base::TaskRunner*,
-                         Producer*);
+                         Producer*,
+                         const std::string& producer_name);
     ~ProducerEndpointImpl() override;
 
     // Service::ProducerEndpoint implementation.
@@ -90,10 +91,10 @@
     SharedMemoryABI shmem_abi_;
     size_t shared_memory_size_hint_bytes_ = 0;
     DataSourceID last_data_source_id_ = 0;
+    const std::string name_;
 
     // This is used only in in-process configurations (mostly tests).
     std::unique_ptr<SharedMemoryArbiterImpl> inproc_shmem_arbiter_;
-
     PERFETTO_THREAD_CHECKER(thread_checker_)
   };
 
@@ -162,6 +163,7 @@
   std::unique_ptr<Service::ProducerEndpoint> ConnectProducer(
       Producer*,
       uid_t uid,
+      const std::string& producer_name,
       size_t shared_memory_size_hint_bytes = 0) override;
 
   std::unique_ptr<Service::ConsumerEndpoint> ConnectConsumer(
@@ -193,12 +195,6 @@
 
     size_t num_buffers() const { return buffers_index.size(); }
 
-    // Retrieves the page size from the trace config.
-    size_t GetDesiredPageSizeKb();
-
-    // Retrieves the SHM size from the trace config.
-    size_t GetDesiredShmSizeKb();
-
     int next_write_period_ms() const {
       PERFETTO_DCHECK(write_period_ms);
       // TODO(primiano): this will drift. Synchronize % period so it aligns.
@@ -243,6 +239,7 @@
   ServiceImpl& operator=(const ServiceImpl&) = delete;
 
   void CreateDataSourceInstance(const TraceConfig::DataSource&,
+                                const TraceConfig::ProducerConfig&,
                                 const RegisteredDataSource&,
                                 TracingSession*);
 
diff --git a/src/tracing/core/service_impl_unittest.cc b/src/tracing/core/service_impl_unittest.cc
index 53afd92..a10dea9 100644
--- a/src/tracing/core/service_impl_unittest.cc
+++ b/src/tracing/core/service_impl_unittest.cc
@@ -90,9 +90,9 @@
   MockProducer mock_producer_1;
   MockProducer mock_producer_2;
   std::unique_ptr<Service::ProducerEndpoint> producer_endpoint_1 =
-      svc->ConnectProducer(&mock_producer_1, 123u /* uid */);
+      svc->ConnectProducer(&mock_producer_1, 123u /* uid */, "mock_producer_1");
   std::unique_ptr<Service::ProducerEndpoint> producer_endpoint_2 =
-      svc->ConnectProducer(&mock_producer_2, 456u /* uid */);
+      svc->ConnectProducer(&mock_producer_2, 456u /* uid */, "mock_producer_2");
 
   ASSERT_TRUE(producer_endpoint_1);
   ASSERT_TRUE(producer_endpoint_2);
@@ -149,7 +149,7 @@
 TEST_F(ServiceImplTest, EnableAndDisableTracing) {
   MockProducer mock_producer;
   std::unique_ptr<Service::ProducerEndpoint> producer_endpoint =
-      svc->ConnectProducer(&mock_producer, 123u /* uid */);
+      svc->ConnectProducer(&mock_producer, 123u /* uid */, "mock_producer");
   MockConsumer mock_consumer;
   std::unique_ptr<Service::ConsumerEndpoint> consumer_endpoint =
       svc->ConnectConsumer(&mock_consumer);
@@ -201,11 +201,13 @@
 
   MockProducer mock_producer;
   std::unique_ptr<Service::ProducerEndpoint> producer_endpoint =
-      svc->ConnectProducer(&mock_producer, geteuid() + 1 /* uid */);
+      svc->ConnectProducer(&mock_producer, geteuid() + 1 /* uid */,
+                           "mock_producer");
 
   MockProducer mock_producer_sameuid;
   std::unique_ptr<Service::ProducerEndpoint> producer_endpoint_sameuid =
-      svc->ConnectProducer(&mock_producer_sameuid, geteuid() /* uid */);
+      svc->ConnectProducer(&mock_producer_sameuid, geteuid() /* uid */,
+                           "mock_producer_sameuid");
 
   EXPECT_CALL(mock_producer, OnConnect()).Times(0);
   EXPECT_CALL(mock_producer_sameuid, OnConnect());
@@ -224,7 +226,7 @@
   EXPECT_CALL(mock_producer_sameuid, OnDisconnect());
   EXPECT_CALL(mock_producer, OnConnect());
   producer_endpoint_sameuid =
-      svc->ConnectProducer(&mock_producer, geteuid() + 1);
+      svc->ConnectProducer(&mock_producer, geteuid() + 1, "mock_producer");
 
   EXPECT_CALL(mock_producer, OnDisconnect());
   task_runner.RunUntilIdle();
@@ -233,7 +235,7 @@
 TEST_F(ServiceImplTest, DisconnectConsumerWhileTracing) {
   MockProducer mock_producer;
   std::unique_ptr<Service::ProducerEndpoint> producer_endpoint =
-      svc->ConnectProducer(&mock_producer, 123u /* uid */);
+      svc->ConnectProducer(&mock_producer, 123u /* uid */, "mock_producer");
   MockConsumer mock_consumer;
   std::unique_ptr<Service::ConsumerEndpoint> consumer_endpoint =
       svc->ConnectConsumer(&mock_consumer);
@@ -273,7 +275,7 @@
 TEST_F(ServiceImplTest, ReconnectProducerWhileTracing) {
   MockProducer mock_producer;
   std::unique_ptr<Service::ProducerEndpoint> producer_endpoint =
-      svc->ConnectProducer(&mock_producer, 123u /* uid */);
+      svc->ConnectProducer(&mock_producer, 123u /* uid */, "mock_producer");
   MockConsumer mock_consumer;
   std::unique_ptr<Service::ConsumerEndpoint> consumer_endpoint =
       svc->ConnectConsumer(&mock_consumer);
@@ -305,7 +307,8 @@
   // Reconnecting a producer with a matching data source should see that data
   // source getting enabled.
   EXPECT_CALL(mock_producer, OnConnect());
-  producer_endpoint = svc->ConnectProducer(&mock_producer, 123u /* uid */);
+  producer_endpoint =
+      svc->ConnectProducer(&mock_producer, 123u /* uid */, "mock_producer");
   task_runner.RunUntilIdle();
   EXPECT_CALL(mock_producer, CreateDataSourceInstance(_, _));
   EXPECT_CALL(mock_producer, TearDownDataSourceInstance(_));
@@ -341,7 +344,7 @@
     auto on_connect = task_runner.CreateCheckpoint(checkpoint_name);
     std::unique_ptr<MockProducer> producer(new MockProducer());
     std::unique_ptr<Service::ProducerEndpoint> producer_endpoint =
-        svc->ConnectProducer(producer.get(), 123u /* uid */);
+        svc->ConnectProducer(producer.get(), 123u /* uid */, "mock_producer");
     EXPECT_CALL(*producer, OnConnect()).WillOnce(Invoke(on_connect));
     task_runner.RunUntilCheckpoint(checkpoint_name);
     EXPECT_EQ(&*producer_endpoint, svc->GetProducer(svc->last_producer_id_));
@@ -389,7 +392,7 @@
 TEST_F(ServiceImplTest, WriteIntoFileAndStopOnMaxSize) {
   MockProducer mock_producer;
   std::unique_ptr<Service::ProducerEndpoint> producer_endpoint =
-      svc->ConnectProducer(&mock_producer, 123u /* uid */);
+      svc->ConnectProducer(&mock_producer, 123u /* uid */, "mock_producer");
   MockConsumer mock_consumer;
   std::unique_ptr<Service::ConsumerEndpoint> consumer_endpoint =
       svc->ConnectConsumer(&mock_consumer);
diff --git a/src/tracing/ipc/producer/producer_ipc_client_impl.cc b/src/tracing/ipc/producer/producer_ipc_client_impl.cc
index 541e080..ee4431e 100644
--- a/src/tracing/ipc/producer/producer_ipc_client_impl.cc
+++ b/src/tracing/ipc/producer/producer_ipc_client_impl.cc
@@ -40,18 +40,21 @@
 std::unique_ptr<Service::ProducerEndpoint> ProducerIPCClient::Connect(
     const char* service_sock_name,
     Producer* producer,
+    const std::string& producer_name,
     base::TaskRunner* task_runner) {
-  return std::unique_ptr<Service::ProducerEndpoint>(
-      new ProducerIPCClientImpl(service_sock_name, producer, task_runner));
+  return std::unique_ptr<Service::ProducerEndpoint>(new ProducerIPCClientImpl(
+      service_sock_name, producer, producer_name, task_runner));
 }
 
 ProducerIPCClientImpl::ProducerIPCClientImpl(const char* service_sock_name,
                                              Producer* producer,
+                                             const std::string& producer_name,
                                              base::TaskRunner* task_runner)
     : producer_(producer),
       task_runner_(task_runner),
       ipc_channel_(ipc::Client::CreateInstance(service_sock_name, task_runner)),
-      producer_port_(this /* event_listener */) {
+      producer_port_(this /* event_listener */),
+      name_(producer_name) {
   ipc_channel_->BindService(producer_port_.GetWeakPtr());
   PERFETTO_DCHECK_THREAD(thread_checker_);
 }
@@ -71,8 +74,9 @@
       [this](ipc::AsyncResult<protos::InitializeConnectionResponse> resp) {
         OnConnectionInitialized(resp.success());
       });
-  producer_port_.InitializeConnection(protos::InitializeConnectionRequest(),
-                                      std::move(on_init));
+  protos::InitializeConnectionRequest req;
+  req.set_producer_name(name_);
+  producer_port_.InitializeConnection(req, std::move(on_init));
 
   // Create the back channel to receive commands from the Service.
   ipc::Deferred<protos::GetAsyncCommandResponse> on_cmd;
diff --git a/src/tracing/ipc/producer/producer_ipc_client_impl.h b/src/tracing/ipc/producer/producer_ipc_client_impl.h
index 1e7fd83..a088d25 100644
--- a/src/tracing/ipc/producer/producer_ipc_client_impl.h
+++ b/src/tracing/ipc/producer/producer_ipc_client_impl.h
@@ -53,6 +53,7 @@
  public:
   ProducerIPCClientImpl(const char* service_sock_name,
                         Producer*,
+                        const std::string& producer_name,
                         base::TaskRunner*);
   ~ProducerIPCClientImpl() override;
 
@@ -97,6 +98,7 @@
   std::unique_ptr<SharedMemoryArbiter> shared_memory_arbiter_;
   size_t shared_buffer_page_size_kb_ = 0;
   bool connected_ = false;
+  std::string const name_;
   PERFETTO_THREAD_CHECKER(thread_checker_)
 };
 
diff --git a/src/tracing/ipc/service/producer_ipc_service.cc b/src/tracing/ipc/service/producer_ipc_service.cc
index 4731498..3132967 100644
--- a/src/tracing/ipc/service/producer_ipc_service.cc
+++ b/src/tracing/ipc/service/producer_ipc_service.cc
@@ -67,7 +67,8 @@
 
   // ConnectProducer will call OnConnect() on the next task.
   producer->service_endpoint = core_service_->ConnectProducer(
-      producer.get(), client_info.uid(), req.shared_memory_size_hint_bytes());
+      producer.get(), client_info.uid(), req.producer_name(),
+      req.shared_memory_size_hint_bytes());
 
   // Could happen if the service has too many producers connected.
   if (!producer->service_endpoint)
diff --git a/src/tracing/test/tracing_integration_test.cc b/src/tracing/test/tracing_integration_test.cc
index e926ba6..426f469 100644
--- a/src/tracing/test/tracing_integration_test.cc
+++ b/src/tracing/test/tracing_integration_test.cc
@@ -93,7 +93,8 @@
 
     // Create and connect a Producer.
     producer_endpoint_ = ProducerIPCClient::Connect(
-        kProducerSockName, &producer_, task_runner_.get());
+        kProducerSockName, &producer_, "com.google.perfetto.mock_producer",
+        task_runner_.get());
     auto on_producer_connect =
         task_runner_->CreateCheckpoint("on_producer_connect");
     EXPECT_CALL(producer_, OnConnect()).WillOnce(Invoke(on_producer_connect));
diff --git a/test/fake_producer.cc b/test/fake_producer.cc
index d9d9a36..9dadf52 100644
--- a/test/fake_producer.cc
+++ b/test/fake_producer.cc
@@ -39,7 +39,8 @@
     std::function<void()> on_create_data_source_instance) {
   PERFETTO_DCHECK_THREAD(thread_checker_);
   task_runner_ = task_runner;
-  endpoint_ = ProducerIPCClient::Connect(socket_name, this, task_runner);
+  endpoint_ = ProducerIPCClient::Connect(
+      socket_name, this, "com.google.perfetto.fake_producer", task_runner);
   on_create_data_source_instance_ = std::move(on_create_data_source_instance);
 }