Teach kdump(8) to handle events marked with KTR_DROP. If a record has

KTR_DROP set in its header, then we output an extra line to stdout to
indicate that events were dropped between the previous record and this
record.  It is a bit trickier because we need to always notify the user
if events are dropped even if KTR_DROP is set on a record of a type that
we aren't interested in since kdump(8) doesn't know if the dropped events
were of the types that the user has requested.  To avoid outputting
multiple events dropped notices in between actual event logs, a state
variable is set whenever a drop is logged and cleared whenever an actual
record is output.

Requested by:	phk
This commit is contained in:
John Baldwin 2003-03-13 18:46:35 +00:00
parent 36aca8d5b7
commit db53f66b42

View File

@ -90,6 +90,7 @@ main(int argc, char *argv[])
int ch, ktrlen, size;
void *m;
int trpoints = ALL_POINTS;
int drop_logged;
(void) setlocale(LC_CTYPE, "");
@ -133,7 +134,17 @@ main(int argc, char *argv[])
errx(1, "%s", strerror(ENOMEM));
if (!freopen(tracefile, "r", stdin))
err(1, "%s", tracefile);
drop_logged = 0;
while (fread_tail(&ktr_header, sizeof(struct ktr_header), 1)) {
if (ktr_header.ktr_type & KTR_DROP) {
ktr_header.ktr_type &= ~KTR_DROP;
if (!drop_logged) {
(void)printf("%6d %-8.*s Events dropped.\n",
ktr_header.ktr_pid, MAXCOMLEN,
ktr_header.ktr_comm);
drop_logged = 1;
}
}
if (trpoints & (1<<ktr_header.ktr_type))
dumpheader(&ktr_header);
if ((ktrlen = ktr_header.ktr_len) < 0)
@ -148,6 +159,7 @@ main(int argc, char *argv[])
errx(1, "data too short");
if ((trpoints & (1<<ktr_header.ktr_type)) == 0)
continue;
drop_logged = 0;
switch (ktr_header.ktr_type) {
case KTR_SYSCALL:
ktrsyscall((struct ktr_syscall *)m);