This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: fix gdb_gcore.sh failure in ash/dash


On Fri, Sep 09, 2005 at 07:11:13PM -0700, Qunying Pan wrote:
> Hi,
> 
> Running gdb_gcore.sh in ash/dash fails with message "Hangup detected on 
> fd 0". The following patch fixes the problem. Acceptable?

Let's just use a tempfile.  This patch also makes one other change in
behavior: it uses gdb from $PATH instead of hardcoding /usr/bin, since
I needed that to test it and it seems more reasonable.

Anyone have comments on this patch?

-- 
Daniel Jacobowitz
CodeSourcery, LLC

2005-09-17  Daniel Jacobowitz  <dan@codesourcery.com>

	* gdb_gcore.sh: Use a temporary file.  Use gdb from $PATH.

Index: gdb_gcore.sh
===================================================================
RCS file: /big/fsf/rsync/src/src/gdb/gdb_gcore.sh,v
retrieving revision 1.1
diff -u -p -r1.1 gdb_gcore.sh
--- gdb_gcore.sh	17 Apr 2003 20:33:09 -0000	1.1
+++ gdb_gcore.sh	17 Sep 2005 21:56:18 -0000
@@ -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,14 @@ then
     shift; shift
 fi
 
+tmpfile=$$.scr
+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 +60,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 +81,3 @@ EOF
 done
 
 exit $rc
-


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]