From 594563c1c05b08979be0352ae42b0217d2fb48d9 Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 19 Mar 2015 13:08:17 +0000 Subject: [PATCH] MFC 278327: Change ktrdump to use the more standard -M/-N flags to specify the path to a crash dump and kernel, respectively. The existing -m/-e flags are still supported for backwards compatiblity but are no longer documented. git-svn-id: svn://svn.freebsd.org/base/stable/9@280255 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- usr.bin/ktrdump/ktrdump.8 | 12 ++++++------ usr.bin/ktrdump/ktrdump.c | 18 ++++++++++-------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/usr.bin/ktrdump/ktrdump.8 b/usr.bin/ktrdump/ktrdump.8 index 9a77bfc3c..f725a7683 100644 --- a/usr.bin/ktrdump/ktrdump.8 +++ b/usr.bin/ktrdump/ktrdump.8 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 8, 2005 +.Dd February 6, 2015 .Dt KTRDUMP 8 .Os .Sh NAME @@ -34,9 +34,9 @@ .Sh SYNOPSIS .Nm .Op Fl cfqrtH -.Op Fl e Ar execfile .Op Fl i Ar ktrfile -.Op Fl m Ar corefile +.Op Fl M Ar core +.Op Fl N Ar system .Op Fl o Ar outfile .Sh DESCRIPTION The @@ -44,7 +44,7 @@ The utility is used to dump the contents of the kernel ktr trace buffer. .Pp The following options are available: -.Bl -tag -width ".Fl e Ar execfile" +.Bl -tag -width ".Fl i Ar ktrfile" .It Fl c Print the CPU number that each entry was logged from. .It Fl f @@ -61,11 +61,11 @@ Print the thread ID for each entry. File containing saved ktr trace events; for more information see the .Xr ktr 4 manual page. -.It Fl e Ar execfile +.It Fl N Ar system The kernel image to resolve symbols from. The default is the value returned via .Xr getbootfile 3 . -.It Fl m Ar corefile +.It Fl M Ar core The core file or memory image to read from. The default is .Pa /dev/mem . diff --git a/usr.bin/ktrdump/ktrdump.c b/usr.bin/ktrdump/ktrdump.c index d74b97916..9663e65eb 100644 --- a/usr.bin/ktrdump/ktrdump.c +++ b/usr.bin/ktrdump/ktrdump.c @@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$"); #define SBUFLEN 128 #define USAGE \ - "usage: ktrdump [-cfqrtH] [-e execfile] [-i ktrfile] [-m corefile] [-o outfile]\n" + "usage: ktrdump [-cfqrtH] [-i ktrfile] [-M core] [-N system] [-o outfile]\n" static void usage(void); @@ -59,9 +59,9 @@ static struct nlist nl[] = { }; static int cflag; -static int eflag; static int fflag; -static int mflag; +static int Mflag; +static int Nflag; static int qflag; static int rflag; static int tflag; @@ -102,16 +102,17 @@ main(int ac, char **av) * Parse commandline arguments. */ out = stdout; - while ((c = getopt(ac, av, "cfqrtHe:i:m:o:")) != -1) + while ((c = getopt(ac, av, "cfqrtHe:i:m:M:N:o:")) != -1) switch (c) { case 'c': cflag = 1; break; + case 'N': case 'e': if (strlcpy(execfile, optarg, sizeof(execfile)) >= sizeof(execfile)) errx(1, "%s: File name too long", optarg); - eflag = 1; + Nflag = 1; break; case 'f': fflag = 1; @@ -121,11 +122,12 @@ main(int ac, char **av) if ((in = open(optarg, O_RDONLY)) == -1) err(1, "%s", optarg); break; + case 'M': case 'm': if (strlcpy(corefile, optarg, sizeof(corefile)) >= sizeof(corefile)) errx(1, "%s: File name too long", optarg); - mflag = 1; + Mflag = 1; break; case 'o': if ((out = fopen(optarg, "w")) == NULL) @@ -156,8 +158,8 @@ main(int ac, char **av) * Open our execfile and corefile, resolve needed symbols and read in * the trace buffer. */ - if ((kd = kvm_openfiles(eflag ? execfile : NULL, - mflag ? corefile : NULL, NULL, O_RDONLY, errbuf)) == NULL) + if ((kd = kvm_openfiles(Nflag ? execfile : NULL, + Mflag ? corefile : NULL, NULL, O_RDONLY, errbuf)) == NULL) errx(1, "%s", errbuf); if (kvm_nlist(kd, nl) != 0 || kvm_read(kd, nl[0].n_value, &version, sizeof(version)) == -1) -- 2.45.0