tmf : Add test suite for the pattern segment builder
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.analysis.xml.core.tests / test_xml_files / test_valid / test_valid_pattern.xml
CommitLineData
74f8a7ec
JCK
1<?xml version="1.0" encoding="UTF-8"?>
2<tmfxml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xsi:noNamespaceSchemaLocation="xmlDefinition.xsd">
4<!-- ***************************************************************************
5* Copyright (c) 2016 Ericsson
6*
7* All rights reserved. This program and the accompanying materials are
8* made available under the terms of the Eclipse Public License v1.0 which
9* accompanies this distribution, and is available at
10* http://www.eclipse.org/legal/epl-v10.html
11*************************************************************************** -->
12<pattern version="0" id="xml syscall abstraction provider">
13 <head>
14 <traceType id="org.eclipse.linuxtools.lttng2.kernel.tracetype" />
15 <label value="xml syscall abstraction provider" />
16 </head>
17
18<!-- STORED FIELDS -->
19
20 <storedField id="filename"/>
21 <storedField id="fd"/>
22 <storedField id="ret" alias="ret"/>
23 <storedField id="flags" alias="flags"/>
24 <storedField id="offset" alias="offset"/>
25 <storedField id="fd_in" alias="fd_in"/>
26 <storedField id="fd_out" alias="fd_out"/>
27 <storedField id="uservaddr" alias="uservaddr"/>
28 <storedField id="upeer_sockaddr" alias="upeer_sockaddr"/>
29
30<!-- SHORTCUTS -->
31
32<!-- Shorcut for the current running thread attribute -->
33 <location id="CurrentThread">
34 <stateAttribute type="constant" value="Threads" />
35 <stateAttribute type="query">
36 <stateAttribute type="constant" value="CPUs" />
37 <stateAttribute type="eventField" value="cpu" />
38 <stateAttribute type="constant" value="Current_thread" />
39 </stateAttribute>
40 </location>
41<!-- Shorcut for the current CPU attribute -->
42 <location id="CurrentCPU">
43 <stateAttribute type="constant" value="CPUs" />
44 <stateAttribute type="eventField" value="cpu" />
45 </location>
46<!-- Shortcut for the current scenario -->
47 <location id="CurrentScenario">
48 <stateAttribute type="constant" value="pattern" />
49 <stateAttribute type="constant" value="scenarios" />
50 <stateAttribute type="constant" value="#scenarioName" />
51 </location>
52
53<!-- The attribute initial specifies the FSMs that will be instanciated at the beginning of the analysis -->
54 <patternHandler initial="sched_switch:syscall">
55
56<!-- CONDITIONS -->
57
58<!-- This condition check if the current running thread PID is 1311 -->
59 <test id="tid_8998">
60 <if>
61 <condition>
62 <stateValue type="query">
63 <stateAttribute type="location" value="CurrentCPU" />
64 <stateAttribute type="constant" value="Current_thread" />
65 </stateValue>
66 <stateValue type="long" value="8998" />
67 </condition>
68 </if>
69 </test>
70<!-- Test this : if ( !(1 ns < ts < 3 ns) || ((ts -state.syscall_entry_x.ts) < 3 ns) ) -->
71 <test id="time_condition">
72 <if>
73 <or>
74 <not>
75 <condition>
76 <timerange unit="ns">
77 <in begin="1" end="3" />
78 </timerange>
79 </condition>
80 </not>
81 <condition>
82 <elapsedTime unit="ns">
83 <less since="syscall_entry_x" value="3" />
84 </elapsedTime>
85 </condition>
86 </or>
87 </if>
88 </test>
89<!-- Test if the current running thread PID is equal to the current scenario thread -->
90 <test id="thread_thread">
91 <if>
92 <condition>
93 <stateValue type="query" >
94 <stateAttribute type="location" value="CurrentCPU" />
95 <stateAttribute type="constant" value="Current_thread" />
96 </stateValue>
97 <stateValue type="query">
98 <stateAttribute type="location" value="CurrentScenario" />
99 <stateAttribute type="constant" value="thread" />
100 </stateValue>
101 </condition>
102 </if>
103 </test>
104
105<!-- ACTIONS -->
106
107<!-- Generates three state changes in the state system -->
108 <action id="sys_x_founded">
109<!-- Save the name of the system call executed under the current scenario path-->
110 <stateChange>
111 <stateAttribute type="location" value="CurrentScenario" />
112 <stateAttribute type="constant" value="syscall" />
113 <stateAttribute type="constant" value="name" />
114 <stateValue type="eventName"/>
115 </stateChange>
116<!-- Save the value of the CPU under the current scenario path -->
117 <stateChange>
118 <stateAttribute type="location" value="CurrentScenario" />
119 <stateAttribute type="constant" value="cpu" />
120 <stateValue type="eventField" value="cpu"/>
121 </stateChange>
122<!-- Save the value of the current thread PID under the current scenario path -->
123 <stateChange>
124 <stateAttribute type="location" value="CurrentScenario" />
125 <stateAttribute type="constant" value="thread" />
126 <stateValue type="query">
127 <stateAttribute type="location" value="CurrentCPU" />
128 <stateAttribute type="constant" value="Current_thread" />
129 </stateValue>
130 </stateChange>
131 </action>
132
133<!-- Generate a pattern segment -->
134 <action id="exit_syscall_founded">
135<!-- Generate a pattern segment with the name of the system call of the current scenario-->
136 <segment>
137 <segType>
138 <segName>
139 <stateValue type="query">
140 <stateAttribute type="location" value="CurrentScenario" />
141 <stateAttribute type="constant" value="syscall" />
142 <stateAttribute type="constant" value="name" />
143 </stateValue>
144 </segName>
145 </segType>
146 </segment>
147 </action>
148
149<!-- FSMs -->
150
151<!-- System call FSM
152 Declare an FSM to match all the system calls on thread 1311.
153 The FSM will generate pattern segments that will represent the system calls found
154-->
155 <fsm id="syscall" initial="wait_syscall_entry_x">
156<!-- Validate that PID == 1311 before going to the initial state -->
157 <initial>
158 <transition cond="tid_8998" target="wait_syscall_entry_x" />
159 </initial>
160 <state id="wait_syscall_entry_x">
161<!-- The state will stay here until we have a "syscall_entry_*" event -->
162 <transition event="syscall_entry_*" target="syscall_entry_x" action="sys_x_founded" saveStoredFields="true"/>
163 </state>
164 <state id="syscall_entry_x" >
165<!-- The state will stay here until we have a "syscall_exit_*" event -->
166 <transition event="syscall_exit_*" cond="thread_thread" target="syscall_exit_x" action="exit_syscall_founded" saveStoredFields="true" clearStoredFields="true"/>
167 </state>
168<!-- The state will stay here forever -->
169 <final id="syscall_exit_x"/>
170 </fsm>
171
172 <!-- SCHED_SWITCH FSM ACTIONS -->
173<!-- Update the value of the current running thread -->
174 <action id="update Current_thread">
175 <stateChange>
176 <stateAttribute type="location" value="CurrentCPU" />
177 <stateAttribute type="constant" value="Current_thread" />
178 <stateValue type="eventField" value="next_tid" />
179 </stateChange>
180 </action>
181<!-- sched_switch fsm
182 Declare an FSM to update the value of the current thread running.
183 The FSM will generate a state change to update the current thread, each time that it will meet a sched_switch event.
184-->
185 <fsm id="sched_switch" multiple="false">
186<!-- if event.name != sched_switch, no processing will be done -->
187 <initial>
188 <transition target="sched_switch"/>
189 <precondition event="sched_switch"/>
190 </initial>
191 <state id="sched_switch">
192<!-- The state will stay here forever and execute the action "update current thread" each time a sched_switch event will be meet-->
193 <transition target="sched_switch" action="update Current_thread" />
194 </state>
195 </fsm>
196 </patternHandler>
197</pattern>
198</tmfxml>
This page took 0.032006 seconds and 5 git commands to generate.