Skip to content

Instantly share code, notes, and snippets.

@abenbachir
Last active March 1, 2017 18:11
Show Gist options
  • Save abenbachir/dd91bf04b5917e634a4804c4f3f7d5e8 to your computer and use it in GitHub Desktop.
Save abenbachir/dd91bf04b5917e634a4804c4f3f7d5e8 to your computer and use it in GitHub Desktop.
<tmfxml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/module/xmlDefinition.xsd">
<pattern version="1" id="VM 0">
<head>
<traceType id="org.eclipse.linuxtools.lttng2.kernel.tracetype"/>
<label value="VM hypercallstack"/>
</head>
<callstack name="hypercallstack">
<level path="VM hypercalls/*"/>
<level path="*"/>
<level path="callstack"/>
</callstack>
<!--
callstack process="Views/*" thread="Threads/*" callstack="callstack" /
-->
<patternHandler>
<!-- CONDITIONS -->
<!--
Test if the current running thread is equal to the current scenario thread
-->
<test id="entry">
<if>
<condition>
<stateValue type="eventField" value="a1" forcedType="int"/>
<stateValue type="int" value="0" forcedType="int"/>
</condition>
</if>
</test>
<test id="exit">
<if>
<condition>
<stateValue type="eventField" value="a1" forcedType="int"/>
<stateValue type="int" value="1" forcedType="int"/>
</condition>
</if>
</test>
<test id="kernelspace">
<if>
<condition>
<stateValue type="eventField" value="nr" forcedType="int"/>
<stateValue type="int" value="1000" forcedType="int"/>
</condition>
</if>
</test>
<test id="userspace">
<if>
<condition>
<stateValue type="eventField" value="nr" forcedType="int"/>
<stateValue type="int" value="2000" forcedType="int"/>
</condition>
</if>
</test>
<test id="schedswitch">
<if>
<condition>
<stateValue type="eventField" value="nr" forcedType="int"/>
<stateValue type="int" value="1001" forcedType="int"/>
</condition>
</if>
</test>
<!-- ACTIONS -->
<!-- Actions and test for time graph view threads -->
<action id="push_hypercallk">
<!-- Push the current event to the thread's callstack -->
<stateChange>
<stateAttribute type="constant" value="VM hypercalls"/>
<stateAttribute type="constant" value="kernel"/>
<stateAttribute type="query">
<stateAttribute type="constant" value="Current thread"/>
<stateAttribute type="eventField" value="cpu"/>
</stateAttribute>
<stateAttribute type="constant" value="callstack"/>
<stateValue type="eventField" value="a0" stack="push"/>
</stateChange>
</action>
<action id="pop_hypercallk">
<!-- Push the current event to the thread's callstack -->
<stateChange>
<stateAttribute type="constant" value="VM hypercalls"/>
<stateAttribute type="constant" value="kernel"/>
<stateAttribute type="query">
<stateAttribute type="constant" value="Current thread"/>
<stateAttribute type="eventField" value="cpu"/>
</stateAttribute>
<stateAttribute type="constant" value="callstack"/>
<stateValue type="eventField" value="a0" stack="pop"/>
</stateChange>
</action>
<action id="push_hypercallu">
<!-- Push the current event to the thread's callstack -->
<stateChange>
<stateAttribute type="constant" value="VM hypercalls"/>
<stateAttribute type="constant" value="userspace"/>
<stateAttribute type="query">
<stateAttribute type="constant" value="Current thread"/>
<stateAttribute type="eventField" value="cpu"/>
</stateAttribute>
<stateAttribute type="constant" value="callstack"/>
<stateValue type="eventField" value="a0" stack="push"/>
</stateChange>
</action>
<action id="pop_hypercallu">
<!-- Push the current event to the thread's callstack -->
<stateChange>
<stateAttribute type="constant" value="VM hypercalls"/>
<stateAttribute type="constant" value="userspace"/>
<stateAttribute type="query">
<stateAttribute type="constant" value="Current thread"/>
<stateAttribute type="eventField" value="cpu"/>
</stateAttribute>
<stateAttribute type="constant" value="callstack"/>
<stateValue type="eventField" value="a0" stack="pop"/>
</stateChange>
</action>
<action id="update_current_thread">
<stateChange>
<stateAttribute type="constant" value="Current thread"/>
<stateAttribute type="eventField" value="cpu"/>
<stateValue type="eventField" value="a2" forcedType="int"/>
</stateChange>
<stateChange>
<stateAttribute type="constant" value="Current process"/>
<stateAttribute type="eventField" value="cpu"/>
<stateValue type="eventField" value="a3" forcedType="int"/>
</stateChange>
</action>
<!-- FSMs -->
<fsm id="hypercalls_kernel" initial="Wait_start" multiple="false">
<state id="Wait_start">
<!--
The state will stay here until we have a thread start event
-->
<transition event="kvm_x86_hypercall" cond="kernelspace:entry" target="in_callstack"
action="push_hypercallk"/>
</state>
<state id="in_callstack">
<!--
The state will loop on itself until the thread ends and increment the operations that happen during the execution
-->
<transition event="kvm_x86_hypercall" cond="kernelspace:entry" target="in_callstack"
action="push_hypercallk"/>
<transition event="kvm_x86_hypercall" cond="kernelspace:exit" target="in_callstack"
action="pop_hypercallk"/>
</state>
</fsm>
<fsm id="hypercalls_userspace" initial="Wait_start" multiple="false">
<state id="Wait_start">
<!--
The state will stay here until we have a thread start event
-->
<transition event="kvm_x86_hypercall" cond="userspace:entry" target="in_callstack"
action="push_hypercallu"/>
</state>
<state id="in_callstack">
<!--
The state will loop on itself until the thread ends and increment the operations that happen during the execution
-->
<transition event="kvm_x86_hypercall" cond="userspace:entry" target="in_callstack"
action="push_hypercallu"/>
<transition event="kvm_x86_hypercall" cond="userspace:exit" target="in_callstack"
action="pop_hypercallu"/>
</state>
</fsm>
<fsm id="sched_switch" initial="in_stat" multiple="false">
<state id="in_stat">
<!--
The state will stay here until we have a thread start event
-->
<transition event="kvm_x86_hypercall" cond="schedswitch" target="in_stat"
action="update_current_thread"/>
</state>
</fsm>
</patternHandler>
</pattern>
</tmfxml>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment