Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch 2/2+rfc+doc] Install gcore by default (+new man page)
@ 2013-04-08 14:15 Jan Kratochvil
  2013-04-08 19:41 ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: Jan Kratochvil @ 2013-04-08 14:15 UTC (permalink / raw)
  To: gdb-patches

Hi,

at least in Fedora the GDB packaging always installed /usr/bin/gcore.
Is it OK for upstream or should it be kept downstream?



Thanks,
Jan


gdb/
2013-04-07  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (install-only, uninstall): Add gcore.
	* configure: Regenerate.
	* configure.ac: New AC_SUBST fir GDB_TRANSFORM_NAME and
	GCORE_TRANSFORM_NAME.  New AC_CONFIG_FILES for gcore.
	* gdb_gcore.sh: Rename to ...
	* gcore.in: ... here.  Remove gcore.sh comment.  Use GDB_TRANSFORM_NAME
	and GCORE_TRANSFORM_NAME substitutions.

gdb/doc/
2013-04-07  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (MAN1S): Add gcore.1.
	(gcore.1): New.
	* gdb.texinfo (Man Pages): Add gcore man.
	(gcore man): New node.

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 498d42a..2193ef0 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1040,6 +1040,16 @@ install-only: $(CONFIG_INSTALL)
 			$(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \
 		$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(includedir)/gdb ; \
 		$(INSTALL_DATA) jit-reader.h $(DESTDIR)$(includedir)/gdb/jit-reader.h
+	transformed_name=`t='$(program_transform_name)'; \
+			  echo gcore | sed -e "$$t"` ; \
+		if test "x$$transformed_name" = x; then \
+		  transformed_name=gcore ; \
+		else \
+		  true ; \
+		fi ; \
+		$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir) ; \
+		$(INSTALL_PROGRAM) gcore \
+			$(DESTDIR)$(bindir)/$$transformed_name
 	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 
 install-python:
@@ -1055,6 +1065,14 @@ uninstall: force $(CONFIG_UNINSTALL)
 		fi ; \
 		rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \
 		      $(DESTDIR)$(man1dir)/$$transformed_name.1
+	transformed_name=`t='$(program_transform_name)'; \
+			  echo gcore | sed -e "$$t"` ; \
+		if test "x$$transformed_name" = x; then \
+		  transformed_name=gcore ; \
+		else \
+		  true ; \
+		fi ; \
+		rm -f $(DESTDIR)$(bindir)/$$transformed_name
 	@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 
 # The C++ name parser can be built standalone for testing.
diff --git a/gdb/configure.ac b/gdb/configure.ac
index c17f587..251c832 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -2349,6 +2349,20 @@ dnl  At the moment, we just assume it's UTF-8.
 AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "UTF-8",
           [Define to be a string naming the default host character set.])
 
+# Undo the $ec_script escaping suitable for Makefile.
+transform=`echo "$program_transform_name" | sed -e 's/[\\$][\\$]/\\$/g'`
+GDB_TRANSFORM_NAME=`echo gdb | sed -e "$transform"`
+if test "x$GDB_TRANSFORM_NAME" = x; then
+  GDB_TRANSFORM_NAME=gdb
+fi
+AC_SUBST(GDB_TRANSFORM_NAME)
+GCORE_TRANSFORM_NAME=`echo gcore | sed -e "$transform"`
+if test "x$GCORE_TRANSFORM_NAME" = x; then
+  GCORE_TRANSFORM_NAME=gcore
+fi
+AC_SUBST(GCORE_TRANSFORM_NAME)
+AC_CONFIG_FILES([gcore])
+
 AC_OUTPUT(Makefile gdb-gdb.gdb doc/Makefile data-directory/Makefile,
 [
 case x$CONFIG_HEADERS in
diff --git a/gdb/doc/Makefile.in b/gdb/doc/Makefile.in
index 70086a3..4ad31d9 100644
--- a/gdb/doc/Makefile.in
+++ b/gdb/doc/Makefile.in
@@ -177,7 +177,7 @@ POD2MAN5 = pod2man --center="GNU Development Tools" \
 		   --release="gdb-`sed q $(srcdir)/../version.in`" --section=5
 
 # List of man pages generated from gdb.texi
-MAN1S = gdb.1 gdbserver.1
+MAN1S = gdb.1 gdbserver.1 gcore.1
 MAN5S = gdbinit.5
 MANS = $(MAN1S) $(MAN5S)
 
@@ -605,6 +605,13 @@ gdbserver.1: $(GDB_DOC_FILES)
 		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
 	rm -f gdbserver.pod
 
+gcore.1: $(GDB_DOC_FILES)
+	touch $@
+	-$(TEXI2POD) $(MANCONF) -Dgcore < $(srcdir)/gdb.texinfo > gcore.pod
+	-($(POD2MAN1) gcore.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
+		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
+	rm -f gcore.pod
+
 gdbinit.5: $(GDB_DOC_FILES)
 	touch $@
 	-$(TEXI2POD) $(MANCONF) -Dgdbinit < $(srcdir)/gdb.texinfo > gdbinit.pod
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index bf7e25e..fc2adc3 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -41609,6 +41609,7 @@ switch (die->tag)
 @menu
 * gdb man::                     The GNU Debugger man page
 * gdbserver man::               Remote Server for the GNU Debugger man page
+* gcore man::                   Generate a core file of a running program
 * gdbinit man::                 gdbinit scripts
 @end menu
 
@@ -42134,6 +42135,53 @@ Richard M. Stallman and Roland H. Pesch, July 1991.
 @end ifset
 @c man end
 
+@node gcore man
+@heading gcore
+
+@c man title gcore Generate a core file of a running program
+
+@format
+@c man begin SYNOPSIS gcore
+gcore [-o @var{filename}] @var{pid}
+@c man end
+@end format
+
+@c man begin DESCRIPTION gcore
+Generate a core dump of a running program with process ID @var{pid}.
+Produced file is equivalent to a kernel produced core file as if the process
+crashed (and also it had to have @command{ulimit -c} enabled appropriately).
+Contrary to it after @command{gcore} the program remains running without any
+change.
+@c man end
+
+@c man begin OPTIONS gcore
+@table @env
+@item -o @var{filename}
+The optional argument
+@var{filename} specifies the file name where to put the core dump.
+If not specified, the file name defaults to @file{core.@var{pid}},
+where @var{pid} is the running program process ID.
+@end table
+@c man end
+
+@c man begin SEEALSO gcore
+@ifset man
+The full documentation for @value{GDBN} is maintained as a Texinfo manual.
+If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
+documentation are properly installed at your site, the command
+
+@smallexample
+info gdb
+@end smallexample
+
+@noindent
+should give you access to the complete manual.
+
+@cite{Using GDB: A Guide to the GNU Source-Level Debugger},
+Richard M. Stallman and Roland H. Pesch, July 1991.
+@end ifset
+@c man end
+
 @node gdbinit man
 @heading gdbinit
 
diff --git a/gdb/gcore.in b/gdb/gcore.in
index 38548f2..9c5b14d 100755
--- a/gdb/gcore.in
+++ b/gdb/gcore.in
@@ -16,14 +16,13 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #
-# gcore.sh
 # Script to generate a core file of a running program.
 # It starts up gdb, attaches to the given PID and invokes the gcore command.
 #
 
 if [ "$#" -eq "0" ]
 then
-    echo "usage:  gcore [-o filename] pid"
+    echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
     exit 2
 fi
 
@@ -35,7 +34,7 @@ then
     if [ "$#" -lt "3" ]
     then
 	# Not enough arguments.
-	echo "usage:  gcore [-o filename] pid"
+	echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
 	exit 2
     fi
     name=$2
@@ -52,14 +51,14 @@ for pid in $*
 do
 	# `</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 \
+	@GDB_TRANSFORM_NAME@ </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
 	else
-	    echo gcore: failed to create $name.$pid
+	    echo "@GCORE_TRANSFORM_NAME@: failed to create $name.$pid"
 	    rc=1
 	    break
 	fi


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page)
  2013-04-08 14:15 [patch 2/2+rfc+doc] Install gcore by default (+new man page) Jan Kratochvil
@ 2013-04-08 19:41 ` Eli Zaretskii
  2013-04-09  2:10   ` Jan Kratochvil
  0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2013-04-08 19:41 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

> Date: Sun, 7 Apr 2013 20:54:43 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> 
> +Produced file is equivalent to a kernel produced core file as if the process
> +crashed (and also it had to have @command{ulimit -c} enabled appropriately).

Suggest to reword in parentheses:

  (and if @kbd{ulimit -c} were used to set up an appropriate core dump
  limit)

Note: @kbd, not @command, as the latter is for command names, not for
command lines.

> +Contrary to it after @command{gcore} the program remains running without any
> +change.

"Unlike after a crash, after @command{gcore} the program ..."

The documentation part is OK with these changes.

Thanks.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page)
  2013-04-08 19:41 ` Eli Zaretskii
@ 2013-04-09  2:10   ` Jan Kratochvil
  2013-04-09  8:53     ` Tom Tromey
  0 siblings, 1 reply; 17+ messages in thread
From: Jan Kratochvil @ 2013-04-09  2:10 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On Mon, 08 Apr 2013 17:08:26 +0200, Eli Zaretskii wrote:
> The documentation part is OK with these changes.

Updated.

Leaving it pending for RFC if gcore should be installed at all and also if
current
	src/gdb/gcore.in + src/gdb/gcore
should not be called for example like before
	src/gdb/gdb_gcore.sh.in + src/gdb/gdb_gcore.sh
(which I find confusing, one could not find the gcore command in src/gdb/ with
<tab>-completion) or if it should not be called with .sh as
	src/gdb/gcore.sh.in + src/gdb/gcore.sh
although I do not see a reason for it, there are some *.sh files but those are
not installed.

Also I hope 755 should remain valid without a need for explicit chmod during
make install.


Thanks,
Jan


gdb/
2013-04-07  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (install-only, uninstall): Add gcore.
	* configure: Regenerate.
	* configure.ac: New AC_SUBST fir GDB_TRANSFORM_NAME and
	GCORE_TRANSFORM_NAME.  New AC_CONFIG_FILES for gcore.
	* gdb_gcore.sh: Rename to ...
	* gcore.in: ... here.  Remove gcore.sh comment.  Use GDB_TRANSFORM_NAME
	and GCORE_TRANSFORM_NAME substitutions.

gdb/doc/
2013-04-07  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (MAN1S): Add gcore.1.
	(gcore.1): New.
	* gdb.texinfo (Man Pages): Add gcore man.
	(gcore man): New node.

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 498d42a..2193ef0 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1040,6 +1040,16 @@ install-only: $(CONFIG_INSTALL)
 			$(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \
 		$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(includedir)/gdb ; \
 		$(INSTALL_DATA) jit-reader.h $(DESTDIR)$(includedir)/gdb/jit-reader.h
+	transformed_name=`t='$(program_transform_name)'; \
+			  echo gcore | sed -e "$$t"` ; \
+		if test "x$$transformed_name" = x; then \
+		  transformed_name=gcore ; \
+		else \
+		  true ; \
+		fi ; \
+		$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir) ; \
+		$(INSTALL_PROGRAM) gcore \
+			$(DESTDIR)$(bindir)/$$transformed_name
 	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 
 install-python:
@@ -1055,6 +1065,14 @@ uninstall: force $(CONFIG_UNINSTALL)
 		fi ; \
 		rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \
 		      $(DESTDIR)$(man1dir)/$$transformed_name.1
+	transformed_name=`t='$(program_transform_name)'; \
+			  echo gcore | sed -e "$$t"` ; \
+		if test "x$$transformed_name" = x; then \
+		  transformed_name=gcore ; \
+		else \
+		  true ; \
+		fi ; \
+		rm -f $(DESTDIR)$(bindir)/$$transformed_name
 	@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 
 # The C++ name parser can be built standalone for testing.
diff --git a/gdb/configure.ac b/gdb/configure.ac
index c17f587..251c832 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -2349,6 +2349,20 @@ dnl  At the moment, we just assume it's UTF-8.
 AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "UTF-8",
           [Define to be a string naming the default host character set.])
 
+# Undo the $ec_script escaping suitable for Makefile.
+transform=`echo "$program_transform_name" | sed -e 's/[\\$][\\$]/\\$/g'`
+GDB_TRANSFORM_NAME=`echo gdb | sed -e "$transform"`
+if test "x$GDB_TRANSFORM_NAME" = x; then
+  GDB_TRANSFORM_NAME=gdb
+fi
+AC_SUBST(GDB_TRANSFORM_NAME)
+GCORE_TRANSFORM_NAME=`echo gcore | sed -e "$transform"`
+if test "x$GCORE_TRANSFORM_NAME" = x; then
+  GCORE_TRANSFORM_NAME=gcore
+fi
+AC_SUBST(GCORE_TRANSFORM_NAME)
+AC_CONFIG_FILES([gcore])
+
 AC_OUTPUT(Makefile gdb-gdb.gdb doc/Makefile data-directory/Makefile,
 [
 case x$CONFIG_HEADERS in
diff --git a/gdb/doc/Makefile.in b/gdb/doc/Makefile.in
index 70086a3..4ad31d9 100644
--- a/gdb/doc/Makefile.in
+++ b/gdb/doc/Makefile.in
@@ -177,7 +177,7 @@ POD2MAN5 = pod2man --center="GNU Development Tools" \
 		   --release="gdb-`sed q $(srcdir)/../version.in`" --section=5
 
 # List of man pages generated from gdb.texi
-MAN1S = gdb.1 gdbserver.1
+MAN1S = gdb.1 gdbserver.1 gcore.1
 MAN5S = gdbinit.5
 MANS = $(MAN1S) $(MAN5S)
 
@@ -605,6 +605,13 @@ gdbserver.1: $(GDB_DOC_FILES)
 		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
 	rm -f gdbserver.pod
 
+gcore.1: $(GDB_DOC_FILES)
+	touch $@
+	-$(TEXI2POD) $(MANCONF) -Dgcore < $(srcdir)/gdb.texinfo > gcore.pod
+	-($(POD2MAN1) gcore.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
+		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
+	rm -f gcore.pod
+
 gdbinit.5: $(GDB_DOC_FILES)
 	touch $@
 	-$(TEXI2POD) $(MANCONF) -Dgdbinit < $(srcdir)/gdb.texinfo > gdbinit.pod
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index bf7e25e..d02ef62 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -41609,6 +41609,7 @@ switch (die->tag)
 @menu
 * gdb man::                     The GNU Debugger man page
 * gdbserver man::               Remote Server for the GNU Debugger man page
+* gcore man::                   Generate a core file of a running program
 * gdbinit man::                 gdbinit scripts
 @end menu
 
@@ -42134,6 +42135,53 @@ Richard M. Stallman and Roland H. Pesch, July 1991.
 @end ifset
 @c man end
 
+@node gcore man
+@heading gcore
+
+@c man title gcore Generate a core file of a running program
+
+@format
+@c man begin SYNOPSIS gcore
+gcore [-o @var{filename}] @var{pid}
+@c man end
+@end format
+
+@c man begin DESCRIPTION gcore
+Generate a core dump of a running program with process ID @var{pid}.
+Produced file is equivalent to a kernel produced core file as if the process
+crashed (and if @kbd{ulimit -c} were used to set up an appropriate core dump
+limit).  Unlike after a crash, after @command{gcore} the program remains
+running without any change.
+@c man end
+
+@c man begin OPTIONS gcore
+@table @env
+@item -o @var{filename}
+The optional argument
+@var{filename} specifies the file name where to put the core dump.
+If not specified, the file name defaults to @file{core.@var{pid}},
+where @var{pid} is the running program process ID.
+@end table
+@c man end
+
+@c man begin SEEALSO gcore
+@ifset man
+The full documentation for @value{GDBN} is maintained as a Texinfo manual.
+If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
+documentation are properly installed at your site, the command
+
+@smallexample
+info gdb
+@end smallexample
+
+@noindent
+should give you access to the complete manual.
+
+@cite{Using GDB: A Guide to the GNU Source-Level Debugger},
+Richard M. Stallman and Roland H. Pesch, July 1991.
+@end ifset
+@c man end
+
 @node gdbinit man
 @heading gdbinit
 
diff --git a/gdb/gcore.in b/gdb/gcore.in
index 38548f2..9c5b14d 100755
--- a/gdb/gcore.in
+++ b/gdb/gcore.in
@@ -16,14 +16,13 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #
-# gcore.sh
 # Script to generate a core file of a running program.
 # It starts up gdb, attaches to the given PID and invokes the gcore command.
 #
 
 if [ "$#" -eq "0" ]
 then
-    echo "usage:  gcore [-o filename] pid"
+    echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
     exit 2
 fi
 
@@ -35,7 +34,7 @@ then
     if [ "$#" -lt "3" ]
     then
 	# Not enough arguments.
-	echo "usage:  gcore [-o filename] pid"
+	echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
 	exit 2
     fi
     name=$2
@@ -52,14 +51,14 @@ for pid in $*
 do
 	# `</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 \
+	@GDB_TRANSFORM_NAME@ </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
 	else
-	    echo gcore: failed to create $name.$pid
+	    echo "@GCORE_TRANSFORM_NAME@: failed to create $name.$pid"
 	    rc=1
 	    break
 	fi


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page)
  2013-04-09  2:10   ` Jan Kratochvil
@ 2013-04-09  8:53     ` Tom Tromey
  2013-04-09  9:01       ` Jan Kratochvil
  2013-04-09 15:29       ` Pedro Alves
  0 siblings, 2 replies; 17+ messages in thread
From: Tom Tromey @ 2013-04-09  8:53 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> Leaving it pending for RFC if gcore should be installed at all

I think it should be, because it is useful and "why not?".

Jan> and also if
Jan> current
Jan> 	src/gdb/gcore.in + src/gdb/gcore
Jan> should not be called for example like before
Jan> 	src/gdb/gdb_gcore.sh.in + src/gdb/gdb_gcore.sh

I like your new naming.

Jan> <tab>-completion) or if it should not be called with .sh as
Jan> 	src/gdb/gcore.sh.in + src/gdb/gcore.sh
Jan> although I do not see a reason for it, there are some *.sh files but those are
Jan> not installed.

I think having ".sh" on an installed script is a mistake.
For one thing, if you change the implementation of the command then you
get confusion -- either the ".sh" is actively wrong, or you have to change
the name.

Jan> Also I hope 755 should remain valid without a need for explicit
Jan> chmod during make install.

I thought INSTALL_PROGRAM handled this, but I see it doesn't.
Weird.  Anyway I would not worry about it.

Maybe you need one at AC_CONFIG_FILES time, like:

    AC_CONFIG_FILES([gcore], [chmod +x gcore])

I'm not sure if this is strictly needed or not.

Tom


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page)
  2013-04-09  8:53     ` Tom Tromey
@ 2013-04-09  9:01       ` Jan Kratochvil
  2013-04-09 14:26         ` Jan Kratochvil
  2013-04-09 15:29       ` Pedro Alves
  1 sibling, 1 reply; 17+ messages in thread
From: Jan Kratochvil @ 2013-04-09  9:01 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Mon, 08 Apr 2013 20:54:55 +0200, Tom Tromey wrote:
> I think having ".sh" on an installed script is a mistake.
> For one thing, if you change the implementation of the command then you
> get confusion -- either the ".sh" is actively wrong, or you have to change
> the name.

I was thinking to have in the source
 	src/gdb/gcore.sh.in + src/gdb/gcore.sh
but still to get it installed as:
	/usr/bin/gcore

I do not mind, currently it is:
 	src/gdb/gcore.in + src/gdb/gcore


> I thought INSTALL_PROGRAM handled this, but I see it doesn't.

I have found now it does.

install(1)
       -m, --mode=MODE
              set permission mode (as in chmod), instead of rwxr-xr-x
+
INSTALL_PROGRAM = /usr/bin/install -c
INSTALL_DATA = /usr/bin/install -c -m 644


> Maybe you need one at AC_CONFIG_FILES time, like:
> 
>     AC_CONFIG_FILES([gcore], [chmod +x gcore])
> 
> I'm not sure if this is strictly needed or not.

I see it is needed to have src/gdb/gcore with +x.  Fixed.


Thanks,
Jan


gdb/
2013-04-07  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (install-only, uninstall): Add gcore.
	* configure: Regenerate.
	* configure.ac: New AC_SUBST fir GDB_TRANSFORM_NAME and
	GCORE_TRANSFORM_NAME.  New AC_CONFIG_FILES for gcore.
	* gdb_gcore.sh: Rename to ...
	* gcore.in: ... here.  Remove gcore.sh comment.  Use GDB_TRANSFORM_NAME
	and GCORE_TRANSFORM_NAME substitutions.

gdb/doc/
2013-04-07  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (MAN1S): Add gcore.1.
	(gcore.1): New.
	* gdb.texinfo (Man Pages): Add gcore man.
	(gcore man): New node.

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 498d42a..2193ef0 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1040,6 +1040,16 @@ install-only: $(CONFIG_INSTALL)
 			$(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \
 		$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(includedir)/gdb ; \
 		$(INSTALL_DATA) jit-reader.h $(DESTDIR)$(includedir)/gdb/jit-reader.h
+	transformed_name=`t='$(program_transform_name)'; \
+			  echo gcore | sed -e "$$t"` ; \
+		if test "x$$transformed_name" = x; then \
+		  transformed_name=gcore ; \
+		else \
+		  true ; \
+		fi ; \
+		$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir) ; \
+		$(INSTALL_PROGRAM) gcore \
+			$(DESTDIR)$(bindir)/$$transformed_name
 	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 
 install-python:
@@ -1055,6 +1065,14 @@ uninstall: force $(CONFIG_UNINSTALL)
 		fi ; \
 		rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \
 		      $(DESTDIR)$(man1dir)/$$transformed_name.1
+	transformed_name=`t='$(program_transform_name)'; \
+			  echo gcore | sed -e "$$t"` ; \
+		if test "x$$transformed_name" = x; then \
+		  transformed_name=gcore ; \
+		else \
+		  true ; \
+		fi ; \
+		rm -f $(DESTDIR)$(bindir)/$$transformed_name
 	@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 
 # The C++ name parser can be built standalone for testing.
diff --git a/gdb/configure.ac b/gdb/configure.ac
index c17f587..a1811b6 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -2349,6 +2349,20 @@ dnl  At the moment, we just assume it's UTF-8.
 AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "UTF-8",
           [Define to be a string naming the default host character set.])
 
+# Undo the $ec_script escaping suitable for Makefile.
+transform=`echo "$program_transform_name" | sed -e 's/[\\$][\\$]/\\$/g'`
+GDB_TRANSFORM_NAME=`echo gdb | sed -e "$transform"`
+if test "x$GDB_TRANSFORM_NAME" = x; then
+  GDB_TRANSFORM_NAME=gdb
+fi
+AC_SUBST(GDB_TRANSFORM_NAME)
+GCORE_TRANSFORM_NAME=`echo gcore | sed -e "$transform"`
+if test "x$GCORE_TRANSFORM_NAME" = x; then
+  GCORE_TRANSFORM_NAME=gcore
+fi
+AC_SUBST(GCORE_TRANSFORM_NAME)
+AC_CONFIG_FILES([gcore], [chmod +x gcore])
+
 AC_OUTPUT(Makefile gdb-gdb.gdb doc/Makefile data-directory/Makefile,
 [
 case x$CONFIG_HEADERS in
diff --git a/gdb/doc/Makefile.in b/gdb/doc/Makefile.in
index 70086a3..4ad31d9 100644
--- a/gdb/doc/Makefile.in
+++ b/gdb/doc/Makefile.in
@@ -177,7 +177,7 @@ POD2MAN5 = pod2man --center="GNU Development Tools" \
 		   --release="gdb-`sed q $(srcdir)/../version.in`" --section=5
 
 # List of man pages generated from gdb.texi
-MAN1S = gdb.1 gdbserver.1
+MAN1S = gdb.1 gdbserver.1 gcore.1
 MAN5S = gdbinit.5
 MANS = $(MAN1S) $(MAN5S)
 
@@ -605,6 +605,13 @@ gdbserver.1: $(GDB_DOC_FILES)
 		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
 	rm -f gdbserver.pod
 
+gcore.1: $(GDB_DOC_FILES)
+	touch $@
+	-$(TEXI2POD) $(MANCONF) -Dgcore < $(srcdir)/gdb.texinfo > gcore.pod
+	-($(POD2MAN1) gcore.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
+		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
+	rm -f gcore.pod
+
 gdbinit.5: $(GDB_DOC_FILES)
 	touch $@
 	-$(TEXI2POD) $(MANCONF) -Dgdbinit < $(srcdir)/gdb.texinfo > gdbinit.pod
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index bf7e25e..d02ef62 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -41609,6 +41609,7 @@ switch (die->tag)
 @menu
 * gdb man::                     The GNU Debugger man page
 * gdbserver man::               Remote Server for the GNU Debugger man page
+* gcore man::                   Generate a core file of a running program
 * gdbinit man::                 gdbinit scripts
 @end menu
 
@@ -42134,6 +42135,53 @@ Richard M. Stallman and Roland H. Pesch, July 1991.
 @end ifset
 @c man end
 
+@node gcore man
+@heading gcore
+
+@c man title gcore Generate a core file of a running program
+
+@format
+@c man begin SYNOPSIS gcore
+gcore [-o @var{filename}] @var{pid}
+@c man end
+@end format
+
+@c man begin DESCRIPTION gcore
+Generate a core dump of a running program with process ID @var{pid}.
+Produced file is equivalent to a kernel produced core file as if the process
+crashed (and if @kbd{ulimit -c} were used to set up an appropriate core dump
+limit).  Unlike after a crash, after @command{gcore} the program remains
+running without any change.
+@c man end
+
+@c man begin OPTIONS gcore
+@table @env
+@item -o @var{filename}
+The optional argument
+@var{filename} specifies the file name where to put the core dump.
+If not specified, the file name defaults to @file{core.@var{pid}},
+where @var{pid} is the running program process ID.
+@end table
+@c man end
+
+@c man begin SEEALSO gcore
+@ifset man
+The full documentation for @value{GDBN} is maintained as a Texinfo manual.
+If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
+documentation are properly installed at your site, the command
+
+@smallexample
+info gdb
+@end smallexample
+
+@noindent
+should give you access to the complete manual.
+
+@cite{Using GDB: A Guide to the GNU Source-Level Debugger},
+Richard M. Stallman and Roland H. Pesch, July 1991.
+@end ifset
+@c man end
+
 @node gdbinit man
 @heading gdbinit
 
diff --git a/gdb/gcore.in b/gdb/gcore.in
index 38548f2..9c5b14d 100755
--- a/gdb/gcore.in
+++ b/gdb/gcore.in
@@ -16,14 +16,13 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #
-# gcore.sh
 # Script to generate a core file of a running program.
 # It starts up gdb, attaches to the given PID and invokes the gcore command.
 #
 
 if [ "$#" -eq "0" ]
 then
-    echo "usage:  gcore [-o filename] pid"
+    echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
     exit 2
 fi
 
@@ -35,7 +34,7 @@ then
     if [ "$#" -lt "3" ]
     then
 	# Not enough arguments.
-	echo "usage:  gcore [-o filename] pid"
+	echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
 	exit 2
     fi
     name=$2
@@ -52,14 +51,14 @@ for pid in $*
 do
 	# `</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 \
+	@GDB_TRANSFORM_NAME@ </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
 	else
-	    echo gcore: failed to create $name.$pid
+	    echo "@GCORE_TRANSFORM_NAME@: failed to create $name.$pid"
 	    rc=1
 	    break
 	fi


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page)
  2013-04-09  9:01       ` Jan Kratochvil
@ 2013-04-09 14:26         ` Jan Kratochvil
  2013-04-09 18:53           ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: Jan Kratochvil @ 2013-04-09 14:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Eli Zaretskii

Hi Eli,

I have probably forgotten to mention it in the NEWS file.


Thanks,
Jan


gdb/
2013-04-09  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (install-only, uninstall): Add gcore.
	* NEWS (Changes since GDB 7.6): Mention newly installed gcore.
	* configure: Regenerate.
	* configure.ac: New AC_SUBST fir GDB_TRANSFORM_NAME and
	GCORE_TRANSFORM_NAME.  New AC_CONFIG_FILES for gcore.
	* gdb_gcore.sh: Rename to ...
	* gcore.in: ... here.  Remove gcore.sh comment.  Use GDB_TRANSFORM_NAME
	and GCORE_TRANSFORM_NAME substitutions.

gdb/doc/
2013-04-09  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (MAN1S): Add gcore.1.
	(gcore.1): New.
	* gdb.texinfo (Man Pages): Add gcore man.
	(gcore man): New node.

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 498d42a..2193ef0 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1040,6 +1040,16 @@ install-only: $(CONFIG_INSTALL)
 			$(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \
 		$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(includedir)/gdb ; \
 		$(INSTALL_DATA) jit-reader.h $(DESTDIR)$(includedir)/gdb/jit-reader.h
+	transformed_name=`t='$(program_transform_name)'; \
+			  echo gcore | sed -e "$$t"` ; \
+		if test "x$$transformed_name" = x; then \
+		  transformed_name=gcore ; \
+		else \
+		  true ; \
+		fi ; \
+		$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir) ; \
+		$(INSTALL_PROGRAM) gcore \
+			$(DESTDIR)$(bindir)/$$transformed_name
 	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 
 install-python:
@@ -1055,6 +1065,14 @@ uninstall: force $(CONFIG_UNINSTALL)
 		fi ; \
 		rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \
 		      $(DESTDIR)$(man1dir)/$$transformed_name.1
+	transformed_name=`t='$(program_transform_name)'; \
+			  echo gcore | sed -e "$$t"` ; \
+		if test "x$$transformed_name" = x; then \
+		  transformed_name=gcore ; \
+		else \
+		  true ; \
+		fi ; \
+		rm -f $(DESTDIR)$(bindir)/$$transformed_name
 	@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 
 # The C++ name parser can be built standalone for testing.
diff --git a/gdb/NEWS b/gdb/NEWS
index a1bc679..0d8d56d 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -19,6 +19,9 @@ show remote trace-status-packet
 * The command 'tsave' can now support new option '-ctf' to save trace
   buffer in Common Trace Format.
 
+* Newly installed $prefix/bin/gcore acts as a shell interface for the
+  GDB command gcore.
+
 * MI changes
 
   ** The -trace-save MI command can optionally save trace buffer in Common
diff --git a/gdb/configure b/gdb/configure
index 0dd67f0..b8ebb12 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -591,6 +591,8 @@ ac_includes_default="\
 enable_option_checking=no
 ac_subst_vars='LTLIBOBJS
 LIBOBJS
+GCORE_TRANSFORM_NAME
+GDB_TRANSFORM_NAME
 GDB_NM_FILE
 frags
 target_subdir
@@ -14131,6 +14133,21 @@ ac_config_links="$ac_config_links $ac_config_links_1"
 $as_echo "#define GDB_DEFAULT_HOST_CHARSET \"UTF-8\"" >>confdefs.h
 
 
+# Undo the $ec_script escaping suitable for Makefile.
+transform=`echo "$program_transform_name" | sed -e 's/\\$\\$/\\$/g'`
+GDB_TRANSFORM_NAME=`echo gdb | sed -e "$transform"`
+if test "x$GDB_TRANSFORM_NAME" = x; then
+  GDB_TRANSFORM_NAME=gdb
+fi
+
+GCORE_TRANSFORM_NAME=`echo gcore | sed -e "$transform"`
+if test "x$GCORE_TRANSFORM_NAME" = x; then
+  GCORE_TRANSFORM_NAME=gcore
+fi
+
+ac_config_files="$ac_config_files gcore"
+
+
 ac_config_files="$ac_config_files Makefile gdb-gdb.gdb doc/Makefile data-directory/Makefile"
 
 ac_config_commands="$ac_config_commands default"
@@ -14841,6 +14858,7 @@ do
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "jit-reader.h") CONFIG_FILES="$CONFIG_FILES jit-reader.h:jit-reader.in" ;;
     "$ac_config_links_1") CONFIG_LINKS="$CONFIG_LINKS $ac_config_links_1" ;;
+    "gcore") CONFIG_FILES="$CONFIG_FILES gcore" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "gdb-gdb.gdb") CONFIG_FILES="$CONFIG_FILES gdb-gdb.gdb" ;;
     "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
@@ -15462,6 +15480,7 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
 
   case $ac_file$ac_mode in
     "depdir":C) $SHELL $ac_aux_dir/mkinstalldirs $DEPDIR ;;
+    "gcore":F) chmod +x gcore ;;
     "default":C)
 case x$CONFIG_HEADERS in
 xconfig.h:config.in)
diff --git a/gdb/configure.ac b/gdb/configure.ac
index c17f587..a1811b6 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -2349,6 +2349,20 @@ dnl  At the moment, we just assume it's UTF-8.
 AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "UTF-8",
           [Define to be a string naming the default host character set.])
 
+# Undo the $ec_script escaping suitable for Makefile.
+transform=`echo "$program_transform_name" | sed -e 's/[\\$][\\$]/\\$/g'`
+GDB_TRANSFORM_NAME=`echo gdb | sed -e "$transform"`
+if test "x$GDB_TRANSFORM_NAME" = x; then
+  GDB_TRANSFORM_NAME=gdb
+fi
+AC_SUBST(GDB_TRANSFORM_NAME)
+GCORE_TRANSFORM_NAME=`echo gcore | sed -e "$transform"`
+if test "x$GCORE_TRANSFORM_NAME" = x; then
+  GCORE_TRANSFORM_NAME=gcore
+fi
+AC_SUBST(GCORE_TRANSFORM_NAME)
+AC_CONFIG_FILES([gcore], [chmod +x gcore])
+
 AC_OUTPUT(Makefile gdb-gdb.gdb doc/Makefile data-directory/Makefile,
 [
 case x$CONFIG_HEADERS in
diff --git a/gdb/doc/Makefile.in b/gdb/doc/Makefile.in
index 70086a3..4ad31d9 100644
--- a/gdb/doc/Makefile.in
+++ b/gdb/doc/Makefile.in
@@ -177,7 +177,7 @@ POD2MAN5 = pod2man --center="GNU Development Tools" \
 		   --release="gdb-`sed q $(srcdir)/../version.in`" --section=5
 
 # List of man pages generated from gdb.texi
-MAN1S = gdb.1 gdbserver.1
+MAN1S = gdb.1 gdbserver.1 gcore.1
 MAN5S = gdbinit.5
 MANS = $(MAN1S) $(MAN5S)
 
@@ -605,6 +605,13 @@ gdbserver.1: $(GDB_DOC_FILES)
 		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
 	rm -f gdbserver.pod
 
+gcore.1: $(GDB_DOC_FILES)
+	touch $@
+	-$(TEXI2POD) $(MANCONF) -Dgcore < $(srcdir)/gdb.texinfo > gcore.pod
+	-($(POD2MAN1) gcore.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
+		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
+	rm -f gcore.pod
+
 gdbinit.5: $(GDB_DOC_FILES)
 	touch $@
 	-$(TEXI2POD) $(MANCONF) -Dgdbinit < $(srcdir)/gdb.texinfo > gdbinit.pod
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index bf7e25e..d02ef62 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -41609,6 +41609,7 @@ switch (die->tag)
 @menu
 * gdb man::                     The GNU Debugger man page
 * gdbserver man::               Remote Server for the GNU Debugger man page
+* gcore man::                   Generate a core file of a running program
 * gdbinit man::                 gdbinit scripts
 @end menu
 
@@ -42134,6 +42135,53 @@ Richard M. Stallman and Roland H. Pesch, July 1991.
 @end ifset
 @c man end
 
+@node gcore man
+@heading gcore
+
+@c man title gcore Generate a core file of a running program
+
+@format
+@c man begin SYNOPSIS gcore
+gcore [-o @var{filename}] @var{pid}
+@c man end
+@end format
+
+@c man begin DESCRIPTION gcore
+Generate a core dump of a running program with process ID @var{pid}.
+Produced file is equivalent to a kernel produced core file as if the process
+crashed (and if @kbd{ulimit -c} were used to set up an appropriate core dump
+limit).  Unlike after a crash, after @command{gcore} the program remains
+running without any change.
+@c man end
+
+@c man begin OPTIONS gcore
+@table @env
+@item -o @var{filename}
+The optional argument
+@var{filename} specifies the file name where to put the core dump.
+If not specified, the file name defaults to @file{core.@var{pid}},
+where @var{pid} is the running program process ID.
+@end table
+@c man end
+
+@c man begin SEEALSO gcore
+@ifset man
+The full documentation for @value{GDBN} is maintained as a Texinfo manual.
+If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
+documentation are properly installed at your site, the command
+
+@smallexample
+info gdb
+@end smallexample
+
+@noindent
+should give you access to the complete manual.
+
+@cite{Using GDB: A Guide to the GNU Source-Level Debugger},
+Richard M. Stallman and Roland H. Pesch, July 1991.
+@end ifset
+@c man end
+
 @node gdbinit man
 @heading gdbinit
 
diff --git a/gdb/gcore.in b/gdb/gcore.in
index 38548f2..9c5b14d 100755
--- a/gdb/gcore.in
+++ b/gdb/gcore.in
@@ -16,14 +16,13 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #
-# gcore.sh
 # Script to generate a core file of a running program.
 # It starts up gdb, attaches to the given PID and invokes the gcore command.
 #
 
 if [ "$#" -eq "0" ]
 then
-    echo "usage:  gcore [-o filename] pid"
+    echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
     exit 2
 fi
 
@@ -35,7 +34,7 @@ then
     if [ "$#" -lt "3" ]
     then
 	# Not enough arguments.
-	echo "usage:  gcore [-o filename] pid"
+	echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
 	exit 2
     fi
     name=$2
@@ -52,14 +51,14 @@ for pid in $*
 do
 	# `</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 \
+	@GDB_TRANSFORM_NAME@ </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
 	else
-	    echo gcore: failed to create $name.$pid
+	    echo "@GCORE_TRANSFORM_NAME@: failed to create $name.$pid"
 	    rc=1
 	    break
 	fi


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page)
  2013-04-09  8:53     ` Tom Tromey
  2013-04-09  9:01       ` Jan Kratochvil
@ 2013-04-09 15:29       ` Pedro Alves
  2013-04-09 19:59         ` Jan Kratochvil
  1 sibling, 1 reply; 17+ messages in thread
From: Pedro Alves @ 2013-04-09 15:29 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Jan Kratochvil, gdb-patches

On 04/08/2013 07:54 PM, Tom Tromey wrote:
>>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> 
> Jan> Leaving it pending for RFC if gcore should be installed at all
> 
> I think it should be, because it is useful and "why not?".

A couple points to consider:

- Should we install it on hosts/builds that don't support gcore
  with the native target?

- Should we install it on mingw hosts (where there'll be
  no shell capable of running the script available)?

> 
> Jan> and also if
> Jan> current
> Jan> 	src/gdb/gcore.in + src/gdb/gcore
> Jan> should not be called for example like before
> Jan> 	src/gdb/gdb_gcore.sh.in + src/gdb/gdb_gcore.sh
> 
> I like your new naming.

Me too.

> 
> Jan> <tab>-completion) or if it should not be called with .sh as
> Jan> 	src/gdb/gcore.sh.in + src/gdb/gcore.sh
> Jan> although I do not see a reason for it, there are some *.sh files but those are
> Jan> not installed.
> 
> I think having ".sh" on an installed script is a mistake.
> For one thing, if you change the implementation of the command then you
> get confusion -- either the ".sh" is actively wrong, or you have to change
> the name.

Definitely agreed.

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page)
  2013-04-09 14:26         ` Jan Kratochvil
@ 2013-04-09 18:53           ` Eli Zaretskii
  0 siblings, 0 replies; 17+ messages in thread
From: Eli Zaretskii @ 2013-04-09 18:53 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

> Date: Tue, 9 Apr 2013 09:15:20 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> Cc: Eli Zaretskii <eliz@gnu.org>
> 
> Hi Eli,
> 
> I have probably forgotten to mention it in the NEWS file.

The addition to NEWS is fine with me.

Thanks.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page)
  2013-04-09 15:29       ` Pedro Alves
@ 2013-04-09 19:59         ` Jan Kratochvil
  2013-04-10 19:49           ` Pedro Alves
  0 siblings, 1 reply; 17+ messages in thread
From: Jan Kratochvil @ 2013-04-09 19:59 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

On Tue, 09 Apr 2013 16:26:06 +0200, Pedro Alves wrote:
> - Should we install it on hosts/builds that don't support gcore
>   with the native target?

I did not consider it worth the work... but here it is.

I have found these files support the legacy to_find_memory_regions way
	amd64fbsd-nat gnu-nat i386fbsd-nat ppcfbsd-nat procfs sparc64fbsd-nat

so I have enabled fcore for any *.mh files using one of those.

The new set_gdbarch_find_memory_regions way uses only linux-tdep so I have put
that in configure.ac, otherwise there would be a new variable in each
configure.tgt rule using linux-tdep (23 cases) which would be IMO more prone
to a future mistake.


> - Should we install it on mingw hosts (where there'll be
>   no shell capable of running the script available)?

Good idea, easier to test, but I do not think any such host would be compliant
with the condition above.


I hope "continue" is compatible in the shell command of Makefile.


Contrary to my recent regression mishaps I have tested various make install
cases this time (not out-of-src-tree but that is not applicable for this
change).


Thanks,
Jan


gdb/
2013-04-09  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (HAVE_NATIVE_GCORE_TARGET): New.
	(install-only, uninstall): Add gcore if HAVE_NATIVE_GCORE_TARGET or
	HAVE_NATIVE_GCORE_HOST.
	* NEWS (Changes since GDB 7.6): Mention newly installed gcore.
	* config/alpha/alpha-osf3.mh, config/i386/fbsd.mh,
	config/i386/fbsd64.mh, config/i386/i386gnu.mh, config/i386/i386sol2.mh,
	config/i386/sol2-64.mh, config/mips/irix5.mh, config/mips/irix6.mh,
	config/powerpc/fbsd.mh, config/sparc/fbsd.mh, config/sparc/sol2.mh:
	Add HAVE_NATIVE_GCORE_HOST.
	* configure: Regenerate.
	* configure.ac (HAVE_NATIVE_GCORE_TARGET): New, set it, AC_SUBST it.
	New AC_SUBST fir GDB_TRANSFORM_NAME and GCORE_TRANSFORM_NAME.  New
	AC_CONFIG_FILES for gcore.
	* gdb_gcore.sh: Rename to ...
	* gcore.in: ... here.  Remove gcore.sh comment.  Use GDB_TRANSFORM_NAME
	and GCORE_TRANSFORM_NAME substitutions.

gdb/doc/
2013-04-09  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (MAN1S): Add gcore.1.
	Remove "Host, target, and site specific Makefile fragments" comment.
	(@host_makefile_frag@, HAVE_NATIVE_GCORE_TARGET): New.
	(install-man1, uninstall-man1): Conditionalize gcore.1.
	(gcore.1): New.
	* gdb.texinfo (Man Pages): Add gcore man.
	(gcore man): New node.

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 498d42a..801f118 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -414,6 +414,7 @@ CONFIG_ALL= @CONFIG_ALL@
 CONFIG_CLEAN= @CONFIG_CLEAN@
 CONFIG_INSTALL = @CONFIG_INSTALL@
 CONFIG_UNINSTALL = @CONFIG_UNINSTALL@
+HAVE_NATIVE_GCORE_TARGET = @HAVE_NATIVE_GCORE_TARGET@
 
 # -I. for config files.
 # -I$(srcdir) for gdb internal headers.
@@ -1040,6 +1041,19 @@ install-only: $(CONFIG_INSTALL)
 			$(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \
 		$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(includedir)/gdb ; \
 		$(INSTALL_DATA) jit-reader.h $(DESTDIR)$(includedir)/gdb/jit-reader.h
+	if test "x$(HAVE_NATIVE_GCORE_TARGET)$(HAVE_NATIVE_GCORE_HOST)" != x; \
+	then \
+	  transformed_name=`t='$(program_transform_name)'; \
+			    echo gcore | sed -e "$$t"` ; \
+		  if test "x$$transformed_name" = x; then \
+		    transformed_name=gcore ; \
+		  else \
+		    true ; \
+		  fi ; \
+		  $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir) ; \
+		  $(INSTALL_PROGRAM) gcore \
+			  $(DESTDIR)$(bindir)/$$transformed_name; \
+	fi
 	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 
 install-python:
@@ -1055,6 +1069,17 @@ uninstall: force $(CONFIG_UNINSTALL)
 		fi ; \
 		rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \
 		      $(DESTDIR)$(man1dir)/$$transformed_name.1
+	if test "x$(HAVE_NATIVE_GCORE_TARGET)$(HAVE_NATIVE_GCORE_HOST)" != x; \
+	then \
+	  transformed_name=`t='$(program_transform_name)'; \
+			    echo gcore | sed -e "$$t"` ; \
+		  if test "x$$transformed_name" = x; then \
+		    transformed_name=gcore ; \
+		  else \
+		    true ; \
+		  fi ; \
+		  rm -f $(DESTDIR)$(bindir)/$$transformed_name; \
+	fi
 	@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 
 # The C++ name parser can be built standalone for testing.
diff --git a/gdb/NEWS b/gdb/NEWS
index 6f202e2..0536c9d 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -19,6 +19,9 @@ show remote trace-status-packet
 * The command 'tsave' can now support new option '-ctf' to save trace
   buffer in Common Trace Format.
 
+* Newly installed $prefix/bin/gcore acts as a shell interface for the
+  GDB command gcore.
+
 * MI changes
 
   ** The -trace-save MI command can optionally save trace buffer in Common
diff --git a/gdb/config/alpha/alpha-osf3.mh b/gdb/config/alpha/alpha-osf3.mh
index 483ef78..aa63dc4 100644
--- a/gdb/config/alpha/alpha-osf3.mh
+++ b/gdb/config/alpha/alpha-osf3.mh
@@ -3,4 +3,5 @@ NAT_FILE= nm-osf3.h
 NATDEPFILES= alpha-nat.o fork-child.o \
 	solib-osf.o procfs.o proc-api.o proc-events.o proc-flags.o \
 	proc-why.o dec-thread.o
+HAVE_NATIVE_GCORE_HOST = 1
 NAT_CLIBS= -lpthreaddebug
diff --git a/gdb/config/i386/fbsd.mh b/gdb/config/i386/fbsd.mh
index 05ac5bb..2c9cd9a 100644
--- a/gdb/config/i386/fbsd.mh
+++ b/gdb/config/i386/fbsd.mh
@@ -3,5 +3,6 @@ NATDEPFILES= fork-child.o inf-ptrace.o \
 	fbsd-nat.o i386-nat.o i386bsd-nat.o i386fbsd-nat.o \
 	bsd-kvm.o
 NAT_FILE= nm-fbsd.h
+HAVE_NATIVE_GCORE_HOST = 1
 
 LOADLIBES= -lkvm
diff --git a/gdb/config/i386/fbsd64.mh b/gdb/config/i386/fbsd64.mh
index 3f43727..c719a17 100644
--- a/gdb/config/i386/fbsd64.mh
+++ b/gdb/config/i386/fbsd64.mh
@@ -2,5 +2,6 @@
 NATDEPFILES= fork-child.o inf-ptrace.o \
 	fbsd-nat.o amd64-nat.o amd64bsd-nat.o amd64fbsd-nat.o \
 	bsd-kvm.o i386-nat.o
+HAVE_NATIVE_GCORE_HOST = 1
 
 LOADLIBES= -lkvm
diff --git a/gdb/config/i386/i386gnu.mh b/gdb/config/i386/i386gnu.mh
index d85744b..a3ea122 100644
--- a/gdb/config/i386/i386gnu.mh
+++ b/gdb/config/i386/i386gnu.mh
@@ -2,6 +2,7 @@
 NATDEPFILES= i386gnu-nat.o gnu-nat.o core-regset.o fork-child.o \
 	     notify_S.o process_reply_S.o msg_reply_S.o \
 	     msg_U.o exc_request_U.o exc_request_S.o
+HAVE_NATIVE_GCORE_HOST = 1
 
 NAT_FILE= nm-i386gnu.h
 MH_CFLAGS = -D_GNU_SOURCE
diff --git a/gdb/config/i386/i386sol2.mh b/gdb/config/i386/i386sol2.mh
index dcf5a79..2f7c3c5 100644
--- a/gdb/config/i386/i386sol2.mh
+++ b/gdb/config/i386/i386sol2.mh
@@ -1,3 +1,4 @@
 # Host: Solaris x86
 NATDEPFILES= fork-child.o i386v4-nat.o i386-sol2-nat.o \
 	procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o
+HAVE_NATIVE_GCORE_HOST = 1
diff --git a/gdb/config/i386/sol2-64.mh b/gdb/config/i386/sol2-64.mh
index bfb6980..7a8304d 100644
--- a/gdb/config/i386/sol2-64.mh
+++ b/gdb/config/i386/sol2-64.mh
@@ -1,3 +1,4 @@
 # Host: Solaris x86_64
 NATDEPFILES= fork-child.o amd64-nat.o i386v4-nat.o i386-sol2-nat.o \
 	procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o
+HAVE_NATIVE_GCORE_HOST = 1
diff --git a/gdb/config/mips/irix5.mh b/gdb/config/mips/irix5.mh
index 7ab5e11..d5740d0 100644
--- a/gdb/config/mips/irix5.mh
+++ b/gdb/config/mips/irix5.mh
@@ -1,3 +1,4 @@
 # Host: SGI Iris running irix 5.x
 NATDEPFILES= fork-child.o irix5-nat.o procfs.o \
 	proc-api.o proc-events.o proc-flags.o proc-why.o
+HAVE_NATIVE_GCORE_HOST = 1
diff --git a/gdb/config/mips/irix6.mh b/gdb/config/mips/irix6.mh
index 28a67eb..098df2e 100644
--- a/gdb/config/mips/irix6.mh
+++ b/gdb/config/mips/irix6.mh
@@ -1,3 +1,4 @@
 # Host: SGI Iris running irix 6.x
 NATDEPFILES= fork-child.o irix5-nat.o procfs.o \
 	proc-api.o proc-events.o proc-flags.o proc-why.o
+HAVE_NATIVE_GCORE_HOST = 1
diff --git a/gdb/config/powerpc/fbsd.mh b/gdb/config/powerpc/fbsd.mh
index 746b286..48ea902 100644
--- a/gdb/config/powerpc/fbsd.mh
+++ b/gdb/config/powerpc/fbsd.mh
@@ -18,6 +18,7 @@
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 NATDEPFILES= fbsd-nat.o fork-child.o inf-ptrace.o ppcfbsd-nat.o bsd-kvm.o
+HAVE_NATIVE_GCORE_HOST = 1
 
 LOADLIBES= -lkvm
 
diff --git a/gdb/config/sparc/fbsd.mh b/gdb/config/sparc/fbsd.mh
index ad36ee6..2774efb 100644
--- a/gdb/config/sparc/fbsd.mh
+++ b/gdb/config/sparc/fbsd.mh
@@ -2,5 +2,6 @@
 NATDEPFILES= fork-child.o inf-ptrace.o \
 	fbsd-nat.o sparc-nat.o sparc64-nat.o sparc64fbsd-nat.o \
 	bsd-kvm.o
+HAVE_NATIVE_GCORE_HOST = 1
 
 LOADLIBES= -lkvm
diff --git a/gdb/config/sparc/sol2.mh b/gdb/config/sparc/sol2.mh
index 9f91583..c6cabd2 100644
--- a/gdb/config/sparc/sol2.mh
+++ b/gdb/config/sparc/sol2.mh
@@ -3,3 +3,4 @@ NAT_FILE= nm-sol2.h
 NATDEPFILES= sparc-sol2-nat.o \
 	core-regset.o fork-child.o \
 	procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o
+HAVE_NATIVE_GCORE_HOST = 1
diff --git a/gdb/configure.ac b/gdb/configure.ac
index c17f587..7e8d4ce 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -203,6 +203,7 @@ fi
 
 TARGET_OBS=
 all_targets=
+HAVE_NATIVE_GCORE_TARGET=
 
 for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
 do
@@ -236,6 +237,14 @@ do
     if test x${want64} = xfalse; then
       . ${srcdir}/../bfd/config.bfd
     fi
+
+    # Check whether this target is native and supports gcore.
+    # Such target has to call set_gdbarch_find_memory_regions.
+    if test $gdb_native = yes -a "$targ_alias" = "$target_alias"; then
+        case " ${gdb_target_obs} " in
+        *" linux-tdep.o "*) HAVE_NATIVE_GCORE_TARGET=1 ;;
+        esac
+    fi
   fi
 done
 
@@ -264,6 +273,7 @@ if test x${all_targets} = xtrue; then
 fi
 
 AC_SUBST(TARGET_OBS)
+AC_SUBST(HAVE_NATIVE_GCORE_TARGET)
 
 # For other settings, only the main target counts.
 gdb_sim=
@@ -2349,6 +2359,20 @@ dnl  At the moment, we just assume it's UTF-8.
 AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "UTF-8",
           [Define to be a string naming the default host character set.])
 
+# Undo the $ec_script escaping suitable for Makefile.
+transform=`echo "$program_transform_name" | sed -e 's/[\\$][\\$]/\\$/g'`
+GDB_TRANSFORM_NAME=`echo gdb | sed -e "$transform"`
+if test "x$GDB_TRANSFORM_NAME" = x; then
+  GDB_TRANSFORM_NAME=gdb
+fi
+AC_SUBST(GDB_TRANSFORM_NAME)
+GCORE_TRANSFORM_NAME=`echo gcore | sed -e "$transform"`
+if test "x$GCORE_TRANSFORM_NAME" = x; then
+  GCORE_TRANSFORM_NAME=gcore
+fi
+AC_SUBST(GCORE_TRANSFORM_NAME)
+AC_CONFIG_FILES([gcore], [chmod +x gcore])
+
 AC_OUTPUT(Makefile gdb-gdb.gdb doc/Makefile data-directory/Makefile,
 [
 case x$CONFIG_HEADERS in
diff --git a/gdb/doc/Makefile.in b/gdb/doc/Makefile.in
index 70086a3..fdd57d6 100644
--- a/gdb/doc/Makefile.in
+++ b/gdb/doc/Makefile.in
@@ -177,11 +177,15 @@ POD2MAN5 = pod2man --center="GNU Development Tools" \
 		   --release="gdb-`sed q $(srcdir)/../version.in`" --section=5
 
 # List of man pages generated from gdb.texi
-MAN1S = gdb.1 gdbserver.1
+MAN1S = gdb.1 gdbserver.1 gcore.1
 MAN5S = gdbinit.5
 MANS = $(MAN1S) $(MAN5S)
 
-#### Host, target, and site specific Makefile fragments come in here.
+# Host-dependent makefile fragment comes in here.
+@host_makefile_frag@
+# End of host-dependent makefile fragment
+HAVE_NATIVE_GCORE_TARGET = @HAVE_NATIVE_GCORE_TARGET@
+
 ###
 
 all:
@@ -269,6 +273,10 @@ install-man: install-man1 install-man5
 install-man1: $(MAN1S)
 	test -z "$(man1dir)" || $(mkinstalldirs) "$(DESTDIR)$(man1dir)"
 	@list='$(MAN1S)'; for p in $$list; do \
+	  if test "x$(HAVE_NATIVE_GCORE_TARGET)$(HAVE_NATIVE_GCORE_HOST)" = x \
+		  -a "$$p" = gcore.1; then \
+	    continue; \
+	  fi; \
 	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
 	  f=`echo $$p | sed -e 's|^.*/||'`; \
 	  echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(man1dir)/$$f'"; \
@@ -288,7 +296,13 @@ uninstall-man: uninstall-man1 uninstall-man5
 
 uninstall-man1:
 	@test -n "$(man1dir)" || exit 0; \
-	files=`{ l2='$(MAN1S)'; for i in $$l2; do echo "$$i"; done | \
+	files=`{ l2='$(MAN1S)'; for i in $$l2; do \
+	  if test "x$(HAVE_NATIVE_GCORE_TARGET)$(HAVE_NATIVE_GCORE_HOST)" = x \
+		  -a "$$i" = gcore.1; then \
+	    continue; \
+	  fi; \
+	  echo "$$i"; \
+	done | \
 	  sed -n '/\.1[a-z]*$$/p'; \
 	} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
 	      -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
@@ -605,6 +619,13 @@ gdbserver.1: $(GDB_DOC_FILES)
 		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
 	rm -f gdbserver.pod
 
+gcore.1: $(GDB_DOC_FILES)
+	touch $@
+	-$(TEXI2POD) $(MANCONF) -Dgcore < $(srcdir)/gdb.texinfo > gcore.pod
+	-($(POD2MAN1) gcore.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
+		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
+	rm -f gcore.pod
+
 gdbinit.5: $(GDB_DOC_FILES)
 	touch $@
 	-$(TEXI2POD) $(MANCONF) -Dgdbinit < $(srcdir)/gdb.texinfo > gdbinit.pod
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index bf7e25e..d02ef62 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -41609,6 +41609,7 @@ switch (die->tag)
 @menu
 * gdb man::                     The GNU Debugger man page
 * gdbserver man::               Remote Server for the GNU Debugger man page
+* gcore man::                   Generate a core file of a running program
 * gdbinit man::                 gdbinit scripts
 @end menu
 
@@ -42134,6 +42135,53 @@ Richard M. Stallman and Roland H. Pesch, July 1991.
 @end ifset
 @c man end
 
+@node gcore man
+@heading gcore
+
+@c man title gcore Generate a core file of a running program
+
+@format
+@c man begin SYNOPSIS gcore
+gcore [-o @var{filename}] @var{pid}
+@c man end
+@end format
+
+@c man begin DESCRIPTION gcore
+Generate a core dump of a running program with process ID @var{pid}.
+Produced file is equivalent to a kernel produced core file as if the process
+crashed (and if @kbd{ulimit -c} were used to set up an appropriate core dump
+limit).  Unlike after a crash, after @command{gcore} the program remains
+running without any change.
+@c man end
+
+@c man begin OPTIONS gcore
+@table @env
+@item -o @var{filename}
+The optional argument
+@var{filename} specifies the file name where to put the core dump.
+If not specified, the file name defaults to @file{core.@var{pid}},
+where @var{pid} is the running program process ID.
+@end table
+@c man end
+
+@c man begin SEEALSO gcore
+@ifset man
+The full documentation for @value{GDBN} is maintained as a Texinfo manual.
+If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
+documentation are properly installed at your site, the command
+
+@smallexample
+info gdb
+@end smallexample
+
+@noindent
+should give you access to the complete manual.
+
+@cite{Using GDB: A Guide to the GNU Source-Level Debugger},
+Richard M. Stallman and Roland H. Pesch, July 1991.
+@end ifset
+@c man end
+
 @node gdbinit man
 @heading gdbinit
 
diff --git a/gdb/gcore.in b/gdb/gcore.in
index 38548f2..9c5b14d 100755
--- a/gdb/gcore.in
+++ b/gdb/gcore.in
@@ -16,14 +16,13 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #
-# gcore.sh
 # Script to generate a core file of a running program.
 # It starts up gdb, attaches to the given PID and invokes the gcore command.
 #
 
 if [ "$#" -eq "0" ]
 then
-    echo "usage:  gcore [-o filename] pid"
+    echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
     exit 2
 fi
 
@@ -35,7 +34,7 @@ then
     if [ "$#" -lt "3" ]
     then
 	# Not enough arguments.
-	echo "usage:  gcore [-o filename] pid"
+	echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
 	exit 2
     fi
     name=$2
@@ -52,14 +51,14 @@ for pid in $*
 do
 	# `</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 \
+	@GDB_TRANSFORM_NAME@ </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
 	else
-	    echo gcore: failed to create $name.$pid
+	    echo "@GCORE_TRANSFORM_NAME@: failed to create $name.$pid"
 	    rc=1
 	    break
 	fi


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page)
  2013-04-09 19:59         ` Jan Kratochvil
@ 2013-04-10 19:49           ` Pedro Alves
  2013-04-11  2:43             ` Jan Kratochvil
  0 siblings, 1 reply; 17+ messages in thread
From: Pedro Alves @ 2013-04-10 19:49 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Tom Tromey, gdb-patches

On 04/09/2013 05:55 PM, Jan Kratochvil wrote:
> On Tue, 09 Apr 2013 16:26:06 +0200, Pedro Alves wrote:
>> - Should we install it on hosts/builds that don't support gcore
>>   with the native target?
> 
> I did not consider it worth the work... but here it is.
> 
> I have found these files support the legacy to_find_memory_regions way
> 	amd64fbsd-nat gnu-nat i386fbsd-nat ppcfbsd-nat procfs sparc64fbsd-nat
> 
> so I have enabled fcore for any *.mh files using one of those.
> 
> The new set_gdbarch_find_memory_regions way uses only linux-tdep so I have put
> that in configure.ac, otherwise there would be a new variable in each
> configure.tgt rule using linux-tdep (23 cases) which would be IMO more prone
> to a future mistake.

Right, but adds the complication of having two ways of doing things.
It made the patch surprisingly harder to read to me than I was expecting, for
instance  (e.g., I had to try it to convince myself that
"--host=x86_64-unknown-linux-gnu --target=arm-linux-gnu" or
"--host=x86_64-unknown-linux-gnu --target=arm-linux-gnu --enable-targest=x86_64-unknown-linux-gnu"
do the right thing).

'grep "^supply_gregset " *' gives a good approximation (if not exact) of
targets that do cores.  I wonder whether instead adding a HAVE_NATIVE_GCORE(_HOST)
to each .mh corresponding to each of those wouldn't be easier on the long run.
It's very similar to what we used to do before:

commit c1180e35dc58a8ce9bb076eaeff249c83423f1bf
Author: Hui Zhu <teawater@gmail.com>
Date:   Mon Oct 26 18:30:39 2009 +0000

    2009-10-26  Michael Snyder  <msnyder@vmware.com>
            Hui Zhu  <teawater@gmail.com>

        * Makefile.in (SFILES): Add gcore.c.
        (COMMON_OBS): Add gcore.o.
        * config/alpha/alpha-linux.mh (NATDEPFILES): Delete gcore.o.
        * config/alpha/fbsd.mh (NATDEPFILES): Ditto.
        * config/arm/linux.mh (NATDEPFILES): Ditto.
        * config/i386/fbsd.mh (NATDEPFILES): Ditto.
        * config/i386/fbsd64.mh (NATDEPFILES): Ditto.
        * config/i386/i386sol2.mh (NATDEPFILES): Ditto.
        * config/i386/linux.mh (NATDEPFILES): Ditto.
        * config/i386/linux64.mh (NATDEPFILES): Ditto.
        * config/i386/sol2-64.mh (NATDEPFILES): Ditto.
        * config/ia64/linux.mh (NATDEPFILES): Ditto.
        * config/m32r/linux.mh (NATDEPFILES): Ditto.
        * config/m68k/linux.mh (NATDEPFILES): Ditto.
        * config/mips/linux.mh (NATDEPFILES): Ditto.
        * config/pa/linux.mh (NATDEPFILES): Ditto.
        * config/powerpc/linux.mh (NATDEPFILES): Ditto.
        * config/powerpc/ppc64-linux.mh (NATDEPFILES): Ditto.
        * config/s390/s390.mh (NATDEPFILES): Ditto.
        * config/sparc/fbsd.mh (NATDEPFILES): Ditto.
        * config/sparc/linux.mh (NATDEPFILES): Ditto.
        * config/sparc/linux64.mh (NATDEPFILES): Ditto.
        * config/sparc/sol2.mh (NATDEPFILES): Ditto.
        * config/xtensa/linux.mh (NATDEPFILES): Ditto.
        * target.c (dummy_find_memory_regions): Change output.
        (dummy_make_corefile_notes): Ditto.

Except we'd set a flag, instead of adding gcore.o to NATDEPFILES.

> Contrary to my recent regression mishaps I have tested various make install
> cases this time (not out-of-src-tree but that is not applicable for this
> change).

With --enable-targets=all, I got:

$ make DESTDIR=/tmp/foo/ install
...
/usr/bin/install: cannot stat `gcore': No such file or directory

But I'm not sure that's related to the issue pointed out
above, or whether I hasn't applied the patch properly.

> --- a/gdb/configure.ac
> +++ b/gdb/configure.ac
> @@ -203,6 +203,7 @@ fi
>  
>  TARGET_OBS=
>  all_targets=
> +HAVE_NATIVE_GCORE_TARGET=
>  
>  for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
>  do
> @@ -236,6 +237,14 @@ do
>      if test x${want64} = xfalse; then
>        . ${srcdir}/../bfd/config.bfd
>      fi
> +
> +    # Check whether this target is native and supports gcore.
> +    # Such target has to call set_gdbarch_find_memory_regions.
> +    if test $gdb_native = yes -a "$targ_alias" = "$target_alias"; then
> +        case " ${gdb_target_obs} " in
> +        *" linux-tdep.o "*) HAVE_NATIVE_GCORE_TARGET=1 ;;

It's still better to push this into configure.tgt.  E.g., keep the
if test line here, but have configure.tgt set $gdb_have_gcore, and
set HAVE_NATIVE_GCORE_TARGET accordingly.  We can still do that

       case " ${gdb_target_obs} " in
             *" linux-tdep.o "*)

bit in configure.tgt instead of touching every target switch case.
The main difference is that #1 the linux-tdep.o knowledge
is localized, and #2, changes to configure.tgt don't
require configure regeneration (thinking of future changes
to that bit for other targets).

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page)
  2013-04-10 19:49           ` Pedro Alves
@ 2013-04-11  2:43             ` Jan Kratochvil
  2013-04-11  7:40               ` Jan Kratochvil
  2013-04-11 17:49               ` [patch 2/2+rfc+doc] Install gcore by default (+new man page) Pedro Alves
  0 siblings, 2 replies; 17+ messages in thread
From: Jan Kratochvil @ 2013-04-11  2:43 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

On Wed, 10 Apr 2013 13:33:04 +0200, Pedro Alves wrote:
> Right, but adds the complication of having two ways of doing things.
> It made the patch surprisingly harder to read to me than I was expecting, for
> instance  (e.g., I had to try it to convince myself that
> "--host=x86_64-unknown-linux-gnu --target=arm-linux-gnu" or
> "--host=x86_64-unknown-linux-gnu --target=arm-linux-gnu --enable-targest=x86_64-unknown-linux-gnu"
> do the right thing).
> 
> 'grep "^supply_gregset " *' gives a good approximation (if not exact) of
> targets that do cores.  I wonder whether instead adding a HAVE_NATIVE_GCORE(_HOST)
> to each .mh corresponding to each of those wouldn't be easier on the long run.
> It's very similar to what we used to do before:
> 
> commit c1180e35dc58a8ce9bb076eaeff249c83423f1bf
> Author: Hui Zhu <teawater@gmail.com>
> Date:   Mon Oct 26 18:30:39 2009 +0000
[...]
>         (dummy_make_corefile_notes): Ditto.
> 
> Except we'd set a flag, instead of adding gcore.o to NATDEPFILES.

I can match the configure.tgt patterns to configure.host patterns and generate
new setting in all such *.mh files.

But I find it overcomplicated, the patch I sent just AFAIK directly maps how
the feature is implemented to the configure process.  THerefore it cannot be
mistaken either now or in the future.  While the implementation may look "more
complicated" I find it as rather the most simple implementation.

I do not find string grepping as acceptably reliable.

While there is a review process I do not fully trust future changes in
configure.tgt get properly mapped into the GCORE flag in all the matching *.mh
files, especially as the GCORE functionality is a rare feature without good
practical testing coverage.

Do you insist on the *.mh flag for the hosts covered by linux-tdep.o ?


> With --enable-targets=all, I got:
> 
> $ make DESTDIR=/tmp/foo/ install
> ...
> /usr/bin/install: cannot stat `gcore': No such file or directory
> 
> But I'm not sure that's related to the issue pointed out
> above, or whether I hasn't applied the patch properly.

I believe you did not run autoconf.  The problem is not reproducible for me
and also I guess it would happen without the configure update.

FYI there is also archer.git branch: jankratochvil/man


> It's still better to push this into configure.tgt.  E.g., keep the
> if test line here, but have configure.tgt set $gdb_have_gcore, and
> set HAVE_NATIVE_GCORE_TARGET accordingly.  We can still do that
> 
>        case " ${gdb_target_obs} " in
>              *" linux-tdep.o "*)
> 
> bit in configure.tgt instead of touching every target switch case.

I agree.


Thanks,
Jan


gdb/
2013-04-09  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (HAVE_NATIVE_GCORE_TARGET): New.
	(install-only, uninstall): Add gcore if HAVE_NATIVE_GCORE_TARGET or
	HAVE_NATIVE_GCORE_HOST.
	* NEWS (Changes since GDB 7.6): Mention newly installed gcore.
	* config/alpha/alpha-osf3.mh, config/i386/fbsd.mh,
	config/i386/fbsd64.mh, config/i386/i386gnu.mh, config/i386/i386sol2.mh,
	config/i386/sol2-64.mh, config/mips/irix5.mh, config/mips/irix6.mh,
	config/powerpc/fbsd.mh, config/sparc/fbsd.mh, config/sparc/sol2.mh:
	Add HAVE_NATIVE_GCORE_HOST.
	* configure: Regenerate.
	* configure.ac (HAVE_NATIVE_GCORE_TARGET): New, set it, AC_SUBST it.
	New AC_SUBST fir GDB_TRANSFORM_NAME and GCORE_TRANSFORM_NAME.  New
	AC_CONFIG_FILES for gcore.
	* configure.tgt: Set gdb_have_gcore.
	* gdb_gcore.sh: Rename to ...
	* gcore.in: ... here.  Remove gcore.sh comment.  Use GDB_TRANSFORM_NAME
	and GCORE_TRANSFORM_NAME substitutions.

gdb/doc/
2013-04-09  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (MAN1S): Add gcore.1.
	Remove "Host, target, and site specific Makefile fragments" comment.
	(@host_makefile_frag@, HAVE_NATIVE_GCORE_TARGET): New.
	(install-man1, uninstall-man1): Conditionalize gcore.1.
	(gcore.1): New.
	* gdb.texinfo (Man Pages): Add gcore man.
	(gcore man): New node.

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 0814bcb..427c122 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -418,6 +418,7 @@ CONFIG_ALL= @CONFIG_ALL@
 CONFIG_CLEAN= @CONFIG_CLEAN@
 CONFIG_INSTALL = @CONFIG_INSTALL@
 CONFIG_UNINSTALL = @CONFIG_UNINSTALL@
+HAVE_NATIVE_GCORE_TARGET = @HAVE_NATIVE_GCORE_TARGET@
 
 # -I. for config files.
 # -I$(srcdir) for gdb internal headers.
@@ -1044,6 +1045,19 @@ install-only: $(CONFIG_INSTALL)
 			$(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \
 		$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(includedir)/gdb ; \
 		$(INSTALL_DATA) jit-reader.h $(DESTDIR)$(includedir)/gdb/jit-reader.h
+	if test "x$(HAVE_NATIVE_GCORE_TARGET)$(HAVE_NATIVE_GCORE_HOST)" != x; \
+	then \
+	  transformed_name=`t='$(program_transform_name)'; \
+			    echo gcore | sed -e "$$t"` ; \
+		  if test "x$$transformed_name" = x; then \
+		    transformed_name=gcore ; \
+		  else \
+		    true ; \
+		  fi ; \
+		  $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir) ; \
+		  $(INSTALL_PROGRAM) gcore \
+			  $(DESTDIR)$(bindir)/$$transformed_name; \
+	fi
 	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 
 install-python:
@@ -1059,6 +1073,17 @@ uninstall: force $(CONFIG_UNINSTALL)
 		fi ; \
 		rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \
 		      $(DESTDIR)$(man1dir)/$$transformed_name.1
+	if test "x$(HAVE_NATIVE_GCORE_TARGET)$(HAVE_NATIVE_GCORE_HOST)" != x; \
+	then \
+	  transformed_name=`t='$(program_transform_name)'; \
+			    echo gcore | sed -e "$$t"` ; \
+		  if test "x$$transformed_name" = x; then \
+		    transformed_name=gcore ; \
+		  else \
+		    true ; \
+		  fi ; \
+		  rm -f $(DESTDIR)$(bindir)/$$transformed_name; \
+	fi
 	@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 
 # The C++ name parser can be built standalone for testing.
diff --git a/gdb/NEWS b/gdb/NEWS
index 86716e0..43f41dc 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -19,6 +19,9 @@ show remote trace-status-packet
 * The command 'tsave' can now support new option '-ctf' to save trace
   buffer in Common Trace Format.
 
+* Newly installed $prefix/bin/gcore acts as a shell interface for the
+  GDB command gcore.
+
 * MI changes
 
   ** The -trace-save MI command can optionally save trace buffer in Common
diff --git a/gdb/config/alpha/alpha-osf3.mh b/gdb/config/alpha/alpha-osf3.mh
index 483ef78..aa63dc4 100644
--- a/gdb/config/alpha/alpha-osf3.mh
+++ b/gdb/config/alpha/alpha-osf3.mh
@@ -3,4 +3,5 @@ NAT_FILE= nm-osf3.h
 NATDEPFILES= alpha-nat.o fork-child.o \
 	solib-osf.o procfs.o proc-api.o proc-events.o proc-flags.o \
 	proc-why.o dec-thread.o
+HAVE_NATIVE_GCORE_HOST = 1
 NAT_CLIBS= -lpthreaddebug
diff --git a/gdb/config/i386/fbsd.mh b/gdb/config/i386/fbsd.mh
index 05ac5bb..2c9cd9a 100644
--- a/gdb/config/i386/fbsd.mh
+++ b/gdb/config/i386/fbsd.mh
@@ -3,5 +3,6 @@ NATDEPFILES= fork-child.o inf-ptrace.o \
 	fbsd-nat.o i386-nat.o i386bsd-nat.o i386fbsd-nat.o \
 	bsd-kvm.o
 NAT_FILE= nm-fbsd.h
+HAVE_NATIVE_GCORE_HOST = 1
 
 LOADLIBES= -lkvm
diff --git a/gdb/config/i386/fbsd64.mh b/gdb/config/i386/fbsd64.mh
index 3f43727..c719a17 100644
--- a/gdb/config/i386/fbsd64.mh
+++ b/gdb/config/i386/fbsd64.mh
@@ -2,5 +2,6 @@
 NATDEPFILES= fork-child.o inf-ptrace.o \
 	fbsd-nat.o amd64-nat.o amd64bsd-nat.o amd64fbsd-nat.o \
 	bsd-kvm.o i386-nat.o
+HAVE_NATIVE_GCORE_HOST = 1
 
 LOADLIBES= -lkvm
diff --git a/gdb/config/i386/i386gnu.mh b/gdb/config/i386/i386gnu.mh
index d85744b..a3ea122 100644
--- a/gdb/config/i386/i386gnu.mh
+++ b/gdb/config/i386/i386gnu.mh
@@ -2,6 +2,7 @@
 NATDEPFILES= i386gnu-nat.o gnu-nat.o core-regset.o fork-child.o \
 	     notify_S.o process_reply_S.o msg_reply_S.o \
 	     msg_U.o exc_request_U.o exc_request_S.o
+HAVE_NATIVE_GCORE_HOST = 1
 
 NAT_FILE= nm-i386gnu.h
 MH_CFLAGS = -D_GNU_SOURCE
diff --git a/gdb/config/i386/i386sol2.mh b/gdb/config/i386/i386sol2.mh
index dcf5a79..2f7c3c5 100644
--- a/gdb/config/i386/i386sol2.mh
+++ b/gdb/config/i386/i386sol2.mh
@@ -1,3 +1,4 @@
 # Host: Solaris x86
 NATDEPFILES= fork-child.o i386v4-nat.o i386-sol2-nat.o \
 	procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o
+HAVE_NATIVE_GCORE_HOST = 1
diff --git a/gdb/config/i386/sol2-64.mh b/gdb/config/i386/sol2-64.mh
index bfb6980..7a8304d 100644
--- a/gdb/config/i386/sol2-64.mh
+++ b/gdb/config/i386/sol2-64.mh
@@ -1,3 +1,4 @@
 # Host: Solaris x86_64
 NATDEPFILES= fork-child.o amd64-nat.o i386v4-nat.o i386-sol2-nat.o \
 	procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o
+HAVE_NATIVE_GCORE_HOST = 1
diff --git a/gdb/config/mips/irix5.mh b/gdb/config/mips/irix5.mh
index 7ab5e11..d5740d0 100644
--- a/gdb/config/mips/irix5.mh
+++ b/gdb/config/mips/irix5.mh
@@ -1,3 +1,4 @@
 # Host: SGI Iris running irix 5.x
 NATDEPFILES= fork-child.o irix5-nat.o procfs.o \
 	proc-api.o proc-events.o proc-flags.o proc-why.o
+HAVE_NATIVE_GCORE_HOST = 1
diff --git a/gdb/config/mips/irix6.mh b/gdb/config/mips/irix6.mh
index 28a67eb..098df2e 100644
--- a/gdb/config/mips/irix6.mh
+++ b/gdb/config/mips/irix6.mh
@@ -1,3 +1,4 @@
 # Host: SGI Iris running irix 6.x
 NATDEPFILES= fork-child.o irix5-nat.o procfs.o \
 	proc-api.o proc-events.o proc-flags.o proc-why.o
+HAVE_NATIVE_GCORE_HOST = 1
diff --git a/gdb/config/powerpc/fbsd.mh b/gdb/config/powerpc/fbsd.mh
index 746b286..48ea902 100644
--- a/gdb/config/powerpc/fbsd.mh
+++ b/gdb/config/powerpc/fbsd.mh
@@ -18,6 +18,7 @@
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 NATDEPFILES= fbsd-nat.o fork-child.o inf-ptrace.o ppcfbsd-nat.o bsd-kvm.o
+HAVE_NATIVE_GCORE_HOST = 1
 
 LOADLIBES= -lkvm
 
diff --git a/gdb/config/sparc/fbsd.mh b/gdb/config/sparc/fbsd.mh
index ad36ee6..2774efb 100644
--- a/gdb/config/sparc/fbsd.mh
+++ b/gdb/config/sparc/fbsd.mh
@@ -2,5 +2,6 @@
 NATDEPFILES= fork-child.o inf-ptrace.o \
 	fbsd-nat.o sparc-nat.o sparc64-nat.o sparc64fbsd-nat.o \
 	bsd-kvm.o
+HAVE_NATIVE_GCORE_HOST = 1
 
 LOADLIBES= -lkvm
diff --git a/gdb/config/sparc/sol2.mh b/gdb/config/sparc/sol2.mh
index 9f91583..c6cabd2 100644
--- a/gdb/config/sparc/sol2.mh
+++ b/gdb/config/sparc/sol2.mh
@@ -3,3 +3,4 @@ NAT_FILE= nm-sol2.h
 NATDEPFILES= sparc-sol2-nat.o \
 	core-regset.o fork-child.o \
 	procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o
+HAVE_NATIVE_GCORE_HOST = 1
diff --git a/gdb/configure b/gdb/configure
index 6588c72..f9d9a17 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -591,6 +591,8 @@ ac_includes_default="\
 enable_option_checking=no
 ac_subst_vars='LTLIBOBJS
 LIBOBJS
+GCORE_TRANSFORM_NAME
+GDB_TRANSFORM_NAME
 GDB_NM_FILE
 LTLIBBABELTRACE
 LIBBABELTRACE
@@ -684,6 +686,7 @@ AWK
 REPORT_BUGS_TEXI
 REPORT_BUGS_TO
 PKGVERSION
+HAVE_NATIVE_GCORE_TARGET
 TARGET_OBS
 subdirs
 GDB_DATADIR
@@ -5083,6 +5086,7 @@ fi
 
 TARGET_OBS=
 all_targets=
+HAVE_NATIVE_GCORE_TARGET=
 
 for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
 do
@@ -5117,6 +5121,12 @@ fi
     if test x${want64} = xfalse; then
       . ${srcdir}/../bfd/config.bfd
     fi
+
+    # Check whether this target is native and supports gcore.
+    if test $gdb_native = yes -a "$targ_alias" = "$target_alias" \
+       && $gdb_have_gcore; then
+      HAVE_NATIVE_GCORE_TARGET=1
+    fi
   fi
 done
 
@@ -5179,6 +5189,7 @@ fi
 
 
 
+
 # For other settings, only the main target counts.
 gdb_sim=
 gdb_osabi=
@@ -14648,6 +14659,21 @@ ac_config_links="$ac_config_links $ac_config_links_1"
 $as_echo "#define GDB_DEFAULT_HOST_CHARSET \"UTF-8\"" >>confdefs.h
 
 
+# Undo the $ec_script escaping suitable for Makefile.
+transform=`echo "$program_transform_name" | sed -e 's/\\$\\$/\\$/g'`
+GDB_TRANSFORM_NAME=`echo gdb | sed -e "$transform"`
+if test "x$GDB_TRANSFORM_NAME" = x; then
+  GDB_TRANSFORM_NAME=gdb
+fi
+
+GCORE_TRANSFORM_NAME=`echo gcore | sed -e "$transform"`
+if test "x$GCORE_TRANSFORM_NAME" = x; then
+  GCORE_TRANSFORM_NAME=gcore
+fi
+
+ac_config_files="$ac_config_files gcore"
+
+
 ac_config_files="$ac_config_files Makefile gdb-gdb.gdb doc/Makefile data-directory/Makefile"
 
 ac_config_commands="$ac_config_commands default"
@@ -15358,6 +15384,7 @@ do
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "jit-reader.h") CONFIG_FILES="$CONFIG_FILES jit-reader.h:jit-reader.in" ;;
     "$ac_config_links_1") CONFIG_LINKS="$CONFIG_LINKS $ac_config_links_1" ;;
+    "gcore") CONFIG_FILES="$CONFIG_FILES gcore" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "gdb-gdb.gdb") CONFIG_FILES="$CONFIG_FILES gdb-gdb.gdb" ;;
     "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
@@ -15979,6 +16006,7 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
 
   case $ac_file$ac_mode in
     "depdir":C) $SHELL $ac_aux_dir/mkinstalldirs $DEPDIR ;;
+    "gcore":F) chmod +x gcore ;;
     "default":C)
 case x$CONFIG_HEADERS in
 xconfig.h:config.in)
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 149ac37..ce6fa7a 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -203,6 +203,7 @@ fi
 
 TARGET_OBS=
 all_targets=
+HAVE_NATIVE_GCORE_TARGET=
 
 for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
 do
@@ -236,6 +237,12 @@ do
     if test x${want64} = xfalse; then
       . ${srcdir}/../bfd/config.bfd
     fi
+
+    # Check whether this target is native and supports gcore.
+    if test $gdb_native = yes -a "$targ_alias" = "$target_alias" \
+       && $gdb_have_gcore; then
+      HAVE_NATIVE_GCORE_TARGET=1
+    fi
   fi
 done
 
@@ -264,6 +271,7 @@ if test x${all_targets} = xtrue; then
 fi
 
 AC_SUBST(TARGET_OBS)
+AC_SUBST(HAVE_NATIVE_GCORE_TARGET)
 
 # For other settings, only the main target counts.
 gdb_sim=
@@ -2390,6 +2398,20 @@ dnl  At the moment, we just assume it's UTF-8.
 AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "UTF-8",
           [Define to be a string naming the default host character set.])
 
+# Undo the $ec_script escaping suitable for Makefile.
+transform=`echo "$program_transform_name" | sed -e 's/[\\$][\\$]/\\$/g'`
+GDB_TRANSFORM_NAME=`echo gdb | sed -e "$transform"`
+if test "x$GDB_TRANSFORM_NAME" = x; then
+  GDB_TRANSFORM_NAME=gdb
+fi
+AC_SUBST(GDB_TRANSFORM_NAME)
+GCORE_TRANSFORM_NAME=`echo gcore | sed -e "$transform"`
+if test "x$GCORE_TRANSFORM_NAME" = x; then
+  GCORE_TRANSFORM_NAME=gcore
+fi
+AC_SUBST(GCORE_TRANSFORM_NAME)
+AC_CONFIG_FILES([gcore], [chmod +x gcore])
+
 AC_OUTPUT(Makefile gdb-gdb.gdb doc/Makefile data-directory/Makefile,
 [
 case x$CONFIG_HEADERS in
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index c6357d2..abbd8cd 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -703,3 +703,14 @@ m68*-*-openbsd* | m88*-*-openbsd* | vax-*-openbsd*) ;;
 *-*-symbianelf*)
 		gdb_osabi=GDB_OSABI_SYMBIAN ;;
 esac
+
+# Check whether this target supports gcore if used as a native one.
+# Such target has to call set_gdbarch_find_memory_regions.
+case " ${gdb_target_obs} " in
+  *" linux-tdep.o "*)
+    gdb_have_gcore=true
+    ;;
+  *)
+    gdb_have_gcore=false
+    ;;
+esac
diff --git a/gdb/doc/Makefile.in b/gdb/doc/Makefile.in
index 70086a3..278a62d 100644
--- a/gdb/doc/Makefile.in
+++ b/gdb/doc/Makefile.in
@@ -177,11 +177,15 @@ POD2MAN5 = pod2man --center="GNU Development Tools" \
 		   --release="gdb-`sed q $(srcdir)/../version.in`" --section=5
 
 # List of man pages generated from gdb.texi
-MAN1S = gdb.1 gdbserver.1
+MAN1S = gdb.1 gdbserver.1 gcore.1 gdb-add-index.1
 MAN5S = gdbinit.5
 MANS = $(MAN1S) $(MAN5S)
 
-#### Host, target, and site specific Makefile fragments come in here.
+# Host-dependent makefile fragment comes in here.
+@host_makefile_frag@
+# End of host-dependent makefile fragment
+HAVE_NATIVE_GCORE_TARGET = @HAVE_NATIVE_GCORE_TARGET@
+
 ###
 
 all:
@@ -269,6 +273,10 @@ install-man: install-man1 install-man5
 install-man1: $(MAN1S)
 	test -z "$(man1dir)" || $(mkinstalldirs) "$(DESTDIR)$(man1dir)"
 	@list='$(MAN1S)'; for p in $$list; do \
+	  if test "x$(HAVE_NATIVE_GCORE_TARGET)$(HAVE_NATIVE_GCORE_HOST)" = x \
+		  -a "$$p" = gcore.1; then \
+	    continue; \
+	  fi; \
 	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
 	  f=`echo $$p | sed -e 's|^.*/||'`; \
 	  echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(man1dir)/$$f'"; \
@@ -288,7 +296,13 @@ uninstall-man: uninstall-man1 uninstall-man5
 
 uninstall-man1:
 	@test -n "$(man1dir)" || exit 0; \
-	files=`{ l2='$(MAN1S)'; for i in $$l2; do echo "$$i"; done | \
+	files=`{ l2='$(MAN1S)'; for i in $$l2; do \
+	  if test "x$(HAVE_NATIVE_GCORE_TARGET)$(HAVE_NATIVE_GCORE_HOST)" = x \
+		  -a "$$i" = gcore.1; then \
+	    continue; \
+	  fi; \
+	  echo "$$i"; \
+	done | \
 	  sed -n '/\.1[a-z]*$$/p'; \
 	} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
 	      -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
@@ -605,6 +619,24 @@ gdbserver.1: $(GDB_DOC_FILES)
 		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
 	rm -f gdbserver.pod
 
+<<<<<<< HEAD
+gcore.1: $(GDB_DOC_FILES)
+	touch $@
+	-$(TEXI2POD) $(MANCONF) -Dgcore < $(srcdir)/gdb.texinfo > gcore.pod
+	-($(POD2MAN1) gcore.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
+		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
+	rm -f gcore.pod
+
+||||||| merged common ancestors
+=======
+gdb-add-index.1: $(GDB_DOC_FILES)
+	touch $@
+	-$(TEXI2POD) $(MANCONF) -Dgdb-add-index < $(srcdir)/gdb.texinfo > gdb-add-index.pod
+	-($(POD2MAN1) gdb-add-index.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
+		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
+	rm -f gdb-add-index.pod
+
+>>>>>>> addindex
 gdbinit.5: $(GDB_DOC_FILES)
 	touch $@
 	-$(TEXI2POD) $(MANCONF) -Dgdbinit < $(srcdir)/gdb.texinfo > gdbinit.pod
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 15a8894..1aac634 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -41652,7 +41652,9 @@ switch (die->tag)
 @menu
 * gdb man::                     The GNU Debugger man page
 * gdbserver man::               Remote Server for the GNU Debugger man page
+* gcore man::                   Generate a core file of a running program
 * gdbinit man::                 gdbinit scripts
+* gdb-add-index man::           Add index files to speed up GDB
 @end menu
 
 @node gdb man
@@ -42177,6 +42179,53 @@ Richard M. Stallman and Roland H. Pesch, July 1991.
 @end ifset
 @c man end
 
+@node gcore man
+@heading gcore
+
+@c man title gcore Generate a core file of a running program
+
+@format
+@c man begin SYNOPSIS gcore
+gcore [-o @var{filename}] @var{pid}
+@c man end
+@end format
+
+@c man begin DESCRIPTION gcore
+Generate a core dump of a running program with process ID @var{pid}.
+Produced file is equivalent to a kernel produced core file as if the process
+crashed (and if @kbd{ulimit -c} were used to set up an appropriate core dump
+limit).  Unlike after a crash, after @command{gcore} the program remains
+running without any change.
+@c man end
+
+@c man begin OPTIONS gcore
+@table @env
+@item -o @var{filename}
+The optional argument
+@var{filename} specifies the file name where to put the core dump.
+If not specified, the file name defaults to @file{core.@var{pid}},
+where @var{pid} is the running program process ID.
+@end table
+@c man end
+
+@c man begin SEEALSO gcore
+@ifset man
+The full documentation for @value{GDBN} is maintained as a Texinfo manual.
+If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
+documentation are properly installed at your site, the command
+
+@smallexample
+info gdb
+@end smallexample
+
+@noindent
+should give you access to the complete manual.
+
+@cite{Using GDB: A Guide to the GNU Source-Level Debugger},
+Richard M. Stallman and Roland H. Pesch, July 1991.
+@end ifset
+@c man end
+
 @node gdbinit man
 @heading gdbinit
 
@@ -42270,6 +42319,53 @@ Richard M. Stallman and Roland H. Pesch, July 1991.
 @end ifset
 @c man end
 
+@node gdb-add-index man
+
+@c man title gdb-add-index Add index files to speed up GDB
+
+@c man begin SYNOPSIS gdb-add-index
+gdb-add-index @var{filename}
+@c man end
+
+@c man begin DESCRIPTION gdb-add-index
+When GDB finds a symbol file, it scans the symbols in the file in order
+to construct an internal symbol table.  This lets most GDB operations
+work quickly--at the cost of a delay early on.  For large programs,
+this delay can be quite lengthy, so GDB provides a way to build an
+index, which speeds up startup.
+
+To determine whether a file contains such an index, use the command
+@command{readelf -S filename}: the index is stored in a section named
+@code{.gdb_index}.  Note that the index is never generated for files that do
+not contain DWARF debug information (sections named @code{.debug_*}).
+
+See more in
+@ifset man
+the @value{GDBN} manual in node @code{Index Files}
+-- shell command @code{info -f gdb -n 'Index Files'}.
+@end ifset
+@ifclear man
+@ref{Index Files}.
+@end ifclear
+@c man end
+
+@c man begin SEEALSO gdb-add-index
+@ifset man
+The full documentation for @value{GDBN} is maintained as a Texinfo manual.
+If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
+documentation are properly installed at your site, the command
+
+@smallexample
+info gdb
+@end smallexample
+
+should give you access to the complete manual.
+
+@cite{Using GDB: A Guide to the GNU Source-Level Debugger},
+Richard M. Stallman and Roland H. Pesch, July 1991.
+@end ifset
+@c man end
+
 @include gpl.texi
 
 @node GNU Free Documentation License
diff --git a/gdb/gcore.in b/gdb/gcore.in
new file mode 100755
index 0000000..9c5b14d
--- /dev/null
+++ b/gdb/gcore.in
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+#   Copyright (C) 2003-2013 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 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, see <http://www.gnu.org/licenses/>.
+
+#
+# Script to generate a core file of a running program.
+# It starts up gdb, attaches to the given PID and invokes the gcore command.
+#
+
+if [ "$#" -eq "0" ]
+then
+    echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
+    exit 2
+fi
+
+# Need to check for -o option, but set default basename to "core".
+name=core
+
+if [ "$1" = "-o" ]
+then
+    if [ "$#" -lt "3" ]
+    then
+	# Not enough arguments.
+	echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
+	exit 2
+    fi
+    name=$2
+
+    # Shift over to start of pid list
+    shift; shift
+fi
+
+# Initialise return code.
+rc=0
+
+# Loop through pids
+for pid in $*
+do
+	# `</dev/null' to avoid touching interactive terminal if it is
+	# available but not accessible as GDB would get stopped on SIGTTIN.
+	@GDB_TRANSFORM_NAME@ </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
+	else
+	    echo "@GCORE_TRANSFORM_NAME@: failed to create $name.$pid"
+	    rc=1
+	    break
+	fi
+
+
+done
+
+exit $rc
diff --git a/gdb/gdb_gcore.sh b/gdb/gdb_gcore.sh
deleted file mode 100755
index 38548f2..0000000
--- a/gdb/gdb_gcore.sh
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/sh
-
-#   Copyright (C) 2003-2013 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 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, see <http://www.gnu.org/licenses/>.
-
-#
-# gcore.sh
-# Script to generate a core file of a running program.
-# It starts up gdb, attaches to the given PID and invokes the gcore command.
-#
-
-if [ "$#" -eq "0" ]
-then
-    echo "usage:  gcore [-o filename] pid"
-    exit 2
-fi
-
-# Need to check for -o option, but set default basename to "core".
-name=core
-
-if [ "$1" = "-o" ]
-then
-    if [ "$#" -lt "3" ]
-    then
-	# Not enough arguments.
-	echo "usage:  gcore [-o filename] pid"
-	exit 2
-    fi
-    name=$2
-
-    # Shift over to start of pid list
-    shift; shift
-fi
-
-# Initialise return code.
-rc=0
-
-# Loop through pids
-for pid in $*
-do
-	# `</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
-	else
-	    echo gcore: failed to create $name.$pid
-	    rc=1
-	    break
-	fi
-
-
-done
-
-exit $rc


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page)
  2013-04-11  2:43             ` Jan Kratochvil
@ 2013-04-11  7:40               ` Jan Kratochvil
  2013-04-11 17:52                 ` auto-generated parts in posted patches (Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page)) Pedro Alves
  2013-04-11 17:49               ` [patch 2/2+rfc+doc] Install gcore by default (+new man page) Pedro Alves
  1 sibling, 1 reply; 17+ messages in thread
From: Jan Kratochvil @ 2013-04-11  7:40 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

On Wed, 10 Apr 2013 21:49:10 +0200, Jan Kratochvil wrote:
> On Wed, 10 Apr 2013 13:33:04 +0200, Pedro Alves wrote:
> > But I'm not sure that's related to the issue pointed out
> > above, or whether I hasn't applied the patch properly.
> 
> I believe you did not run autoconf.  The problem is not reproducible for me
> and also I guess it would happen without the configure update.
> 
> FYI there is also archer.git branch: jankratochvil/man

Forgot to state here were always replies one should strip all auto-generated
parts from posted patches - so I do it.  But I find that inconvenient.  It is
easier to skip a part of patch when reviewing it than to regenerate it
hopefully the same way as the patch submitter because the source tree requires
special autotools (old version + unpatched).


Jan


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page)
  2013-04-11  2:43             ` Jan Kratochvil
  2013-04-11  7:40               ` Jan Kratochvil
@ 2013-04-11 17:49               ` Pedro Alves
  2013-04-11 22:59                 ` [commit] " Jan Kratochvil
  1 sibling, 1 reply; 17+ messages in thread
From: Pedro Alves @ 2013-04-11 17:49 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Tom Tromey, gdb-patches

On 04/10/2013 08:49 PM, Jan Kratochvil wrote:

> Do you insist on the *.mh flag for the hosts covered by linux-tdep.o ?

I agree with your reasoning, and I do not insist.

>> With --enable-targets=all, I got:
>>
>> $ make DESTDIR=/tmp/foo/ install
>> ...
>> /usr/bin/install: cannot stat `gcore': No such file or directory
>>
>> But I'm not sure that's related to the issue pointed out
>> above, or whether I hasn't applied the patch properly.
> 
> I believe you did not run autoconf.  

I did run autoconf.  If I hadn't I wouldn't have been able
to do the other "--host=x86_64-unknown-linux-gnu --target=arm-linux-gnu"
or "--host=x86_64-unknown-linux-gnu --target=arm-linux-gnu \
--enable-targest=x86_64-unknown-linux-gnu" tests I mentioned.  ;-)

> The problem is not reproducible for me
> and also I guess it would happen without the configure update.

I see what happened.  While doing my several tests, and switching
configurations, I deleted the generated "gcore" from the build dir.
"make" alone is not triggering a regeneration of gcore.  Only the
configure step is generating it.  This fixes it:

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 427c122..ebe6eb7 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -969,7 +969,7 @@ DISTSTUFF = $(YYFILES)

 # All generated files which can be included by another file.
 generated_files = config.h observer.h observer.inc ada-lex.c jit-reader.h \
-	$(GNULIB_H) $(NAT_GENERATED_FILES)
+	$(GNULIB_H) $(NAT_GENERATED_FILES) gcore

 .c.o:
 	$(COMPILE) $<
@@ -1328,6 +1328,9 @@ data-directory/Makefile: data-directory/Makefile.in config.status @frags@
 jit-reader.h: $(srcdir)/jit-reader.in
 	$(SHELL) config.status $@

+gcore: $(srcdir)/gcore.in
+	$(SHELL) config.status $@
+
 config.h: stamp-h ; @true
 stamp-h: $(srcdir)/config.in config.status
 	CONFIG_HEADERS=config.h:config.in \

With that, "make" generates gcore.

> FYI there is also archer.git branch: jankratochvil/man

Thanks.

(I find it much better for review when test branches
are rebased versions on top of upstream, just containing
the proposed patches though.)

>  case x$CONFIG_HEADERS in
> diff --git a/gdb/configure.tgt b/gdb/configure.tgt
> index c6357d2..abbd8cd 100644
> --- a/gdb/configure.tgt
> +++ b/gdb/configure.tgt
> @@ -703,3 +703,14 @@ m68*-*-openbsd* | m88*-*-openbsd* | vax-*-openbsd*) ;;
>  *-*-symbianelf*)
>  		gdb_osabi=GDB_OSABI_SYMBIAN ;;
>  esac
> +
> +# Check whether this target supports gcore if used as a native one.

s/if used as a native one//  .  The "native" aspect is a
concern of a particular caller.

> +# Such target has to call set_gdbarch_find_memory_regions.
> +case " ${gdb_target_obs} " in
> +  *" linux-tdep.o "*)
> +    gdb_have_gcore=true
> +    ;;
> +  *)
> +    gdb_have_gcore=false
> +    ;;

Please document $gdb_have_gcore at the top of the configure.tgt
file though, in the "This file sets the following shell variables:"
section.

> +<<<<<<< HEAD
> +gcore.1: $(GDB_DOC_FILES)
> +	touch $@
> +	-$(TEXI2POD) $(MANCONF) -Dgcore < $(srcdir)/gdb.texinfo > gcore.pod
> +	-($(POD2MAN1) gcore.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
> +		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
> +	rm -f gcore.pod
> +
> +||||||| merged common ancestors
> +=======
> +gdb-add-index.1: $(GDB_DOC_FILES)
> +	touch $@
> +	-$(TEXI2POD) $(MANCONF) -Dgdb-add-index < $(srcdir)/gdb.texinfo > gdb-add-index.pod
> +	-($(POD2MAN1) gdb-add-index.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
> +		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
> +	rm -f gdb-add-index.pod
> +
> +>>>>>>> addindex

I see this on the branch as well.

>  
> +@node gdb-add-index man
> +

This whole node looks unrelated ?

> +@c man title gdb-add-index Add index files to speed up GDB
> +
> +@c man begin SYNOPSIS gdb-add-index
> +gdb-add-index @var{filename}
> +@c man end
> +
> +@c man begin DESCRIPTION gdb-add-index
> +When GDB finds a symbol file, it scans the symbols in the file in order
> +to construct an internal symbol table.  This lets most GDB operations
> +work quickly--at the cost of a delay early on.  For large programs,
> +this delay can be quite lengthy, so GDB provides a way to build an
> +index, which speeds up startup.
> +
> +To determine whether a file contains such an index, use the command
> +@command{readelf -S filename}: the index is stored in a section named
> +@code{.gdb_index}.  Note that the index is never generated for files that do
> +not contain DWARF debug information (sections named @code{.debug_*}).
> +
> +See more in
> +@ifset man
> +the @value{GDBN} manual in node @code{Index Files}
> +-- shell command @code{info -f gdb -n 'Index Files'}.
> +@end ifset
> +@ifclear man
> +@ref{Index Files}.
> +@end ifclear
> +@c man end
> +

Otherwise looks good to me.

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 17+ messages in thread

* auto-generated parts in posted patches (Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page))
  2013-04-11  7:40               ` Jan Kratochvil
@ 2013-04-11 17:52                 ` Pedro Alves
  2013-04-12 18:16                   ` Tom Tromey
  0 siblings, 1 reply; 17+ messages in thread
From: Pedro Alves @ 2013-04-11 17:52 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Tom Tromey, gdb-patches

On 04/11/2013 05:03 AM, Jan Kratochvil wrote:
> Forgot to state here were always replies one should strip all auto-generated
> parts from posted patches - so I do it.  But I find that inconvenient.  It is
> easier to skip a part of patch when reviewing it than to regenerate it
> hopefully the same way as the patch submitter because the source tree requires
> special autotools (old version + unpatched).

I fully agree.  It's also very useful to see the generated bits to check
whether a submitter who has commit/write access is using the right versions
of the tools to regenerate the patches, and check whether the correct set
of files is being regenerated.

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [commit] [patch 2/2+rfc+doc] Install gcore by default (+new man page)
  2013-04-11 17:49               ` [patch 2/2+rfc+doc] Install gcore by default (+new man page) Pedro Alves
@ 2013-04-11 22:59                 ` Jan Kratochvil
  2013-04-11 23:00                   ` Pedro Alves
  0 siblings, 1 reply; 17+ messages in thread
From: Jan Kratochvil @ 2013-04-11 22:59 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

On Thu, 11 Apr 2013 12:33:10 +0200, Pedro Alves wrote:
> I see what happened.  While doing my several tests, and switching
> configurations, I deleted the generated "gcore" from the build dir.
> "make" alone is not triggering a regeneration of gcore.  Only the
> configure step is generating it.  This fixes it:

OK, thanks, I did not notice generated_files.


> > FYI there is also archer.git branch: jankratochvil/man
> 
> Thanks.
> 
> (I find it much better for review when test branches
> are rebased versions on top of upstream, just containing
> the proposed patches though.)

I probably should not have mentioned it, I did not put too much attention to
the branch, I also did not consider it for reviewing but rather just for
practical testing, sorry for your time.


> > +@node gdb-add-index man
> > +
> 
> This whole node looks unrelated ?

That branch had an unrelated patch merged inside.  I have not even posted the
other (gdb-add-index) part.

For more background /usr/bin/gdb-add-index was originally checked in FSF GDB
HEAD by Tom and later removed due to various issues.  As it is going to say
shipped in Fedora also the gdb-add-index man page has to stay shipped only in
Fedora.


> Otherwise looks good to me.

Checked in.


Thanks,
Jan


http://sourceware.org/ml/gdb-cvs/2013-04/msg00109.html

--- src/gdb/ChangeLog	2013/04/11 13:14:04	1.15397
+++ src/gdb/ChangeLog	2013/04/11 14:13:42	1.15398
@@ -1,4 +1,28 @@
 2013-04-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
+	    Pedro Alves  <palves@redhat.com>
+
+	* Makefile.in (HAVE_NATIVE_GCORE_TARGET): New.
+	(generated_files): Add gcore.
+	(install-only, uninstall): Add gcore if HAVE_NATIVE_GCORE_TARGET or
+	HAVE_NATIVE_GCORE_HOST.
+	(gcore): New.
+	* NEWS (Changes since GDB 7.6): Mention newly installed gcore.
+	* config/alpha/alpha-osf3.mh, config/i386/fbsd.mh,
+	config/i386/fbsd64.mh, config/i386/i386gnu.mh, config/i386/i386sol2.mh,
+	config/i386/sol2-64.mh, config/mips/irix5.mh, config/mips/irix6.mh,
+	config/powerpc/fbsd.mh, config/sparc/fbsd.mh, config/sparc/sol2.mh:
+	Add HAVE_NATIVE_GCORE_HOST.
+	* configure: Regenerate.
+	* configure.ac (HAVE_NATIVE_GCORE_TARGET): New, set it, AC_SUBST it.
+	New AC_SUBST fir GDB_TRANSFORM_NAME and GCORE_TRANSFORM_NAME.  New
+	AC_CONFIG_FILES for gcore.
+	* configure.tgt: Add gdb_have_gcore to the initial comment.  Set
+	gdb_have_gcore.
+	* gdb_gcore.sh: Rename to ...
+	* gcore.in: ... here.  Remove gcore.sh comment.  Use GDB_TRANSFORM_NAME
+	and GCORE_TRANSFORM_NAME substitutions.
+
+2013-04-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
 	* remote.c (unpush_and_perror): Add output message final dot.
 
--- src/gdb/doc/ChangeLog	2013/04/10 15:11:12	1.1440
+++ src/gdb/doc/ChangeLog	2013/04/11 14:13:44	1.1441
@@ -1,3 +1,13 @@
+2013-04-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* Makefile.in (MAN1S): Add gcore.1.
+	Remove "Host, target, and site specific Makefile fragments" comment.
+	(@host_makefile_frag@, HAVE_NATIVE_GCORE_TARGET): New.
+	(install-man1, uninstall-man1): Conditionalize gcore.1.
+	(gcore.1): New.
+	* gdb.texinfo (Man Pages): Add gcore man.
+	(gcore man): New node.
+
 2013-04-10  Pedro Alves  <palves@redhat.com>
 
 	* gdb.texinfo (Process Record and Replay): Document that "set
--- src/gdb/gcore.in
+++ src/gdb/gcore.in	2013-04-11 14:15:23.866456268 +0000
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+#   Copyright (C) 2003-2013 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 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, see <http://www.gnu.org/licenses/>.
+
+#
+# Script to generate a core file of a running program.
+# It starts up gdb, attaches to the given PID and invokes the gcore command.
+#
+
+if [ "$#" -eq "0" ]
+then
+    echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
+    exit 2
+fi
+
+# Need to check for -o option, but set default basename to "core".
+name=core
+
+if [ "$1" = "-o" ]
+then
+    if [ "$#" -lt "3" ]
+    then
+	# Not enough arguments.
+	echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
+	exit 2
+    fi
+    name=$2
+
+    # Shift over to start of pid list
+    shift; shift
+fi
+
+# Initialise return code.
+rc=0
+
+# Loop through pids
+for pid in $*
+do
+	# `</dev/null' to avoid touching interactive terminal if it is
+	# available but not accessible as GDB would get stopped on SIGTTIN.
+	@GDB_TRANSFORM_NAME@ </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
+	else
+	    echo "@GCORE_TRANSFORM_NAME@: failed to create $name.$pid"
+	    rc=1
+	    break
+	fi
+
+
+done
+
+exit $rc
--- ./gdb/gdb_gcore.sh	2013-01-01 07:32:42.000000000 +0100
+++ ./gdb/gdb_gcore.sh	2013-04-11 08:16:23.002210347 +0200
@@ -1,70 +0,0 @@
-#!/bin/sh
-
-#   Copyright (C) 2003-2013 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 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, see <http://www.gnu.org/licenses/>.
-
-#
-# gcore.sh
-# Script to generate a core file of a running program.
-# It starts up gdb, attaches to the given PID and invokes the gcore command.
-#
-
-if [ "$#" -eq "0" ]
-then
-    echo "usage:  gcore [-o filename] pid"
-    exit 2
-fi
-
-# Need to check for -o option, but set default basename to "core".
-name=core
-
-if [ "$1" = "-o" ]
-then
-    if [ "$#" -lt "3" ]
-    then
-	# Not enough arguments.
-	echo "usage:  gcore [-o filename] pid"
-	exit 2
-    fi
-    name=$2
-
-    # Shift over to start of pid list
-    shift; shift
-fi
-
-# Initialise return code.
-rc=0
-
-# Loop through pids
-for pid in $*
-do
-	# `</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
-	else
-	    echo gcore: failed to create $name.$pid
-	    rc=1
-	    break
-	fi
-
-
-done
-
-exit $rc
--- src/gdb/Makefile.in	2013/04/10 09:42:56	1.1248
+++ src/gdb/Makefile.in	2013/04/11 14:13:43	1.1249
@@ -418,6 +418,7 @@
 CONFIG_CLEAN= @CONFIG_CLEAN@
 CONFIG_INSTALL = @CONFIG_INSTALL@
 CONFIG_UNINSTALL = @CONFIG_UNINSTALL@
+HAVE_NATIVE_GCORE_TARGET = @HAVE_NATIVE_GCORE_TARGET@
 
 # -I. for config files.
 # -I$(srcdir) for gdb internal headers.
@@ -968,7 +969,7 @@
 
 # All generated files which can be included by another file.
 generated_files = config.h observer.h observer.inc ada-lex.c jit-reader.h \
-	$(GNULIB_H) $(NAT_GENERATED_FILES)
+	$(GNULIB_H) $(NAT_GENERATED_FILES) gcore
 
 .c.o:
 	$(COMPILE) $<
@@ -1044,6 +1045,19 @@
 			$(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \
 		$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(includedir)/gdb ; \
 		$(INSTALL_DATA) jit-reader.h $(DESTDIR)$(includedir)/gdb/jit-reader.h
+	if test "x$(HAVE_NATIVE_GCORE_TARGET)$(HAVE_NATIVE_GCORE_HOST)" != x; \
+	then \
+	  transformed_name=`t='$(program_transform_name)'; \
+			    echo gcore | sed -e "$$t"` ; \
+		  if test "x$$transformed_name" = x; then \
+		    transformed_name=gcore ; \
+		  else \
+		    true ; \
+		  fi ; \
+		  $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir) ; \
+		  $(INSTALL_PROGRAM) gcore \
+			  $(DESTDIR)$(bindir)/$$transformed_name; \
+	fi
 	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 
 install-python:
@@ -1059,6 +1073,17 @@
 		fi ; \
 		rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \
 		      $(DESTDIR)$(man1dir)/$$transformed_name.1
+	if test "x$(HAVE_NATIVE_GCORE_TARGET)$(HAVE_NATIVE_GCORE_HOST)" != x; \
+	then \
+	  transformed_name=`t='$(program_transform_name)'; \
+			    echo gcore | sed -e "$$t"` ; \
+		  if test "x$$transformed_name" = x; then \
+		    transformed_name=gcore ; \
+		  else \
+		    true ; \
+		  fi ; \
+		  rm -f $(DESTDIR)$(bindir)/$$transformed_name; \
+	fi
 	@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 
 # The C++ name parser can be built standalone for testing.
@@ -1303,6 +1328,9 @@
 jit-reader.h: $(srcdir)/jit-reader.in
 	$(SHELL) config.status $@
 
+gcore: $(srcdir)/gcore.in
+	$(SHELL) config.status $@
+
 config.h: stamp-h ; @true
 stamp-h: $(srcdir)/config.in config.status
 	CONFIG_HEADERS=config.h:config.in \
--- src/gdb/NEWS	2013/04/10 09:42:56	1.585
+++ src/gdb/NEWS	2013/04/11 14:13:43	1.586
@@ -19,6 +19,9 @@
 * The command 'tsave' can now support new option '-ctf' to save trace
   buffer in Common Trace Format.
 
+* Newly installed $prefix/bin/gcore acts as a shell interface for the
+  GDB command gcore.
+
 * MI changes
 
   ** The -trace-save MI command can optionally save trace buffer in Common
--- src/gdb/configure	2013/04/10 09:42:56	1.386
+++ src/gdb/configure	2013/04/11 14:13:43	1.387
@@ -591,6 +591,8 @@
 enable_option_checking=no
 ac_subst_vars='LTLIBOBJS
 LIBOBJS
+GCORE_TRANSFORM_NAME
+GDB_TRANSFORM_NAME
 GDB_NM_FILE
 LTLIBBABELTRACE
 LIBBABELTRACE
@@ -684,6 +686,7 @@
 REPORT_BUGS_TEXI
 REPORT_BUGS_TO
 PKGVERSION
+HAVE_NATIVE_GCORE_TARGET
 TARGET_OBS
 subdirs
 GDB_DATADIR
@@ -5083,6 +5086,7 @@
 
 TARGET_OBS=
 all_targets=
+HAVE_NATIVE_GCORE_TARGET=
 
 for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
 do
@@ -5117,6 +5121,12 @@
     if test x${want64} = xfalse; then
       . ${srcdir}/../bfd/config.bfd
     fi
+
+    # Check whether this target is native and supports gcore.
+    if test $gdb_native = yes -a "$targ_alias" = "$target_alias" \
+       && $gdb_have_gcore; then
+      HAVE_NATIVE_GCORE_TARGET=1
+    fi
   fi
 done
 
@@ -5179,6 +5189,7 @@
 
 
 
+
 # For other settings, only the main target counts.
 gdb_sim=
 gdb_osabi=
@@ -14648,6 +14659,21 @@
 $as_echo "#define GDB_DEFAULT_HOST_CHARSET \"UTF-8\"" >>confdefs.h
 
 
+# Undo the $ec_script escaping suitable for Makefile.
+transform=`echo "$program_transform_name" | sed -e 's/\\$\\$/\\$/g'`
+GDB_TRANSFORM_NAME=`echo gdb | sed -e "$transform"`
+if test "x$GDB_TRANSFORM_NAME" = x; then
+  GDB_TRANSFORM_NAME=gdb
+fi
+
+GCORE_TRANSFORM_NAME=`echo gcore | sed -e "$transform"`
+if test "x$GCORE_TRANSFORM_NAME" = x; then
+  GCORE_TRANSFORM_NAME=gcore
+fi
+
+ac_config_files="$ac_config_files gcore"
+
+
 ac_config_files="$ac_config_files Makefile gdb-gdb.gdb doc/Makefile data-directory/Makefile"
 
 ac_config_commands="$ac_config_commands default"
@@ -15358,6 +15384,7 @@
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "jit-reader.h") CONFIG_FILES="$CONFIG_FILES jit-reader.h:jit-reader.in" ;;
     "$ac_config_links_1") CONFIG_LINKS="$CONFIG_LINKS $ac_config_links_1" ;;
+    "gcore") CONFIG_FILES="$CONFIG_FILES gcore" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "gdb-gdb.gdb") CONFIG_FILES="$CONFIG_FILES gdb-gdb.gdb" ;;
     "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
@@ -15979,6 +16006,7 @@
 
   case $ac_file$ac_mode in
     "depdir":C) $SHELL $ac_aux_dir/mkinstalldirs $DEPDIR ;;
+    "gcore":F) chmod +x gcore ;;
     "default":C)
 case x$CONFIG_HEADERS in
 xconfig.h:config.in)
--- src/gdb/configure.ac	2013/04/10 09:42:56	1.198
+++ src/gdb/configure.ac	2013/04/11 14:13:43	1.199
@@ -203,6 +203,7 @@
 
 TARGET_OBS=
 all_targets=
+HAVE_NATIVE_GCORE_TARGET=
 
 for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
 do
@@ -236,6 +237,12 @@
     if test x${want64} = xfalse; then
       . ${srcdir}/../bfd/config.bfd
     fi
+
+    # Check whether this target is native and supports gcore.
+    if test $gdb_native = yes -a "$targ_alias" = "$target_alias" \
+       && $gdb_have_gcore; then
+      HAVE_NATIVE_GCORE_TARGET=1
+    fi
   fi
 done
 
@@ -264,6 +271,7 @@
 fi
 
 AC_SUBST(TARGET_OBS)
+AC_SUBST(HAVE_NATIVE_GCORE_TARGET)
 
 # For other settings, only the main target counts.
 gdb_sim=
@@ -2390,6 +2398,20 @@
 AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "UTF-8",
           [Define to be a string naming the default host character set.])
 
+# Undo the $ec_script escaping suitable for Makefile.
+transform=`echo "$program_transform_name" | sed -e 's/[\\$][\\$]/\\$/g'`
+GDB_TRANSFORM_NAME=`echo gdb | sed -e "$transform"`
+if test "x$GDB_TRANSFORM_NAME" = x; then
+  GDB_TRANSFORM_NAME=gdb
+fi
+AC_SUBST(GDB_TRANSFORM_NAME)
+GCORE_TRANSFORM_NAME=`echo gcore | sed -e "$transform"`
+if test "x$GCORE_TRANSFORM_NAME" = x; then
+  GCORE_TRANSFORM_NAME=gcore
+fi
+AC_SUBST(GCORE_TRANSFORM_NAME)
+AC_CONFIG_FILES([gcore], [chmod +x gcore])
+
 AC_OUTPUT(Makefile gdb-gdb.gdb doc/Makefile data-directory/Makefile,
 [
 case x$CONFIG_HEADERS in
--- src/gdb/configure.tgt	2013/04/10 00:47:32	1.272
+++ src/gdb/configure.tgt	2013/04/11 14:13:43	1.273
@@ -6,6 +6,7 @@
 #  gdb_sim		simulator library for target
 #  gdb_osabi		default OS ABI to use with target
 #  build_gdbserver	set to "yes" if gdbserver supports target
+#  gdb_have_gcore	set to "true"/"false" if this target can run gcore
 
 # NOTE: Every file added to a gdb_target_obs variable for any target here
 #       must also be added to either ALL_TARGET_OBS or ALL_64_TARGET_OBS
@@ -703,3 +704,14 @@
 *-*-symbianelf*)
 		gdb_osabi=GDB_OSABI_SYMBIAN ;;
 esac
+
+# Check whether this target supports gcore.
+# Such target has to call set_gdbarch_find_memory_regions.
+case " ${gdb_target_obs} " in
+  *" linux-tdep.o "*)
+    gdb_have_gcore=true
+    ;;
+  *)
+    gdb_have_gcore=false
+    ;;
+esac
--- src/gdb/config/alpha/alpha-osf3.mh	2012/01/10 16:30:44	1.10
+++ src/gdb/config/alpha/alpha-osf3.mh	2013/04/11 14:13:43	1.11
@@ -3,4 +3,5 @@
 NATDEPFILES= alpha-nat.o fork-child.o \
 	solib-osf.o procfs.o proc-api.o proc-events.o proc-flags.o \
 	proc-why.o dec-thread.o
+HAVE_NATIVE_GCORE_HOST = 1
 NAT_CLIBS= -lpthreaddebug
--- src/gdb/config/i386/fbsd.mh	2009/10/26 18:28:13	1.20
+++ src/gdb/config/i386/fbsd.mh	2013/04/11 14:13:43	1.21
@@ -3,5 +3,6 @@
 	fbsd-nat.o i386-nat.o i386bsd-nat.o i386fbsd-nat.o \
 	bsd-kvm.o
 NAT_FILE= nm-fbsd.h
+HAVE_NATIVE_GCORE_HOST = 1
 
 LOADLIBES= -lkvm
--- src/gdb/config/i386/fbsd64.mh	2012/02/09 16:06:44	1.13
+++ src/gdb/config/i386/fbsd64.mh	2013/04/11 14:13:43	1.14
@@ -2,5 +2,6 @@
 NATDEPFILES= fork-child.o inf-ptrace.o \
 	fbsd-nat.o amd64-nat.o amd64bsd-nat.o amd64fbsd-nat.o \
 	bsd-kvm.o i386-nat.o
+HAVE_NATIVE_GCORE_HOST = 1
 
 LOADLIBES= -lkvm
--- src/gdb/config/i386/i386gnu.mh	2012/01/10 16:30:44	1.14
+++ src/gdb/config/i386/i386gnu.mh	2013/04/11 14:13:43	1.15
@@ -2,6 +2,7 @@
 NATDEPFILES= i386gnu-nat.o gnu-nat.o core-regset.o fork-child.o \
 	     notify_S.o process_reply_S.o msg_reply_S.o \
 	     msg_U.o exc_request_U.o exc_request_S.o
+HAVE_NATIVE_GCORE_HOST = 1
 
 NAT_FILE= nm-i386gnu.h
 MH_CFLAGS = -D_GNU_SOURCE
--- src/gdb/config/i386/i386sol2.mh	2010/04/26 13:53:56	1.13
+++ src/gdb/config/i386/i386sol2.mh	2013/04/11 14:13:43	1.14
@@ -1,3 +1,4 @@
 # Host: Solaris x86
 NATDEPFILES= fork-child.o i386v4-nat.o i386-sol2-nat.o \
 	procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o
+HAVE_NATIVE_GCORE_HOST = 1
--- src/gdb/config/i386/sol2-64.mh	2010/04/26 13:53:57	1.3
+++ src/gdb/config/i386/sol2-64.mh	2013/04/11 14:13:44	1.4
@@ -1,3 +1,4 @@
 # Host: Solaris x86_64
 NATDEPFILES= fork-child.o amd64-nat.o i386v4-nat.o i386-sol2-nat.o \
 	procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o
+HAVE_NATIVE_GCORE_HOST = 1
--- src/gdb/config/mips/irix5.mh	2012/01/10 16:30:45	1.6
+++ src/gdb/config/mips/irix5.mh	2013/04/11 14:13:44	1.7
@@ -1,3 +1,4 @@
 # Host: SGI Iris running irix 5.x
 NATDEPFILES= fork-child.o irix5-nat.o procfs.o \
 	proc-api.o proc-events.o proc-flags.o proc-why.o
+HAVE_NATIVE_GCORE_HOST = 1
--- src/gdb/config/mips/irix6.mh	2012/01/10 16:30:45	1.7
+++ src/gdb/config/mips/irix6.mh	2013/04/11 14:13:44	1.8
@@ -1,3 +1,4 @@
 # Host: SGI Iris running irix 6.x
 NATDEPFILES= fork-child.o irix5-nat.o procfs.o \
 	proc-api.o proc-events.o proc-flags.o proc-why.o
+HAVE_NATIVE_GCORE_HOST = 1
--- src/gdb/config/powerpc/fbsd.mh	2013/02/04 20:48:53	1.1
+++ src/gdb/config/powerpc/fbsd.mh	2013/04/11 14:13:44	1.2
@@ -18,6 +18,7 @@
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 NATDEPFILES= fbsd-nat.o fork-child.o inf-ptrace.o ppcfbsd-nat.o bsd-kvm.o
+HAVE_NATIVE_GCORE_HOST = 1
 
 LOADLIBES= -lkvm
 
--- src/gdb/config/sparc/fbsd.mh	2009/10/26 18:28:15	1.10
+++ src/gdb/config/sparc/fbsd.mh	2013/04/11 14:13:44	1.11
@@ -2,5 +2,6 @@
 NATDEPFILES= fork-child.o inf-ptrace.o \
 	fbsd-nat.o sparc-nat.o sparc64-nat.o sparc64fbsd-nat.o \
 	bsd-kvm.o
+HAVE_NATIVE_GCORE_HOST = 1
 
 LOADLIBES= -lkvm
--- src/gdb/config/sparc/sol2.mh	2012/01/10 16:30:49	1.5
+++ src/gdb/config/sparc/sol2.mh	2013/04/11 14:13:44	1.6
@@ -3,3 +3,4 @@
 NATDEPFILES= sparc-sol2-nat.o \
 	core-regset.o fork-child.o \
 	procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o
+HAVE_NATIVE_GCORE_HOST = 1
--- src/gdb/doc/Makefile.in	2013/04/07 06:20:19	1.61
+++ src/gdb/doc/Makefile.in	2013/04/11 14:13:44	1.62
@@ -177,11 +177,15 @@
 		   --release="gdb-`sed q $(srcdir)/../version.in`" --section=5
 
 # List of man pages generated from gdb.texi
-MAN1S = gdb.1 gdbserver.1
+MAN1S = gdb.1 gdbserver.1 gcore.1
 MAN5S = gdbinit.5
 MANS = $(MAN1S) $(MAN5S)
 
-#### Host, target, and site specific Makefile fragments come in here.
+# Host-dependent makefile fragment comes in here.
+@host_makefile_frag@
+# End of host-dependent makefile fragment
+HAVE_NATIVE_GCORE_TARGET = @HAVE_NATIVE_GCORE_TARGET@
+
 ###
 
 all:
@@ -269,6 +273,10 @@
 install-man1: $(MAN1S)
 	test -z "$(man1dir)" || $(mkinstalldirs) "$(DESTDIR)$(man1dir)"
 	@list='$(MAN1S)'; for p in $$list; do \
+	  if test "x$(HAVE_NATIVE_GCORE_TARGET)$(HAVE_NATIVE_GCORE_HOST)" = x \
+		  -a "$$p" = gcore.1; then \
+	    continue; \
+	  fi; \
 	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
 	  f=`echo $$p | sed -e 's|^.*/||'`; \
 	  echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(man1dir)/$$f'"; \
@@ -288,7 +296,13 @@
 
 uninstall-man1:
 	@test -n "$(man1dir)" || exit 0; \
-	files=`{ l2='$(MAN1S)'; for i in $$l2; do echo "$$i"; done | \
+	files=`{ l2='$(MAN1S)'; for i in $$l2; do \
+	  if test "x$(HAVE_NATIVE_GCORE_TARGET)$(HAVE_NATIVE_GCORE_HOST)" = x \
+		  -a "$$i" = gcore.1; then \
+	    continue; \
+	  fi; \
+	  echo "$$i"; \
+	done | \
 	  sed -n '/\.1[a-z]*$$/p'; \
 	} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
 	      -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
@@ -605,6 +619,13 @@
 		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
 	rm -f gdbserver.pod
 
+gcore.1: $(GDB_DOC_FILES)
+	touch $@
+	-$(TEXI2POD) $(MANCONF) -Dgcore < $(srcdir)/gdb.texinfo > gcore.pod
+	-($(POD2MAN1) gcore.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
+		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
+	rm -f gcore.pod
+
 gdbinit.5: $(GDB_DOC_FILES)
 	touch $@
 	-$(TEXI2POD) $(MANCONF) -Dgdbinit < $(srcdir)/gdb.texinfo > gdbinit.pod
--- src/gdb/doc/gdb.texinfo	2013/04/10 15:11:12	1.1074
+++ src/gdb/doc/gdb.texinfo	2013/04/11 14:13:44	1.1075
@@ -41652,6 +41652,7 @@
 @menu
 * gdb man::                     The GNU Debugger man page
 * gdbserver man::               Remote Server for the GNU Debugger man page
+* gcore man::                   Generate a core file of a running program
 * gdbinit man::                 gdbinit scripts
 @end menu
 
@@ -42177,6 +42178,53 @@
 @end ifset
 @c man end
 
+@node gcore man
+@heading gcore
+
+@c man title gcore Generate a core file of a running program
+
+@format
+@c man begin SYNOPSIS gcore
+gcore [-o @var{filename}] @var{pid}
+@c man end
+@end format
+
+@c man begin DESCRIPTION gcore
+Generate a core dump of a running program with process ID @var{pid}.
+Produced file is equivalent to a kernel produced core file as if the process
+crashed (and if @kbd{ulimit -c} were used to set up an appropriate core dump
+limit).  Unlike after a crash, after @command{gcore} the program remains
+running without any change.
+@c man end
+
+@c man begin OPTIONS gcore
+@table @env
+@item -o @var{filename}
+The optional argument
+@var{filename} specifies the file name where to put the core dump.
+If not specified, the file name defaults to @file{core.@var{pid}},
+where @var{pid} is the running program process ID.
+@end table
+@c man end
+
+@c man begin SEEALSO gcore
+@ifset man
+The full documentation for @value{GDBN} is maintained as a Texinfo manual.
+If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
+documentation are properly installed at your site, the command
+
+@smallexample
+info gdb
+@end smallexample
+
+@noindent
+should give you access to the complete manual.
+
+@cite{Using GDB: A Guide to the GNU Source-Level Debugger},
+Richard M. Stallman and Roland H. Pesch, July 1991.
+@end ifset
+@c man end
+
 @node gdbinit man
 @heading gdbinit
 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [commit] [patch 2/2+rfc+doc] Install gcore by default (+new man page)
  2013-04-11 22:59                 ` [commit] " Jan Kratochvil
@ 2013-04-11 23:00                   ` Pedro Alves
  0 siblings, 0 replies; 17+ messages in thread
From: Pedro Alves @ 2013-04-11 23:00 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Tom Tromey, gdb-patches

On 04/11/2013 03:29 PM, Jan Kratochvil wrote:

> I probably should not have mentioned it, I did not put too much attention to
> the branch, I also did not consider it for reviewing but rather just for
> practical testing, sorry for your time.

No worries.  Thank you for doing all this.

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: auto-generated parts in posted patches (Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page))
  2013-04-11 17:52                 ` auto-generated parts in posted patches (Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page)) Pedro Alves
@ 2013-04-12 18:16                   ` Tom Tromey
  0 siblings, 0 replies; 17+ messages in thread
From: Tom Tromey @ 2013-04-12 18:16 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Jan Kratochvil, gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Jan> Forgot to state here were always replies one should strip all
Jan> auto-generated parts from posted patches - so I do it.  But I find
Jan> that inconvenient.  It is easier to skip a part of patch when
Jan> reviewing it than to regenerate it hopefully the same way as the
Jan> patch submitter because the source tree requires special autotools
Jan> (old version + unpatched).

Pedro> I fully agree.  It's also very useful to see the generated bits
Pedro> to check whether a submitter who has commit/write access is using
Pedro> the right versions of the tools to regenerate the patches, and
Pedro> check whether the correct set of files is being regenerated.

I'm also not averse to changing this rule.

One drawback is that it would mean a different rule for gdb than for
other parts of the toolchain.  But that is already true in various ways.

I'd like it if non-trivial series were available in git somewhere.  Then
if someone really wanted to try the patch out it would be available
without re-applying.

Tom


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2013-04-12 14:48 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-08 14:15 [patch 2/2+rfc+doc] Install gcore by default (+new man page) Jan Kratochvil
2013-04-08 19:41 ` Eli Zaretskii
2013-04-09  2:10   ` Jan Kratochvil
2013-04-09  8:53     ` Tom Tromey
2013-04-09  9:01       ` Jan Kratochvil
2013-04-09 14:26         ` Jan Kratochvil
2013-04-09 18:53           ` Eli Zaretskii
2013-04-09 15:29       ` Pedro Alves
2013-04-09 19:59         ` Jan Kratochvil
2013-04-10 19:49           ` Pedro Alves
2013-04-11  2:43             ` Jan Kratochvil
2013-04-11  7:40               ` Jan Kratochvil
2013-04-11 17:52                 ` auto-generated parts in posted patches (Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page)) Pedro Alves
2013-04-12 18:16                   ` Tom Tromey
2013-04-11 17:49               ` [patch 2/2+rfc+doc] Install gcore by default (+new man page) Pedro Alves
2013-04-11 22:59                 ` [commit] " Jan Kratochvil
2013-04-11 23:00                   ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox