Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ifs
sconsider
Commits
8df1a0fe
Commit
8df1a0fe
authored
Nov 21, 2019
by
Marcel Huber
Browse files
Merge branch '11-update-compiler-defines-to-latest-version' into 'master'
updated defines.sh to latest version See merge request
!15
parents
1323159a
f3acaad2
Pipeline
#48228
failed with stages
in 6 minutes and 37 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
SConsider/SomeUtils.py
View file @
8df1a0fe
...
...
@@ -344,7 +344,14 @@ def runCommand(args, logpath='', filename=None, stdincontent=None, timeout=120.0
if
not
os
.
path
.
isdir
(
logpath
):
os
.
makedirs
(
logpath
)
logfilebasename
=
os
.
path
.
basename
(
args
[
0
])
logfilebasename
=
''
if
kw
.
get
(
'shell'
,
False
):
logfilebasename
=
'shell.'
if
isinstance
(
args
,
str
):
# split args as it might contain newlines if it is a shell command
logfilebasename
+=
os
.
path
.
basename
(
args
.
split
()[
0
])
else
:
logfilebasename
+=
os
.
path
.
basename
(
args
[
0
])
if
filename
:
logfilebasename
=
logfilebasename
+
'.'
+
os
.
path
.
basename
(
filename
)
errfilename
=
os
.
path
.
join
(
logpath
,
logfilebasename
+
'.stderr'
)
...
...
SConsider/site_tools/defines.sh
View file @
8df1a0fe
...
...
@@ -52,6 +52,10 @@
# 4.1.1 20031130 Greg Roelofs
# * Added some GCC-specific "long long" macros (note: uses defined(),
# not ifdef--break into four-level nested block to support K&R compilers)
#
# 4.1.2 20100821 Uffe Jakobsen
# * Added LC_ALL export to handle a problem with illegal byte sequences in
# tr on Darwin.
# parse options, if any (change "if" to "while" if add more options)
...
...
@@ -67,38 +71,42 @@ while [ $# -ne 0 ]; do
esac
done
LC_ALL
=
C
export
LC_ALL
# print some helpful identifying info for those who collect these things
echo
\
'This is output from `defines'
"' version
$v
, from your buddies at Newtware!"
date
# search the path for uname and strings (apparently "which" is broken in some
# versions of Ultrix, and "test" does not accept the -x option)
path
=
"
`
echo
$PATH
|
sed
-e
's/:/ /g'
`
"
unpath
=
`
for
dir
in
$path
;
do
if
[
-r
$dir
/uname
]
;
then
echo
$dir
/uname
path
=
"
$(
echo
"
$PATH
"
|
sed
-e
's/:/ /g'
)
"
unpath
=
$(
for
dir
in
$path
;
do
if
[
-r
"
$dir
/uname
"
]
;
then
echo
"
$dir
/uname
"
exit
fi
done
`
done
)
if
[
"
$unpath
"
!=
""
]
;
then
$unpath
-a
else
echo
"[no uname command]"
fi
strpath
=
`
for
dir
in
$path
;
do
if
[
-r
$dir
/strings
]
;
then
echo
$dir
/strings
strpath
=
$(
for
dir
in
$path
;
do
if
[
-r
"
$dir
/strings
"
]
;
then
echo
"
$dir
/strings
"
exit
fi
done
`
done
)
if
[
"
$1
"
!=
""
]
;
then
if
[
"
`
basename
$1
`
"
!=
"
$1
"
]
;
then
cc
=
`
basename
$1
`
ccpath
=
`
dirname
$1
`
if
[
"
$(
basename
"
$1
"
)
"
!=
"
$1
"
]
;
then
cc
=
$(
basename
"
$1
"
)
ccpath
=
$(
dirname
"
$1
"
)
path
=
"
$path
$ccpath
"
else
cc
=
$1
...
...
@@ -111,6 +119,7 @@ else
fi
echo
""
# this is the start of a *really big* if-block; look for "END IF-BLOCK 1"
# about 135 lines down...
...
...
@@ -118,21 +127,23 @@ if [ "$strpath" = "" ]; then
echo
"
$0
: error: no "
'`'
"strings' command...giving up."
else
# search the path for the compiler
if
[
"
$ccpath
"
=
""
]
;
then
ccpath
=
`
for
dir
in
$path
;
do
if
[
-r
$dir
/
$cc
]
;
then
echo
$dir
ccpath
=
$(
for
dir
in
$path
;
do
if
[
-r
"
$dir
/
$cc
"
]
;
then
echo
"
$dir
"
exit
fi
done
`
done
)
fi
eval
'echo "debug: ccpath = [$ccpath]"'
"
$DEBUG
"
if
[
"
$ccpath
"
=
""
]
;
then
echo
"
$0
: warning:
$cc
unreadable (can't search for strings)"
fi
# create a list of possible preprocessors; cd into /tmp now to avoid
# problems with "." in path during "cc -v" compilation
# $dir/$cc/*cpp : Convex cc; *not* caught by "cc -v": no -v option
...
...
@@ -142,30 +153,32 @@ fi
# $dir/cpp.ansi : HP-UX
# /usr/lib/cmplrs/<compiler>/{decc,driver,cfe} : DEC Ultrix and OSF/1;
# shellcheck disable=SC2164
cd
/tmp
cpp
=
`
for
file
in
/etc/
*
.cfg
;
do
if
[
-r
$file
]
;
then
echo
$file
cpp
=
$(
for
file
in
/etc/
*
.cfg
;
do
if
[
-r
"
$file
"
]
;
then
echo
"
$file
"
fi
done
for
dir
in
$path
/lib /usr/lib /usr/local/lib /usr/lib/cmplrs/
$cc
/usr/lpp/
$cc
/bin
;
do
for
file
in
$dir
/
*
cpp
*
$dir
/
*
cc
$dir
/
*
comp
$dir
/
$cc
/
*
cpp
;
do
if
[
-r
$file
]
;
then
echo
$file
for
dir
in
$path
/lib /usr/lib /usr/local/lib
"
/usr/lib/cmplrs/
$cc
"
"
/usr/lpp/
$cc
/bin
"
;
do
for
file
in
"
$dir
"
/
*
cpp
*
"
$dir
"
/
*
cc
"
$dir
"
/
*
comp
"
$dir
"
/
"
$cc
"
/
*
cpp
;
do
if
[
-r
"
$file
"
]
;
then
echo
"
$file
"
fi
done
# these are Ultrix- and AIX-specific, sigh:
for
file
in
$dir
/driver
$dir
/cfe
$dir
/xlc
*
;
do
if
[
-r
$file
]
;
then
echo
$file
for
file
in
"
$dir
"
/driver
"
$dir
"
/cfe
"
$dir
"
/xlc
*
;
do
if
[
-r
"
$file
"
]
;
then
echo
"
$file
"
fi
done
done
`
done
)
eval
'echo "debug: cpp = [$cpp]"'
"
$DEBUG
"
if
[
"
$cpp
"
=
""
]
;
then
echo
"
$0
: warning: preprocessor(s) unreadable (can't search for strings)"
fi
# grab all possible compiler components out of "cc -v" output (catches GNU
# cpp and Sun acomp, in particular) and "cc -#" output (catches DNIX cc and
# dcc; others?). awkward tr syntax is required due to incompatibilities
...
...
@@ -173,66 +186,70 @@ fi
# (generic BSD/SysV problem?)
echo
"int i;"
>
/tmp/def
$$
.c
ccv
=
`
2>&1
$ccpath
/
$cc
-v
-c
/tmp/def
$$
.c |
ccv
=
$(
"
$ccpath
/
$cc
"
-v
-c
/tmp/def
$$
.c
2>&1
|
tr
' \009()<>,;:&|'
'\012\012\012\012\012\012\012\012\012\012\012'
|
grep
'^/'
|
grep
-v
'/tmp/'
|
grep
-v
'\.o$'
|
sort
-u
`
sort
-u
)
eval
'echo "debug: ccv = [$ccv]"'
"
$DEBUG
"
ccv2
=
`
2>&1
$ccpath
/
$cc
-#
-c
/tmp/def
$$
.c |
ccv2
=
$(
"
$ccpath
/
$cc
"
-#
-c
/tmp/def
$$
.c
2>&1
|
tr
' \009()<>,;:&|'
'\012\012\012\012\012\012\012\012\012\012\012'
|
grep
'^/'
|
grep
-v
'/tmp/'
|
grep
-v
'\.o$'
|
sort
-u
`
sort
-u
)
eval
'echo "debug: ccv2 = [$ccv2]"'
"
$DEBUG
"
cleanccv
=
`
for
file
in
$ccv
$ccv2
;
do
if
[
-r
$file
-a
!
-d
$file
]
;
then
echo
$file
cleanccv
=
$(
for
file
in
$ccv
$ccv2
;
do
if
[
-r
"
$file
"
]
&&
[
!
-d
"
$file
"
]
;
then
echo
"
$file
"
fi
done
`
done
)
eval
'echo "debug: cleanccv = [$cleanccv]"'
"
$DEBUG
"
# temp files used again for stropts, below
# if requested, grab header files, too: even if all compiler components
# unreadable, system header files should reference at least some of the
# predefined macros [drawback: potentially very slow; may increase number
# of strings tested by more than an order of magnitude]
if
[
$doincl
=
true
]
;
then
incl
=
`
for
dir
in
/usr/
*
include/ /usr/
*
include/
*
/
;
do
for
file
in
$dir
/
*
.h
;
do
if
[
-r
$file
]
;
then
echo
$file
incl
=
$(
for
dir
in
/usr/
*
include/ /usr/
*
include/
*
/
;
do
for
file
in
"
$dir
"
/
*
.h
;
do
if
[
-r
"
$file
"
]
;
then
echo
"
$file
"
fi
done
done
|
sed
's#//#/#g'
`
done
|
sed
's#//#/#g'
)
else
incl
=
fi
eval
'echo "debug: incl = [$incl]"'
"
$DEBUG
"
# if nothing is readable, no point in continuing: strings would hang (this
# is the start of another big if-block; look for "END IF-BLOCK 2" about 50
# lines down)
all
=
`
echo
$ccpath
/
$cc
$cpp
$cleanccv
$incl
|
tr
' '
'\012'
|
sort
-u
`
all
=
$(
echo
"
$ccpath
/
$cc
"
"
$cpp
"
"
$cleanccv
"
"
$incl
"
|
tr
' '
'\012'
|
sort
-u
)
eval
'echo "debug: all = [$all]"'
"
$DEBUG
"
if
[
"
$all
"
=
""
]
;
then
echo
"
$0
: error: all compiler components unreadable...giving up."
else
# figure out proper "strings" options for searching entire executable with
# minimum string-length 2
stropt1
=
"-a"
2>&1
$strpath
$stropt1
/tmp/def
$$
.c
>
/dev/null
"
$strpath
"
$stropt1
/tmp/def
$$
.c
>
/dev/null 2>&1
# shellcheck disable=SC2181
if
[
$?
-ne
0
]
;
then
stropt1
=
"-"
2>&1
$strpath
$stropt1
/tmp/def
$$
.c
>
/dev/null
"
$strpath
"
$stropt1
/tmp/def
$$
.c
>
/dev/null
2>&1
if
[
$?
-ne
0
]
;
then
# Coherent (
`
uname -v
`
= "COHERENT") doesn't have *either* option
# Coherent (
$(
uname -v
)
= "COHERENT") doesn't have *either* option
stropt1
=
""
fi
fi
...
...
@@ -242,7 +259,9 @@ eval 'echo "debug: stropt1 = [$stropt1]"'"$DEBUG"
# interpreted as "-50" or something; therefore try "-n 2" version first
stropt2
=
"-n 2"
2>&1
$strpath
$stropt2
/tmp/def
$$
.c
>
/dev/null
# shellcheck disable=SC2086
"
$strpath
"
$stropt2
/tmp/def
$$
.c
>
/dev/null 2>&1
# shellcheck disable=SC2181
if
[
$?
-ne
0
]
;
then
stropt2
=
"-2"
# GRR: I trust there's no version so pathetic it doesn't have a min-length
...
...
@@ -253,6 +272,7 @@ stropts="$stropt1 $stropt2"
eval
'echo "debug: stropts = [$stropts]"'
"
$DEBUG
"
rm
-f
/tmp/def
$$
.c /tmp/def
$$
.o
# create a pseudo-C "program" with every possible #ifdef included; quote
# each macro once to avoid expansion, then print it again to get its value.
# (the "char foo" shenanigans are necessary to work around a bug in the
...
...
@@ -262,7 +282,8 @@ rm -f /tmp/def$$.c /tmp/def$$.o
# [GRR: could also write "cc -v" output to tmp file and add that to
# strings list...]
$strpath
$stropts
$all
|
# shellcheck disable=SC2086,SC1004
"
$strpath
"
$stropts
$all
2>/dev/null |
tr
-s
" =:;,{}"
'\012\012\012\012\012\012\012'
|
sed
-e
's/^-D//'
|
sed
-n
'/^[a-zA-Z_][a-zA-Z0-9_]*$/p'
|
...
...
@@ -271,19 +292,23 @@ sed 's/^.*$/#ifdef &\
char foo[] = "%&" = &;\
#endif/'
>
/tmp/def
$$
.c
# preprocess the "program" to figure out which of the possible macros are real
$ccpath
/
$cc
$1
$2
$3
$4
-E
/tmp/def
$$
.c |
# shellcheck disable=SC2086
"
$ccpath
/
$cc
"
$1
$2
$3
$4
-E
/tmp/def
$$
.c 2>/dev/null |
sed
-n
'/^char.*"%/s///p'
|
sed
-e
's/"//'
-e
's/;//'
rm
-f
/tmp/def
$$
.c
fi
# END IF-BLOCK 2
fi
# END IF-BLOCK 1
#-----------------------------------------------------------------------------
echo
""
# compile another program to check for oversights and get sizes of basic types
# (the \\" combos around the %s fields and the sed-backslash command are re-
# quired to work around Coherent bug: plain \" loses backslash)
...
...
@@ -339,7 +364,8 @@ main()
}
END_O_DE_LINE
$ccpath
/
$cc
$1
$2
$3
$4
-o
/tmp/def
$$
/tmp/def
$$
.c
# shellcheck disable=SC2086
"
$ccpath
/
$cc
"
$1
$2
$3
$4
-o
/tmp/def
$$
/tmp/def
$$
.c 2>/dev/null
/tmp/def
$$
rm
-f
/tmp/def
$$
.c /tmp/def
$$
...
...
SConsider/site_tools/generateScript.py
View file @
8df1a0fe
...
...
@@ -31,7 +31,7 @@ def generateShellScript(scriptFile, env, binpath):
(
'SCRIPTDIR'
,
lambda
env
:
env
[
'SCRIPTDIR'
]),
(
'VARIANTDIR'
,
lambda
env
:
env
.
getRelativeVariantDirectory
()),
(
'BINARYNAME'
,
os
.
path
.
basename
(
binpath
)),
(
'BASEDIR'
,
'
`
searchBaseDirUp
\\
"${SCRIPTPATH}
\\
"
\\
"${SCRIPTDIR}
\\
"`
'
),
(
'BASEDIR'
,
'
$(
searchBaseDirUp "${SCRIPTPATH}
"
"${SCRIPTDIR}
")
'
),
]
specificExtensions
=
[]
...
...
@@ -74,32 +74,33 @@ def generateShellScript(scriptFile, env, binpath):
GDBSERVERPORT=2345
MYNAME="`basename
\\
"$0
\\
"`"
SCRIPTPATH="`dirname
\\
"$0
\\
"`"
SCRIPTPATH="`cd
\\
"$SCRIPTPATH
\\
" 2>/dev/null && """
+
pwdCommand
+
"""`"
STARTPATH="`"""
+
pwdCommand
+
r
"""`"
MYNAME="$(basename "$0")"
SCRIPTPATH="$(dirname "$0")"
SCRIPTPATH="$(cd "$SCRIPTPATH" 2>/dev/null && """
+
pwdCommand
+
""")"
# shellcheck disable=SC2034
STARTPATH="$("""
+
pwdCommand
+
r
""")"
doChangeDir=1
doDebug=0
doDebugServer=0
doTrace=0
declare -a cmdArr
doCommandWithArgs=0
showhelp()
{
echo ''
echo 'usage: '$MYNAME' [options]'
echo 'where options are:'
echo ' -d : run under debugger control (gdb) in foreground'
echo ' second -d runs executable in background mode'
echo ' and logs stacktrace on failure'
echo ' -e : run under debugger control in your IDE (gdbserver)'
echo ' -S : do not change directory before executing target'
echo ' eg. stay in current directory for executino'
echo ' -x <tool|opts> : run <tool tool-opts server-command server-options>'
echo ' to specify tool options, use multiple -x <opts> options'
echo ' -v : verbose mode'
[ -n "${1}" ] && echo "${1}";
echo ""
echo "usage: $MYNAME [options]"
echo "where options are:"
echo " -d : run under debugger control (gdb) in foreground"
echo " second -d runs executable in background mode"
echo " and logs stacktrace on failure"
echo " -e : run under debugger control in your IDE (gdbserver)"
echo " -S : do not change directory before executing target"
echo " eg. stay in current directory for execution"
echo " -x <tool|opts> : run <tool tool-opts server-command server-options>"
echo " to specify tool options, use multiple -x <opts> options"
echo " -v : verbose mode, second -v keeps generated batch files"
echo .
exit 3;
}
...
...
@@ -109,11 +110,10 @@ while getopts ":deSvx:-" opt
do
case $opt in
:)
echo "ERROR: -$OPTARG parameter missing, exiting!";
showhelp;
showhelp "ERROR: -$OPTARG parameter missing, exiting!";
;;
d)
doDebug=
`expr $
doDebug + 1
`
;
doDebug=
$((
doDebug + 1
))
;
;;
e)
doDebugServer=1;
...
...
@@ -122,10 +122,10 @@ do
doChangeDir=0;
;;
v)
doTrace=
1
;
doTrace=
$((doTrace + 1))
;
;;
x)
cmdArr=(${cmdArr[@]}
$OPTARG);
cmdArr=(
"
${cmdArr[@]}
" "
$OPTARG
"
);
;;
-)
break;
...
...
@@ -136,7 +136,7 @@ do
esac
done
shift
`expr $
OPTIND - 1
`
shift
$((
OPTIND - 1
))
# find base directory for a given path
# param 1: path to start from
...
...
@@ -147,24 +147,24 @@ searchBaseDirUp()
start_dir="${1}";
searchSegment="${2}";
dirDefault="${3}";
basePath="
`
cd
\
"$start_dir
\
" &&
while [ ! -d
\
"${searchSegment}
\
" ] && [
\"\`pwd\`\
" != / ]; do
basePath="
$(
cd "$start_dir"
2>/dev/null
&&
while [ ! -d "${searchSegment}" ] && [
"$(pwd)
" != / ]; do
cd .. 2>/dev/null;
done;
"""
+
pwdCommand
+
"""
`
";
)
";
test -d "${basePath}/${searchSegment}" || basePath="${dirDefault}";
echo "$basePath";
}
die() {
printf "%s
\n
" "$@";
printf "%s
\
\
n" "$@";
exit 1;
}
"""
+
expandvars
(
env
,
defaultExpansions
)
+
"""
# find the base directory
LIBDIR_BASE="
`
searchBaseDirUp
\\
"${SCRIPTPATH}
\\
"
\\
"${LIBDIR}
\\
"`
"
LIBDIR_BASE="
$(
searchBaseDirUp "${SCRIPTPATH}
"
"${LIBDIR}
")
"
test -n "${LIBDIR_BASE}" || die "No base directory found containing library directory [$LIBDIR], exiting."
...
...
@@ -174,7 +174,7 @@ test -d "${ABS_LIBDIR}/${VARIANTDIR}" && ABS_LIBDIR="${ABS_LIBDIR}/$VARIANTDIR"
"""
+
libpathvariable
+
"""="${ABS_LIBDIR}":$"""
+
libpathvariable
+
"""
export """
+
libpathvariable
+
"""
BINDIR_BASE="
`
searchBaseDirUp
\\
"${SCRIPTPATH}
\\
"
\\
"${BINDIR}
\\
"`
"
BINDIR_BASE="
$(
searchBaseDirUp "${SCRIPTPATH}
"
"${BINDIR}
")
"
test -n "${BINDIR_BASE}" || die "No base directory found containing binary directory [$BINDIR], exiting."
...
...
@@ -187,19 +187,13 @@ test -d "${ABS_BINDIR}/${VARIANTDIR}" && ABS_BINDIR="${ABS_BINDIR}/$VARIANTDIR"
#
# param 1: is the name of the generated batch file
# param 2: binary to execute
# param 3: run executable in background, default 1, set to 0 to run gdb in foreground
# param 4.. arguments passed to the debugged program
#
generateGdbCommandFile()
{
ggcfBatchFile="${1}";
ggcfBinaryToExecute="${2}";
ggcfRunInBackground=${3};
test $# -ge 3 || return 1;
shift 3
ggcfServerOptions="$@";
test $# -eq 2 || return 1;
# <<-EOF ignore tabs, nice for formatting heredocs
cat > ${ggcfBatchFile} <<-EOF
cat >
"
${ggcfBatchFile}
"
<<-EOF
handle SIGSTOP nostop nopass
handle SIGLWP nostop pass
handle SIGTERM nostop pass
...
...
@@ -210,22 +204,28 @@ cat > ${ggcfBatchFile} <<-EOF
set environment """
+
libpathvariable
+
"""=${"""
+
libpathvariable
+
"""}
set auto-solib-add 1
# convert to Windows path on mingw (msys supplies it automatically to non-msys tools)
file
\"
"""
+
(
"
`
cmd //c echo ${ggcfBinaryToExecute}
`
"
file
\"
"""
+
(
"
$(
cmd //c echo ${ggcfBinaryToExecute}
)
"
if
"mingw"
in
env
[
"TOOLS"
]
else
"${ggcfBinaryToExecute}"
)
+
r
'''"
set args ${ggcfServerOptions}
EOF
if [ $ggcfRunInBackground -eq 2 ]; then
cat >> ${ggcfBatchFile} <<-EOF
}
# generate gnu debugger command file which may be used for batch
# invocations of the debugger.
#
# param 1: is the name of the generated batch file
extendGdbCommandFileBatch()
{
ggcfBatchFile="${1}";
cat >> "$ggcfBatchFile" <<-EOF
set pagination 0
run
if \$_isvoid(\$_siginfo)
shell rm ${ggcfBatchFile}
if \$_isvoid(\$_exitcode)
set \$_exitcode=0
end
quit \$_exitcode
else
! echo "\
`
date +'%Y%m%d%H%M%S'
\`
: ========== GDB backtrace =========="
! echo "\
$(
date +'%Y%m%d%H%M%S'
)
: ========== GDB backtrace =========="
backtrace full
info registers
x/16i \$pc
...
...
@@ -236,46 +236,81 @@ cat >> ${ggcfBatchFile} <<-EOF
if \$_isvoid(\$_exitcode)
set \$_exitcode=55
end
shell rm ${ggcfBatchFile}
quit \$_exitcode
end
EOF
fi;
}
CMD="${ABS_BINDIR}/${BINARYNAME}"
test -x "${CMD}" || die "binary [${CMD}] is not executable, aborting!"
test ${doChangeDir} -eq 1 -a -d "${BINDIR_BASE}" && cd "${BINDIR_BASE}"
if [ "${doChangeDir}" -eq 1 ] && [ -d "${BINDIR_BASE}" ]; then
#shellcheck disable=SC2164
cd "${BINDIR_BASE}" 2>/dev/null
fi;
test ${doTrace} -eq 1 && ( cat <<EOF
test
"
${doTrace}
"
-eq 1 && ( cat <<EOF
Executing command [${CMD}]
with arguments [$@]
in directory [
`
pwd
`
]
in directory [
$(
pwd
)
]
EOF
)
toolPath=$(type -fP ${cmdArr[0]} 2>/dev/null)
if [ -
n
"$toolPath" ]; then
doCommandWithArgs=1
toolPath=$(type -fP
"
${cmdArr[0]}
"
2>/dev/null)
if [ -
z
"$toolPath"
] && [ "${cmdArr[0]}" != "exec"
]; then
cmdArr=()
fi
if [ ${doDebug:-0} -ge 1 ]; then
cfg_gdbcommands="'''
+
(
tempfile
.
gettempdir
()
+
os
.
sep
).
replace
(
'
\\
'
,
'/'
)
+
"""`basename
\\
"$0
\\
"`_$$";
generateGdbCommandFile "${cfg_gdbcommands}" "$CMD" $doDebug "$@"
test ${doTrace} -eq 1 && echo "Generated gdb command file:"
test ${doTrace} -eq 1 && cat ${cfg_gdbcommands}
cfg_gdbcommands="--command $cfg_gdbcommands";
test $doDebug -gt 1 && cfg_gdbcommands="--batch $cfg_gdbcommands";
exec bash -c "eval gdb ${cfg_gdbcommands}"
elif [ ${doDebugServer:-0} -eq 1 -a -x "$(type -fP gdbserver 2>/dev/null)" ]; then
exec gdbserver :${GDBSERVERPORT} "${CMD}" "$@"
elif [ ${doCommandWithArgs:-0} -eq 1 ]; then
test ${doTrace} -eq 1 && echo "executing command [${cmdArr[*]} ${CMD} $@]"
exec bash -c "eval ${cmdArr[*]} ${CMD} $@"
else
exec "$CMD" "$@"
fn="$(mktemp)"
fn_gdb="$(mktemp)"
if [ "${doDebugServer:-0}" -ge 1 ]; then
if [ -x "$(type -fP gdbserver 2>/dev/null)" ]; then
CMD="gdbserver :${GDBSERVERPORT} ${CMD}"
else
echo "gdbserver executable not found, executing cmd only"
fi
fi
"""
if [ "${doDebug:-0}" -ge 1 ]; then
if [ -x "$(type -fP gdb 2>/dev/null)" ]; then
generateGdbCommandFile "$fn_gdb" "$CMD"
_fn_org="$fn"
fn="$fn_gdb"
CMD="set args"
else
echo "gdb executable not found, executing cmd only"
doDebug=0
fi
fi
_cmd="${cmdArr[*]} ${CMD}"
for i in "$@"; do
_cmd="$_cmd \"$i\""
done
cat <<-EOF >>"$fn"
$_cmd
EOF
if [ "${doDebug:-0}" -ge 1 ]; then
cfg_gdbcommands="--command $fn_gdb";
if [ "$doDebug" -gt 1 ]; then
cfg_gdbcommands="--batch $cfg_gdbcommands";
extendGdbCommandFileBatch "$fn_gdb"
fi
test "${doTrace}" -ge 1 && {
echo "Generated gdb commands file for command [$cfg_gdbcommands]:";
cat "$fn_gdb";
}
fn="$_fn_org"
cat <<-EOF >>"$fn"
gdb $cfg_gdbcommands
EOF
fi
if [ "${doTrace}" -ge 1 ]; then
[ "${doTrace}" -lt 2 ] && echo rm -f "$fn" "$fn_gdb" >>"$fn"
echo "executing [$(cat "$fn")]";
fi
bash "$fn"
'''
scriptFile
.
write
(
scriptText
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment