diff --git a/dist/bin/common b/dist/bin/common index 8e1de94ff3cc..1c0757c5fe74 100755 --- a/dist/bin/common +++ b/dist/bin/common @@ -112,3 +112,6 @@ SCALA_ASM=$(find_lib "*scala-asm*") SCALA_LIB=$(find_lib "*scala-library*") SCALA_XML=$(find_lib "*scala-xml*") SBT_INTF=$(find_lib "*sbt-interface*") + +# debug +DEBUG_STR=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 diff --git a/dist/bin/dotc b/dist/bin/dotc index ef4e7c945be3..08b6554e3557 100755 --- a/dist/bin/dotc +++ b/dist/bin/dotc @@ -76,7 +76,7 @@ case "$1" in --) shift; for arg; do addResidual "$arg"; done; set -- ;; -h|-help) help=true && shift ;; -v|-verbose) verbose=true && shift ;; - -debug) debug=true && shift ;; + -debug) DEBUG="$DEBUG_STR" && shift ;; -q|-quiet) quiet=true && shift ;; # Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222 @@ -103,6 +103,7 @@ classpathArgs eval exec "\"$JAVACMD\"" \ ${JAVA_OPTS:-$default_java_opts} \ + "$DEBUG" \ "${java_args[@]}" \ "$jvm_cp_args" \ -Dscala.usejavacp=true \ diff --git a/dist/bin/dotr b/dist/bin/dotr index c5677581900f..c2563808e67b 100755 --- a/dist/bin/dotr +++ b/dist/bin/dotr @@ -31,6 +31,11 @@ source "$PROG_HOME/bin/common" CLASS_PATH=".$PSEP$DOTTY_LIB$PSEP$SCALA_LIB" +# -d must be the first option +case "$1" in + -d) DEBUG="$DEBUG_STR" && shift ;; +esac + first_arg="$1" if [ -z "$1" ]; then @@ -39,5 +44,5 @@ if [ -z "$1" ]; then elif [[ ${first_arg:0:1} == "-" ]]; then eval "$PROG_HOME/bin/dotc -repl $@" else - eval exec "\"$JAVACMD\"" "-classpath \"$CLASS_PATH\"" $@ + eval exec "\"$JAVACMD\"" "$DEBUG" "-classpath \"$CLASS_PATH\"" $@ fi