truss.h revision 247338
1101282Smdodd/*
2204977Simp * Copyright 2001 Jamey Wood
3101282Smdodd *
4101282Smdodd * Redistribution and use in source and binary forms, with or without
5101282Smdodd * modification, are permitted provided that the following conditions
6101282Smdodd * are met:
7101282Smdodd * 1. Redistributions of source code must retain the above copyright
8101282Smdodd *    notice, this list of conditions and the following disclaimer.
9101282Smdodd * 2. Redistributions in binary form must reproduce the above copyright
10101282Smdodd *    notice, this list of conditions and the following disclaimer in the
11101282Smdodd *    documentation and/or other materials provided with the distribution.
12101282Smdodd *
13101282Smdodd * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14101282Smdodd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15101282Smdodd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16101282Smdodd * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17101282Smdodd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18101282Smdodd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19101282Smdodd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20101282Smdodd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21101282Smdodd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22101282Smdodd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23101282Smdodd * SUCH DAMAGE.
24101282Smdodd *
25101282Smdodd * $FreeBSD: head/usr.bin/truss/truss.h 247338 2013-02-26 19:46:59Z delphij $
26101282Smdodd */
27101282Smdodd
28168569Sdelphij#include <sys/queue.h>
29168569Sdelphij
30240005Szont#define	FOLLOWFORKS		0x00000001
31240005Szont#define	RELATIVETIMESTAMPS	0x00000002
32240005Szont#define	ABSOLUTETIMESTAMPS	0x00000004
33240005Szont#define	NOSIGS			0x00000008
34240005Szont#define	EXECVEARGS		0x00000010
35240005Szont#define	EXECVEENVS		0x00000020
36240005Szont#define	COUNTONLY		0x00000040
37101282Smdodd
38168569Sdelphijstruct threadinfo
39168569Sdelphij{
40168569Sdelphij	SLIST_ENTRY(threadinfo) entries;
41168569Sdelphij	lwpid_t tid;
42168569Sdelphij	int in_syscall;
43168569Sdelphij	int in_fork;
44240562Szont	void *fsc;
45240562Szont	struct timespec before;
46240562Szont	struct timespec after;
47168569Sdelphij};
48168569Sdelphij
49101282Smdoddstruct trussinfo
50101282Smdodd{
51239501Szont	pid_t pid;
52101282Smdodd	int flags;
53168569Sdelphij	int pr_why;
54168569Sdelphij	int pr_data;
55153963Sbrian	int strsize;
56101282Smdodd	FILE *outfile;
57101285Smdodd
58101373Smdodd	struct timespec start_time;
59168569Sdelphij
60168569Sdelphij	struct threadinfo *curthread;
61240005Szont
62168569Sdelphij	SLIST_HEAD(, threadinfo) threadlist;
63101282Smdodd};
64158630Spav
65247338Sdelphij#define	timespecsubt(tvp, uvp, vvp)					\
66158630Spav	do {								\
67158630Spav		(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;		\
68158630Spav		(vvp)->tv_nsec = (tvp)->tv_nsec - (uvp)->tv_nsec;	\
69158630Spav		if ((vvp)->tv_nsec < 0) {				\
70158630Spav			(vvp)->tv_sec--;				\
71158630Spav			(vvp)->tv_nsec += 1000000000;			\
72158630Spav		}							\
73158630Spav	} while (0)
74168569Sdelphij
75247338Sdelphij#define	timespecadd(tvp, uvp, vvp)					\
76192025Sdds	do {								\
77192025Sdds		(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;		\
78192025Sdds		(vvp)->tv_nsec = (tvp)->tv_nsec + (uvp)->tv_nsec;	\
79192025Sdds		if ((vvp)->tv_nsec > 1000000000) {				\
80192025Sdds			(vvp)->tv_sec++;				\
81192025Sdds			(vvp)->tv_nsec -= 1000000000;			\
82192025Sdds		}							\
83192025Sdds	} while (0)
84192025Sdds
85240005Szont#define	S_NONE	0
86240005Szont#define	S_SCE	1
87240005Szont#define	S_SCX	2
88240005Szont#define	S_EXIT	3
89240005Szont#define	S_SIG	4
90240005Szont#define	S_EXEC	5
91240393Szont#define	S_DETACHED	6
92