From a53014fba63a9a2ba6b8eec65b3ad468dcfbc148 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sun, 1 Mar 2015 17:01:22 -0800 Subject: [PATCH] dmesg - Add -n dumpnr option * Add the -n option to specify a kernel core dump number, similar to how kgdb works, as a convenience so you don't have to write out the long -M and -N options. --- sbin/dmesg/dmesg.8 | 3 +++ sbin/dmesg/dmesg.c | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sbin/dmesg/dmesg.8 b/sbin/dmesg/dmesg.8 index d5208b03f6..3e4c64d731 100644 --- a/sbin/dmesg/dmesg.8 +++ b/sbin/dmesg/dmesg.8 @@ -45,6 +45,7 @@ .Op Fl f[f] .Op Fl M Ar core .Op Fl N Ar system +.Op Fl n Ar dumpnr .Sh DESCRIPTION The .Nm @@ -89,6 +90,8 @@ instead of the default .It Fl N Extract the name list from the specified system instead of the default, which is the kernel image the system has booted from. +.It Fl n Ar dumnr +Use the kernel core dump file numbered dumpnr for debugging. .El .Sh FILES .Bl -tag -width ".Pa /var/run/dmesg.boot" -compact diff --git a/sbin/dmesg/dmesg.c b/sbin/dmesg/dmesg.c index 3f7ecd8174..1b12d9cbf0 100644 --- a/sbin/dmesg/dmesg.c +++ b/sbin/dmesg/dmesg.c @@ -73,12 +73,13 @@ main(int argc, char **argv) int clear = 0; int pri = 0; int tailmode = 0; + int kno; unsigned int rindex; size_t buflen, bufpos; setlocale(LC_CTYPE, ""); memf = nlistf = NULL; - while ((ch = getopt(argc, argv, "acfM:N:")) != -1) { + while ((ch = getopt(argc, argv, "acfM:N:n:")) != -1) { switch(ch) { case 'a': all_opt++; @@ -95,6 +96,11 @@ main(int argc, char **argv) case 'N': nlistf = optarg; break; + case 'n': + kno = strtol(optarg, NULL, 0); + asprintf(&memf, "/var/crash/vmcore.%d", kno); + asprintf(&nlistf, "/var/crash/kern.%d", kno); + break; case '?': default: usage(); -- 2.41.0