• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "src/tracing/ipc/default_socket.h"
18 
19 #include "perfetto/base/build_config.h"
20 #include "perfetto/ipc/basic_types.h"
21 #include "perfetto/tracing/core/basic_types.h"
22 
23 #include <stdlib.h>
24 
25 namespace perfetto {
26 
27 static_assert(kInvalidUid == ipc::kInvalidUid, "kInvalidUid mismatching");
28 
GetProducerSocket()29 const char* GetProducerSocket() {
30   static const char* name = getenv("PERFETTO_PRODUCER_SOCK_NAME");
31   if (name == nullptr) {
32 #if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID)
33     name = "/dev/socket/traced_producer";
34 #else
35     name = "/tmp/perfetto-producer";
36 #endif
37   }
38   return name;
39 }
40 
GetConsumerSocket()41 const char* GetConsumerSocket() {
42   static const char* name = getenv("PERFETTO_CONSUMER_SOCK_NAME");
43   if (name == nullptr) {
44 #if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID)
45     name = "/dev/socket/traced_consumer";
46 #else
47     name = "/tmp/perfetto-consumer";
48 #endif
49   }
50   return name;
51 }
52 
53 }  // namespace perfetto
54