diff --git a/Makefile.include b/Makefile.include index befb9d8647..18f272c6d6 100644 --- a/Makefile.include +++ b/Makefile.include @@ -570,6 +570,16 @@ define check_cmd exit 1;} endef +# Check if setsid command is available on the system for debug target +# This is not the case on MacOSX, so it must be built on the fly +ifneq (,$(filter debug, $(MAKECMDGOALS))) + ifneq (0,$(shell which setsid 2>&1 > /dev/null ; echo $$?)) + SETSID = $(RIOTTOOLS)/setsid/setsid + $(call target-export-variables,debug,$(SETSID)) + DEBUGDEPS += $(SETSID) + endif +endif + ..compiler-check: $(call check_cmd,$(CC),Compiler) @@ -643,7 +653,7 @@ list-ttys: doc: make -BC $(RIOTBASE) doc -debug: +debug: $(DEBUGDEPS) $(call check_cmd,$(DEBUGGER),Debug program) $(DEBUGGER) $(DEBUGGER_FLAGS) diff --git a/boards/common/arduino-atmega/dist/debug.sh b/boards/common/arduino-atmega/dist/debug.sh index 0b10852f20..46dc7377ca 100644 --- a/boards/common/arduino-atmega/dist/debug.sh +++ b/boards/common/arduino-atmega/dist/debug.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash + +# The setsid command is needed so that Ctrl+C in GDB doesn't kill avarice +: ${SETSID:=setsid} + sleep 2 -setsid -w avarice $1 & +${SETSID} -w avarice $1 & #sleep 2 && $2/avr-gdb-wrapper -ex "target remote localhost:$3" $4 sleep 3 && avr-gdb -ex "target remote localhost:$3" $4 diff --git a/boards/mega-xplained/dist/debug.sh b/boards/mega-xplained/dist/debug.sh index 0b10852f20..46dc7377ca 100755 --- a/boards/mega-xplained/dist/debug.sh +++ b/boards/mega-xplained/dist/debug.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash + +# The setsid command is needed so that Ctrl+C in GDB doesn't kill avarice +: ${SETSID:=setsid} + sleep 2 -setsid -w avarice $1 & +${SETSID} -w avarice $1 & #sleep 2 && $2/avr-gdb-wrapper -ex "target remote localhost:$3" $4 sleep 3 && avr-gdb -ex "target remote localhost:$3" $4 diff --git a/boards/waspmote-pro/dist/debug.sh b/boards/waspmote-pro/dist/debug.sh index 0b10852f20..46dc7377ca 100755 --- a/boards/waspmote-pro/dist/debug.sh +++ b/boards/waspmote-pro/dist/debug.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash + +# The setsid command is needed so that Ctrl+C in GDB doesn't kill avarice +: ${SETSID:=setsid} + sleep 2 -setsid -w avarice $1 & +${SETSID} -w avarice $1 & #sleep 2 && $2/avr-gdb-wrapper -ex "target remote localhost:$3" $4 sleep 3 && avr-gdb -ex "target remote localhost:$3" $4 diff --git a/dist/tools/setsid/.gitignore b/dist/tools/setsid/.gitignore new file mode 100644 index 0000000000..3dd9233a7a --- /dev/null +++ b/dist/tools/setsid/.gitignore @@ -0,0 +1,2 @@ +setsid +bin diff --git a/dist/tools/setsid/Makefile b/dist/tools/setsid/Makefile new file mode 100644 index 0000000000..164392026f --- /dev/null +++ b/dist/tools/setsid/Makefile @@ -0,0 +1,17 @@ +PKG_NAME = setsid +PKG_URL = https://github.com/tzvetkoff/setsid-macosx +PKG_VERSION = e5b851df41591021baf5cf88d4e41572baf8e08b +PKG_LICENSE = BSD-2-Clause +PKG_BUILDDIR = $(CURDIR)/bin + +.PHONY: all + +all: git-download + @echo "[INFO] compiling setsid from source now" + $(MAKE) BINDIR=$(PKG_BUILDDIR) -C $(PKG_BUILDDIR) + @mv $(PKG_BUILDDIR)/setsid $(CURDIR)/setsid + +distclean:: + @rm -f $(CURDIR)/setsid + +include $(RIOTBASE)/pkg/pkg.mk diff --git a/makefiles/tools/targets.inc.mk b/makefiles/tools/targets.inc.mk index f80fa73b31..baf9dd864f 100644 --- a/makefiles/tools/targets.inc.mk +++ b/makefiles/tools/targets.inc.mk @@ -29,3 +29,8 @@ $(RIOTTOOLS)/mosquitto_rsmb/mosquitto_rsmb: mosquitto_rsmb: $(RIOTTOOLS)/mosquitto_rsmb/mosquitto_rsmb @make -C $(RIOTTOOLS)/mosquitto_rsmb run + +$(RIOTTOOLS)/setsid/setsid: $(RIOTTOOLS)/setsid/Makefile + @echo "[INFO] setsid binary not found - building it from source now" + @make -C $(RIOTTOOLS)/setsid + @echo "[INFO] setsid binary successfully build!" diff --git a/makefiles/vars.inc.mk b/makefiles/vars.inc.mk index f2bfcc5557..135bd81605 100644 --- a/makefiles/vars.inc.mk +++ b/makefiles/vars.inc.mk @@ -19,6 +19,7 @@ export USEPKG # Pkg dependencies (third party modules) of the app export DISABLE_MODULE # Used in the application's Makefile to suppress DEFAULT_MODULEs. export APPDEPS # Files / Makefile targets that need to be created before the application can be build. Set in the application's Makefile. # BUILDDEPS # Files / Makefile targets that need to be created before starting to build. +# DEBUGDEPS # Files / Makefile targets that need to be created before starting a debug session. export RIOTBASE # The root folder of RIOT. The folder where this very file lives in. export RIOTCPU # For third party CPUs this folder is the base of the CPUs.