blob: 7234cb463fe19fd6e7420bb4738a85d8a6f6a85d [file] [log] [blame]
Florian Mayerc29e0d32018-04-04 15:55:46 +01001/*
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"
Primiano Tucci3cbb10a2018-04-10 17:52:40 +010020#include "perfetto/ipc/basic_types.h"
21#include "perfetto/tracing/core/basic_types.h"
Florian Mayerc29e0d32018-04-04 15:55:46 +010022
23#include <stdlib.h>
24
25namespace perfetto {
26
Primiano Tucci3cbb10a2018-04-10 17:52:40 +010027static_assert(kInvalidUid == ipc::kInvalidUid, "kInvalidUid mismatching");
28
Florian Mayerc29e0d32018-04-04 15:55:46 +010029const 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
41const 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