4 #include <lttv/processTrace.h>
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.
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. */
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.
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
32 gboolean
lttv_state_add_event_hooks(LttvTracesetState
*self
);
34 gboolean
lttv_state_remove_event_hooks(LttvTracesetState
*self
);
37 /* The interrupt type is one of "user mode", "kernel thread", "system call",
38 "interrupt request", "fault". */
40 typedef GQuark LttvInterruptType
;
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"). */
49 typedef GQuark LttvInterruptNumber
;
52 /* The process status is one of "running", "wait-cpu" (runnable), or "wait-*"
53 where "*" describes the resource waited for (e.g. timer, process,
56 typedef GQuark LttvProcessStatus
;
59 typedef _LttvInterruptState
{
61 LttvInterruptNumber n
;
68 typedef struct _LttvProcessState
{
72 GArray
*interrupt_stack
; /* Array of LttvInterruptState */
73 LttvInterruptState
*state
; /* Top of interrupt stack */
74 /* opened file descriptors, address map... */
78 /* The LttvTraceSetState, LttvTraceState and LttvTracefileState types
79 inherit from the corresponding Context objects defined in processTrace. */
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))
88 typedef struct _LttvTraceSetState LttvTraceSetState
;
89 typedef struct _LttvTraceSetStateClass LttvTraceSetStateClass
;
91 struct _LttvTraceSetState
{
92 LttvTraceSetContext parent
;
95 struct _LttvTracesetStateClass
{
96 LttvTraceSetClass parent
;
99 GType
lttv_traceset_state_get_type (void);
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))
109 typedef struct _LttvTraceState LttvTraceState
;
110 typedef struct _LttvTraceStateClass LttvTraceStateClass
;
112 struct _LttvTraceState
{
113 LttvTraceContext parent
;
115 GHashTable
*processes
; /* LttvProcessState objects indexed by pid */
116 /* Block/char devices, locks, memory pages... */
119 struct _LttvTraceStateClass
{
120 LttvTraceContextClass parent
;
123 GType
lttv_trace_state_get_type (void);
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))
133 typedef struct _LttvTracefileState LttvTracefileState
;
134 typedef struct _LttvTracefileStateClass LttvTracefileStateClass
;
136 struct _LttvTracefileState
{
137 LttvTracefileContext parent
;
139 LttvProcessState
*process
;
142 struct _LttvTracefileStateClass
{
143 LttvTracefileContextClass parent
;
146 GType
lttv_tracefile_state_get_type (void);
149 #endif // PROCESSTRACE_H