a -h or --help option, which prints each options and a brief
description.
+* The gcore script now has a -g option that lets you specify the GDB
+ binary invoked by gcore.
+
* On systems that support linker namespaces, the output of the command
"info sharedlibraries" may add one more column, NS, which identifies the
namespace into which the library was loaded, if more than one namespace
process ID of the running program being analyzed by @command{gcore}.
If not specified, @var{prefix} defaults to @var{core}.
+@item -g @var{gdb}
+Use @var{gdb} as the executable binary to invoke @value{GDBN} for
+running the gcore command. This argument is optional, and defaults to
+invoking the @value{GDBN} binary that is installed alongside
+@command{gcore}.
+
@item -d @var{directory}
Use @var{directory} as the data directory when invoking @value{GDBN} for running
the gcore command. This argument is optional.
data_directory_opt=()
+# The GDB binary to run.
+gdb_binary=
+
function print_usage() {
prefix="Usage: $0"
padding=$(printf '%*s' ${#prefix})
echo "$prefix [-h|--help] [-v|--version]"
- echo "$padding [-a] [-o prefix] [-d data-directory]"
+ echo "$padding [-a] [-o prefix] [-g gdb] [-d data-directory]"
echo "$padding pid1 [pid2...pidN]"
}
echo " -a Dump all memory mappings."
echo " -o prefix Use 'prefix.pid' as the core file name."
echo " The default prefix is 'core'."
+ echo " -g gdb The GDB binary to run."
+ echo " Defaults to GDB installed alongside gcore."
echo " -d dir Pass '--data-directory dir' as an argument"
echo " to GDB."
}
echo "GNU gcore (${PKGVERSION}) ${VERSION}"
}
-while getopts vhao:d:-: OPT; do
+while getopts vhao:g:d:-: OPT; do
if [ "$OPT" = "-" ]; then
OPT="${OPTARG%%=*}"
OPTARG="${OPTARG#'$OPT'}"
o)
prefix=$OPTARG
;;
+ g)
+ gdb_binary="$OPTARG"
+ ;;
d)
data_directory_opt=("--data-directory" "$OPTARG")
;;
fi
fi
+if [ -z "$gdb_binary" ]; then
+ gdb_binary="$binary_path/@GDB_TRANSFORM_NAME@"
+fi
+
+gdb_binary_basename=`basename "$gdb_binary"`
+
# Check if the GDB binary is in the expected path. If not, just
# quit with a message.
-if [ ! -f "$binary_path/@GDB_TRANSFORM_NAME@" ]; then
- echo "gcore: GDB binary (${binary_path}/@GDB_TRANSFORM_NAME@) not found"
+if [ ! -f "$gdb_binary" ]; then
+ echo "gcore: GDB binary ($gdb_binary) not found"
exit 1
fi
do
# `</dev/null' to avoid touching interactive terminal if it is
# available but not accessible as GDB would get stopped on SIGTTIN.
- "$binary_path/@GDB_TRANSFORM_NAME@" </dev/null \
+ "$gdb_binary" </dev/null \
"${data_directory_opt[@]}" \
--nx --batch --readnever -iex 'set debuginfod enabled off' \
-ex "set pagination off" -ex "set height 0" -ex "set width 0" \
if [ -r "$prefix.$pid" ] ; then
rc=0
else
- echo "@GCORE_TRANSFORM_NAME@: failed to create $prefix.$pid"
+ echo "$gdb_binary_basename: failed to create $prefix.$pid"
rc=1
break
fi