From f1f602e748feff19baae376457fb7284ff820021 Mon Sep 17 00:00:00 2001 From: Orion Hodson Date: Tue, 4 Apr 2023 13:13:42 +0100 Subject: [PATCH] Add wrappers for gdb and lldb when invoked from bazel Usage: $ bazel run --run_under $(realpath tools/bazel-gdb-wrapper.sh) //src/workerd/server:workerd -- \ serve $(realpath /samples/helloworld_esm/config.capnp) --- tools/bazel-gdb-wrapper.sh | 14 ++++++++++++++ tools/bazel-lldb-wrapper.sh | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 tools/bazel-gdb-wrapper.sh create mode 100755 tools/bazel-lldb-wrapper.sh diff --git a/tools/bazel-gdb-wrapper.sh b/tools/bazel-gdb-wrapper.sh new file mode 100755 index 00000000000..c8cec7b4e29 --- /dev/null +++ b/tools/bazel-gdb-wrapper.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# +# A wrapper script so workerd can be debugged with gdb, if invoked via bazel run. +# +# Example command-line invocation: +# +# bazel run -c dbg --run_under $(realpath tools/bazel-gdb-wrapper.sh) \ +# //src/workerd/server:workerd -- serve samples/helloworld_esm/config.capnp +# + +set -euo pipefail + +cd "${BUILD_WORKSPACE_DIRECTORY}" +gdb --args "$@" diff --git a/tools/bazel-lldb-wrapper.sh b/tools/bazel-lldb-wrapper.sh new file mode 100755 index 00000000000..bf07f015450 --- /dev/null +++ b/tools/bazel-lldb-wrapper.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# +# A wrapper script so workerd can be debugged with lldb, if invoked via bazel run. +# +# Example command-line invocation: +# +# bazel run -c dbg --spawn_strategy=local --features=oso_prefix_is_pwd --run_under \ +# $(realpath tools/bazel-lldb-wrapper.sh) \ +# //src/workerd/server:workerd -- serve samples/helloworld_esm/config.capnp +# +# NB the additional spawn_strategy and features flags are necessary on OS X per +# https://github.com/bazelbuild/bazel/issues/6327. + +set -euo pipefail + +cd "${BUILD_WORKSPACE_DIRECTORY}" +lldb -- "$@"