1 /* 2 * Copyright (C) 2023 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 package android.tracing.perfetto; 18 19 import android.annotation.IntDef; 20 21 import java.lang.annotation.Retention; 22 import java.lang.annotation.RetentionPolicy; 23 24 /** 25 * @hide 26 */ 27 public class InitArguments { 28 public final @PerfettoBackend int backends; 29 public final int shmemSizeHintKb; 30 31 /** 32 * @hide 33 */ 34 @IntDef(value = { 35 PERFETTO_BACKEND_IN_PROCESS, 36 PERFETTO_BACKEND_SYSTEM, 37 }) 38 @Retention(RetentionPolicy.SOURCE) 39 public @interface PerfettoBackend {} 40 41 // The in-process tracing backend. Keeps trace buffers in the process memory. 42 public static final int PERFETTO_BACKEND_IN_PROCESS = (1 << 0); 43 44 // The system tracing backend. Connects to the system tracing service (e.g. 45 // on Linux/Android/Mac uses a named UNIX socket). 46 public static final int PERFETTO_BACKEND_SYSTEM = (1 << 1); 47 48 public static InitArguments DEFAULTS = new InitArguments(PERFETTO_BACKEND_SYSTEM, 0); 49 50 public static InitArguments TESTING = new InitArguments(PERFETTO_BACKEND_IN_PROCESS, 0); 51 52 /** 53 * Perfetto initialization arguments. 54 * 55 * @param backends Bitwise-or of backends that should be enabled. 56 * @param shmemSizeHintKb [Optional] Tune the size of the shared memory buffer between the 57 * current process and the service backend(s). This is a trade-off between memory footprint and 58 * the ability to sustain bursts of trace writes. If set, the value must be a multiple of 4KB. 59 * The value can be ignored if larger than kMaxShmSize (32MB) or not a multiple of 4KB. 60 */ InitArguments(@erfettoBackend int backends, int shmemSizeHintKb)61 public InitArguments(@PerfettoBackend int backends, int shmemSizeHintKb) { 62 this.backends = backends; 63 this.shmemSizeHintKb = shmemSizeHintKb; 64 } 65 } 66