From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Pedro Alves <palves@redhat.com>
Cc: Tom Tromey <tromey@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [patch 2/2+rfc+doc] Install gcore by default (+new man page)
Date: Tue, 09 Apr 2013 19:59:00 -0000 [thread overview]
Message-ID: <20130409165525.GA29570@host2.jankratochvil.net> (raw)
In-Reply-To: <516424FE.4050307@redhat.com>
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
next prev parent reply other threads:[~2013-04-09 16:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-08 14:15 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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130409165525.GA29570@host2.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox