aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2005-10-02 23:01:01 +0000
committerDaniel Jacobowitz <drow@false.org>2005-10-02 23:01:01 +0000
commitdfb893afaae70c155f38277942f74f754080b356 (patch)
treef7865b83fd93fde50ddfdbc249c3239f2900e3c6 /gdb
parent5f9dfa63e99eedb21567ebdadaef471937e02af3 (diff)
downloadgdb-dfb893afaae70c155f38277942f74f754080b356.zip
gdb-dfb893afaae70c155f38277942f74f754080b356.tar.gz
gdb-dfb893afaae70c155f38277942f74f754080b356.tar.bz2
* gdb_gcore.sh: Use a temporary file. Use gdb from $PATH.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog4
-rwxr-xr-xgdb/gdb_gcore.sh33
2 files changed, 23 insertions, 14 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d59cd4e..3fb9f9a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2005-10-02 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * gdb_gcore.sh: Use a temporary file. Use gdb from $PATH.
+
2005-09-29 Andreas Schwab <schwab@suse.de>
PR threads/2015
diff --git a/gdb/gdb_gcore.sh b/gdb/gdb_gcore.sh
index 9b42808..26af881 100755
--- a/gdb/gdb_gcore.sh
+++ b/gdb/gdb_gcore.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-# Copyright 2003 Free Software Foundation, Inc.
+# Copyright 2003, 2005 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
@@ -16,9 +16,6 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-# Please email any bugs, comments, and/or additions to this file to:
-# bug-gdb@prep.ai.mit.edu
-
#
# gcore.sh
# Script to generate a core file of a running program.
@@ -48,6 +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
@@ -55,17 +63,15 @@ rc=0
for pid in $*
do
# Write gdb script for pid $pid.
-
- # Avoid need for temporary files by using funky "here
- # document" feature of sh.
-
- /usr/bin/gdb > /dev/null << EOF
- attach $pid
- gcore $name.$pid
- detach
- quit
+ cat >>$tmpfile <<EOF
+attach $pid
+gcore $name.$pid
+detach
+quit
EOF
+ gdb -x $tmpfile -batch
+
if [ -r $name.$pid ] ; then
rc=0
else
@@ -78,4 +84,3 @@ EOF
done
exit $rc
-