Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/truss/truss.h
Show All 19 Lines | |||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
* | * | ||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#include <sys/linker_set.h> | |||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#define FOLLOWFORKS 0x00000001 | #define FOLLOWFORKS 0x00000001 | ||||
#define RELATIVETIMESTAMPS 0x00000002 | #define RELATIVETIMESTAMPS 0x00000002 | ||||
#define ABSOLUTETIMESTAMPS 0x00000004 | #define ABSOLUTETIMESTAMPS 0x00000004 | ||||
#define NOSIGS 0x00000008 | #define NOSIGS 0x00000008 | ||||
#define EXECVEARGS 0x00000010 | #define EXECVEARGS 0x00000010 | ||||
#define EXECVEENVS 0x00000020 | #define EXECVEENVS 0x00000020 | ||||
#define COUNTONLY 0x00000040 | #define COUNTONLY 0x00000040 | ||||
struct procinfo; | |||||
struct trussinfo; | |||||
struct procabi { | |||||
const char *type; | |||||
const char **syscallnames; | |||||
int nsyscalls; | |||||
int (*fetch_args)(struct trussinfo *); | |||||
int (*fetch_retval)(struct trussinfo *, long *, int *); | |||||
}; | |||||
#define PROCABI(abi) DATA_SET(procabi, abi) | |||||
/* | |||||
* This is confusingly named. It holds per-thread state about the | |||||
* currently executing system call. syscalls.h defines a struct | |||||
* syscall that holds metadata used to format system call arguments. | |||||
*/ | |||||
struct current_syscall { | |||||
struct syscall *sc; | |||||
const char *name; | |||||
int number; | |||||
unsigned long *args; | |||||
int nargs; | |||||
char **s_args; /* the printable arguments */ | |||||
}; | |||||
struct threadinfo | struct threadinfo | ||||
{ | { | ||||
SLIST_ENTRY(threadinfo) entries; | SLIST_ENTRY(threadinfo) entries; | ||||
struct procinfo *proc; | |||||
lwpid_t tid; | lwpid_t tid; | ||||
int in_syscall; | int in_syscall; | ||||
int in_fork; | struct current_syscall cs; | ||||
void *fsc; | |||||
struct timespec before; | struct timespec before; | ||||
struct timespec after; | struct timespec after; | ||||
}; | }; | ||||
struct procinfo { | |||||
LIST_ENTRY(procinfo) entries; | |||||
pid_t pid; | |||||
struct procabi *abi; | |||||
SLIST_HEAD(, threadinfo) threadlist; | |||||
}; | |||||
struct trussinfo | struct trussinfo | ||||
{ | { | ||||
pid_t pid; | |||||
int flags; | int flags; | ||||
int pr_why; | |||||
int pr_data; | |||||
int strsize; | int strsize; | ||||
FILE *outfile; | FILE *outfile; | ||||
struct timespec start_time; | struct timespec start_time; | ||||
struct threadinfo *curthread; | struct threadinfo *curthread; | ||||
SLIST_HEAD(, threadinfo) threadlist; | LIST_HEAD(, procinfo) proclist; | ||||
}; | }; | ||||
#define timespecsubt(tvp, uvp, vvp) \ | #define timespecsubt(tvp, uvp, vvp) \ | ||||
do { \ | do { \ | ||||
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ | (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ | ||||
(vvp)->tv_nsec = (tvp)->tv_nsec - (uvp)->tv_nsec; \ | (vvp)->tv_nsec = (tvp)->tv_nsec - (uvp)->tv_nsec; \ | ||||
if ((vvp)->tv_nsec < 0) { \ | if ((vvp)->tv_nsec < 0) { \ | ||||
(vvp)->tv_sec--; \ | (vvp)->tv_sec--; \ | ||||
(vvp)->tv_nsec += 1000000000; \ | (vvp)->tv_nsec += 1000000000; \ | ||||
} \ | } \ | ||||
} while (0) | } while (0) | ||||
#define timespecadd(tvp, uvp, vvp) \ | #define timespecadd(tvp, uvp, vvp) \ | ||||
do { \ | do { \ | ||||
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ | (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ | ||||
(vvp)->tv_nsec = (tvp)->tv_nsec + (uvp)->tv_nsec; \ | (vvp)->tv_nsec = (tvp)->tv_nsec + (uvp)->tv_nsec; \ | ||||
if ((vvp)->tv_nsec > 1000000000) { \ | if ((vvp)->tv_nsec > 1000000000) { \ | ||||
(vvp)->tv_sec++; \ | (vvp)->tv_sec++; \ | ||||
(vvp)->tv_nsec -= 1000000000; \ | (vvp)->tv_nsec -= 1000000000; \ | ||||
} \ | } \ | ||||
} while (0) | } while (0) | ||||
#define S_NONE 0 | |||||
#define S_SCE 1 | |||||
#define S_SCX 2 | |||||
#define S_EXIT 3 | |||||
#define S_SIG 4 | |||||
#define S_EXEC 5 | |||||
#define S_DETACHED 6 |