1 /* 2 * Copyright (c) 1988 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 * @(#)ktrace.h 7.1 (Berkeley) 09/04/89 18 */ 19 20 /* 21 * operations to ktrace system call (op & 0x3) 22 */ 23 #define KTROP_SET 0 /* set traces */ 24 #define KTROP_CLEAR 1 /* clear traces */ 25 #define KTROP_CLEARFILE 2 /* stop all tracing to file */ 26 /* 27 * flags to OR in with operation 28 */ 29 #define KTROP_INHERITFLAG 4 /* pass to children flag */ 30 31 /* 32 * ktrace record header 33 */ 34 struct ktr_header { 35 int ktr_len; /* length of buf */ 36 short ktr_type; /* trace record type */ 37 pid_t ktr_pid; /* process id */ 38 char ktr_comm[MAXCOMLEN+1]; /* command name */ 39 struct timeval ktr_time; /* timestamp */ 40 caddr_t ktr_buf; 41 }; 42 43 /* 44 * Test for kernel trace point 45 */ 46 #define KTRPOINT(p, type) ((p)->p_traceflag & (1<<(type))) 47 48 /* 49 * ktrace record types - add new ones here 50 */ 51 52 /* 53 * KTR_SYSCALL - system call record 54 */ 55 #define KTR_SYSCALL 0x1 56 struct ktr_syscall { 57 short ktr_code; /* syscall number */ 58 short ktr_narg; /* number of arguments */ 59 /* 60 * followed by ktr_narg ints 61 */ 62 }; 63 64 /* 65 * KTR_SYSRET - return from system call record 66 */ 67 #define KTR_SYSRET 0x2 68 struct ktr_sysret { 69 short ktr_code; 70 short ktr_eosys; 71 int ktr_error; 72 int ktr_retval; 73 }; 74 75 /* 76 * KTR_NAMEI - namei record 77 */ 78 #define KTR_NAMEI 0x3 79 /* record contains pathname */ 80 81 /* 82 * KTR_GENIO - trace generic process i/o 83 */ 84 #define KTR_GENIO 0x4 85 struct ktr_genio { 86 int ktr_fd; 87 enum uio_rw ktr_rw; 88 /* 89 * followed by data successfully read/written 90 */ 91 }; 92 93 /* 94 * kernel trace facilities 95 */ 96 #define KTRFAC_SYSCALL (1<<KTR_SYSCALL) 97 #define KTRFAC_SYSRET (1<<KTR_SYSRET) 98 #define KTRFAC_NAMEI (1<<KTR_NAMEI) 99 #define KTRFAC_GENIO (1<<KTR_GENIO) 100