This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page)
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: Eli Zaretskii <eliz at gnu dot org>
- Date: Tue, 9 Apr 2013 09:15:20 +0200
- Subject: Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page)
- References: <20130407185443 dot GB15389 at host2 dot jankratochvil dot net> <83r4ilawlx dot fsf at gnu dot org> <20130408172841 dot GA28868 at host2 dot jankratochvil dot net> <87hajgua2o dot fsf at fleche dot redhat dot com> <20130408191637 dot GA2548 at host2 dot jankratochvil dot net>
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