Subject: Re: lwp id in ktrace
To: Emmanuel Dreyfus <manu@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-kern
Date: 12/01/2003 12:30:32
On Dec 1,  3:52pm, manu@netbsd.org (Emmanuel Dreyfus) wrote:
-- Subject: Re: lwp id in ktrace

| What's wrong with shortening the name string so that we get enough extra
| bytes to point to a xheader record? Having the old binary displaying
| shorter names is better than having it displaying nothing...

That is a cute idea. Do we really need the backwards compatibility though,
at the expense of making the file a lot larger? There is of course the
following hack that gives backwards compatibility and lwpid if < 64K:


struct ktr_header {
	int	ktr_len;		/* length of buf */
#if _BYTE_ORDER == _LITTLE_ENDIAN
	u_short	ktr_lwpid;		/* lwp id */
#endif
	u_short	ktr_type;		/* trace record type */
#if _BYTE_ORDER == _BIG_ENDIAN
	u_short	ktr_lwpid;		/* lwp id */
#endif
	pid_t	ktr_pid;		/* process id */
	char	ktr_comm[MAXCOMLEN+1];	/* command name */
	struct	timeval ktr_time;	/* timestamp */
	void   *ktr_buf;
};

Which is not that ugly, retains backwards compatibility and works unless
you have more than 64K of lwps.

christos