Repository: incubator-mynewt-core Updated Branches: refs/heads/develop 2b3d6ccf7 -> 631db7704
Fix ctrl-c handling on Windows by launching separate cmd instances Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/56444edf Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/56444edf Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/56444edf Branch: refs/heads/develop Commit: 56444edfae339e40330686aeb3ca9d8a641eea7f Parents: 2b3d6cc Author: Simon Ratner <simon+git...@probablyprime.net> Authored: Sat Mar 4 11:41:30 2017 -0800 Committer: Marko Kiiskila <ma...@runtime.io> Committed: Fri Mar 10 13:10:05 2017 -0800 ---------------------------------------------------------------------- hw/scripts/jlink.sh | 63 ++++++++++++++++++++++++++++------------------ hw/scripts/openocd.sh | 32 ++++++++++++++++------- 2 files changed, 61 insertions(+), 34 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/56444edf/hw/scripts/jlink.sh ---------------------------------------------------------------------- diff --git a/hw/scripts/jlink.sh b/hw/scripts/jlink.sh index e6a4dfe..2f3fbe8 100644 --- a/hw/scripts/jlink.sh +++ b/hw/scripts/jlink.sh @@ -105,37 +105,50 @@ jlink_load () { # jlink_debug() { if [ -z "$NO_GDB" ]; then - GDB_CMD_FILE=.gdb_cmds + GDB_CMD_FILE=.gdb_cmds - if [ -z $FILE_NAME ]; then + if [ -z $FILE_NAME ]; then echo "Missing filename" exit 1 - fi - if [ ! -f "$FILE_NAME" ]; then + fi + if [ ! -f "$FILE_NAME" ]; then echo "Cannot find file" $FILE_NAME exit 1 - fi - - echo "Debugging" $FILE_NAME - - # Monitor mode. Background process gets it's own process group. - set -m - $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun > /dev/null & - set +m - - echo "target remote localhost:3333" > $GDB_CMD_FILE - # Whether target should be reset or not - if [ ! -z "$RESET" ]; then - echo "mon reset" >> $GDB_CMD_FILE - echo "si" >> $GDB_CMD_FILE - fi - echo "$EXTRA_GDB_CMDS" >> $GDB_CMD_FILE - - arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME - - rm $GDB_CMD_FILE + fi + + echo "Debugging" $FILE_NAME + + if [ -x "$COMSPEC" ]; then + # + # Launch jlink server in a separate command interpreter, to make + # sure it doesn't get killed by Ctrl-C signal from bash. + # + $COMSPEC /C "start $COMSPEC /C $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun" + else + # + # Block Ctrl-C from getting passed to jlink server. + # + set -m + $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun > /dev/null & + set +m + fi + + echo "target remote localhost:3333" > $GDB_CMD_FILE + # Whether target should be reset or not + if [ ! -z "$RESET" ]; then + echo "mon reset" >> $GDB_CMD_FILE + echo "si" >> $GDB_CMD_FILE + fi + echo "$EXTRA_GDB_CMDS" >> $GDB_CMD_FILE + + if [ -x "$COMSPEC" ]; then + $COMSPEC /C "start $COMSPEC /C arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME" + else + arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME + rm $GDB_CMD_FILE + fi else - $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun + $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun fi return 0 } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/56444edf/hw/scripts/openocd.sh ---------------------------------------------------------------------- diff --git a/hw/scripts/openocd.sh b/hw/scripts/openocd.sh index 7c6c012..e838bcd 100644 --- a/hw/scripts/openocd.sh +++ b/hw/scripts/openocd.sh @@ -76,12 +76,20 @@ openocd_debug () { exit 1 fi - # - # Block Ctrl-C from getting passed to openocd. - # - set -m - openocd $CFG -f $OCD_CMD_FILE -c init -c halt & - set +m + if [ -x "$COMSPEC" ]; then + # + # Launch openocd in a separate command interpreter, to make sure + # it doesn't get killed by Ctrl-C signal from bash. + # + $COMSPEC /C "start $COMSPEC /C openocd $CFG -f $OCD_CMD_FILE -c init -c halt" + else + # + # Block Ctrl-C from getting passed to openocd. + # + set -m + openocd $CFG -f $OCD_CMD_FILE -c init -c halt & + set +m + fi GDB_CMD_FILE=.gdb_cmds @@ -89,15 +97,21 @@ openocd_debug () { if [ ! -z "$RESET" ]; then echo "mon reset halt" >> $GDB_CMD_FILE fi - arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME - rm $GDB_CMD_FILE + if [ -x "$COMSPEC" ]; then + $COMSPEC /C "start $COMSPEC /C arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME" + else + arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME + rm $GDB_CMD_FILE + fi else # No GDB, wait for openocd to exit openocd $CFG -f $OCD_CMD_FILE -c init -c halt return $? fi - rm $OCD_CMD_FILE + if [ ! -x "$COMSPEC" ]; then + rm $OCD_CMD_FILE + fi return 0 }