Improve the process for GNU tools
[minix3.git] / minix / usr.bin / trace / proc.h
blobf89a979914087c20ad5ba28cdeb91edc6fc6cbf2
2 #include <sys/queue.h>
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
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.
16 #define RECORD_BUFSZ 256
18 struct trace_proc {
19 /* identity (public) */
20 pid_t pid;
22 /* data structure management (proc.c) */
23 TAILQ_ENTRY(trace_proc) next;
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;
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;
40 /* output state (output.c) */
41 int recording;
42 char outbuf[RECORD_BUFSZ];
43 size_t outlen;
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];
53 /* ioctl state (ioctl.c) */
54 int ioctl_index;
55 unsigned int ioctl_flags;
57 /* sysctl state (service/mib.c) */
58 uint32_t sctl_flags;
59 size_t sctl_size;
60 int (*sctl_proc)(struct trace_proc *, const char *, int, const void *,
61 vir_bytes, size_t);
62 int sctl_arg;
65 /* Trace flags. */
66 #define TF_INCALL 0x01 /* the process has entered a system call */
67 #define TF_SKIP 0x02 /* the system call result is to be skipped */
68 #define TF_CTX_SKIP 0x04 /* skip call result only if context changes */
69 #define TF_STOPPING 0x08 /* the process is expecting a SIGSTOP */
70 #define TF_ATTACH 0x10 /* we have not started this process */
71 #define TF_DETACH 0x20 /* detach from the process as soon as we can */
72 #define TF_EXEC 0x40 /* the process may be performing an execve() */
73 #define TF_NOCALL 0x80 /* no system call seen yet (for info only) */
75 /* Trace classes, determining how the tracer engine should handle a call. */
76 #define TC_NORMAL 0 /* normal call, no exceptions required */
77 #define TC_EXEC 1 /* exec call, success on subsequent SIGSTOP */
78 #define TC_SIGRET 2 /* sigreturn call, success on context change */
80 /* Call flags. */
81 #define CF_DONE 0x01 /* printing the call parameters is done */
82 #define CF_NORETURN 0x02 /* the call does not return on success */
83 #define CF_HIDE 0x04 /* do not print the current call */
84 #define CF_IPC_ERR 0x08 /* a failure occurred at the IPC level */
85 #define CF_REG_ERR 0x10 /* unable to retrieve the result register */
86 #define CF_MSG_ERR 0x20 /* unable to copy in the reply message */
88 /* Call types, determining how much has been printed up to the call split. */
89 #define CT_NOTDONE (0) /* not all parameters have been printed yet */
90 #define CT_DONE (CF_DONE) /* all parameters have been printed */
91 #define CT_NORETURN (CF_DONE | CF_NORETURN) /* the no-return call type */
93 /* Put flags. */
94 #define PF_FAILED 0x01 /* call failed, results may be invalid */
95 #define PF_LOCADDR 0x02 /* pointer is into local address space */
96 /* Yes, PF_LOCAL would conflict with the packet family definition. Bah. */
97 #define PF_ALT 0x04 /* alternative output (callee specific) */
98 #define PF_STRING PF_ALT /* buffer is string (put_buf only) */
99 #define PF_FULL 0x08 /* print full format (callee specific) */
100 #define PF_PATH (PF_STRING | PF_FULL) /* flags for path names */
101 #define PF_NONAME 0x10 /* default to no field names at this depth */
103 /* I/O control flags. */
104 #define IF_OUT 0x1 /* call to print outgoing (written) data */
105 #define IF_IN 0x2 /* call to print incoming (read) data */
106 #define IF_ALL 0x4 /* all fields printed (not really a bit) */
108 /* Sysctl processing types, determining what the callback function is to do. */
109 #define ST_NAME 0 /* print the rest of the name */
110 #define ST_OLDP 1 /* print the data pointed to by oldp */
111 #define ST_NEWP 2 /* print the data pointed to by newp */