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