xref: /aosp_15_r20/external/grpc-grpc/tools/docker_runners/examples/gdb_in_docker.sh (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1#!/bin/bash
2# Copyright 2021 The gRPC Authors
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
16set -ex
17
18# change to grpc repo root
19cd "$(dirname "$0")/../../.."
20
21# Use the docker image used as the default for C++ by run_tests.py
22# To use the correct docker image for your experiments,
23# note that every invocation of run_tests.py with "--use_docker"
24# prints the docker image used as a debug message at the end of the run.
25# This is expecially important when --compiler/--arch params are
26# use, since they usually influence with docker image will be used
27# by run_tests.py
28export DOCKERFILE_DIR=tools/dockerfile/test/cxx_debian11_x64
29
30# "--privileged" docker arg is required to be disable address randomization by gdb
31# TODO: is "--security-opt=seccomp=unconfined" actually needed?
32export DOCKER_EXTRA_ARGS="--privileged --security-opt=seccomp=unconfined"
33
34# start the docker container with interactive shell
35tools/docker_runners/run_in_docker.sh bash
36
37# Run these commands under the docker container
38#
39# Install gdb (or similar command for non-debian based distros)
40# $ apt-get update && apt-get install -y gdb
41#
42# Build e.g. the C tests
43# $ ./tools/run_tests/run_tests.py -l c -c dbg --build_only
44#
45# Run a test under gdb
46# NOTE: Some old distros (e.g. debian 8 "jessie") might have a gdb version
47# that doesn't work with C++11 symbols properly and crashes when
48# loading the symbols.
49# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61233
50# $ gdb cmake/build/histogram_test
51