Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin bring back gcore from the dead.
details: https://anonhg.NetBSD.org/src/rev/ee895a07a04a
branches: trunk
changeset: 542192:ee895a07a04a
user: christos <christos%NetBSD.org@localhost>
date: Thu Jan 23 17:34:49 2003 +0000
description:
bring back gcore from the dead.
diffstat:
usr.bin/Makefile | 4 +-
usr.bin/gcore/Makefile | 5 ++
usr.bin/gcore/gcore.1 | 76 +++++++++++++++++++++++++++++++++++++++
usr.bin/gcore/gcore.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 179 insertions(+), 2 deletions(-)
diffs (207 lines):
diff -r 763358e77519 -r ee895a07a04a usr.bin/Makefile
--- a/usr.bin/Makefile Thu Jan 23 16:26:46 2003 +0000
+++ b/usr.bin/Makefile Thu Jan 23 17:34:49 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.130 2003/01/22 00:16:39 jhawk Exp $
+# $NetBSD: Makefile,v 1.131 2003/01/23 17:34:49 christos Exp $
# from: @(#)Makefile 8.3 (Berkeley) 1/7/94
.include <bsd.own.mk>
@@ -9,7 +9,7 @@
column comm compress crontab crunch ctags cut \
db dirname du eject elf2aout elf2ecoff env error expand \
false fdformat fgen file find finger fmt fold fpr \
- from fsplit fstat ftp gencat getconf getopt gprof \
+ from fsplit fstat ftp gcore gencat getconf getopt gprof \
head hexdump id indent innetgr ipcrm ipcs join jot \
kdump ktrace ktruss lam last lastcomm ldd leave less \
lex locate lock logger login logname look lorder m4 \
diff -r 763358e77519 -r ee895a07a04a usr.bin/gcore/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/gcore/Makefile Thu Jan 23 17:34:49 2003 +0000
@@ -0,0 +1,5 @@
+# $NetBSD: Makefile,v 1.5 2003/01/23 17:34:50 christos Exp $
+
+PROG= gcore
+
+.include <bsd.prog.mk>
diff -r 763358e77519 -r ee895a07a04a usr.bin/gcore/gcore.1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/gcore/gcore.1 Thu Jan 23 17:34:49 2003 +0000
@@ -0,0 +1,76 @@
+.\" Copyright (c) 1983, 1990, 1992, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" @(#)gcore.1 8.2 (Berkeley) 4/18/94
+.\" $NetBSD: gcore.1,v 1.4 2003/01/23 17:34:50 christos Exp $
+.\"
+.Dd "April 18, 1994"
+.Dt GCORE 1
+.Os
+.Sh NAME
+.Nm gcore
+.Nd get core images of running process
+.Sh SYNOPSIS
+.Nm
+.Ar pid Op ...pid
+.Sh DESCRIPTION
+.Nm
+creates a core image of the specified processes
+suitable for use with
+.Xr gdb 1 .
+By default, the core is written to the file
+.Dq Pa progname.<core>
+(where
+.Dq Pa progname
+is the program name of the process corresponding to the pid that is given on
+the command line) or to what the
+.Xr sysctl 8
+.Dq Pa proc.<pid>.corename
+argument is set to.
+.Sh FILES
+.Bl -tag -width /var/log/messages -compact
+.It Pa progname.<core>
+The core image.
+.EL
+.Dp
+.Sh HISTORY
+.Nm
+appeared in BSD 4.2, dissappeared in
+.Nx 1.2 ,
+and reappeared in
+.Nx 2.0 .
+.Sh SEE ALSO
+.Xr gdb 1 ,
+.Xr sysctl 8
+.Sh BUGS
+The
+.Op Fl o Ar corename
+option is not implemented.
diff -r 763358e77519 -r ee895a07a04a usr.bin/gcore/gcore.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/gcore/gcore.c Thu Jan 23 17:34:49 2003 +0000
@@ -0,0 +1,96 @@
+/* $NetBSD: gcore.c,v 1.4 2003/01/23 17:34:50 christos Exp $ */
+
+/*-
+ * Copyright (c) 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: gcore.c,v 1.4 2003/01/23 17:34:50 christos Exp $");
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/ptrace.h>
+#include <sys/proc.h>
+
+#include <stdio.h>
+#include <err.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+
+static void usage(void) __attribute__((__noreturn__));
+
+static void
+usage(void)
+{
+ (void)fprintf(stderr, "Usage: %s <pid> [...<pid>]", getprogname());
+ exit(1);
+}
+
+
+int
+main(int argc, char **argv)
+{
+ int c;
+
+ while ((c = getopt(argc, argv, "o:")) != -1)
+ switch (c) {
+ case 'o':
+ errx(1, "-o is not supported yet.");
+ /*NOTREACHED*/
+ case '?':
+ default:
+ usage();
+ /*NOTREACHED*/
+ }
+
+ if (optind == argc)
+ usage();
+
+ for (c = optind; c < argc; c++) {
+ char *ep;
+ long lval = strtol(argv[c], &ep, 0);
+
+ if (argv[c] == '\0' || *ep)
+ errx(1, "`%s' is not a number.", argv[c]);
+ if (errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))
+ err(1, "Pid `%s'", argv[c]);
+ if (ptrace(PT_DUMPCORE, (pid_t)lval, NULL, 0) == -1)
+ err(1, "ptrace(PT_DUMPCORE) failed");
+ }
+ return 0;
+}
Home |
Main Index |
Thread Index |
Old Index