3 # Copyright (C) 2003-2013 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # Script to generate a core file of a running program.
20 # It starts up gdb, attaches to the given PID and invokes the gcore command.
25 echo "usage: @GCORE_TRANSFORM_NAME@ [-o filename] pid"
29 # Need to check for -o option, but set default basename to "core".
36 # Not enough arguments.
37 echo "usage: @GCORE_TRANSFORM_NAME@ [-o filename] pid"
42 # Shift over to start of pid list
46 # Initialise return code.
52 # `</dev/null' to avoid touching interactive terminal if it is
53 # available but not accessible as GDB would get stopped on SIGTTIN.
54 @GDB_TRANSFORM_NAME@ </dev/null --nx --batch \
55 -ex "set pagination off" -ex "set height 0" -ex "set width 0" \
56 -ex "attach $pid" -ex "gcore $name.$pid" -ex detach -ex quit
58 if [ -r $name.$pid ] ; then
61 echo "@GCORE_TRANSFORM_NAME@: failed to create $name.$pid"