//
// Copyright (C) 2018 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// @generated by protoc-gen-es v2.2.2 with parameter "target=ts"
// @generated from file protos/perfetto/config/profiling/heapprofd_config.proto (package perfetto.protos, syntax proto2)
/* eslint-disable */

import type { GenFile, GenMessage } from "@bufbuild/protobuf/codegenv1";
import { fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv1";
import type { Message } from "@bufbuild/protobuf";

/**
 * Describes the file protos/perfetto/config/profiling/heapprofd_config.proto.
 */
export const file_protos_perfetto_config_profiling_heapprofd_config: GenFile = /*@__PURE__*/
  fileDesc("Cjdwcm90b3MvcGVyZmV0dG8vY29uZmlnL3Byb2ZpbGluZy9oZWFwcHJvZmRfY29uZmlnLnByb3RvEg9wZXJmZXR0by5wcm90b3MizAYKD0hlYXBwcm9mZENvbmZpZxIfChdzYW1wbGluZ19pbnRlcnZhbF9ieXRlcxgBIAEoBBIpCiFhZGFwdGl2ZV9zYW1wbGluZ19zaG1lbV90aHJlc2hvbGQYGCABKAQSNQotYWRhcHRpdmVfc2FtcGxpbmdfbWF4X3NhbXBsaW5nX2ludGVydmFsX2J5dGVzGBkgASgEEhcKD3Byb2Nlc3NfY21kbGluZRgCIAMoCRILCgNwaWQYBCADKAQSGwoTdGFyZ2V0X2luc3RhbGxlZF9ieRgaIAMoCRINCgVoZWFwcxgUIAMoCRIVCg1leGNsdWRlX2hlYXBzGBsgAygJEhoKEnN0cmVhbV9hbGxvY2F0aW9ucxgXIAEoCBIfChdoZWFwX3NhbXBsaW5nX2ludGVydmFscxgWIAMoBBIRCglhbGxfaGVhcHMYFSABKAgSCwoDYWxsGAUgASgIEh8KF21pbl9hbm9ueW1vdXNfbWVtb3J5X2tiGA8gASgNEh8KF21heF9oZWFwcHJvZmRfbWVtb3J5X2tiGBAgASgNEh4KFm1heF9oZWFwcHJvZmRfY3B1X3NlY3MYESABKAQSGgoSc2tpcF9zeW1ib2xfcHJlZml4GAcgAygJElUKFmNvbnRpbnVvdXNfZHVtcF9jb25maWcYBiABKAsyNS5wZXJmZXR0by5wcm90b3MuSGVhcHByb2ZkQ29uZmlnLkNvbnRpbnVvdXNEdW1wQ29uZmlnEhgKEHNobWVtX3NpemVfYnl0ZXMYCCABKAQSFAoMYmxvY2tfY2xpZW50GAkgASgIEh8KF2Jsb2NrX2NsaWVudF90aW1lb3V0X3VzGA4gASgNEhIKCm5vX3N0YXJ0dXAYCiABKAgSEgoKbm9fcnVubmluZxgLIAEoCBITCgtkdW1wX2F0X21heBgNIAEoCBIdChVkaXNhYmxlX2ZvcmtfdGVhcmRvd24YEiABKAgSHwoXZGlzYWJsZV92Zm9ya19kZXRlY3Rpb24YEyABKAgaRwoUQ29udGludW91c0R1bXBDb25maWcSFQoNZHVtcF9waGFzZV9tcxgFIAEoDRIYChBkdW1wX2ludGVydmFsX21zGAYgASgNSgQIDBAN");

/**
 * Configuration for go/heapprofd.
 * Next id: 28
 *
 * @generated from message perfetto.protos.HeapprofdConfig
 */
export type HeapprofdConfig = Message<"perfetto.protos.HeapprofdConfig"> & {
  /**
   * Sampling rate for all heaps not specified via heap_sampling_intervals.
   *
   * These are:
   * * All heaps if heap_sampling_intervals is empty.
   * * Those profiled due to all_heaps and not named in heaps if
   *   heap_sampling_intervals is not empty.
   * * The implicit libc.malloc heap if heaps is empty.
   *
   * Set to 1 for perfect accuracy.
   * Otherwise, sample every sample_interval_bytes on average.
   *
   * See
   * https://perfetto.dev/docs/data-sources/native-heap-profiler#sampling-interval
   * for more details.
   *
   * BUGS
   * Before Android 12, setting this to 0 would crash the target process.
   *
   * N.B. This must be explicitly set to a non-zero value for all heaps (with
   * this field or with heap_sampling_intervals), otherwise the producer will
   * not start.
   *
   * @generated from field: optional uint64 sampling_interval_bytes = 1;
   */
  samplingIntervalBytes: bigint;

  /**
   * If less than the given numbers of bytes are left free in the shared
   * memory buffer, increase sampling interval by a factor of two.
   * Adaptive sampling is disabled when set to 0.
   *
   * @generated from field: optional uint64 adaptive_sampling_shmem_threshold = 24;
   */
  adaptiveSamplingShmemThreshold: bigint;

  /**
   * Stop doubling the sampling_interval once the sampling interval has reached
   * this value.
   *
   * @generated from field: optional uint64 adaptive_sampling_max_sampling_interval_bytes = 25;
   */
  adaptiveSamplingMaxSamplingIntervalBytes: bigint;

  /**
   * E.g. surfaceflinger, com.android.phone
   * This input is normalized in the following way: if it contains slashes,
   * everything up to the last slash is discarded. If it contains "@",
   * everything after the first @ is discared.
   * E.g. /system/bin/surfaceflinger@1.0 normalizes to surfaceflinger.
   * This transformation is also applied to the processes' command lines when
   * matching.
   *
   * @generated from field: repeated string process_cmdline = 2;
   */
  processCmdline: string[];

  /**
   * For watermark based triggering or local debugging.
   *
   * @generated from field: repeated uint64 pid = 4;
   */
  pid: bigint[];

  /**
   * Only profile target if it was installed by one of the packages given.
   * Special values are:
   * * @system: installed on the system partition
   * * @product: installed on the product partition
   * * @null: sideloaded
   * Supported on Android 12+.
   *
   * @generated from field: repeated string target_installed_by = 26;
   */
  targetInstalledBy: string[];

  /**
   * Which heaps to sample, e.g. "libc.malloc". If left empty, only samples
   * "malloc".
   *
   * Introduced in Android 12.
   *
   * @generated from field: repeated string heaps = 20;
   */
  heaps: string[];

  /**
   * Which heaps not to sample, e.g. "libc.malloc". This is useful when used in
   * combination with all_heaps;
   *
   * Introduced in Android 12.
   *
   * @generated from field: repeated string exclude_heaps = 27;
   */
  excludeHeaps: string[];

  /**
   * @generated from field: optional bool stream_allocations = 23;
   */
  streamAllocations: boolean;

  /**
   * If given, needs to be the same length as heaps and gives the sampling
   * interval for the respective entry in heaps.
   *
   * Otherwise, sampling_interval_bytes is used.
   *
   * It is recommended to set sampling_interval_bytes to a reasonable default
   * value when using this, as a value of 0 for sampling_interval_bytes will
   * crash the target process before Android 12.
   *
   * Introduced in Android 12.
   *
   * All values must be non-zero or the producer will not start.
   *
   * @generated from field: repeated uint64 heap_sampling_intervals = 22;
   */
  heapSamplingIntervals: bigint[];

  /**
   * Sample all heaps registered by target process. Introduced in Android 12.
   *
   * @generated from field: optional bool all_heaps = 21;
   */
  allHeaps: boolean;

  /**
   * Profile all processes eligible for profiling on the system.
   * See
   * https://perfetto.dev/docs/data-sources/native-heap-profiler#heapprofd-targets
   * for which processes are eligible.
   *
   * On unmodified userdebug builds, this will lead to system crashes. Zygote
   * will crash when trying to launch a new process as it will have an
   * unexpected open socket to heapprofd.
   *
   * heapprofd will likely be overloaded by the amount of data for low
   * sampling intervals.
   *
   * @generated from field: optional bool all = 5;
   */
  all: boolean;

  /**
   * Do not profile processes whose anon RSS + swap < given value.
   * Introduced in Android 11.
   *
   * @generated from field: optional uint32 min_anonymous_memory_kb = 15;
   */
  minAnonymousMemoryKb: number;

  /**
   * Stop profile if heapprofd memory usage goes beyond the given value.
   * Introduced in Android 11.
   *
   * @generated from field: optional uint32 max_heapprofd_memory_kb = 16;
   */
  maxHeapprofdMemoryKb: number;

  /**
   * Stop profile if heapprofd CPU time since start of this data-source
   * goes beyond given value.
   * Introduced in Android 11.
   *
   * @generated from field: optional uint64 max_heapprofd_cpu_secs = 17;
   */
  maxHeapprofdCpuSecs: bigint;

  /**
   * Do not emit function names for mappings starting with this prefix.
   * E.g. /system to not emit symbols for any system libraries.
   *
   * @generated from field: repeated string skip_symbol_prefix = 7;
   */
  skipSymbolPrefix: string[];

  /**
   * Dump at a predefined interval.
   *
   * @generated from field: optional perfetto.protos.HeapprofdConfig.ContinuousDumpConfig continuous_dump_config = 6;
   */
  continuousDumpConfig?: HeapprofdConfig_ContinuousDumpConfig;

  /**
   * Size of the shared memory buffer between the profiled processes and
   * heapprofd. Defaults to 8 MiB. If larger than 500 MiB, truncated to 500
   * MiB.
   *
   * Needs to be:
   * * at least 8192,
   * * a power of two,
   * * a multiple of 4096.
   *
   * @generated from field: optional uint64 shmem_size_bytes = 8;
   */
  shmemSizeBytes: bigint;

  /**
   * When the shmem buffer is full, block the client instead of ending the
   * trace. Use with caution as this will significantly slow down the target
   * process.
   *
   * @generated from field: optional bool block_client = 9;
   */
  blockClient: boolean;

  /**
   * If set, stop the trace session after blocking the client for this
   * timeout. Needs to be larger than 100 us, otherwise no retries are done.
   * Introduced in Android 11.
   *
   * @generated from field: optional uint32 block_client_timeout_us = 14;
   */
  blockClientTimeoutUs: number;

  /**
   * Do not profile processes from startup, only match already running
   * processes.
   *
   * Can not be set at the same time as no_running.
   * Introduced in Android 11.
   *
   * @generated from field: optional bool no_startup = 10;
   */
  noStartup: boolean;

  /**
   * Do not profile running processes. Only match processes on startup.
   *
   * Can not be set at the same time as no_startup.
   * Introduced in Android 11.
   *
   * @generated from field: optional bool no_running = 11;
   */
  noRunning: boolean;

  /**
   * Cause heapprofd to emit a single dump at the end, showing the memory usage
   * at the point in time when the sampled heap usage of the process was at its
   * maximum. This causes ProfilePacket.HeapSample.self_max to be set, and
   * self_allocated and self_freed to not be set.
   * Introduced in Android 11.
   *
   * @generated from field: optional bool dump_at_max = 13;
   */
  dumpAtMax: boolean;

  /**
   * Escape hatch if the session is being torn down because of a forked child
   * that shares memory space, but is not correctly identified as a vforked
   * child.
   * Introduced in Android 11.
   *
   * @generated from field: optional bool disable_fork_teardown = 18;
   */
  disableForkTeardown: boolean;

  /**
   * We try to automatically detect when a target applicatation vforks but then
   * does a memory allocation (or free). This auto-detection can be disabled
   * with this.
   * Introduced in Android 11.
   *
   * @generated from field: optional bool disable_vfork_detection = 19;
   */
  disableVforkDetection: boolean;
};

/**
 * Describes the message perfetto.protos.HeapprofdConfig.
 * Use `create(HeapprofdConfigSchema)` to create a new message.
 */
export const HeapprofdConfigSchema: GenMessage<HeapprofdConfig> = /*@__PURE__*/
  messageDesc(file_protos_perfetto_config_profiling_heapprofd_config, 0);

/**
 * @generated from message perfetto.protos.HeapprofdConfig.ContinuousDumpConfig
 */
export type HeapprofdConfig_ContinuousDumpConfig = Message<"perfetto.protos.HeapprofdConfig.ContinuousDumpConfig"> & {
  /**
   * ms to wait before first dump.
   *
   * @generated from field: optional uint32 dump_phase_ms = 5;
   */
  dumpPhaseMs: number;

  /**
   * ms to wait between following dumps.
   *
   * @generated from field: optional uint32 dump_interval_ms = 6;
   */
  dumpIntervalMs: number;
};

/**
 * Describes the message perfetto.protos.HeapprofdConfig.ContinuousDumpConfig.
 * Use `create(HeapprofdConfig_ContinuousDumpConfigSchema)` to create a new message.
 */
export const HeapprofdConfig_ContinuousDumpConfigSchema: GenMessage<HeapprofdConfig_ContinuousDumpConfig> = /*@__PURE__*/
  messageDesc(file_protos_perfetto_config_profiling_heapprofd_config, 0, 0);

