#!/usr/bin/env bash set -e target=$1 bazel build --strip=never -c dbg "${target}" outs=$(bazel cquery --strip=never -c dbg --output=files "${target}") n=${#outs[@]} if [[ "$n" -gt 1 ]]; then echo "too many outputs, not sure which one to debug" fi command="${outs[0]}" echo "###############" echo "Starting headless dlv debug server" echo "- You will need to connect with a DAP client (eg, vscode) on the given port" echo "- Call @dk185217 if you want a vscode launch config. Help wanted for other clients" echo "- If something isnt working, useful options are: --log --log-output=dap" echo "- You will need to pkill dlv to stop it if your client doesnt" echo "###############" set -x dlv exec "${command}" --headless --listen=127.0.0.1:50034 --api-version=2 -- "${@:3}"