Skip to content

Commit

Permalink
run gdb client in docker instead of host (#1616)
Browse files Browse the repository at this point in the history
* run gdb client in docker instead of host
this gives gdb access to the full source tree for debugging

* Update gdb-server.sh

* Update gdb-server.sh

* Update gdb-client.sh
  • Loading branch information
recursiveforte authored Apr 25, 2024
1 parent f5152ea commit 9399a22
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion firmware/spade/docker/dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM alpine:3.19

RUN apk add git python3 clang make cmake entr uglify-js gcc-arm-none-eabi g++-arm-none-eabi
RUN apk add git python3 clang make cmake entr uglify-js gcc-arm-none-eabi g++-arm-none-eabi gdb-multiarch

COPY ./importBuildRepos.sh /opt/importBuildRepos.sh

Expand Down
33 changes: 27 additions & 6 deletions scripts/gardenshed/gdb-client.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
#!/bin/bash
a=`uname`
if [[ "$a" == "Linux" ]]; then
/usr/bin/gdb-multiarch -ex 'target remote :3333' ./spade.elf
else
/opt/homebrew/bin/arm-none-eabi-gdb -ex 'target remote :3333' ./spade.elf
fi

dependencies=("docker" "echo" "whoami" "grep")

for dep in "${dependencies[@]}"; do
if ! command -v $dep > /dev/null; then
printf "%s not found, please install %s\n" "$dep" "$dep"
exit 1
fi
done

echo "Dependencies found successfully"

# Ensure user in docker group if on linux
if id -nG $(whoami) | grep -qw "docker"; then
echo User in docker group, continuing
else
if [[ $OSTYPE != *"linux"* ]]; then
echo "Platform is not linux, skipping docker group check"
else
echo User $(whoami) not in the docker group. Please add user $(whoami) to the docker group and try again
exit 1
fi
fi

case $1 in
"--log") docker build ./docker | tee dockerBuildLog.txt
docker run -it --security-opt label:disable --network host --rm --volume `pwd`:/root/spade $(docker images | awk '{print $3}' | awk 'NR==2') /usr/bin/gdb-multiarch -ex "target remote :3333" /root/spade/spade.elf | tee -a dockerBuildLog.txt ;;
*) docker build ./docker
docker run -it --security-opt label:disable --network host --rm --volume `pwd`:/root/spade $(docker images | awk '{print $3}' | awk 'NR==2') /usr/bin/gdb-multiarch -ex "target remote :3333" /root/spade/spade.elf ;;
esac

0 comments on commit 9399a22

Please sign in to comment.