Subject: ktrace and lwp's
To: None <tech-kern@netbsd.org>
From: Darren Reed <darrenr@reed.wattle.id.au>
List: tech-kern
Date: 03/05/2003 15:31:09
I don't know if anyone else has looked at this yet but it's bothered
me at least once since upgrading to SA...maybe there's a lot of work
here that I'm seriously underestimating O:)

First task is to pass 'struct lwp *' around in more places than is
currently done (replace nearly all internal passing of 'struct proc* ?)

Then, when the lwp is being passed to the ktrace routines there are
two paths forward.  The first is relatively easy but is a hack:

- put lwp# in ktr_buf, ignored by current kdump/ktrace/ktruss and make
  new versions report it.

The other option requires more work:

<sys/ktrace.h>
- add a new ktrace message type - KTR_VERSION, length is just that for
  ktr_header.  Put version number in ktr_buf ?
- add a ktr_lwp field (int) to new format ktr_header

ktrace(2)
- add KTROP_ORIGINAL to indicate original format to be used;

kernel:
- for new-format ktrace dumps, emit KTR_VERSION message at start
  (old-format does not have this)

kdump:
- files starting with KTR_VERSION use that for the basis of the format
  for the rest of the file.
- files that do not start with KTR_VERSION are considered to be old
  format ktrace output files

ktrace/ktruss:
- add -O command line option that passes KTROP_ORIGINAL to ktrace(2)
  to indicate old format ktrace data to be generated

Long term aim:
- kdump/ktruss to be able to correctly read any ktrace file in a
  backaward compatible scenario;
- kernel only supports original format (what we currently have)
  and whatever it considers to be the "current" format