Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 221b44546009cd843c69d3fe24952384e67fec8d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
[module traceLTTng('http://www.eclipse.org/uml2/5.0.0/UML')/]

[import org::eclipse::papyrus::qompass::designer::core::acceleo::UMLTool/]
[import org::eclipse::papyrus::qompass::designer::core::acceleo::TransformationContext/]
[import org::eclipse::papyrus::qompass::designer::core::acceleo::utils_cpp/]

[query public hasTrace(element : Element) : Boolean =
	invoke('org.eclipse.papyrus.qompass.modellibs.tracing.acceleo.TraceUtils',
		'hasTrace(org.eclipse.uml2.uml.Element)',
		Sequence{element}) /]

[template public declareTP(cl: Classifier)]
#if !defined(HFILENAME_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
#define HFILENAME_H

#ifdef __cplusplus
extern "C" {
#endif

#include <lttng/tracepoint.h>
[for (operation : Operation | cl.getAllOperations())]
[if hasTrace()]
[declareTPop(tpName1(), operation)/]
[/if]
[/for]

#undef TRACEPOINT_PROVIDER
#define TRACEPOINT_PROVIDER [tpName1() /]

#undef TRACEPOINT_INCLUDE_FILE
#define TRACEPOINT_INCLUDE_FILE [trafoContextClassifier().getQualifiedName().replaceAll('::', '/') /].h

#include <lttng/tracepoint-event.h>

#ifdef __cplusplus
}
#endif

#endif
[/template]

[template public declareTPop(tpName : String, operation : Operation)]
#include <stdint.h>

// declare trace point
TRACEPOINT_EVENT([tpName1()/], [operation.tpName2()/],
	TP_ARGS(const char *, instanceName[if (operation.parametersInInout()->size() > 0)], [/if][for (parameter : Parameter | operation.parametersInInout()) separator(', ')][flattenParNameAndType()/][/for]),
	TP_FIELDS(
		ctf_string(instanceName, instanceName)
		[for (parameter : Parameter | operation.parametersInInout())]
		[trafoContextClassifier().declareDependency(parameter.type)/][flattenCtfType(parameter.type, parameter.name)/]
		[/for]
	)
)
TRACEPOINT_MODEL_EMF_URI([tpName1()/], [operation.tpName2()/], "[operation.modelRef()/]")

[/template]

[template public declareCreateDestroy(tpName : String)]
TRACEPOINT_EVENT([tpName/], createClass,
	TP_ARGS(const char *, classURI),
	TP_FIELDS(
		ctf_string(classURI, classURI)
	)
)
TRACEPOINT_EVENT([tpName/], destroyClass,
	TP_ARGS(const char *, className),
	TP_FIELDS(
		ctf_string(xmdID, className)
	)
)
[/template]


[comment
	The name that is used for the trace provider
/]
[template public tpName1()]
[templateBinding().getNearestPackage().getQualifiedName().varName()/]
[/template]


[comment
	The name that is used for the type
/]
[template public tpName2(operation : Operation)]
[operation.name/]
[/template]


[comment
	Reference either the port (if available in the context) or the operation that is traced
/]
[template public modelRef(operation : Operation) post(trim())]
[if (trafoContextPort() = null)]
	[operation.getSourceRoot().getURI()/]#[operation.xmlID()/]
[else]
	[operation.getSourceRoot().getURI()/]#[trafoContextPort().xmlID()/]	
[/if]
[/template]

[comment
/]
[template public declareTraceOp(operation : Operation)]
[/template]

[template public invokeTP(operation : Operation)]
[if hasTrace()]
// use (call) tracepoint
tracepoint([tpName1()/], [operation.tpName2()/], instanceName[if (operation.parametersInInout()->size() > 0)], [/if][for (parameter : Parameter | operation.parametersInInout()) separator(', ')][flattenParName()/][/for]);
[/if]
[/template]


[template public flattenParNameAndType(parameter : Parameter) post(trim())]
[if (type.oclIsTypeOf(DataType))]
	[for (attribute : Property | type.oclAsType(DataType).attribute) separator(', ')][attribute.type.cppTypeWB()/], [parameter.name + '_' + attribute.name/][/for]
[else]
	[parameter.type.cppTypeWB()/], [parameter.name/]
[/if]
[/template]

[template public flattenParName(parameter : Parameter) post(trim())]
[if (type.oclIsTypeOf(DataType))]
	[for (attribute : Property | type.oclAsType(DataType).attribute) separator(', ')][parameter.name + '.' + attribute.name/][/for]
[else]
	[parameter.name/]
[/if]
[/template]


[template public flattenCtfType(type : Type, name : String) post(trim())]
[if (type.oclIsTypeOf(DataType))]
	[for (attribute : Property | type.oclAsType(DataType).attribute) separator('\n')][ctfType(attribute.type, name + '_' + attribute.name)/][/for]
[else]
	[ctfType(type, name)/]
[/if]
[/template]


[template public cppTypeWB(type : Type) post(trim())]
[if
	(type.qualifiedName = 'UMLPrimitiveTypes::Boolean') or
	(type.qualifiedName = 'PrimitiveTypes::Boolean') or
	(type.qualifiedName = 'CORBA::Boolean')]
	/* bool */ unsigned char
[else]
	[cppType()/]
[/if]
[/template]


[comment
	Calculate the typename, defaulting to ctf_integer
	TODO: treat pointer & ref stereotypes (can only evaulate on parameter or attribute, not on Type)
/]
[template public ctfType(type : Type, name : String) post(trim())]
[if
	(type.qualifiedName = 'CORBA::String') or
	(type.qualifiedName = 'PrimitiveTypes::String') or
	(type.qualifiedName = 'UMLPrimitiveTypes::String')]
	ctf_string([name/], [name/])
[elseif
	(type.qualifiedName = 'CORBA::Float') or
	(type.qualifiedName = 'CORBA::Double') or
	(type.qualifiedName = 'AnsiCLibrary::float') or
	(type.qualifiedName = 'AnsiCLibrary::double')]
	ctf_float([type.cppType()/], [name/], [name/])
[else]
	ctf_integer([type.cppTypeWB()/], [name/], [name/])
[/if]
[/template]

Back to the top