2011-02-28 Michael Snyder <msnyder@vmware.com>
[deliverable/binutils-gdb.git] / gdb / gdb_gcore.sh
index 26af881066efdcf7dff203c73b58fea152f60089..76b45a8fcbfee68e7ea1084a68ffcd5fe4432dab 100755 (executable)
@@ -1,20 +1,20 @@
 #!/bin/sh
 
-#   Copyright 2003, 2005  Free Software Foundation, Inc.
+#   Copyright (C) 2003, 2005, 2007, 2008, 2009, 2010, 2011
+#   Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program 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 for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #
 # gcore.sh
@@ -45,32 +45,17 @@ then
     shift; shift
 fi
 
-# Create a temporary file.  Use mktemp if available, but cope if it is not.
-tmpfile=`mktemp ${name}.XXXXXX 2>/dev/null` || {
-  tmpfile=${name}.$$
-  if test -e $tmpfile; then
-    echo "Could not create temporary file $tmpfile"
-    exit 1
-  fi
-  touch $tmpfile
-}
-trap "rm -f $tmpfile" EXIT
-
 # Initialise return code.
 rc=0
 
 # Loop through pids
 for pid in $*
 do
-       # Write gdb script for pid $pid.  
-       cat >>$tmpfile <<EOF
-attach $pid
-gcore $name.$pid
-detach
-quit
-EOF
-
-       gdb -x $tmpfile -batch
+       # `</dev/null' to avoid touching interactive terminal if it is
+       # available but not accessible as GDB would get stopped on SIGTTIN.
+       gdb </dev/null --nx --batch \
+           -ex "set pagination off" -ex "set height 0" -ex "set width 0" \
+           -ex "attach $pid" -ex "gcore $name.$pid" -ex detach -ex quit
 
        if [ -r $name.$pid ] ; then 
            rc=0
This page took 0.023683 seconds and 4 git commands to generate.