Compilation errors are done. Some makefile.am fixes are required for linking
[lttv.git] / ltt / branches / poly / include / lttv / state.h
CommitLineData
dc877563 1#ifndef STATE_H
2#define STATE_H
3
ffd54a90 4#include <glib.h>
dc877563 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
ffd54a90 11 The state information is added to LttvTracesetContext, LttvTraceContext
dc877563 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
ffd54a90 33typedef struct _LttvTracesetState LttvTracesetState;
34typedef struct _LttvTracesetStateClass LttvTracesetStateClass;
35
36typedef struct _LttvTraceState LttvTraceState;
37typedef struct _LttvTraceStateClass LttvTraceStateClass;
38
39typedef struct _LttvTracefileState LttvTracefileState;
40typedef struct _LttvTracefileStateClass LttvTracefileStateClass;
41
996acd92 42gboolean lttv_state_add_event_hooks(LttvTracesetState *self);
dc877563 43
996acd92 44gboolean lttv_state_remove_event_hooks(LttvTracesetState *self);
dc877563 45
46
47/* The interrupt type is one of "user mode", "kernel thread", "system call",
48 "interrupt request", "fault". */
49
50typedef GQuark LttvInterruptType;
51
ffd54a90 52extern LttvInterruptType
53 LTTV_STATE_USER_MODE,
54 LTTV_STATE_SYSCALL,
55 LTTV_STATE_TRAP,
56 LTTV_STATE_IRQ;
57
dc877563 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
996acd92 63 (e.g. "page fault"), and system call name (e.g. "select"). */
dc877563 64
65typedef 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
72typedef GQuark LttvProcessStatus;
73
ffd54a90 74extern 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;
dc877563 81
ffd54a90 82
83typedef struct _LttvInterruptState {
dc877563 84 LttvInterruptType t;
85 LttvInterruptNumber n;
ba576a78 86 LttTime entry;
87 LttTime last_change;
dc877563 88 LttvProcessStatus s;
89} LttvInterruptState;
90
91
92typedef struct _LttvProcessState {
93 guint pid;
ba576a78 94 LttTime birth;
dc877563 95 GQuark name;
96 GArray *interrupt_stack; /* Array of LttvInterruptState */
97 LttvInterruptState *state; /* Top of interrupt stack */
98 /* opened file descriptors, address map... */
99} LttvProcessState;
100
101
ffd54a90 102/* The LttvTracesetState, LttvTraceState and LttvTracefileState types
dc877563 103 inherit from the corresponding Context objects defined in processTrace. */
104
105#define LTTV_TRACESET_STATE_TYPE (lttv_traceset_state_get_type ())
ffd54a90 106#define LTTV_TRACESET_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACESET_STATE_TYPE, LttvTracesetState))
107#define LTTV_TRACESET_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACESET_STATE_TYPE, LttvTracesetStateClass))
dc877563 108#define LTTV_IS_TRACESET_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACESET_STATE_TYPE))
109#define LTTV_IS_TRACESET_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACESET_STATE_TYPE))
ffd54a90 110#define LTTV_TRACESET_STATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACESET_STATE_TYPE, LttvTracesetStateClass))
dc877563 111
ffd54a90 112struct _LttvTracesetState {
113 LttvTracesetContext parent;
dc877563 114};
115
116struct _LttvTracesetStateClass {
ffd54a90 117 LttvTracesetContextClass parent;
dc877563 118};
119
120GType lttv_traceset_state_get_type (void);
121
122
123#define LTTV_TRACE_STATE_TYPE (lttv_trace_state_get_type ())
124#define LTTV_TRACE_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACE_STATE_TYPE, LttvTraceState))
125#define LTTV_TRACE_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACE_STATE_TYPE, LttvTraceStateClass))
126#define LTTV_IS_TRACE_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACE_STATE_TYPE))
127#define LTTV_IS_TRACE_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACE_STATE_TYPE))
128#define LTTV_TRACE_STATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACE_STATE_TYPE, LttvTraceStateClass))
129
dc877563 130struct _LttvTraceState {
131 LttvTraceContext parent;
132
133 GHashTable *processes; /* LttvProcessState objects indexed by pid */
134 /* Block/char devices, locks, memory pages... */
135};
136
137struct _LttvTraceStateClass {
138 LttvTraceContextClass parent;
139};
140
141GType lttv_trace_state_get_type (void);
142
143
144#define LTTV_TRACEFILE_STATE_TYPE (lttv_tracefile_state_get_type ())
145#define LTTV_TRACEFILE_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACEFILE_STATE_TYPE, LttvTracefileState))
146#define LTTV_TRACEFILE_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACEFILE_STATE_TYPE, LttvTracefileStateClass))
147#define LTTV_IS_TRACEFILE_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACEFILE_STATE_TYPE))
148#define LTTV_IS_TRACEFILE_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACEFILE_STATE_TYPE))
149#define LTTV_TRACEFILE_STATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACEFILE_STATE_TYPE, LttvTracefileStateClass))
150
dc877563 151struct _LttvTracefileState {
152 LttvTracefileContext parent;
153
154 LttvProcessState *process;
155};
156
157struct _LttvTracefileStateClass {
158 LttvTracefileContextClass parent;
159};
160
161GType lttv_tracefile_state_get_type (void);
162
163
164#endif // PROCESSTRACE_H
This page took 0.034838 seconds and 4 git commands to generate.