undefect. CWE-407 — 63 sites patched across 27 ecosystems
Authors: russell@unturf.com · brackishbert@gmail.com · foxhop.net · TimeHexOn.com Patches, unit tests, benchmarks, whitepaper, and outreach briefs. Public domain — no copyright claimed. Use freely.
This commit is contained in:
commit
0a580b313d
70422 changed files with 17213626 additions and 0 deletions
59
make/scripts/compare-logger.sh
Normal file
59
make/scripts/compare-logger.sh
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
# Usage: ./logger.sh thelogfile acommand arg1 arg2
|
||||
#
|
||||
# Execute acommand with args, in such a way that
|
||||
# both stdout and stderr from acommand are appended to
|
||||
# thelogfile.
|
||||
#
|
||||
# Preserve stdout and stderr, so that the stdout
|
||||
# from logger.sh is the same from acommand and equally
|
||||
# for stderr.
|
||||
#
|
||||
# Propagate the result code from acommand so that
|
||||
# ./logger.sh exits with the same result code.
|
||||
|
||||
# Create a temporary directory to store the result code from
|
||||
# the wrapped command.
|
||||
RCDIR=`mktemp -dt jdk-build-logger.tmp.XXXXXX` || exit $?
|
||||
trap "rm -rf \"$RCDIR\"" EXIT
|
||||
LOGFILE=$1
|
||||
shift
|
||||
|
||||
# We need to handle command likes like "VAR1=val1 /usr/bin/cmd VAR2=val2".
|
||||
# Do this by shifting away prepended variable assignments, and export them
|
||||
# instead.
|
||||
is_prefix=true
|
||||
for opt; do
|
||||
if [[ "$is_prefix" = true && "$opt" =~ ^.*=.*$ ]]; then
|
||||
export $opt
|
||||
shift
|
||||
else
|
||||
is_prefix=false
|
||||
fi
|
||||
done
|
||||
|
||||
(exec 3>&1 ; ("$@" 2>&1 1>&3; echo $? > "$RCDIR/rc") | tee -a $LOGFILE 1>&2 ; exec 3>&-) | tee -a $LOGFILE
|
||||
exit `cat "$RCDIR/rc"`
|
||||
1679
make/scripts/compare.sh
Normal file
1679
make/scripts/compare.sh
Normal file
File diff suppressed because it is too large
Load diff
47
make/scripts/extract-vs-env.cmd
Normal file
47
make/scripts/extract-vs-env.cmd
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
@echo off
|
||||
REM
|
||||
REM Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
REM DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
REM
|
||||
REM This code is free software; you can redistribute it and/or modify it
|
||||
REM under the terms of the GNU General Public License version 2 only, as
|
||||
REM published by the Free Software Foundation.
|
||||
REM
|
||||
REM This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
REM ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
REM FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
REM version 2 for more details (a copy is included in the LICENSE file that
|
||||
REM accompanied this code).
|
||||
REM
|
||||
REM You should have received a copy of the GNU General Public License version
|
||||
REM 2 along with this work; if not, write to the Free Software Foundation,
|
||||
REM Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
REM
|
||||
REM Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
REM or visit www.oracle.com if you need additional information or have any
|
||||
REM questions.
|
||||
REM
|
||||
|
||||
set vcvarscmd=%1
|
||||
set output=%2
|
||||
if not "%3" == "auto" set version=-vcvars_ver=%3
|
||||
|
||||
set PATH_BEFORE=%PATH%
|
||||
|
||||
call %vcvarscmd% %version% %4 %5 %6 %7 %8 %9
|
||||
if exist %output% del %output%
|
||||
|
||||
call :extract "%PATH_BEFORE%", PATH_BEFORE
|
||||
call :extract "%PATH%", PATH_AFTER
|
||||
call :extract "%INCLUDE%", VS_INCLUDE
|
||||
call :extract "%LIB%", VS_LIB
|
||||
call :extract "%VCINSTALLDIR%", VCINSTALLDIR
|
||||
call :extract "%VCToolsRedistDir%", VCToolsRedistDir
|
||||
call :extract "%WindowsSdkDir%", WindowsSdkDir
|
||||
call :extract "%WINDOWSSDKDIR%", WINDOWSSDKDIR
|
||||
|
||||
exit /b 0
|
||||
|
||||
:extract
|
||||
echo %~2=$($BASH $TOPDIR/make/scripts/fixpath.sh -i import '%~1 ') >> %output%
|
||||
exit /b 0
|
||||
543
make/scripts/fixpath.sh
Normal file
543
make/scripts/fixpath.sh
Normal file
|
|
@ -0,0 +1,543 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation. Oracle designates this
|
||||
# particular file as subject to the "Classpath" exception as provided
|
||||
# by Oracle in the LICENSE file that accompanied this code.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
# Setup the environment fixpath assumes. Read from command line options if
|
||||
# available, or extract values automatically from the environment if missing.
|
||||
# This is robust, but slower.
|
||||
function setup() {
|
||||
|
||||
# Make regexp tests case insensitive
|
||||
shopt -s nocasematch
|
||||
# Prohibit msys2 from meddling with paths
|
||||
export MSYS2_ARG_CONV_EXCL="*"
|
||||
# Make sure WSL gets a copy of the path
|
||||
export WSLENV=PATH/l
|
||||
|
||||
while getopts "e:p:r:t:c:qmi" opt; do
|
||||
case "$opt" in
|
||||
e) PATHTOOL="$OPTARG" ;;
|
||||
p) DRIVEPREFIX="$OPTARG" ;;
|
||||
r) ENVROOT="$OPTARG" ;;
|
||||
t) WINTEMP="$OPTARG" ;;
|
||||
c) CMD="$OPTARG" ;;
|
||||
q) QUIET=true ;;
|
||||
m) MIXEDMODE=true ;;
|
||||
i) IGNOREFAILURES=true ;;
|
||||
?)
|
||||
# optargs found argument error
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND-1))
|
||||
ACTION="$1"
|
||||
|
||||
# Locate variables ourself if not giving from caller
|
||||
if [[ -z ${PATHTOOL+x} ]]; then
|
||||
PATHTOOL="$(type -p cygpath)"
|
||||
if [[ $PATHTOOL == "" ]]; then
|
||||
PATHTOOL="$(type -p wslpath)"
|
||||
if [[ $PATHTOOL == "" ]]; then
|
||||
if [[ $QUIET != true ]]; then
|
||||
echo fixpath: failure: Cannot locate cygpath or wslpath >&2
|
||||
fi
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z ${DRIVEPREFIX+x} ]]; then
|
||||
winroot="$($PATHTOOL -u c:/)"
|
||||
DRIVEPREFIX="${winroot%/c/}"
|
||||
else
|
||||
if [[ $DRIVEPREFIX == "NONE" ]]; then
|
||||
DRIVEPREFIX=""
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z ${ENVROOT+x} ]]; then
|
||||
unixroot="$($PATHTOOL -w / 2> /dev/null)"
|
||||
# Remove trailing backslash
|
||||
ENVROOT="${unixroot%\\}"
|
||||
elif [[ "$ENVROOT" == "[unavailable]" ]]; then
|
||||
ENVROOT=""
|
||||
fi
|
||||
|
||||
if [[ -z ${CMD+x} ]]; then
|
||||
CMD="$DRIVEPREFIX/c/windows/system32/cmd.exe"
|
||||
fi
|
||||
|
||||
if [[ -z ${WINTEMP+x} ]]; then
|
||||
wintemp_win="$($CMD /q /c echo %TEMP% 2>/dev/null | tr -d \\n\\r)"
|
||||
WINTEMP="$($PATHTOOL -u "$wintemp_win")"
|
||||
fi
|
||||
}
|
||||
|
||||
# Cleanup handling
|
||||
TEMPDIRS=""
|
||||
trap "cleanup" EXIT
|
||||
function cleanup() {
|
||||
if [[ "$TEMPDIRS" != "" ]]; then
|
||||
rm -rf $TEMPDIRS
|
||||
fi
|
||||
}
|
||||
|
||||
# Import a single path
|
||||
# Result: imported path returned in $result
|
||||
function import_path() {
|
||||
path="$1"
|
||||
# Strip trailing and leading space
|
||||
path="${path#"${path%%[![:space:]]*}"}"
|
||||
path="${path%"${path##*[![:space:]]}"}"
|
||||
|
||||
if [[ $path =~ ^.:[/\\].*$ ]] || [[ "$path" =~ ^"$ENVROOT"\\.*$ ]] ; then
|
||||
# We got a Windows path as input; use pathtool to convert to unix path
|
||||
path="$($PATHTOOL -u "$path")"
|
||||
# Path will now be absolute
|
||||
else
|
||||
# Make path absolute, and resolve embedded '..' in path
|
||||
dirpart="$(dirname "$path")"
|
||||
dirpart="$(cd "$dirpart" 2>&1 > /dev/null && pwd)"
|
||||
if [[ $? -ne 0 ]]; then
|
||||
if [[ $QUIET != true ]]; then
|
||||
echo fixpath: failure: Directory containing path "'"$path"'" does not exist >&2
|
||||
fi
|
||||
if [[ $IGNOREFAILURES != true ]]; then
|
||||
exit 1
|
||||
else
|
||||
path=""
|
||||
fi
|
||||
else
|
||||
basepart="$(basename "$path")"
|
||||
if [[ $dirpart == / ]]; then
|
||||
# Avoid double leading /
|
||||
dirpart=""
|
||||
fi
|
||||
if [[ $basepart == / ]]; then
|
||||
# Avoid trailing /
|
||||
basepart=""
|
||||
fi
|
||||
path="$dirpart/$basepart"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$path" != "" ]]; then
|
||||
# Store current unix path
|
||||
unixpath="$path"
|
||||
# If $unixpath does not exist, add .exe (needed on WSL)
|
||||
if [[ ! -e "$unixpath" ]]; then
|
||||
unixpath="$unixpath.exe"
|
||||
fi
|
||||
# Now turn it into a windows path
|
||||
winpath="$($PATHTOOL -w "$unixpath" 2>/dev/null)"
|
||||
if [[ $? -eq 0 && -e "$unixpath" ]]; then
|
||||
if [[ ! "$winpath" =~ ^"$ENVROOT"\\.*$ ]] ; then
|
||||
# If it is not in envroot, it's a generic windows path
|
||||
if [[ ! $winpath =~ ^[-_.:~+\\a-zA-Z0-9]*$ ]] ; then
|
||||
# Path has forbidden characters, rewrite as short name
|
||||
# This monster of a command uses the %~s support from cmd.exe to
|
||||
# reliably convert to short paths on all winenvs.
|
||||
shortpath="$($CMD /q /c for %I in \( "$winpath" \) do echo %~sI 2>/dev/null | tr -d \\n\\r)"
|
||||
if [[ ! $shortpath =~ ^[-_.:~+\\a-zA-Z0-9]*$ ]] ; then
|
||||
if [[ $QUIET != true ]]; then
|
||||
echo fixpath: failure: Path "'"$path"'" could not be converted to short path >&2
|
||||
fi
|
||||
if [[ $IGNOREFAILURES != true ]]; then
|
||||
exit 1
|
||||
else
|
||||
shortpath=""
|
||||
fi
|
||||
fi
|
||||
unixpath="$($PATHTOOL -u "$shortpath")"
|
||||
# unixpath is based on short name
|
||||
fi
|
||||
# Make it lower case
|
||||
path="$(echo "$unixpath" | tr '[:upper:]' '[:lower:]')"
|
||||
fi
|
||||
else
|
||||
# On WSL1, PATHTOOL will fail for files in envroot. If the unix path
|
||||
# exists, we assume that $path is a valid unix path.
|
||||
|
||||
if [[ ! -e $path ]]; then
|
||||
if [[ -e $path.exe ]]; then
|
||||
path="$path.exe"
|
||||
else
|
||||
if [[ $QUIET != true ]]; then
|
||||
echo fixpath: warning: Path "'"$path"'" does not exist >&2
|
||||
fi
|
||||
# This is not a fatal error, maybe the path will be created later on
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$path" =~ " " ]]; then
|
||||
# Our conversion attempts failed. Perhaps the path did not exists, and thus
|
||||
# we could not convert it to short name.
|
||||
if [[ $QUIET != true ]]; then
|
||||
echo fixpath: failure: Path "'"$path"'" contains space >&2
|
||||
fi
|
||||
if [[ $IGNOREFAILURES != true ]]; then
|
||||
exit 1
|
||||
else
|
||||
path=""
|
||||
fi
|
||||
fi
|
||||
|
||||
result="$path"
|
||||
}
|
||||
|
||||
# Import a single path, or a pathlist in Windows style (i.e. ; separated)
|
||||
# Incoming paths can be in Windows or unix style.
|
||||
# Returns in $result a converted path or path list
|
||||
function import_command_line() {
|
||||
imported=""
|
||||
|
||||
old_ifs="$IFS"
|
||||
IFS=";"
|
||||
for arg in $1; do
|
||||
if ! [[ $arg =~ ^" "+$ ]]; then
|
||||
import_path "$arg"
|
||||
|
||||
if [[ "$result" != "" && "$imported" = "" ]]; then
|
||||
imported="$result"
|
||||
else
|
||||
imported="$imported:$result"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
IFS="$old_ifs"
|
||||
|
||||
result="$imported"
|
||||
}
|
||||
|
||||
# If argument seems to be colon separated path list, and all elements
|
||||
# are possible to convert to paths, make a windows path list
|
||||
# Return 0 if successful with converted path list in $result, or
|
||||
# 1 if it was not a path list.
|
||||
function convert_pathlist() {
|
||||
converted_list=""
|
||||
pathlist_args="$1"
|
||||
|
||||
IFS=':' read -r -a arg_array <<< "$pathlist_args"
|
||||
for arg in "${arg_array[@]}"; do
|
||||
winpath=""
|
||||
# Start looking for drive prefix
|
||||
if [[ $arg =~ ^($DRIVEPREFIX/)([a-z])(/[^/]+.*$) ]] ; then
|
||||
winpath="${BASH_REMATCH[2]}:${BASH_REMATCH[3]}"
|
||||
# Change slash to backslash (or vice versa if mixed mode)
|
||||
if [[ $MIXEDMODE != true ]]; then
|
||||
winpath="${winpath//'/'/'\'}"
|
||||
else
|
||||
winpath="${winpath//'\'/'/'}"
|
||||
fi
|
||||
elif [[ $arg =~ ^(/[-_.*a-zA-Z0-9]+(/[-_.*a-zA-Z0-9]+)+.*$) ]] ; then
|
||||
# This looks like a unix path, like /foo/bar
|
||||
pathmatch="${BASH_REMATCH[1]}"
|
||||
if [[ $ENVROOT == "" ]]; then
|
||||
if [[ $QUIET != true ]]; then
|
||||
echo fixpath: failure: Path "'"$pathmatch"'" cannot be converted to Windows path >&2
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
winpath="$ENVROOT$pathmatch"
|
||||
# Change slash to backslash (or vice versa if mixed mode)
|
||||
if [[ $MIXEDMODE != true ]]; then
|
||||
winpath="${winpath//'/'/'\'}"
|
||||
else
|
||||
winpath="${winpath//'\'/'/'}"
|
||||
fi
|
||||
else
|
||||
# This does not look like a path, so assume this is not a proper pathlist.
|
||||
# Flag this to caller.
|
||||
result=""
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ "$converted_list" = "" ]]; then
|
||||
converted_list="$winpath"
|
||||
else
|
||||
converted_list="$converted_list;$winpath"
|
||||
fi
|
||||
done
|
||||
|
||||
result="$converted_list"
|
||||
return 0
|
||||
}
|
||||
|
||||
# The central conversion function. Convert a single argument, so that any
|
||||
# contained paths are converted to Windows style paths. Result is returned
|
||||
# in $result. If it is a path list, convert it as one.
|
||||
function convert_path() {
|
||||
if [[ $1 =~ : ]]; then
|
||||
convert_pathlist "$1"
|
||||
if [[ $? -eq 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
# Not all elements was possible to convert to Windows paths, so we
|
||||
# presume it is not a pathlist. Continue using normal conversion.
|
||||
fi
|
||||
|
||||
arg="$1"
|
||||
winpath=""
|
||||
# Start looking for drive prefix. Also allow /xxxx prefixes (typically options
|
||||
# for Visual Studio tools), and embedded file:// URIs.
|
||||
if [[ $arg =~ ^([^/]*|-[^:=]*[:=]|.*file://|/[a-zA-Z:]{1,3}:?)($DRIVEPREFIX/)([a-z])(/[^/]+.*$) ]] ; then
|
||||
prefix="${BASH_REMATCH[1]}"
|
||||
winpath="${BASH_REMATCH[3]}:${BASH_REMATCH[4]}"
|
||||
|
||||
# If the thing in its entirety points to an existing path, use that instead of thinking
|
||||
# we have a prefix. This can only happen if the top-level directory has a single-letter name.
|
||||
if [[ ${#prefix} -eq 2 && "${prefix:0:1}" == "/" ]]; then
|
||||
possiblepath="${BASH_REMATCH[1]}/${BASH_REMATCH[3]}${BASH_REMATCH[4]}"
|
||||
if [[ -e "$possiblepath" || -e "$(dirname $possiblepath)" || -e "$(echo $possiblepath | cut -d / -f 1-5)" ]] ; then
|
||||
prefix=
|
||||
drivepart="${possiblepath:1:1}"
|
||||
pathpart="${possiblepath:2}"
|
||||
winpath="$drivepart:$pathpart"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Change slash to backslash (or vice versa if mixed mode)
|
||||
if [[ $MIXEDMODE != true ]]; then
|
||||
winpath="${winpath//'/'/'\'}"
|
||||
else
|
||||
winpath="${winpath//'\'/'/'}"
|
||||
fi
|
||||
elif [[ $arg =~ ^([^/]*|-[^:=]*[:=]|(.*file://))(/([-_.+a-zA-Z0-9]+)(/[-_.+a-zA-Z0-9]+)+)(.*)?$ ]] ; then
|
||||
# This looks like a unix path, like /foo/bar. Also embedded file:// URIs.
|
||||
prefix="${BASH_REMATCH[1]}"
|
||||
pathmatch="${BASH_REMATCH[3]}"
|
||||
firstdir="${BASH_REMATCH[4]}"
|
||||
suffix="${BASH_REMATCH[6]}"
|
||||
|
||||
# We only believe this is a path if the first part is an existing directory
|
||||
# and the prefix is not a subdirectory in the current working directory. Remove
|
||||
# any part leading up to a : or = in the prefix before checking.
|
||||
if [[ -d "/$firstdir" && ! -d "${prefix##*:}" && ! -d "${prefix##*=}" ]]; then
|
||||
if [[ $ENVROOT == "" ]]; then
|
||||
if [[ $QUIET != true ]]; then
|
||||
echo fixpath: failure: Path "'"$pathmatch"'" cannot be converted to Windows path >&2
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
winpath="$ENVROOT$pathmatch"
|
||||
# Change slash to backslash (or vice versa if mixed mode)
|
||||
if [[ $MIXEDMODE != true ]]; then
|
||||
winpath="${winpath//'/'/'\'}"
|
||||
else
|
||||
winpath="${winpath//'\'/'/'}"
|
||||
fi
|
||||
winpath="$winpath$suffix"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $winpath != "" ]]; then
|
||||
result="$prefix$winpath"
|
||||
else
|
||||
# Return the arg unchanged
|
||||
result="$arg"
|
||||
fi
|
||||
}
|
||||
|
||||
# Treat $1 as name of a file containing paths. Convert those paths to Windows style,
|
||||
# and output them to the file specified by $2.
|
||||
# If the output file already exists, it is overwritten.
|
||||
function convert_file() {
|
||||
infile="$1"
|
||||
outfile="$2"
|
||||
if [[ -e $outfile ]] ; then
|
||||
rm $outfile
|
||||
fi
|
||||
while read line; do
|
||||
convert_path "$line"
|
||||
echo "$result" >> $outfile
|
||||
done < $infile
|
||||
}
|
||||
|
||||
# Treat $1 as name of a file containing paths. Convert those paths to Windows style,
|
||||
# in a new temporary file, and return a string "@<temp file>" pointing to that
|
||||
# new file.
|
||||
function convert_at_file() {
|
||||
infile="$1"
|
||||
if [[ -e $infile ]] ; then
|
||||
tempdir=$(mktemp -dt fixpath.XXXXXX -p "$WINTEMP")
|
||||
TEMPDIRS="$TEMPDIRS $tempdir"
|
||||
|
||||
while read line; do
|
||||
convert_path "$line"
|
||||
echo "$result" >> $tempdir/atfile
|
||||
done < $infile
|
||||
convert_path "$tempdir/atfile"
|
||||
result="@$result"
|
||||
else
|
||||
result="@$infile"
|
||||
fi
|
||||
}
|
||||
|
||||
# Convert an entire command line, replacing all unix paths with Windows paths,
|
||||
# and all unix-style path lists (colon separated) with Windows-style (semicolon
|
||||
# separated).
|
||||
function print_command_line() {
|
||||
converted_args=""
|
||||
for arg in "$@" ; do
|
||||
if [[ $arg =~ ^@(.*$) ]] ; then
|
||||
# This is an @-file with paths that need converting
|
||||
convert_at_file "${BASH_REMATCH[1]}"
|
||||
else
|
||||
convert_path "$arg"
|
||||
fi
|
||||
converted_args="$converted_args$result "
|
||||
done
|
||||
result="${converted_args% }"
|
||||
}
|
||||
|
||||
# Check if the winenv will allow us to start a Windows program when we are
|
||||
# standing in the current directory
|
||||
function verify_current_dir() {
|
||||
arg="$PWD"
|
||||
if [[ $arg =~ ^($DRIVEPREFIX/)([a-z])(/[^/]+.*$) ]] ; then
|
||||
return 0
|
||||
elif [[ $arg =~ ^(/[^/]+.*$) ]] ; then
|
||||
if [[ $ENVROOT == "" || $ENVROOT =~ ^\\\\.* ]]; then
|
||||
# This is a WSL1 or WSL2 environment
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
# This should not happen
|
||||
return 1
|
||||
}
|
||||
|
||||
# The core functionality of fixpath. Take the given command line, and convert
|
||||
# it and execute it, so that all paths are converted to Windows style.
|
||||
# The return code is the return code of the executed command.
|
||||
function exec_command_line() {
|
||||
# Check that Windows can handle our current directory (only an issue for WSL)
|
||||
verify_current_dir
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
# WSL1 will just forcefully put us in C:\Windows\System32 if we execute this from
|
||||
# a unix directory. WSL2 will do the same, and print a warning. In both cases,
|
||||
# we prefer to take control.
|
||||
cd "$WINTEMP"
|
||||
if [[ $QUIET != true ]]; then
|
||||
echo fixpath: warning: Changing directory to $WINTEMP >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
collected_args=()
|
||||
command=""
|
||||
for arg in "$@" ; do
|
||||
if [[ $command == "" ]]; then
|
||||
# We have not yet located the command to run
|
||||
if [[ $arg =~ ^(.*)=(.*)$ ]]; then
|
||||
# It's a leading env variable assignment (FOO=bar)
|
||||
key="${BASH_REMATCH[1]}"
|
||||
arg="${BASH_REMATCH[2]}"
|
||||
convert_path "$arg"
|
||||
# Set the variable to the converted result
|
||||
export $key="$result"
|
||||
# While this is only needed on WSL, it does not hurt to do everywhere
|
||||
export WSLENV=$WSLENV:$key/w
|
||||
else
|
||||
# The actual command will be executed by bash, so don't convert it
|
||||
command="$arg"
|
||||
fi
|
||||
else
|
||||
# Now we are collecting arguments; they all need converting
|
||||
if [[ $arg =~ ^@(.*$) ]] ; then
|
||||
# This is an @-file with paths that need converting
|
||||
convert_at_file "${BASH_REMATCH[1]}"
|
||||
else
|
||||
convert_path "$arg"
|
||||
fi
|
||||
collected_args=("${collected_args[@]}" "$result")
|
||||
fi
|
||||
done
|
||||
|
||||
# Now execute it
|
||||
if [[ -v DEBUG_FIXPATH ]]; then
|
||||
echo fixpath: debug: input: "$@" >&2
|
||||
echo fixpath: debug: output: "$command" "${collected_args[@]}" >&2
|
||||
fi
|
||||
|
||||
if [[ ! -e "$command" ]]; then
|
||||
if [[ -e "$command.exe" ]]; then
|
||||
command="$command.exe"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $ENVROOT != "" || ! -x /bin/grep ]]; then
|
||||
"$command" "${collected_args[@]}"
|
||||
else
|
||||
# For WSL1, automatically strip away warnings from WSLENV=PATH/l
|
||||
"$command" "${collected_args[@]}" 2> >(/bin/grep -v "ERROR: UtilTranslatePathList" 1>&2)
|
||||
fi
|
||||
}
|
||||
|
||||
# Check that the input represents a path that is reachable from Windows
|
||||
function verify_command_line() {
|
||||
arg="$1"
|
||||
if [[ $arg =~ ^($DRIVEPREFIX/)([a-z])(/[^/]+.*$) ]] ; then
|
||||
return 0
|
||||
elif [[ $arg =~ ^(/[^/]+/[^/]+.*$) ]] ; then
|
||||
if [[ $ENVROOT != "" ]]; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
#### MAIN FUNCTION
|
||||
|
||||
setup "$@"
|
||||
# Shift away the options processed in setup
|
||||
shift $((OPTIND))
|
||||
|
||||
if [[ "$ACTION" == "import" ]] ; then
|
||||
import_command_line "$@"
|
||||
echo "$result"
|
||||
elif [[ "$ACTION" == "print" ]] ; then
|
||||
print_command_line "$@"
|
||||
echo "$result"
|
||||
elif [[ "$ACTION" == "convert" ]] ; then
|
||||
convert_file "$@"
|
||||
elif [[ "$ACTION" == "exec" ]] ; then
|
||||
exec_command_line "$@"
|
||||
# Propagate exit code
|
||||
exit $?
|
||||
elif [[ "$ACTION" == "verify" ]] ; then
|
||||
verify_command_line "$@"
|
||||
exit $?
|
||||
else
|
||||
if [[ $QUIET != true ]]; then
|
||||
echo Unknown operation: "$ACTION" >&2
|
||||
echo Supported operations: import print exec verify >&2
|
||||
fi
|
||||
exit 2
|
||||
fi
|
||||
234
make/scripts/hotspot.sh.template
Normal file
234
make/scripts/hotspot.sh.template
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
|
||||
|
||||
# This script launches HotSpot.
|
||||
#
|
||||
# If the first parameter is either "-gdb" or "-gud", HotSpot will be
|
||||
# launched inside gdb. "-gud" means "open an Emacs window and run gdb
|
||||
# inside Emacs".
|
||||
#
|
||||
# If the first parameter is "-dbx", HotSpot will be launched inside dbx.
|
||||
#
|
||||
# If the first parameter is "-valgrind", HotSpot will be launched
|
||||
# inside Valgrind (http://valgrind.kde.org) using the Memcheck skin,
|
||||
# and with memory leak detection enabled. This currently (2005jan19)
|
||||
# requires at least Valgrind 2.3.0. -Xmx16m will also be passed as
|
||||
# the first parameter to HotSpot, since lowering HotSpot's memory
|
||||
# consumption makes execution inside of Valgrind *a lot* faster.
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# User changeable parameters ------------------------------------------------
|
||||
#
|
||||
|
||||
# This is the name of the gdb binary to use
|
||||
if [ ! "$GDB" ]
|
||||
then
|
||||
GDB=gdb
|
||||
fi
|
||||
|
||||
# This is the name of the dbx binary to use
|
||||
if [ ! "$DBX" ]
|
||||
then
|
||||
DBX=dbx
|
||||
fi
|
||||
|
||||
# This is the name of the Valgrind binary to use
|
||||
if [ ! "$VALGRIND" ]
|
||||
then
|
||||
VALGRIND=valgrind
|
||||
fi
|
||||
|
||||
# This is the name of Emacs for running GUD
|
||||
EMACS=emacs
|
||||
|
||||
#
|
||||
# End of user changeable parameters -----------------------------------------
|
||||
#
|
||||
|
||||
OS=`uname -s`
|
||||
|
||||
# Make sure the paths are fully specified, i.e. they must begin with /.
|
||||
REL_MYDIR=`dirname $0`
|
||||
MYDIR=`cd $REL_MYDIR && pwd`
|
||||
case "$OS" in
|
||||
CYGWIN*)
|
||||
MYDIR=`cygpath -m "$MYDIR"`
|
||||
;;
|
||||
esac
|
||||
|
||||
#
|
||||
# Look whether the user wants to run inside gdb
|
||||
case "$1" in
|
||||
-gdb)
|
||||
MODE=gdb
|
||||
shift
|
||||
;;
|
||||
-gud)
|
||||
MODE=gud
|
||||
shift
|
||||
;;
|
||||
-dbx)
|
||||
MODE=dbx
|
||||
shift
|
||||
;;
|
||||
-valgrind)
|
||||
MODE=valgrind
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
MODE=run
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "${ALT_JAVA_HOME}" != "" ]; then
|
||||
JDK=${ALT_JAVA_HOME%%/jre}
|
||||
else
|
||||
JDK=@@JDK_IMPORT_PATH@@
|
||||
fi
|
||||
|
||||
if [ "${JDK}" != "" ]; then
|
||||
case "$OS" in
|
||||
CYGWIN*)
|
||||
JDK=`cygpath -m "$JDK"`
|
||||
;;
|
||||
esac
|
||||
|
||||
else
|
||||
echo "Failed to find JDK." \
|
||||
"Either ALT_JAVA_HOME is not set or JDK_IMPORT_PATH is empty."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# We will set the LD_LIBRARY_PATH as follows:
|
||||
# o $JVMPATH (directory portion only)
|
||||
# o $JRE/lib
|
||||
# followed by the user's previous effective LD_LIBRARY_PATH, if
|
||||
# any.
|
||||
JRE=$JDK
|
||||
JAVA_HOME=$JDK
|
||||
export JAVA_HOME
|
||||
|
||||
SBP=${MYDIR}:${JRE}/lib
|
||||
|
||||
|
||||
# Set up a suitable LD_LIBRARY_PATH or DYLD_LIBRARY_PATH
|
||||
if [ "${OS}" = "Darwin" ]
|
||||
then
|
||||
if [ -z "$DYLD_LIBRARY_PATH" ]
|
||||
then
|
||||
DYLD_LIBRARY_PATH="$SBP"
|
||||
else
|
||||
DYLD_LIBRARY_PATH="$SBP:$DYLD_LIBRARY_PATH"
|
||||
fi
|
||||
export DYLD_LIBRARY_PATH
|
||||
else
|
||||
# not 'Darwin'
|
||||
if [ -z "$LD_LIBRARY_PATH" ]
|
||||
then
|
||||
LD_LIBRARY_PATH="$SBP"
|
||||
else
|
||||
LD_LIBRARY_PATH="$SBP:$LD_LIBRARY_PATH"
|
||||
fi
|
||||
export LD_LIBRARY_PATH
|
||||
fi
|
||||
|
||||
JPARMS="-XXaltjvm=$MYDIR -Dsun.java.launcher.is_altjvm=true";
|
||||
|
||||
# Locate the java launcher
|
||||
LAUNCHER=$JDK/bin/java
|
||||
if [ ! -x $LAUNCHER ] ; then
|
||||
echo Error: Cannot find the java launcher \"$LAUNCHER\"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
GDBSRCDIR=$MYDIR
|
||||
BASEDIR=`cd $MYDIR/../../.. && pwd`
|
||||
case "$OS" in
|
||||
CYGWIN*)
|
||||
BASEDIR=`cygpath -m "$BASEDIR"`
|
||||
;;
|
||||
esac
|
||||
|
||||
init_gdb() {
|
||||
# Create a gdb script in case we should run inside gdb
|
||||
GDBSCR=/tmp/hsl.$$
|
||||
rm -f $GDBSCR
|
||||
cat >>$GDBSCR <<EOF
|
||||
cd `pwd`
|
||||
handle SIGUSR1 nostop noprint
|
||||
handle SIGUSR2 nostop noprint
|
||||
directory $GDBSRCDIR
|
||||
# Get us to a point where we can set breakpoints in libjvm.so
|
||||
set breakpoint pending on
|
||||
break JNI_CreateJavaVM
|
||||
run
|
||||
# Stop in JNI_CreateJavaVM
|
||||
delete 1
|
||||
# We can now set breakpoints wherever we like
|
||||
EOF
|
||||
}
|
||||
|
||||
case "$MODE" in
|
||||
gdb)
|
||||
init_gdb
|
||||
$GDB -x $GDBSCR --args $LAUNCHER $JPARMS "$@" $JAVA_ARGS
|
||||
rm -f $GDBSCR
|
||||
;;
|
||||
gud)
|
||||
init_gdb
|
||||
# First find out what emacs version we're using, so that we can
|
||||
# use the new pretty GDB mode if emacs -version >= 22.1
|
||||
case `$EMACS -version 2> /dev/null` in
|
||||
*GNU\ Emacs\ 2[23]*)
|
||||
emacs_gud_cmd="gdba"
|
||||
emacs_gud_args="--annotate=3"
|
||||
;;
|
||||
*)
|
||||
emacs_gud_cmd="gdb"
|
||||
emacs_gud_args=
|
||||
;;
|
||||
esac
|
||||
$EMACS --eval "($emacs_gud_cmd \"$GDB $emacs_gud_args -x $GDBSCR\")";
|
||||
rm -f $GDBSCR
|
||||
;;
|
||||
dbx)
|
||||
$DBX -s $HOME/.dbxrc -c "loadobject -load libjvm.so; stop in JNI_CreateJavaVM; run $JPARMS $@ $JAVA_ARGS; delete all" $LAUNCHER
|
||||
;;
|
||||
valgrind)
|
||||
echo Warning: Defaulting to 16Mb heap to make Valgrind run faster, use -Xmx for larger heap
|
||||
echo
|
||||
$VALGRIND --tool=memcheck --leak-check=yes --num-callers=50 $LAUNCHER -Xmx16m $JPARMS "$@" $JAVA_ARGS
|
||||
;;
|
||||
run)
|
||||
LD_PRELOAD=$PRELOADING exec $LAUNCHER $JPARMS "$@" $JAVA_ARGS
|
||||
;;
|
||||
*)
|
||||
echo Error: Internal error, unknown launch mode \"$MODE\"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
RETVAL=$?
|
||||
exit $RETVAL
|
||||
28
make/scripts/pandoc-html-manpage-filter.sh.template
Normal file
28
make/scripts/pandoc-html-manpage-filter.sh.template
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
# Simple wrapper script to call Java with the pandoc filter
|
||||
|
||||
@@JAVA_SMALL@@ -cp @@BUILDTOOLS_OUTPUTDIR@@/jdk_tools_classes \
|
||||
build.tools.pandocfilter.PandocManPageHtmlFilter
|
||||
28
make/scripts/pandoc-troff-manpage-filter.sh.template
Normal file
28
make/scripts/pandoc-troff-manpage-filter.sh.template
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
# Simple wrapper script to call Java with the pandoc filter
|
||||
|
||||
@@JAVA_SMALL@@ -cp @@BUILDTOOLS_OUTPUTDIR@@/jdk_tools_classes \
|
||||
build.tools.pandocfilter.PandocManPageTroffFilter
|
||||
69
make/scripts/shell-profiler.sh
Normal file
69
make/scripts/shell-profiler.sh
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
# Usage: sh shell-tracer.sh <TIME_CMD_TYPE> <TIME_CMD> <OUTPUT_FILE> <shell command line>
|
||||
#
|
||||
# This shell script is supposed to be set as a replacement for SHELL in make,
|
||||
# causing it to be called whenever make wants to execute shell commands.
|
||||
# The <shell command line> is suitable for passing on to the old shell,
|
||||
# typically beginning with -c.
|
||||
#
|
||||
# This script will run the shell command line and it will also store a simple
|
||||
# log of the time it takes to execute the command in the OUTPUT_FILE, using
|
||||
# utility for time measure specified with TIME_CMD option.
|
||||
#
|
||||
# Type of time measure utility is specified with TIME_CMD_TYPE option.
|
||||
# Recognized options values of TIME_CMD_TYPE option: "gnutime", "flock".
|
||||
|
||||
TIME_CMD_TYPE="$1"
|
||||
TIME_CMD="$2"
|
||||
OUTPUT_FILE="$3"
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
if [ "$TIME_CMD_TYPE" = "gnutime" ]; then
|
||||
# Escape backslashes (\) and percent chars (%). See man for GNU 'time'.
|
||||
msg=${@//\\/\\\\}
|
||||
msg=${msg//%/%%}
|
||||
"$TIME_CMD" -f "[TIME:%E] $msg" -a -o "$OUTPUT_FILE" "$@"
|
||||
elif [ "$TIME_CMD_TYPE" = "flock" ]; then
|
||||
# Emulated GNU 'time' with 'flock' and 'date'.
|
||||
ts=`date +%s%3N`
|
||||
"$@"
|
||||
status=$?
|
||||
ts2=`date +%s%3N`
|
||||
millis=$((ts2 - ts))
|
||||
ms=$(($millis % 1000))
|
||||
seconds=$((millis / 1000))
|
||||
ss=$(($seconds % 60))
|
||||
minutes=$(($seconds / 60))
|
||||
mm=$(($minutes % 60))
|
||||
hh=$(($minutes / 60)):
|
||||
[ $hh != "0:" ] || hh=
|
||||
# Synchronize on this script.
|
||||
flock -w 10 "$0" printf "[TIME:${hh}${mm}:${ss}.%.2s] %s\n" $ms "$*" >> "$OUTPUT_FILE" || true
|
||||
exit $status
|
||||
else
|
||||
"$@"
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue