Skip to content

Commit

Permalink
[soil] Shell function for local shell debugging
Browse files Browse the repository at this point in the history
- Allow disabling ASLR inside docker
- But I reproduced the spec-cpp bug outside the container, with Clang!
  - must be undefined behavior
- Put mypy in ../oil_DEPS
  • Loading branch information
Andy C committed May 17, 2022
1 parent d3916b0 commit d67f6e0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mycpp/common.sh
Expand Up @@ -13,4 +13,4 @@ if test -z "${REPO_ROOT:-}"; then
exit 1
fi

readonly MYPY_REPO=$REPO_ROOT/_clone/mypy
readonly MYPY_REPO=$REPO_ROOT/../oil_DEPS/_clone/mypy
4 changes: 2 additions & 2 deletions mycpp/deps.sh
Expand Up @@ -42,7 +42,7 @@ git-clone() {
}

create-venv() {
local dir=_tmp/mycpp-venv
local dir=../oil_DEPS/mycpp-venv
python3 -m venv $dir

ls -l $dir
Expand All @@ -66,7 +66,7 @@ pip-install() {
set +o nounset
set +o pipefail
set +o errexit
source _tmp/mycpp-venv/bin/activate
source ../oil_DEPS/mycpp-venv/bin/activate

mypy-deps # install deps in virtual env

Expand Down
31 changes: 29 additions & 2 deletions soil/host-shim.sh
Expand Up @@ -28,6 +28,7 @@ run-job-uke() {
local docker=$1 # docker or podman
local repo_root=$2
local task=$3 # e.g. dev-minimal
local debug_shell=${4:-}

local -a flags=()

Expand All @@ -50,10 +51,28 @@ run-job-uke() {
command time -p -o $metadata_dir/image-pull-time.txt \
$docker pull $image

local -a args
if test -n "$debug_shell"; then
# launch interactive shell
flags+=( -i -t )

# So we can run GDB
# https://stackoverflow.com/questions/35860527/warning-error-disabling-address-space-randomization-operation-not-permitted
flags+=( --cap-add SYS_PTRACE --security-opt seccomp=unconfined )

# can mount other tools for debugging, like clang
#local clang_dir=~/git/oilshell/oil_DEPS/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04
#flags+=( --mount "type=bind,source=$clang_dir,target=/home/uke/oil_DEPS/$(basename $clang_dir)" )

args=(bash)
else
args=(sh -c "cd /home/uke/oil; soil/worker.sh run-$task")
fi

$docker run "${flags[@]}" \
--mount "type=bind,source=$repo_root,target=/home/uke/oil" \
$image \
sh -c "cd /home/uke/oil; soil/worker.sh run-$task"
"${args[@]}"
}

local-test-uke() {
Expand All @@ -62,7 +81,7 @@ local-test-uke() {

local branch=$(git rev-parse --abbrev-ref HEAD)

local fresh_clone=/tmp/oil
local fresh_clone=/tmp/oil # TODO: /tmp/soil-$task
rm -r -f -v $fresh_clone

local this_repo=$PWD
Expand All @@ -75,6 +94,14 @@ local-test-uke() {
sudo $0 run-job-uke docker $fresh_clone $task
}

local-shell() {
local task=${1:-cpp}

local repo_root=/tmp/oil # TODO: /tmp/soil-$task
# Run bash as debug shell
sudo $0 run-job-uke docker $repo_root $task bash
}

cleanup() {
sudo rm -r -f -v _tmp/soil
sudo rm -r -f -v /tmp/oil
Expand Down
6 changes: 6 additions & 0 deletions test/spec-cpp.sh
Expand Up @@ -371,4 +371,10 @@ one-off() {
#run-with-osh-eval builtin-io -r 54 -v # to_float()
}

repro() {
test/spec.sh alias -r 0 -p > _tmp/a
ninja _bin/clang-dbg/osh_eval
_bin/clang-dbg/osh_eval _tmp/a
}

"$@"

0 comments on commit d67f6e0

Please sign in to comment.