2c2fa1
http://sourceware.org/ml/gdb-cvs/2013-04/msg00109.html
2c2fa1
2c2fa1
### src/gdb/ChangeLog	2013/04/11 13:14:04	1.15397
2c2fa1
### src/gdb/ChangeLog	2013/04/11 14:13:42	1.15398
2c2fa1
## -1,4 +1,28 @@
2c2fa1
 2013-04-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
2c2fa1
+	    Pedro Alves  <palves@redhat.com>
2c2fa1
+
2c2fa1
+	* Makefile.in (HAVE_NATIVE_GCORE_TARGET): New.
2c2fa1
+	(generated_files): Add gcore.
2c2fa1
+	(install-only, uninstall): Add gcore if HAVE_NATIVE_GCORE_TARGET or
2c2fa1
+	HAVE_NATIVE_GCORE_HOST.
2c2fa1
+	(gcore): New.
2c2fa1
+	* NEWS (Changes since GDB 7.6): Mention newly installed gcore.
2c2fa1
+	* config/alpha/alpha-osf3.mh, config/i386/fbsd.mh,
2c2fa1
+	config/i386/fbsd64.mh, config/i386/i386gnu.mh, config/i386/i386sol2.mh,
2c2fa1
+	config/i386/sol2-64.mh, config/mips/irix5.mh, config/mips/irix6.mh,
2c2fa1
+	config/powerpc/fbsd.mh, config/sparc/fbsd.mh, config/sparc/sol2.mh:
2c2fa1
+	Add HAVE_NATIVE_GCORE_HOST.
2c2fa1
+	* configure: Regenerate.
2c2fa1
+	* configure.ac (HAVE_NATIVE_GCORE_TARGET): New, set it, AC_SUBST it.
2c2fa1
+	New AC_SUBST fir GDB_TRANSFORM_NAME and GCORE_TRANSFORM_NAME.  New
2c2fa1
+	AC_CONFIG_FILES for gcore.
2c2fa1
+	* configure.tgt: Add gdb_have_gcore to the initial comment.  Set
2c2fa1
+	gdb_have_gcore.
2c2fa1
+	* gdb_gcore.sh: Rename to ...
2c2fa1
+	* gcore.in: ... here.  Remove gcore.sh comment.  Use GDB_TRANSFORM_NAME
2c2fa1
+	and GCORE_TRANSFORM_NAME substitutions.
2c2fa1
+
2c2fa1
+2013-04-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
2c2fa1
 
2c2fa1
 	* remote.c (unpush_and_perror): Add output message final dot.
2c2fa1
 
2c2fa1
### src/gdb/doc/ChangeLog	2013/04/10 15:11:12	1.1440
2c2fa1
### src/gdb/doc/ChangeLog	2013/04/11 14:13:44	1.1441
2c2fa1
## -1,3 +1,13 @@
2c2fa1
+2013-04-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
2c2fa1
+
2c2fa1
+	* Makefile.in (MAN1S): Add gcore.1.
2c2fa1
+	Remove "Host, target, and site specific Makefile fragments" comment.
2c2fa1
+	(@host_makefile_frag@, HAVE_NATIVE_GCORE_TARGET): New.
2c2fa1
+	(install-man1, uninstall-man1): Conditionalize gcore.1.
2c2fa1
+	(gcore.1): New.
2c2fa1
+	* gdb.texinfo (Man Pages): Add gcore man.
2c2fa1
+	(gcore man): New node.
2c2fa1
+
2c2fa1
 2013-04-10  Pedro Alves  <palves@redhat.com>
2c2fa1
 
2c2fa1
 	* gdb.texinfo (Process Record and Replay): Document that "set
2c2fa1
Index: gdb-7.6/gdb/gcore.in
2c2fa1
===================================================================
2c2fa1
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
2c2fa1
+++ gdb-7.6/gdb/gcore.in	2013-04-26 15:33:01.171049247 +0200
2c2fa1
@@ -0,0 +1,69 @@
2c2fa1
+#!/bin/sh
2c2fa1
+
2c2fa1
+#   Copyright (C) 2003-2013 Free Software Foundation, Inc.
2c2fa1
+
2c2fa1
+# This program is free software; you can redistribute it and/or modify
2c2fa1
+# it under the terms of the GNU General Public License as published by
2c2fa1
+# the Free Software Foundation; either version 3 of the License, or
2c2fa1
+# (at your option) any later version.
2c2fa1
+#
2c2fa1
+# This program is distributed in the hope that it will be useful,
2c2fa1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2c2fa1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2c2fa1
+# GNU General Public License for more details.
2c2fa1
+#
2c2fa1
+# You should have received a copy of the GNU General Public License
2c2fa1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2c2fa1
+
2c2fa1
+#
2c2fa1
+# Script to generate a core file of a running program.
2c2fa1
+# It starts up gdb, attaches to the given PID and invokes the gcore command.
2c2fa1
+#
2c2fa1
+
2c2fa1
+if [ "$#" -eq "0" ]
2c2fa1
+then
2c2fa1
+    echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
2c2fa1
+    exit 2
2c2fa1
+fi
2c2fa1
+
2c2fa1
+# Need to check for -o option, but set default basename to "core".
2c2fa1
+name=core
2c2fa1
+
2c2fa1
+if [ "$1" = "-o" ]
2c2fa1
+then
2c2fa1
+    if [ "$#" -lt "3" ]
2c2fa1
+    then
2c2fa1
+	# Not enough arguments.
2c2fa1
+	echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
2c2fa1
+	exit 2
2c2fa1
+    fi
2c2fa1
+    name=$2
2c2fa1
+
2c2fa1
+    # Shift over to start of pid list
2c2fa1
+    shift; shift
2c2fa1
+fi
2c2fa1
+
2c2fa1
+# Initialise return code.
2c2fa1
+rc=0
2c2fa1
+
2c2fa1
+# Loop through pids
2c2fa1
+for pid in $*
2c2fa1
+do
2c2fa1
+	# `
2c2fa1
+	# available but not accessible as GDB would get stopped on SIGTTIN.
2c2fa1
+	@GDB_TRANSFORM_NAME@ 
2c2fa1
+	    -ex "set pagination off" -ex "set height 0" -ex "set width 0" \
2c2fa1
+	    -ex "attach $pid" -ex "gcore $name.$pid" -ex detach -ex quit
2c2fa1
+
2c2fa1
+	if [ -r $name.$pid ] ; then 
2c2fa1
+	    rc=0
2c2fa1
+	else
2c2fa1
+	    echo "@GCORE_TRANSFORM_NAME@: failed to create $name.$pid"
2c2fa1
+	    rc=1
2c2fa1
+	    break
2c2fa1
+	fi
2c2fa1
+
2c2fa1
+
2c2fa1
+done
2c2fa1
+
2c2fa1
+exit $rc
2c2fa1
Index: gdb-7.6/gdb/gdb_gcore.sh
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/gdb_gcore.sh	2013-01-01 07:32:42.000000000 +0100
2c2fa1
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
2c2fa1
@@ -1,70 +0,0 @@
2c2fa1
-#!/bin/sh
2c2fa1
-
2c2fa1
-#   Copyright (C) 2003-2013 Free Software Foundation, Inc.
2c2fa1
-
2c2fa1
-# This program is free software; you can redistribute it and/or modify
2c2fa1
-# it under the terms of the GNU General Public License as published by
2c2fa1
-# the Free Software Foundation; either version 3 of the License, or
2c2fa1
-# (at your option) any later version.
2c2fa1
-#
2c2fa1
-# This program is distributed in the hope that it will be useful,
2c2fa1
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
2c2fa1
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2c2fa1
-# GNU General Public License for more details.
2c2fa1
-#
2c2fa1
-# You should have received a copy of the GNU General Public License
2c2fa1
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2c2fa1
-
2c2fa1
-#
2c2fa1
-# gcore.sh
2c2fa1
-# Script to generate a core file of a running program.
2c2fa1
-# It starts up gdb, attaches to the given PID and invokes the gcore command.
2c2fa1
-#
2c2fa1
-
2c2fa1
-if [ "$#" -eq "0" ]
2c2fa1
-then
2c2fa1
-    echo "usage:  gcore [-o filename] pid"
2c2fa1
-    exit 2
2c2fa1
-fi
2c2fa1
-
2c2fa1
-# Need to check for -o option, but set default basename to "core".
2c2fa1
-name=core
2c2fa1
-
2c2fa1
-if [ "$1" = "-o" ]
2c2fa1
-then
2c2fa1
-    if [ "$#" -lt "3" ]
2c2fa1
-    then
2c2fa1
-	# Not enough arguments.
2c2fa1
-	echo "usage:  gcore [-o filename] pid"
2c2fa1
-	exit 2
2c2fa1
-    fi
2c2fa1
-    name=$2
2c2fa1
-
2c2fa1
-    # Shift over to start of pid list
2c2fa1
-    shift; shift
2c2fa1
-fi
2c2fa1
-
2c2fa1
-# Initialise return code.
2c2fa1
-rc=0
2c2fa1
-
2c2fa1
-# Loop through pids
2c2fa1
-for pid in $*
2c2fa1
-do
2c2fa1
-	# `
2c2fa1
-	# available but not accessible as GDB would get stopped on SIGTTIN.
2c2fa1
-	gdb 
2c2fa1
-	    -ex "set pagination off" -ex "set height 0" -ex "set width 0" \
2c2fa1
-	    -ex "attach $pid" -ex "gcore $name.$pid" -ex detach -ex quit
2c2fa1
-
2c2fa1
-	if [ -r $name.$pid ] ; then 
2c2fa1
-	    rc=0
2c2fa1
-	else
2c2fa1
-	    echo gcore: failed to create $name.$pid
2c2fa1
-	    rc=1
2c2fa1
-	    break
2c2fa1
-	fi
2c2fa1
-
2c2fa1
-
2c2fa1
-done
2c2fa1
-
2c2fa1
-exit $rc
2c2fa1
Index: gdb-7.6/gdb/Makefile.in
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/Makefile.in	2013-04-26 15:32:58.000000000 +0200
2c2fa1
+++ gdb-7.6/gdb/Makefile.in	2013-04-26 15:33:01.172049246 +0200
2c2fa1
@@ -414,6 +414,7 @@ CONFIG_ALL= @CONFIG_ALL@
2c2fa1
 CONFIG_CLEAN= @CONFIG_CLEAN@
2c2fa1
 CONFIG_INSTALL = @CONFIG_INSTALL@
2c2fa1
 CONFIG_UNINSTALL = @CONFIG_UNINSTALL@
2c2fa1
+HAVE_NATIVE_GCORE_TARGET = @HAVE_NATIVE_GCORE_TARGET@
2c2fa1
 
2c2fa1
 # -I. for config files.
2c2fa1
 # -I$(srcdir) for gdb internal headers.
2c2fa1
@@ -963,7 +964,7 @@ DISTSTUFF = $(YYFILES)
2c2fa1
 
2c2fa1
 # All generated files which can be included by another file.
2c2fa1
 generated_files = config.h observer.h observer.inc ada-lex.c jit-reader.h \
2c2fa1
-	$(GNULIB_H) $(NAT_GENERATED_FILES)
2c2fa1
+	$(GNULIB_H) $(NAT_GENERATED_FILES) gcore
2c2fa1
 
2c2fa1
 .c.o:
2c2fa1
 	$(COMPILE) $<
2c2fa1
@@ -1039,6 +1040,19 @@ install-only: $(CONFIG_INSTALL)
2c2fa1
 			$(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \
2c2fa1
 		$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(includedir)/gdb ; \
2c2fa1
 		$(INSTALL_DATA) jit-reader.h $(DESTDIR)$(includedir)/gdb/jit-reader.h
2c2fa1
+	if test "x$(HAVE_NATIVE_GCORE_TARGET)$(HAVE_NATIVE_GCORE_HOST)" != x; \
2c2fa1
+	then \
2c2fa1
+	  transformed_name=`t='$(program_transform_name)'; \
2c2fa1
+			    echo gcore | sed -e "$$t"` ; \
2c2fa1
+		  if test "x$$transformed_name" = x; then \
2c2fa1
+		    transformed_name=gcore ; \
2c2fa1
+		  else \
2c2fa1
+		    true ; \
2c2fa1
+		  fi ; \
2c2fa1
+		  $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir) ; \
2c2fa1
+		  $(INSTALL_PROGRAM) gcore \
2c2fa1
+			  $(DESTDIR)$(bindir)/$$transformed_name; \
2c2fa1
+	fi
2c2fa1
 	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
2c2fa1
 
2c2fa1
 install-python:
2c2fa1
@@ -1054,6 +1068,17 @@ uninstall: force $(CONFIG_UNINSTALL)
2c2fa1
 		fi ; \
2c2fa1
 		rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \
2c2fa1
 		      $(DESTDIR)$(man1dir)/$$transformed_name.1
2c2fa1
+	if test "x$(HAVE_NATIVE_GCORE_TARGET)$(HAVE_NATIVE_GCORE_HOST)" != x; \
2c2fa1
+	then \
2c2fa1
+	  transformed_name=`t='$(program_transform_name)'; \
2c2fa1
+			    echo gcore | sed -e "$$t"` ; \
2c2fa1
+		  if test "x$$transformed_name" = x; then \
2c2fa1
+		    transformed_name=gcore ; \
2c2fa1
+		  else \
2c2fa1
+		    true ; \
2c2fa1
+		  fi ; \
2c2fa1
+		  rm -f $(DESTDIR)$(bindir)/$$transformed_name; \
2c2fa1
+	fi
2c2fa1
 	@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
2c2fa1
 
2c2fa1
 # The C++ name parser can be built standalone for testing.
2c2fa1
@@ -1298,6 +1323,9 @@ data-directory/Makefile: data-directory/
2c2fa1
 jit-reader.h: $(srcdir)/jit-reader.in
2c2fa1
 	$(SHELL) config.status $@
2c2fa1
 
2c2fa1
+gcore: $(srcdir)/gcore.in
2c2fa1
+	$(SHELL) config.status $@
2c2fa1
+
2c2fa1
 config.h: stamp-h ; @true
2c2fa1
 stamp-h: $(srcdir)/config.in config.status
2c2fa1
 	CONFIG_HEADERS=config.h:config.in \
2c2fa1
Index: gdb-7.6/gdb/NEWS
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/NEWS	2013-04-26 13:43:30.000000000 +0200
2c2fa1
+++ gdb-7.6/gdb/NEWS	2013-04-26 15:33:19.784032404 +0200
2c2fa1
@@ -1,6 +1,9 @@
2c2fa1
 		What has changed in GDB?
2c2fa1
 	     (Organized release by release)
2c2fa1
 
2c2fa1
+* Newly installed $prefix/bin/gcore acts as a shell interface for the
2c2fa1
+  GDB command gcore.
2c2fa1
+
2c2fa1
 *** Changes in GDB 7.6
2c2fa1
 
2c2fa1
 * Target record has been renamed to record-full.
2c2fa1
Index: gdb-7.6/gdb/configure
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/configure	2013-03-12 23:25:32.000000000 +0100
2c2fa1
+++ gdb-7.6/gdb/configure	2013-04-26 15:33:01.179049240 +0200
2c2fa1
@@ -591,6 +591,8 @@ ac_includes_default="\
2c2fa1
 enable_option_checking=no
2c2fa1
 ac_subst_vars='LTLIBOBJS
2c2fa1
 LIBOBJS
2c2fa1
+GCORE_TRANSFORM_NAME
2c2fa1
+GDB_TRANSFORM_NAME
2c2fa1
 GDB_NM_FILE
2c2fa1
 frags
2c2fa1
 target_subdir
2c2fa1
@@ -681,6 +683,7 @@ AWK
2c2fa1
 REPORT_BUGS_TEXI
2c2fa1
 REPORT_BUGS_TO
2c2fa1
 PKGVERSION
2c2fa1
+HAVE_NATIVE_GCORE_TARGET
2c2fa1
 TARGET_OBS
2c2fa1
 subdirs
2c2fa1
 GDB_DATADIR
2c2fa1
@@ -5075,6 +5078,7 @@ fi
2c2fa1
 
2c2fa1
 TARGET_OBS=
2c2fa1
 all_targets=
2c2fa1
+HAVE_NATIVE_GCORE_TARGET=
2c2fa1
 
2c2fa1
 for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
2c2fa1
 do
2c2fa1
@@ -5109,6 +5113,12 @@ fi
2c2fa1
     if test x${want64} = xfalse; then
2c2fa1
       . ${srcdir}/../bfd/config.bfd
2c2fa1
     fi
2c2fa1
+
2c2fa1
+    # Check whether this target is native and supports gcore.
2c2fa1
+    if test $gdb_native = yes -a "$targ_alias" = "$target_alias" \
2c2fa1
+       && $gdb_have_gcore; then
2c2fa1
+      HAVE_NATIVE_GCORE_TARGET=1
2c2fa1
+    fi
2c2fa1
   fi
2c2fa1
 done
2c2fa1
 
2c2fa1
@@ -5171,6 +5181,7 @@ fi
2c2fa1
 
2c2fa1
 
2c2fa1
 
2c2fa1
+
2c2fa1
 # For other settings, only the main target counts.
2c2fa1
 gdb_sim=
2c2fa1
 gdb_osabi=
2c2fa1
@@ -14131,6 +14142,21 @@ ac_config_links="$ac_config_links $ac_co
2c2fa1
 $as_echo "#define GDB_DEFAULT_HOST_CHARSET \"UTF-8\"" >>confdefs.h
2c2fa1
 
2c2fa1
 
2c2fa1
+# Undo the $ec_script escaping suitable for Makefile.
2c2fa1
+transform=`echo "$program_transform_name" | sed -e 's/\\$\\$/\\$/g'`
2c2fa1
+GDB_TRANSFORM_NAME=`echo gdb | sed -e "$transform"`
2c2fa1
+if test "x$GDB_TRANSFORM_NAME" = x; then
2c2fa1
+  GDB_TRANSFORM_NAME=gdb
2c2fa1
+fi
2c2fa1
+
2c2fa1
+GCORE_TRANSFORM_NAME=`echo gcore | sed -e "$transform"`
2c2fa1
+if test "x$GCORE_TRANSFORM_NAME" = x; then
2c2fa1
+  GCORE_TRANSFORM_NAME=gcore
2c2fa1
+fi
2c2fa1
+
2c2fa1
+ac_config_files="$ac_config_files gcore"
2c2fa1
+
2c2fa1
+
2c2fa1
 ac_config_files="$ac_config_files Makefile gdb-gdb.gdb doc/Makefile data-directory/Makefile"
2c2fa1
 
2c2fa1
 ac_config_commands="$ac_config_commands default"
2c2fa1
@@ -14841,6 +14867,7 @@ do
2c2fa1
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
2c2fa1
     "jit-reader.h") CONFIG_FILES="$CONFIG_FILES jit-reader.h:jit-reader.in" ;;
2c2fa1
     "$ac_config_links_1") CONFIG_LINKS="$CONFIG_LINKS $ac_config_links_1" ;;
2c2fa1
+    "gcore") CONFIG_FILES="$CONFIG_FILES gcore" ;;
2c2fa1
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
2c2fa1
     "gdb-gdb.gdb") CONFIG_FILES="$CONFIG_FILES gdb-gdb.gdb" ;;
2c2fa1
     "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
2c2fa1
@@ -15462,6 +15489,7 @@ $as_echo "$as_me: executing $ac_file com
2c2fa1
 
2c2fa1
   case $ac_file$ac_mode in
2c2fa1
     "depdir":C) $SHELL $ac_aux_dir/mkinstalldirs $DEPDIR ;;
2c2fa1
+    "gcore":F) chmod +x gcore ;;
2c2fa1
     "default":C)
2c2fa1
 case x$CONFIG_HEADERS in
2c2fa1
 xconfig.h:config.in)
2c2fa1
Index: gdb-7.6/gdb/configure.ac
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/configure.ac	2013-03-12 23:25:32.000000000 +0100
2c2fa1
+++ gdb-7.6/gdb/configure.ac	2013-04-26 15:33:01.180049239 +0200
2c2fa1
@@ -203,6 +203,7 @@ fi
2c2fa1
 
2c2fa1
 TARGET_OBS=
2c2fa1
 all_targets=
2c2fa1
+HAVE_NATIVE_GCORE_TARGET=
2c2fa1
 
2c2fa1
 for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
2c2fa1
 do
2c2fa1
@@ -236,6 +237,12 @@ do
2c2fa1
     if test x${want64} = xfalse; then
2c2fa1
       . ${srcdir}/../bfd/config.bfd
2c2fa1
     fi
2c2fa1
+
2c2fa1
+    # Check whether this target is native and supports gcore.
2c2fa1
+    if test $gdb_native = yes -a "$targ_alias" = "$target_alias" \
2c2fa1
+       && $gdb_have_gcore; then
2c2fa1
+      HAVE_NATIVE_GCORE_TARGET=1
2c2fa1
+    fi
2c2fa1
   fi
2c2fa1
 done
2c2fa1
 
2c2fa1
@@ -264,6 +271,7 @@ if test x${all_targets} = xtrue; then
2c2fa1
 fi
2c2fa1
 
2c2fa1
 AC_SUBST(TARGET_OBS)
2c2fa1
+AC_SUBST(HAVE_NATIVE_GCORE_TARGET)
2c2fa1
 
2c2fa1
 # For other settings, only the main target counts.
2c2fa1
 gdb_sim=
2c2fa1
@@ -2349,6 +2357,20 @@ dnl  At the moment, we just assume it's
2c2fa1
 AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "UTF-8",
2c2fa1
           [Define to be a string naming the default host character set.])
2c2fa1
 
2c2fa1
+# Undo the $ec_script escaping suitable for Makefile.
2c2fa1
+transform=`echo "$program_transform_name" | sed -e 's/[\\$][\\$]/\\$/g'`
2c2fa1
+GDB_TRANSFORM_NAME=`echo gdb | sed -e "$transform"`
2c2fa1
+if test "x$GDB_TRANSFORM_NAME" = x; then
2c2fa1
+  GDB_TRANSFORM_NAME=gdb
2c2fa1
+fi
2c2fa1
+AC_SUBST(GDB_TRANSFORM_NAME)
2c2fa1
+GCORE_TRANSFORM_NAME=`echo gcore | sed -e "$transform"`
2c2fa1
+if test "x$GCORE_TRANSFORM_NAME" = x; then
2c2fa1
+  GCORE_TRANSFORM_NAME=gcore
2c2fa1
+fi
2c2fa1
+AC_SUBST(GCORE_TRANSFORM_NAME)
2c2fa1
+AC_CONFIG_FILES([gcore], [chmod +x gcore])
2c2fa1
+
2c2fa1
 AC_OUTPUT(Makefile gdb-gdb.gdb doc/Makefile data-directory/Makefile,
2c2fa1
 [
2c2fa1
 case x$CONFIG_HEADERS in
2c2fa1
Index: gdb-7.6/gdb/configure.tgt
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/configure.tgt	2013-03-05 14:37:10.000000000 +0100
2c2fa1
+++ gdb-7.6/gdb/configure.tgt	2013-04-26 15:33:01.180049239 +0200
2c2fa1
@@ -6,6 +6,7 @@
2c2fa1
 #  gdb_sim		simulator library for target
2c2fa1
 #  gdb_osabi		default OS ABI to use with target
2c2fa1
 #  build_gdbserver	set to "yes" if gdbserver supports target
2c2fa1
+#  gdb_have_gcore	set to "true"/"false" if this target can run gcore
2c2fa1
 
2c2fa1
 # NOTE: Every file added to a gdb_target_obs variable for any target here
2c2fa1
 #       must also be added to either ALL_TARGET_OBS or ALL_64_TARGET_OBS
2c2fa1
@@ -703,3 +704,14 @@ m68*-*-openbsd* | m88*-*-openbsd* | vax-
2c2fa1
 *-*-symbianelf*)
2c2fa1
 		gdb_osabi=GDB_OSABI_SYMBIAN ;;
2c2fa1
 esac
2c2fa1
+
2c2fa1
+# Check whether this target supports gcore.
2c2fa1
+# Such target has to call set_gdbarch_find_memory_regions.
2c2fa1
+case " ${gdb_target_obs} " in
2c2fa1
+  *" linux-tdep.o "*)
2c2fa1
+    gdb_have_gcore=true
2c2fa1
+    ;;
2c2fa1
+  *)
2c2fa1
+    gdb_have_gcore=false
2c2fa1
+    ;;
2c2fa1
+esac
2c2fa1
Index: gdb-7.6/gdb/config/alpha/alpha-osf3.mh
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/config/alpha/alpha-osf3.mh	2012-01-10 17:30:44.000000000 +0100
2c2fa1
+++ gdb-7.6/gdb/config/alpha/alpha-osf3.mh	2013-04-26 15:33:01.181049238 +0200
2c2fa1
@@ -3,4 +3,5 @@ NAT_FILE= nm-osf3.h
2c2fa1
 NATDEPFILES= alpha-nat.o fork-child.o \
2c2fa1
 	solib-osf.o procfs.o proc-api.o proc-events.o proc-flags.o \
2c2fa1
 	proc-why.o dec-thread.o
2c2fa1
+HAVE_NATIVE_GCORE_HOST = 1
2c2fa1
 NAT_CLIBS= -lpthreaddebug
2c2fa1
Index: gdb-7.6/gdb/config/i386/fbsd.mh
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/config/i386/fbsd.mh	2009-10-26 19:28:13.000000000 +0100
2c2fa1
+++ gdb-7.6/gdb/config/i386/fbsd.mh	2013-04-26 15:33:01.181049238 +0200
2c2fa1
@@ -3,5 +3,6 @@ NATDEPFILES= fork-child.o inf-ptrace.o \
2c2fa1
 	fbsd-nat.o i386-nat.o i386bsd-nat.o i386fbsd-nat.o \
2c2fa1
 	bsd-kvm.o
2c2fa1
 NAT_FILE= nm-fbsd.h
2c2fa1
+HAVE_NATIVE_GCORE_HOST = 1
2c2fa1
 
2c2fa1
 LOADLIBES= -lkvm
2c2fa1
Index: gdb-7.6/gdb/config/i386/fbsd64.mh
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/config/i386/fbsd64.mh	2012-02-09 17:06:44.000000000 +0100
2c2fa1
+++ gdb-7.6/gdb/config/i386/fbsd64.mh	2013-04-26 15:33:01.181049238 +0200
2c2fa1
@@ -2,5 +2,6 @@
2c2fa1
 NATDEPFILES= fork-child.o inf-ptrace.o \
2c2fa1
 	fbsd-nat.o amd64-nat.o amd64bsd-nat.o amd64fbsd-nat.o \
2c2fa1
 	bsd-kvm.o i386-nat.o
2c2fa1
+HAVE_NATIVE_GCORE_HOST = 1
2c2fa1
 
2c2fa1
 LOADLIBES= -lkvm
2c2fa1
Index: gdb-7.6/gdb/config/i386/i386gnu.mh
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/config/i386/i386gnu.mh	2012-01-10 17:30:44.000000000 +0100
2c2fa1
+++ gdb-7.6/gdb/config/i386/i386gnu.mh	2013-04-26 15:33:01.181049238 +0200
2c2fa1
@@ -2,6 +2,7 @@
2c2fa1
 NATDEPFILES= i386gnu-nat.o gnu-nat.o core-regset.o fork-child.o \
2c2fa1
 	     notify_S.o process_reply_S.o msg_reply_S.o \
2c2fa1
 	     msg_U.o exc_request_U.o exc_request_S.o
2c2fa1
+HAVE_NATIVE_GCORE_HOST = 1
2c2fa1
 
2c2fa1
 NAT_FILE= nm-i386gnu.h
2c2fa1
 MH_CFLAGS = -D_GNU_SOURCE
2c2fa1
Index: gdb-7.6/gdb/config/i386/i386sol2.mh
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/config/i386/i386sol2.mh	2010-04-26 15:53:56.000000000 +0200
2c2fa1
+++ gdb-7.6/gdb/config/i386/i386sol2.mh	2013-04-26 15:33:01.181049238 +0200
2c2fa1
@@ -1,3 +1,4 @@
2c2fa1
 # Host: Solaris x86
2c2fa1
 NATDEPFILES= fork-child.o i386v4-nat.o i386-sol2-nat.o \
2c2fa1
 	procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o
2c2fa1
+HAVE_NATIVE_GCORE_HOST = 1
2c2fa1
Index: gdb-7.6/gdb/config/i386/sol2-64.mh
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/config/i386/sol2-64.mh	2010-04-26 15:53:57.000000000 +0200
2c2fa1
+++ gdb-7.6/gdb/config/i386/sol2-64.mh	2013-04-26 15:33:01.182049237 +0200
2c2fa1
@@ -1,3 +1,4 @@
2c2fa1
 # Host: Solaris x86_64
2c2fa1
 NATDEPFILES= fork-child.o amd64-nat.o i386v4-nat.o i386-sol2-nat.o \
2c2fa1
 	procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o
2c2fa1
+HAVE_NATIVE_GCORE_HOST = 1
2c2fa1
Index: gdb-7.6/gdb/config/mips/irix5.mh
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/config/mips/irix5.mh	2012-01-10 17:30:45.000000000 +0100
2c2fa1
+++ gdb-7.6/gdb/config/mips/irix5.mh	2013-04-26 15:33:01.182049237 +0200
2c2fa1
@@ -1,3 +1,4 @@
2c2fa1
 # Host: SGI Iris running irix 5.x
2c2fa1
 NATDEPFILES= fork-child.o irix5-nat.o procfs.o \
2c2fa1
 	proc-api.o proc-events.o proc-flags.o proc-why.o
2c2fa1
+HAVE_NATIVE_GCORE_HOST = 1
2c2fa1
Index: gdb-7.6/gdb/config/mips/irix6.mh
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/config/mips/irix6.mh	2012-01-10 17:30:45.000000000 +0100
2c2fa1
+++ gdb-7.6/gdb/config/mips/irix6.mh	2013-04-26 15:33:01.182049237 +0200
2c2fa1
@@ -1,3 +1,4 @@
2c2fa1
 # Host: SGI Iris running irix 6.x
2c2fa1
 NATDEPFILES= fork-child.o irix5-nat.o procfs.o \
2c2fa1
 	proc-api.o proc-events.o proc-flags.o proc-why.o
2c2fa1
+HAVE_NATIVE_GCORE_HOST = 1
2c2fa1
Index: gdb-7.6/gdb/config/powerpc/fbsd.mh
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/config/powerpc/fbsd.mh	2013-02-04 21:48:53.000000000 +0100
2c2fa1
+++ gdb-7.6/gdb/config/powerpc/fbsd.mh	2013-04-26 15:33:01.182049237 +0200
2c2fa1
@@ -18,6 +18,7 @@
2c2fa1
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
2c2fa1
 
2c2fa1
 NATDEPFILES= fbsd-nat.o fork-child.o inf-ptrace.o ppcfbsd-nat.o bsd-kvm.o
2c2fa1
+HAVE_NATIVE_GCORE_HOST = 1
2c2fa1
 
2c2fa1
 LOADLIBES= -lkvm
2c2fa1
 
2c2fa1
Index: gdb-7.6/gdb/config/sparc/fbsd.mh
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/config/sparc/fbsd.mh	2009-10-26 19:28:15.000000000 +0100
2c2fa1
+++ gdb-7.6/gdb/config/sparc/fbsd.mh	2013-04-26 15:33:01.182049237 +0200
2c2fa1
@@ -2,5 +2,6 @@
2c2fa1
 NATDEPFILES= fork-child.o inf-ptrace.o \
2c2fa1
 	fbsd-nat.o sparc-nat.o sparc64-nat.o sparc64fbsd-nat.o \
2c2fa1
 	bsd-kvm.o
2c2fa1
+HAVE_NATIVE_GCORE_HOST = 1
2c2fa1
 
2c2fa1
 LOADLIBES= -lkvm
2c2fa1
Index: gdb-7.6/gdb/config/sparc/sol2.mh
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/config/sparc/sol2.mh	2012-01-10 17:30:49.000000000 +0100
2c2fa1
+++ gdb-7.6/gdb/config/sparc/sol2.mh	2013-04-26 15:33:01.182049237 +0200
2c2fa1
@@ -3,3 +3,4 @@ NAT_FILE= nm-sol2.h
2c2fa1
 NATDEPFILES= sparc-sol2-nat.o \
2c2fa1
 	core-regset.o fork-child.o \
2c2fa1
 	procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o
2c2fa1
+HAVE_NATIVE_GCORE_HOST = 1
2c2fa1
Index: gdb-7.6/gdb/doc/Makefile.in
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/doc/Makefile.in	2013-04-26 15:32:58.000000000 +0200
2c2fa1
+++ gdb-7.6/gdb/doc/Makefile.in	2013-04-26 15:33:01.183049235 +0200
2c2fa1
@@ -177,11 +177,15 @@ POD2MAN5 = pod2man --center="GNU Develop
2c2fa1
 		   --release="gdb-`sed q $(srcdir)/../version.in`" --section=5
2c2fa1
 
2c2fa1
 # List of man pages generated from gdb.texi
2c2fa1
-MAN1S = gdb.1 gdbserver.1
2c2fa1
+MAN1S = gdb.1 gdbserver.1 gcore.1
2c2fa1
 MAN5S = gdbinit.5
2c2fa1
 MANS = $(MAN1S) $(MAN5S)
2c2fa1
 
2c2fa1
-#### Host, target, and site specific Makefile fragments come in here.
2c2fa1
+# Host-dependent makefile fragment comes in here.
2c2fa1
+@host_makefile_frag@
2c2fa1
+# End of host-dependent makefile fragment
2c2fa1
+HAVE_NATIVE_GCORE_TARGET = @HAVE_NATIVE_GCORE_TARGET@
2c2fa1
+
2c2fa1
 ###
2c2fa1
 
2c2fa1
 all:
2c2fa1
@@ -269,6 +273,10 @@ install-man: install-man1 install-man5
2c2fa1
 install-man1: $(MAN1S)
2c2fa1
 	test -z "$(man1dir)" || $(mkinstalldirs) "$(DESTDIR)$(man1dir)"
2c2fa1
 	@list='$(MAN1S)'; for p in $$list; do \
2c2fa1
+	  if test "x$(HAVE_NATIVE_GCORE_TARGET)$(HAVE_NATIVE_GCORE_HOST)" = x \
2c2fa1
+		  -a "$$p" = gcore.1; then \
2c2fa1
+	    continue; \
2c2fa1
+	  fi; \
2c2fa1
 	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
2c2fa1
 	  f=`echo $$p | sed -e 's|^.*/||'`; \
2c2fa1
 	  echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(man1dir)/$$f'"; \
2c2fa1
@@ -288,7 +296,13 @@ uninstall-man: uninstall-man1 uninstall-
2c2fa1
 
2c2fa1
 uninstall-man1:
2c2fa1
 	@test -n "$(man1dir)" || exit 0; \
2c2fa1
-	files=`{ l2='$(MAN1S)'; for i in $$l2; do echo "$$i"; done | \
2c2fa1
+	files=`{ l2='$(MAN1S)'; for i in $$l2; do \
2c2fa1
+	  if test "x$(HAVE_NATIVE_GCORE_TARGET)$(HAVE_NATIVE_GCORE_HOST)" = x \
2c2fa1
+		  -a "$$i" = gcore.1; then \
2c2fa1
+	    continue; \
2c2fa1
+	  fi; \
2c2fa1
+	  echo "$$i"; \
2c2fa1
+	done | \
2c2fa1
 	  sed -n '/\.1[a-z]*$$/p'; \
2c2fa1
 	} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
2c2fa1
 	      -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
2c2fa1
@@ -605,6 +619,13 @@ gdbserver.1: $(GDB_DOC_FILES)
2c2fa1
 		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
2c2fa1
 	rm -f gdbserver.pod
2c2fa1
 
2c2fa1
+gcore.1: $(GDB_DOC_FILES)
2c2fa1
+	touch $@
2c2fa1
+	-$(TEXI2POD) $(MANCONF) -Dgcore < $(srcdir)/gdb.texinfo > gcore.pod
2c2fa1
+	-($(POD2MAN1) gcore.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
2c2fa1
+		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
2c2fa1
+	rm -f gcore.pod
2c2fa1
+
2c2fa1
 gdbinit.5: $(GDB_DOC_FILES)
2c2fa1
 	touch $@
2c2fa1
 	-$(TEXI2POD) $(MANCONF) -Dgdbinit < $(srcdir)/gdb.texinfo > gdbinit.pod
2c2fa1
Index: gdb-7.6/gdb/doc/gdb.texinfo
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/doc/gdb.texinfo	2013-04-26 15:32:58.000000000 +0200
2c2fa1
+++ gdb-7.6/gdb/doc/gdb.texinfo	2013-04-26 15:33:01.191049229 +0200
2c2fa1
@@ -41709,6 +41709,7 @@ switch (die->tag)
2c2fa1
 @menu
2c2fa1
 * gdb man::                     The GNU Debugger man page
2c2fa1
 * gdbserver man::               Remote Server for the GNU Debugger man page
2c2fa1
+* gcore man::                   Generate a core file of a running program
2c2fa1
 * gdbinit man::                 gdbinit scripts
2c2fa1
 @end menu
2c2fa1
 
2c2fa1
@@ -42230,6 +42231,53 @@ info gdb
2c2fa1
 should give you access to the complete manual.
2c2fa1
 
2c2fa1
 @cite{Using GDB: A Guide to the GNU Source-Level Debugger},
2c2fa1
+Richard M. Stallman and Roland H. Pesch, July 1991.
2c2fa1
+@end ifset
2c2fa1
+@c man end
2c2fa1
+
2c2fa1
+@node gcore man
2c2fa1
+@heading gcore
2c2fa1
+
2c2fa1
+@c man title gcore Generate a core file of a running program
2c2fa1
+
2c2fa1
+@format
2c2fa1
+@c man begin SYNOPSIS gcore
2c2fa1
+gcore [-o @var{filename}] @var{pid}
2c2fa1
+@c man end
2c2fa1
+@end format
2c2fa1
+
2c2fa1
+@c man begin DESCRIPTION gcore
2c2fa1
+Generate a core dump of a running program with process ID @var{pid}.
2c2fa1
+Produced file is equivalent to a kernel produced core file as if the process
2c2fa1
+crashed (and if @kbd{ulimit -c} were used to set up an appropriate core dump
2c2fa1
+limit).  Unlike after a crash, after @command{gcore} the program remains
2c2fa1
+running without any change.
2c2fa1
+@c man end
2c2fa1
+
2c2fa1
+@c man begin OPTIONS gcore
2c2fa1
+@table @env
2c2fa1
+@item -o @var{filename}
2c2fa1
+The optional argument
2c2fa1
+@var{filename} specifies the file name where to put the core dump.
2c2fa1
+If not specified, the file name defaults to @file{core.@var{pid}},
2c2fa1
+where @var{pid} is the running program process ID.
2c2fa1
+@end table
2c2fa1
+@c man end
2c2fa1
+
2c2fa1
+@c man begin SEEALSO gcore
2c2fa1
+@ifset man
2c2fa1
+The full documentation for @value{GDBN} is maintained as a Texinfo manual.
2c2fa1
+If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
2c2fa1
+documentation are properly installed at your site, the command
2c2fa1
+
2c2fa1
+@smallexample
2c2fa1
+info gdb
2c2fa1
+@end smallexample
2c2fa1
+
2c2fa1
+@noindent
2c2fa1
+should give you access to the complete manual.
2c2fa1
+
2c2fa1
+@cite{Using GDB: A Guide to the GNU Source-Level Debugger},
2c2fa1
 Richard M. Stallman and Roland H. Pesch, July 1991.
2c2fa1
 @end ifset
2c2fa1
 @c man end