History log of /freebsd-current/usr.bin/ktrdump/ktrdump.c
Revision Date Author Comments
# 5e3934b1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.bin: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# a1b6427a 07-Jul-2023 Alfonso Gregory <gfunni234@gmail.com>

Mark usage function as __dead2 in programs where it does not return

In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/735


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# dcb724b5 30-Dec-2021 Gleb Smirnoff <glebius@FreeBSD.org>

ktrdump: properly parse %% in the format string

Discovered by: 27ca37acb7c25


# 9e5aeba5 24-Mar-2021 Dmitry Chagin <dchagin@FreeBSD.org>

Fix warning about signed comparison and drop WARNS for ktrdump(8).

Reviewed By: jhb, imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29381


# 377421df 04-Nov-2018 Mariusz Zaborski <oshogbo@FreeBSD.org>

capsicum: use a new capsicum helpers in tools

Use caph_{rights,ioctls,fcntls}_limit to simplify the code.


# 44036570 22-Oct-2018 John Baldwin <jhb@FreeBSD.org>

Add a "live" mode to ktrdump.

Support a "live" mode in ktrdump enabled via the -l flag. In this
mode, ktrdump polls the kernel's trace buffer periodically (currently
hardcoded as a 50 millisecond interval) and dumps any newly added
entries. Fancier logic for the timeout (e.g. a command line option or
some kind of backoff based on the time since the last entry) can be
added later as the need arises.

While here, fix some bugs from when this was Capsicum-ized:
- Use caph_limit_stream() for the output stream so that isatty() works
and the output can be line-buffered (especially useful for live
mode).
- Use caph_limit_stderr() to permit error messages to be displayed if
an error occurs after cap_enter().

Reviewed by: kib, 0mp (manpage)
MFC after: 2 months
Differential Revision: https://reviews.freebsd.org/D17315


# 7672a014 19-Jun-2018 Mariusz Zaborski <oshogbo@FreeBSD.org>

Convert `cap_enter() < 0 && errno != ENOSYS` to `caph_enter() < 0`.

No functional change intended.


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.


# 8e15d40d 11-Sep-2017 Mark Johnston <markj@FreeBSD.org>

Provide an error message if KTR symbols in a vmcore cannot be resolved.

libkvm does not set an error string in this case, so we were previously
failing silently.

MFC after: 1 week


# 208a8594 15-Dec-2016 Conrad Meyer <cem@FreeBSD.org>

ktrdump(8): Capsicumify

We restrict the (optional) input file and output files. It would be
nice to restrict the KVM files, but that's up to libkvm.

We wait until after kvm_nlist() is invoked to cap_enter() because
kldsym() isn't supported in the Capsicum sandbox.

Feedback from: emaste@ (earlier versions)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D7921


# 330c5443 06-Feb-2015 John Baldwin <jhb@FreeBSD.org>

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.

Requested by: np
MFC after: 2 weeks


# 3447a66d 14-Mar-2014 Neel Natu <neel@FreeBSD.org>

Don't dump entries that were modified during the time the KTR buffer was being
copied to userspace. Failing to do this would result in entries at the bottom
of the ktrdump output to be more recent than entries at the top.

With this change the timestamps are monotonically decreasing going from the
top to the bottom of the ktrdump output.


# f8c8b7ee 14-Mar-2014 Neel Natu <neel@FreeBSD.org>

Fix an issue with ktrdump(8) where it would not print all entries in the
KTR buffer.

This happens when 'i' tries to wrap around from 0 to 'entries - 1'. Since 'i'
is a signed integer the modulo operation actually returns a negative number.

Fix this by computing the next index to use "by hand" instead of relying
on the modulo operator.


# 0d52168e 17-Jan-2014 Gleb Smirnoff <glebius@FreeBSD.org>

Print the ktr(4) format line that caused a failure.

Sponsored by: Nginx, Inc.


# 28d91af3 14-Nov-2012 Jeff Roberson <jeff@FreeBSD.org>

- Implement run-time expansion of the KTR buffer via sysctl.
- Implement a function to ensure that all preempted threads have switched
back out at least once. Use this to make sure there are no stale
references to the old ktr_buf or the lock profiling buffers before
updating them.

Reviewed by: marius (sparc64 parts), attilio (earlier patch)
Sponsored by: EMC / Isilon Storage Division


# 913f53dc 30-Oct-2012 Navdeep Parhar <np@FreeBSD.org>

Catch up with r238925. ktr_entries may not be a power of 2.


# 718f2aed 25-Jan-2011 Dmitry Chagin <dchagin@FreeBSD.org>

Add -H flag to print thread id.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 612f2a05 20-Feb-2009 Xin LI <delphij@FreeBSD.org>

Remove unnecessary opt* definations.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# e5ed7bcc 12-Jan-2006 Gleb Smirnoff <glebius@FreeBSD.org>

Skip format flags, when parsing ktr_desc.


# ee574da5 09-Dec-2005 Nate Lawson <njl@FreeBSD.org>

Really fix the relative timestamp bug. It was only incorrect for the ALQ
case. It seems entries are in reverse order when read from the kernel
memory but in the right order when read from a file (i.e. ALQ). Handle
both cases.

MFC after: 1 day


# c578cf5e 06-Dec-2005 Nate Lawson <njl@FreeBSD.org>

Fix -r flag to actually work. "now" comes after "then", not vice versa.

MFC after: 1 day


# 671cff5a 05-Jun-2005 Christian S.J. Peron <csjp@FreeBSD.org>

Append a newline character to the usage string.

MFC after: 3 days


# f682f10c 21-May-2005 Ruslan Ermilov <ru@FreeBSD.org>

Sync program's usage() with manpage's SYNOPSIS.


# c7f4c395 26-Sep-2004 Julian Elischer <julian@FreeBSD.org>

Don't use an uninitialised variable when reading from a ktr alq file.


# 7d8c7fe1 22-May-2004 Robert Watson <rwatson@FreeBSD.org>

Add a "-r" flag to ktrdump(1) to print relative timestamps when used
with "-t" rather than absolute timestamps. This allows the reader
to get a better sense of latency between events, such as time to
schedule an interrupt thread from time the interrupt occurred. Assert
a copyright on ktrdump.c since I seem to be modifying it more than I
thought.


# 7ddc8937 21-May-2004 Robert Watson <rwatson@FreeBSD.org>

Add a quiet mode to ktrdump(1): if the "-q" flag is used, don't print
the pretty text header on top of the output. Simplifies feeding the
results of tracing into a script for mechanical processing.


# dd6cf019 21-May-2004 Robert Watson <rwatson@FreeBSD.org>

When the 'f' flag is passed to ktrdump(1), use 40 characters for the
"file and line" field consistently; previously, a 32-character field
length was used for the table header, which resulted in the header
not lining up with the table.


# feeb2580 15-Feb-2004 David Malone <dwmalone@FreeBSD.org>

Remove an unused variable.


# b241e69d 06-Oct-2002 Kris Kennaway <kris@FreeBSD.org>

Use strlcpy() instead of strcpy() to not overflow static buffers.


# cba1f1e0 22-Sep-2002 Jeff Roberson <jeff@FreeBSD.org>

- Add the -i option to read in a saved ktr file output by KTR_ALQ.


# d93b1f83 01-Apr-2002 Jake Burkholder <jake@FreeBSD.org>

1. Add missing include of stdint.h.
2. Fix reversed arguments to strcpy.

Noticed by: davidc (2)


# be6ba83a 31-Mar-2002 Jake Burkholder <jake@FreeBSD.org>

ktrdump is a utility to dump the ktr trace buffer from userland. It can
also be run on a core dump.