blob: f48d6c3f9b5926712b000faa871a524cdaa2b7e4 [file]
#!/bin/bash
# Copyright 2023 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#### CATEGORY=Run, inspect and debug
### pprof wrapper that gives access to local files in symbol-index
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/../lib/vars.sh || exit $?
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/symbol-index.sh || exit $?
fx-config-read
# Ensure the current build directory is registered in symbol-index.
if [[ -f "${FUCHSIA_BUILD_DIR}/.symbol-index.json" ]]; then
# Use ffx to register the symbol-index.json from the build directory.
# This is a no-op if it's already registered.
fx-command-run ffx debug symbol-index add "${FUCHSIA_BUILD_DIR}/.symbol-index.json" > /dev/null 2>&1
fi
# Append the build-id directories from symbol-index to PPROF_BINARY_PATH.
extra_dirs="$(fx-symbol-index-get-build-id-dirs | paste -sd:)"
export PPROF_BINARY_PATH="${PPROF_BINARY_PATH:+${PPROF_BINARY_PATH}:}$extra_dirs"
pprof "$@"