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. */
17 typedef struct _LttvTracesetState LttvTracesetState
;
18 typedef struct _LttvTracesetStateClass LttvTracesetStateClass
;
20 typedef struct _LttvTraceState LttvTraceState
;
21 typedef struct _LttvTraceStateClass LttvTraceStateClass
;
23 typedef struct _LttvTracefileState LttvTracefileState
;
24 typedef struct _LttvTracefileStateClass LttvTracefileStateClass
;
26 gboolean
lttv_state_add_event_hooks(LttvTracesetState
*self
);
28 gboolean
lttv_state_remove_event_hooks(LttvTracesetState
*self
);
30 /* The LttvProcessState structure defines the current state for each process.
31 A process can make system calls (in some rare cases nested) and receive
32 interrupts/faults. For instance, a process may issue a system call,
33 generate a page fault while reading an argument from user space, and
34 get caught by an interrupt. To represent these nested states, an
35 execution mode stack is maintained. The stack bottom is normal user mode
36 and the top of stack is the current execution mode.
38 The execution mode stack tells about the process status, execution mode and
39 submode (interrupt, system call or IRQ number). All these could be
40 defined as enumerations but may need extensions (e.g. new process state).
41 GQuark are thus used. They are as easy to manipulate as integers but have
42 a string associated, just like enumerations.
44 The execution mode is one of "user mode", "kernel thread", "system call",
45 "interrupt request", "fault". */
47 typedef GQuark LttvExecutionMode
;
49 extern LttvExecutionMode
54 LTTV_STATE_MODE_UNKNOWN
;
57 /* The submode number depends on the execution mode. For user mode or kernel
58 thread, which are the normal mode (execution mode stack bottom),
59 it is set to "none". For interrupt requests, faults and system calls,
60 it is set respectively to the interrupt name (e.g. "timer"), fault name
61 (e.g. "page fault"), and system call name (e.g. "select"). */
63 typedef GQuark LttvExecutionSubmode
;
65 extern LttvExecutionSubmode
66 LTTV_STATE_SUBMODE_NONE
,
67 LTTV_STATE_SUBMODE_UNKNOWN
;
69 /* The process status is one of "running", "wait-cpu" (runnable), or "wait-*"
70 where "*" describes the resource waited for (e.g. timer, process,
73 typedef GQuark LttvProcessStatus
;
75 extern LttvProcessStatus
84 typedef struct _LttvExecutionState
{
86 LttvExecutionSubmode n
;
93 typedef struct _LttvProcessState
{
96 LttTime creation_time
;
99 GArray
*execution_stack
; /* Array of LttvExecutionState */
100 LttvExecutionState
*state
; /* Top of interrupt stack */
101 /* opened file descriptors, address map?... */
105 LttvProcessState
*lttv_state_find_process(LttvTracefileState
*tfs
, guint pid
);
108 /* The LttvTracesetState, LttvTraceState and LttvTracefileState types
109 inherit from the corresponding Context objects defined in processTrace. */
111 #define LTTV_TRACESET_STATE_TYPE (lttv_traceset_state_get_type ())
112 #define LTTV_TRACESET_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACESET_STATE_TYPE, LttvTracesetState))
113 #define LTTV_TRACESET_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACESET_STATE_TYPE, LttvTracesetStateClass))
114 #define LTTV_IS_TRACESET_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACESET_STATE_TYPE))
115 #define LTTV_IS_TRACESET_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACESET_STATE_TYPE))
116 #define LTTV_TRACESET_STATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACESET_STATE_TYPE, LttvTracesetStateClass))
118 struct _LttvTracesetState
{
119 LttvTracesetContext parent
;
122 struct _LttvTracesetStateClass
{
123 LttvTracesetContextClass parent
;
126 GType
lttv_traceset_state_get_type (void);
129 #define LTTV_TRACE_STATE_TYPE (lttv_trace_state_get_type ())
130 #define LTTV_TRACE_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACE_STATE_TYPE, LttvTraceState))
131 #define LTTV_TRACE_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACE_STATE_TYPE, LttvTraceStateClass))
132 #define LTTV_IS_TRACE_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACE_STATE_TYPE))
133 #define LTTV_IS_TRACE_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACE_STATE_TYPE))
134 #define LTTV_TRACE_STATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACE_STATE_TYPE, LttvTraceStateClass))
136 struct _LttvTraceState
{
137 LttvTraceContext parent
;
139 GHashTable
*processes
; /* LttvProcessState objects indexed by pid */
140 /* Block/char devices, locks, memory pages... */
141 GQuark
*eventtype_names
;
142 GQuark
*syscall_names
;
147 struct _LttvTraceStateClass
{
148 LttvTraceContextClass parent
;
151 GType
lttv_trace_state_get_type (void);
154 #define LTTV_TRACEFILE_STATE_TYPE (lttv_tracefile_state_get_type ())
155 #define LTTV_TRACEFILE_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACEFILE_STATE_TYPE, LttvTracefileState))
156 #define LTTV_TRACEFILE_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACEFILE_STATE_TYPE, LttvTracefileStateClass))
157 #define LTTV_IS_TRACEFILE_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACEFILE_STATE_TYPE))
158 #define LTTV_IS_TRACEFILE_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACEFILE_STATE_TYPE))
159 #define LTTV_TRACEFILE_STATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACEFILE_STATE_TYPE, LttvTracefileStateClass))
161 struct _LttvTracefileState
{
162 LttvTracefileContext parent
;
164 LttvProcessState
*process
;
168 struct _LttvTracefileStateClass
{
169 LttvTracefileContextClass parent
;
172 GType
lttv_tracefile_state_get_type (void);