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
{
97 GArray
*interrupt_stack
; /* Array of LttvInterruptState */
98 LttvInterruptState
*state
; /* Top of interrupt stack */
99 /* opened file descriptors, address map... */
103 /* The LttvTracesetState, LttvTraceState and LttvTracefileState types
104 inherit from the corresponding Context objects defined in processTrace. */
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))
113 struct _LttvTracesetState
{
114 LttvTracesetContext parent
;
117 struct _LttvTracesetStateClass
{
118 LttvTracesetContextClass parent
;
121 GType
lttv_traceset_state_get_type (void);
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))
131 struct _LttvTraceState
{
132 LttvTraceContext parent
;
134 GHashTable
*processes
; /* LttvProcessState objects indexed by pid */
135 /* Block/char devices, locks, memory pages... */
138 struct _LttvTraceStateClass
{
139 LttvTraceContextClass parent
;
142 GType
lttv_trace_state_get_type (void);
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))
152 struct _LttvTracefileState
{
153 LttvTracefileContext parent
;
155 LttvProcessState
*process
;
158 struct _LttvTracefileStateClass
{
159 LttvTracefileContextClass parent
;
162 GType
lttv_tracefile_state_get_type (void);
165 #endif // PROCESSTRACE_H