1#ifndef DEFS_H 2#define DEFS_H 3 4#define MAX_PIDS 64 5#define TOTAL_PIDS 3000 6 7enum top { 8 TOP_Open = 0, 9 TOP_Create = 1, 10 TOP_Unlink = 2, 11 TOP_Read = 3, 12 TOP_Write = 4, 13 TOP_Close = 5, 14 TOP_Exit = 6, 15 TOP_Seek = 7, 16 TOPs_Total, 17}; 18 19static char __attribute__((unused)) *top2str[] = { 20 [TOP_Open ] = "open", 21 [TOP_Create] = "create", 22 [TOP_Unlink] = "unlink", 23 [TOP_Read ] = "read", 24 [TOP_Write ] = "write", 25 [TOP_Close ] = "close", 26 [TOP_Exit ] = "exit", 27 [TOP_Seek ] = "seek", 28 [TOPs_Total] = "___YOU_SHOULD_NOT_SEE_THIS___" 29}; 30 31enum flags { 32 FLAGS_RdOnly, 33 FLAGS_WrOnly, 34 FLAGS_RdWr, 35}; 36 37typedef struct { 38 uint32_t fnumsize; /* for Open/Create/Unlink -> fnum, for Read/Write/Seek -> offset */ 39 uint16_t pid; 40 uint8_t op; 41 uint8_t fd; 42 uint8_t mode; 43 /* uint32 fline; */ 44} replay_eventrec_t; 45 46struct trace_entry { 47 enum top op; 48 union { 49 size_t fnum; 50 size_t size; 51 } u; 52 int fd; 53 enum flags mode; 54 int pid; 55 int fline; 56 57 struct trace_entry *next; 58}; 59 60#if 0 //__linux__ 61struct _replay_eventrec__struct { 62 uint8_t op; 63 uint32_t fnumsize; 64 uint8_t fd; 65 uint8_t mode; 66 uint32_t fline; 67 uint16_t pid; 68}; 69typedef struct _replay_eventrec__struct replay_eventrec_t; 70#endif 71 72#define dbg_print_str__ ">>>>>>>>>>>>>> %s() [%s +%d]" 73#define dbg_print_arg__ __FUNCTION__, __FILE__, __LINE__ 74#define dbg_print(msg ,fmt, args...)\ 75 printf(dbg_print_str__ " " msg fmt , dbg_print_arg__ , ##args) 76 77//#define XDEBUG 78#define msg(fmt,args...) dbg_print("msg:",fmt, ##args) 79#ifdef XDEBUG 80 #define dmsg(fmt,args...) dbg_print("dbg:",fmt, ##args) 81#else 82 #define dmsg(fmt,args...) do { } while (0) 83#endif 84 85 86#endif 87