5 #include <lttv/processTrace.h>
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.
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. */
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.
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
33 typedef struct _LttvTracesetState LttvTracesetState
;
34 typedef struct _LttvTracesetStateClass LttvTracesetStateClass
;
36 typedef struct _LttvTraceState LttvTraceState
;
37 typedef struct _LttvTraceStateClass LttvTraceStateClass
;
39 typedef struct _LttvTracefileState LttvTracefileState
;
40 typedef struct _LttvTracefileStateClass LttvTracefileStateClass
;
42 gboolean
lttv_state_add_event_hooks(LttvTracesetState
*self
);
44 gboolean
lttv_state_remove_event_hooks(LttvTracesetState
*self
);
47 /* The interrupt type is one of "user mode", "kernel thread", "system call",
48 "interrupt request", "fault". */
50 typedef GQuark LttvInterruptType
;
52 extern LttvInterruptType
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"). */
65 typedef GQuark LttvInterruptNumber
;
68 /* The process status is one of "running", "wait-cpu" (runnable), or "wait-*"
69 where "*" describes the resource waited for (e.g. timer, process,
72 typedef GQuark LttvProcessStatus
;
74 extern LttvProcessStatus
83 typedef struct _LttvInterruptState
{
85 LttvInterruptNumber n
;
92 typedef struct _LttvProcessState
{
96 GArray
*interrupt_stack
; /* Array of LttvInterruptState */
97 LttvInterruptState
*state
; /* Top of interrupt stack */
98 /* opened file descriptors, address map... */
102 /* The LttvTracesetState, LttvTraceState and LttvTracefileState types
103 inherit from the corresponding Context objects defined in processTrace. */
105 #define LTTV_TRACESET_STATE_TYPE (lttv_traceset_state_get_type ())
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))
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))
110 #define LTTV_TRACESET_STATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACESET_STATE_TYPE, LttvTracesetStateClass))
112 struct _LttvTracesetState
{
113 LttvTracesetContext parent
;
116 struct _LttvTracesetStateClass
{
117 LttvTracesetContextClass parent
;
120 GType
lttv_traceset_state_get_type (void);
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))
130 struct _LttvTraceState
{
131 LttvTraceContext parent
;
133 GHashTable
*processes
; /* LttvProcessState objects indexed by pid */
134 /* Block/char devices, locks, memory pages... */
137 struct _LttvTraceStateClass
{
138 LttvTraceContextClass parent
;
141 GType
lttv_trace_state_get_type (void);
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))
151 struct _LttvTracefileState
{
152 LttvTracefileContext parent
;
154 LttvProcessState
*process
;
157 struct _LttvTracefileStateClass
{
158 LttvTracefileContextClass parent
;
161 GType
lttv_tracefile_state_get_type (void);
164 #endif // PROCESSTRACE_H