git-svn-id: http://ltt.polymtl.ca/svn@289 04897980-b3bd-0310-b5e0-8ef037075253
[lttv.git] / ltt / branches / poly / include / lttv / state.h
1 #ifndef STATE_H
2 #define STATE_H
3
4 #include <glib.h>
5 #include <lttv/processTrace.h>
6
7 /* The operating system state kept during the trace analysis
8 contains a subset of the real operating system state,
9 sufficient for the analysis, and possibly organized quite differently.
10
11 The state information is added to LttvTracesetContext, LttvTraceContext
12 and LttvTracefileContext objects, used by processTrace, through
13 subtyping. The context objects already reflect the multiple tracefiles
14 (one per cpu) per trace and multiple traces per trace set. The state
15 objects defined here simply add fields to the relevant context objects. */
16
17
18 /* The LttvProcessState structure defines the current state for each process.
19 A process can make system calls (in some rare cases nested) and receive
20 interrupts/faults. For instance, a process may issue a system call,
21 generate a page fault while reading an argument from user space, and
22 get caught by an interrupt. To represent these nested states, an
23 interrupt stack is maintained. The stack bottom is normal user mode and
24 the top of stack is the current interrupt state.
25
26 The interrupt state tells about the process status, interrupt type and
27 interrupt number. All these could be defined as enumerations but may
28 need extensions (e.g. new process state). GQuark are thus used being
29 as easy to manipulate as integers but having a string associated, just
30 like enumerations. */
31
32
33 typedef struct _LttvTracesetState LttvTracesetState;
34 typedef struct _LttvTracesetStateClass LttvTracesetStateClass;
35
36 typedef struct _LttvTraceState LttvTraceState;
37 typedef struct _LttvTraceStateClass LttvTraceStateClass;
38
39 typedef struct _LttvTracefileState LttvTracefileState;
40 typedef struct _LttvTracefileStateClass LttvTracefileStateClass;
41
42 gboolean lttv_state_add_event_hooks(LttvTracesetState *self);
43
44 gboolean lttv_state_remove_event_hooks(LttvTracesetState *self);
45
46
47 /* The interrupt type is one of "user mode", "kernel thread", "system call",
48 "interrupt request", "fault". */
49
50 typedef GQuark LttvInterruptType;
51
52 extern LttvInterruptType
53 LTTV_STATE_USER_MODE,
54 LTTV_STATE_SYSCALL,
55 LTTV_STATE_TRAP,
56 LTTV_STATE_IRQ;
57
58
59 /* The interrupt number depends on the interrupt type. For user mode or kernel
60 thread, which are the normal mode (interrupt stack bottom), it is set to
61 "none". For interrupt requests, faults and system calls, it is set
62 respectively to the interrupt name (e.g. "timer"), fault name
63 (e.g. "page fault"), and system call name (e.g. "select"). */
64
65 typedef GQuark LttvInterruptNumber;
66
67
68 /* The process status is one of "running", "wait-cpu" (runnable), or "wait-*"
69 where "*" describes the resource waited for (e.g. timer, process,
70 disk...). */
71
72 typedef GQuark LttvProcessStatus;
73
74 extern LttvProcessStatus
75 LTTV_STATE_UNNAMED,
76 LTTV_STATE_WAIT_FORK,
77 LTTV_STATE_WAIT_CPU,
78 LTTV_STATE_EXIT,
79 LTTV_STATE_WAIT,
80 LTTV_STATE_RUN;
81
82
83 typedef struct _LttvInterruptState {
84 LttvInterruptType t;
85 LttvInterruptNumber n;
86 LttTime entry;
87 LttTime last_change;
88 LttvProcessStatus s;
89 } LttvInterruptState;
90
91
92 typedef struct _LttvProcessState {
93 guint pid;
94 guint ppid;
95 LttTime birth;
96 GQuark name;
97 GArray *interrupt_stack; /* Array of LttvInterruptState */
98 LttvInterruptState *state; /* Top of interrupt stack */
99 /* opened file descriptors, address map... */
100 } LttvProcessState;
101
102
103 /* The LttvTracesetState, LttvTraceState and LttvTracefileState types
104 inherit from the corresponding Context objects defined in processTrace. */
105
106 #define LTTV_TRACESET_STATE_TYPE (lttv_traceset_state_get_type ())
107 #define LTTV_TRACESET_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACESET_STATE_TYPE, LttvTracesetState))
108 #define LTTV_TRACESET_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACESET_STATE_TYPE, LttvTracesetStateClass))
109 #define LTTV_IS_TRACESET_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACESET_STATE_TYPE))
110 #define LTTV_IS_TRACESET_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACESET_STATE_TYPE))
111 #define LTTV_TRACESET_STATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACESET_STATE_TYPE, LttvTracesetStateClass))
112
113 struct _LttvTracesetState {
114 LttvTracesetContext parent;
115 };
116
117 struct _LttvTracesetStateClass {
118 LttvTracesetContextClass parent;
119 };
120
121 GType lttv_traceset_state_get_type (void);
122
123
124 #define LTTV_TRACE_STATE_TYPE (lttv_trace_state_get_type ())
125 #define LTTV_TRACE_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACE_STATE_TYPE, LttvTraceState))
126 #define LTTV_TRACE_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACE_STATE_TYPE, LttvTraceStateClass))
127 #define LTTV_IS_TRACE_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACE_STATE_TYPE))
128 #define LTTV_IS_TRACE_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACE_STATE_TYPE))
129 #define LTTV_TRACE_STATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACE_STATE_TYPE, LttvTraceStateClass))
130
131 struct _LttvTraceState {
132 LttvTraceContext parent;
133
134 GHashTable *processes; /* LttvProcessState objects indexed by pid */
135 /* Block/char devices, locks, memory pages... */
136 };
137
138 struct _LttvTraceStateClass {
139 LttvTraceContextClass parent;
140 };
141
142 GType lttv_trace_state_get_type (void);
143
144
145 #define LTTV_TRACEFILE_STATE_TYPE (lttv_tracefile_state_get_type ())
146 #define LTTV_TRACEFILE_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACEFILE_STATE_TYPE, LttvTracefileState))
147 #define LTTV_TRACEFILE_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACEFILE_STATE_TYPE, LttvTracefileStateClass))
148 #define LTTV_IS_TRACEFILE_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACEFILE_STATE_TYPE))
149 #define LTTV_IS_TRACEFILE_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACEFILE_STATE_TYPE))
150 #define LTTV_TRACEFILE_STATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACEFILE_STATE_TYPE, LttvTracefileStateClass))
151
152 struct _LttvTracefileState {
153 LttvTracefileContext parent;
154
155 LttvProcessState *process;
156 };
157
158 struct _LttvTracefileStateClass {
159 LttvTracefileContextClass parent;
160 };
161
162 GType lttv_tracefile_state_get_type (void);
163
164
165 #endif // PROCESSTRACE_H
This page took 0.032891 seconds and 5 git commands to generate.