truss.h revision 192025
1101282Smdodd/*
2101282Smdodd * Copryight 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 192025 2009-05-12 20:42:12Z dds $
26101282Smdodd */
27101282Smdodd
28168569Sdelphij#include <sys/queue.h>
29168569Sdelphij
30101283Smdodd#define FOLLOWFORKS        0x00000001
31101285Smdodd#define RELATIVETIMESTAMPS 0x00000002
32101285Smdodd#define ABSOLUTETIMESTAMPS 0x00000004
33101282Smdodd#define NOSIGS             0x00000008
34101289Smdodd#define EXECVEARGS         0x00000010
35101289Smdodd#define EXECVEENVS         0x00000020
36192025Sdds#define COUNTONLY          0x00000040
37101282Smdodd
38168569Sdelphijstruct threadinfo
39168569Sdelphij{
40168569Sdelphij	SLIST_ENTRY(threadinfo) entries;
41168569Sdelphij	lwpid_t tid;
42168569Sdelphij	int in_syscall;
43168569Sdelphij	int in_fork;
44168569Sdelphij};
45168569Sdelphij
46101282Smdoddstruct trussinfo
47101282Smdodd{
48101282Smdodd	int pid;
49101282Smdodd	int flags;
50168569Sdelphij	int pr_why;
51168569Sdelphij	int pr_data;
52153963Sbrian	int strsize;
53101282Smdodd	FILE *outfile;
54101285Smdodd
55101373Smdodd	struct timespec start_time;
56101373Smdodd	struct timespec before;
57101373Smdodd	struct timespec after;
58168569Sdelphij
59168569Sdelphij	struct threadinfo *curthread;
60168569Sdelphij
61168569Sdelphij	SLIST_HEAD(, threadinfo) threadlist;
62101282Smdodd};
63158630Spav
64158630Spav#define timespecsubt(tvp, uvp, vvp)					\
65158630Spav	do {								\
66158630Spav		(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;		\
67158630Spav		(vvp)->tv_nsec = (tvp)->tv_nsec - (uvp)->tv_nsec;	\
68158630Spav		if ((vvp)->tv_nsec < 0) {				\
69158630Spav			(vvp)->tv_sec--;				\
70158630Spav			(vvp)->tv_nsec += 1000000000;			\
71158630Spav		}							\
72158630Spav	} while (0)
73168569Sdelphij
74192025Sdds#define timespecadd(tvp, uvp, vvp)					\
75192025Sdds	do {								\
76192025Sdds		(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;		\
77192025Sdds		(vvp)->tv_nsec = (tvp)->tv_nsec + (uvp)->tv_nsec;	\
78192025Sdds		if ((vvp)->tv_nsec > 1000000000) {				\
79192025Sdds			(vvp)->tv_sec++;				\
80192025Sdds			(vvp)->tv_nsec -= 1000000000;			\
81192025Sdds		}							\
82192025Sdds	} while (0)
83192025Sdds
84168569Sdelphij#define S_NONE  0
85168569Sdelphij#define S_SCE   1
86168569Sdelphij#define S_SCX   2
87168569Sdelphij#define S_EXIT  3
88168569Sdelphij#define S_SIG   4
89168569Sdelphij#define S_EXEC  5
90