1 /* 2 * Copyright (c) 1988 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)ktrace.h 7.3 (Berkeley) 06/28/90 8 */ 9 10 /* 11 * operations to ktrace system call (KTROP(op)) 12 */ 13 #define KTROP_SET 0 /* set trace points */ 14 #define KTROP_CLEAR 1 /* clear trace points */ 15 #define KTROP_CLEARFILE 2 /* stop all tracing to file */ 16 #define KTROP(o) ((o)&3) /* macro to extract operation */ 17 /* 18 * flags (ORed in with operation) 19 */ 20 #define KTRFLAG_DESCEND 4 /* perform op on all children too */ 21 22 /* 23 * ktrace record header 24 */ 25 struct ktr_header { 26 int ktr_len; /* length of buf */ 27 short ktr_type; /* trace record type */ 28 pid_t ktr_pid; /* process id */ 29 char ktr_comm[MAXCOMLEN+1]; /* command name */ 30 struct timeval ktr_time; /* timestamp */ 31 caddr_t ktr_buf; 32 }; 33 34 /* 35 * Test for kernel trace point 36 */ 37 #define KTRPOINT(p, type) ((p)->p_traceflag & (1<<(type))) 38 39 /* 40 * ktrace record types 41 */ 42 43 /* 44 * KTR_SYSCALL - system call record 45 */ 46 #define KTR_SYSCALL 1 47 struct ktr_syscall { 48 short ktr_code; /* syscall number */ 49 short ktr_narg; /* number of arguments */ 50 /* 51 * followed by ktr_narg ints 52 */ 53 }; 54 55 /* 56 * KTR_SYSRET - return from system call record 57 */ 58 #define KTR_SYSRET 2 59 struct ktr_sysret { 60 short ktr_code; 61 short ktr_eosys; 62 int ktr_error; 63 int ktr_retval; 64 }; 65 66 /* 67 * KTR_NAMEI - namei record 68 */ 69 #define KTR_NAMEI 3 70 /* record contains pathname */ 71 72 /* 73 * KTR_GENIO - trace generic process i/o 74 */ 75 #define KTR_GENIO 4 76 struct ktr_genio { 77 int ktr_fd; 78 enum uio_rw ktr_rw; 79 /* 80 * followed by data successfully read/written 81 */ 82 }; 83 84 /* 85 * KTR_PSIG - trace processed signal 86 */ 87 #define KTR_PSIG 5 88 struct ktr_psig { 89 int signo; 90 sig_t action; 91 int mask; 92 int code; 93 }; 94 95 /* 96 * kernel trace points 97 */ 98 #define KTRFAC_SYSCALL (1<<KTR_SYSCALL) 99 #define KTRFAC_SYSRET (1<<KTR_SYSRET) 100 #define KTRFAC_NAMEI (1<<KTR_NAMEI) 101 #define KTRFAC_GENIO (1<<KTR_GENIO) 102 #define KTRFAC_PSIG (1<<KTR_PSIG) 103 #define KTRFAC_INHERIT 0x80000000 104