1 2 #include <sys/queue.h> 3 4 /* 5 * The maximum nesting depth of parentheses/brackets. The current maximum 6 * depth is something like six, for UDS control messages. This constant can be 7 * increased as necessary without any problem. 8 */ 9 #define MAX_DEPTH 10 10 11 /* 12 * The maximum size of text that may be recorded, including null terminator. 13 * Increasing this allows longer lines to be recorded and replayed without 14 * being cut short (see call_replay), but also increases memory usage. 15 */ 16 #define RECORD_BUFSZ 256 17 18 struct trace_proc { 19 /* identity (public) */ 20 pid_t pid; 21 22 /* data structure management (proc.c) */ 23 TAILQ_ENTRY(trace_proc) next; 24 25 /* general process state (trace.c) */ 26 char name[PROC_NAME_LEN]; 27 unsigned int trace_flags; 28 reg_t last_pc; 29 reg_t last_sp; 30 31 /* call enter-to-leave state (call.c) */ 32 int call_type; 33 vir_bytes m_addr; 34 message m_out; 35 const char *call_name; 36 unsigned int call_flags; 37 const struct call_handler *call_handler; 38 int call_result; 39 40 /* output state (output.c) */ 41 int recording; 42 char outbuf[RECORD_BUFSZ]; 43 size_t outlen; 44 45 /* formatting state (format.c) */ 46 const char *next_sep; 47 int depth; 48 struct { 49 const char *sep; 50 int name; 51 } depths[MAX_DEPTH]; 52 53 /* ioctl state (ioctl.c) */ 54 int ioctl_index; 55 unsigned int ioctl_flags; 56 }; 57 58 /* Trace flags. */ 59 #define TF_INCALL 0x01 /* the process has entered a system call */ 60 #define TF_SKIP 0x02 /* the system call result is to be skipped */ 61 #define TF_CTX_SKIP 0x04 /* skip call result only if context changes */ 62 #define TF_STOPPING 0x08 /* the process is expecting a SIGSTOP */ 63 #define TF_ATTACH 0x10 /* we have not started this process */ 64 #define TF_DETACH 0x20 /* detach from the process as soon as we can */ 65 #define TF_EXEC 0x40 /* the process may be performing an execve() */ 66 #define TF_NOCALL 0x80 /* no system call seen yet (for info only) */ 67 68 /* Trace classes, determining how the tracer engine should handle a call. */ 69 #define TC_NORMAL 0 /* normal call, no exceptions required */ 70 #define TC_EXEC 1 /* exec call, success on subsequent SIGSTOP */ 71 #define TC_SIGRET 2 /* sigreturn call, success on context change */ 72 73 /* Call flags. */ 74 #define CF_DONE 0x01 /* printing the call parameters is done */ 75 #define CF_NORETURN 0x02 /* the call does not return on success */ 76 #define CF_HIDE 0x04 /* do not print the current call */ 77 #define CF_IPC_ERR 0x08 /* a failure occurred at the IPC level */ 78 #define CF_REG_ERR 0x10 /* unable to retrieve the result register */ 79 #define CF_MSG_ERR 0x20 /* unable to copy in the reply message */ 80 81 /* Call types, determining how much has been printed up to the call split. */ 82 #define CT_NOTDONE (0) /* not all parameters have been printed yet */ 83 #define CT_DONE (CF_DONE) /* all parameters have been printed */ 84 #define CT_NORETURN (CF_DONE | CF_NORETURN) /* the no-return call type */ 85 86 /* Put flags. */ 87 #define PF_FAILED 0x01 /* call failed, results may be invalid */ 88 #define PF_LOCADDR 0x02 /* pointer is into local address space */ 89 /* Yes, PF_LOCAL would conflict with the packet family definition. Bah. */ 90 #define PF_ALT 0x04 /* alternative output (callee specific) */ 91 #define PF_STRING PF_ALT /* buffer is string (put_buf only) */ 92 #define PF_FULL 0x08 /* print full format (callee specific) */ 93 #define PF_PATH (PF_STRING | PF_FULL) /* flags for path names */ 94 #define PF_NONAME 0x10 /* default to no field names at this depth */ 95 96 /* I/O control flags. */ 97 #define IF_OUT 0x1 /* call to print outgoing (written) data */ 98 #define IF_IN 0x2 /* call to print incoming (read) data */ 99 #define IF_ALL 0x4 /* all fields printed (not really a bit) */ 100