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


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

Re: [patch] gdb_gcore man/help/install [+doc]


On Mon, 25 Apr 2011 10:32:02 +0200, Andreas Schwab wrote:
> --help should exit successfully.  Also, test .. -o .. should be avoided.
> 
> case $#$1 in 0|1-h|1--help) ...

OK, thanks.

Jan


gdb/
2011-04-25  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (INSTALL_SCRIPT): New.
	(gdb.z): Rename to ...
	(.1.z): ... here and generalize it.
	(install-only): Install also gdb_gcore.sh and gdb_gcore.1.
	(uninstall): Uninstall also gcore and gcore.1.
	* gdb_gcore.1: New file.
	* gdb_gcore.sh: Support also -h and --help.  Document multiple PIDs.

--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -59,6 +59,7 @@ LN_S = @LN_S@
 INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
 
 DESTDIR =
 
@@ -991,10 +992,10 @@ check//%: force
 info install-info clean-info dvi pdf install-pdf html install-html: force
 	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
 
-gdb.z:gdb.1
-	nroff -man $(srcdir)/gdb.1 | col -b > gdb.t
-	pack gdb.t ; rm -f gdb.t
-	mv gdb.t.z gdb.z
+.1.z:
+	nroff -man $< | col -b > $@.t
+	pack $@.t ; rm -f $@.t
+	mv $@.t.z $@
 
 # Traditionally "install" depends on "all".  But it may be useful
 # not to; for example, if the user has made some trivial change to a
@@ -1019,6 +1020,20 @@ install-only: $(CONFIG_INSTALL)
 			$(DESTDIR)$(man1dir) ; \
 		$(INSTALL_DATA) $(srcdir)/gdb.1 \
 			$(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 ; \
+		$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir) ; \
+		$(INSTALL_SCRIPT) $(srcdir)/gdb_gcore.sh \
+			$(DESTDIR)$(bindir)/$$transformed_name ; \
+		$(SHELL) $(srcdir)/../mkinstalldirs \
+			$(DESTDIR)$(man1dir) ; \
+		$(INSTALL_DATA) $(srcdir)/gdb_gcore.1 \
+			$(DESTDIR)$(man1dir)/$$transformed_name.1
 	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 .PHONY: install-tui
 install-tui:
@@ -1050,6 +1065,15 @@ 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 \
+		      $(DESTDIR)$(man1dir)/$$transformed_name.1
 	@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 .PHONY: uninstall-tui
 uninstall-tui:
--- /dev/null
+++ b/gdb/gdb_gcore.1
@@ -0,0 +1,45 @@
+.\"
+.\" gcore manual page.
+.\" Copyright (c) 2011 Red Hat, 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 2, 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; see the file COPYING.  If not, write to
+.\" the Free Software Foundation, 59 Temple Place - Suite 330,
+.\" Boston, MA 02111-1307, USA.
+.\"
+.TH GCORE 1 "Apr 25 2011" "Red Hat Linux" "Linux Programmer's Manual"
+
+.SH NAME
+gcore \- generate a core file of a running program
+
+.SH SYNOPSIS
+.B gcore
+[-o \fIfilename\fR] \fIPID1\fR [\fIPID2\fR...]
+
+.SH DESCRIPTION
+.PP
+\f3gcore\f1 starts up \fBgdb\fR, attaches to the given \fIPID\fR and invokes the
+gcore command dumping the cores into files core.\fIPID1\fR, core.\fIPID2\fR
+etc.  The programs being dumped remain running unaffected, except for being
+stopped for a short time during the dump.
+
+.SH OPTIONS
+.TP
+\fB\-o\fR \fIfilename\fR
+Alternative core files base name from the default "core".
+
+.SH SEE ALSO
+gdb(1)
+
+.SH AUTHORS
+Jan Kratochvil <jan.kratochvil@redhat.com>
--- a/gdb/gdb_gcore.sh
+++ b/gdb/gdb_gcore.sh
@@ -22,11 +22,16 @@
 # 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
+case $#$1 in
+  0|1-h|1--help)
+    echo "usage:  gcore [-o filename] pid1 [pid2...]"
+    if [ "$#" -eq "0" ]
+    then
+      exit 2
+    fi
+    exit 0
+    ;;
+esac
 
 # Need to check for -o option, but set default basename to "core".
 name=core


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