-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathtrcddi.cpp.mako
More file actions
145 lines (127 loc) · 4.67 KB
/
trcddi.cpp.mako
File metadata and controls
145 lines (127 loc) · 4.67 KB
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
<%!
import re
from templates import helper as th
%><%
n=namespace
N=n.upper()
x=tags['$x']
X=x.upper()
%>/*
*
* Copyright (C) 2020-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
* @file ${name}.cpp
*
*/
#include <iostream>
#include "${x}_tracing_layer.h"
namespace tracing_layer
{
%for obj in th.extract_objs(specs, r"function"):
<%
ret_type = obj['return_type']
failure_return = None
if ret_type != 'ze_result_t':
failure_return = th.get_first_failure_return(obj)
params_list = th.make_param_lines(n, tags, obj, format=["name"])
is_void_params = len(params_list) == 0
%>///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for ${th.make_func_name(n, tags, obj)}
%if 'condition' in obj:
#if ${th.subt(n, tags, obj['condition'])}
%endif
__${x}dlllocal ${ret_type} ${X}_APICALL
${th.make_func_name(n, tags, obj)}(
%for line in th.make_param_lines(n, tags, obj):
${line}
%endfor
)
{
auto ${th.make_pfn_name(n, tags, obj)} = context.${n}DdiTable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)};
if( nullptr == ${th.make_pfn_name(n, tags, obj)})
%if ret_type == "ze_result_t":
return ${X}_RESULT_ERROR_UNSUPPORTED_FEATURE;
%else:
return ${failure_return};
%endif
ZE_HANDLE_TRACER_RECURSION(context.${n}DdiTable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}\
%if not is_void_params:
, ${", ".join(params_list)}\
%endif
);
// capture parameters
%if not is_void_params:
${th.make_pfncb_param_type(n, tags, obj)} tracerParams = {
&${",\n &".join(params_list)}
};
%endif
tracing_layer::APITracerCallbackDataImp<${th.make_pfncb_type(n, tags, obj)}> apiCallbackData;
${N}_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ${th.make_pfncb_type(n, tags, obj)}, ${th.get_callback_table_name(n, tags, obj)}, ${th.make_pfncb_name(n, tags, obj)});
return tracing_layer::APITracerWrapperImp<${ret_type}>(context.${n}DdiTable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)},
%if not is_void_params:
&tracerParams,
%else:
nullptr,
%endif
apiCallbackData.apiOrdinal,
apiCallbackData.prologCallbacks,
apiCallbackData.epilogCallbacks\
%if not is_void_params:
,
*tracerParams.p${",\n *tracerParams.p".join(params_list)}\
%endif
);
}
%if 'condition' in obj:
#endif // ${th.subt(n, tags, obj['condition'])}
%endif
%endfor
} // namespace tracing_layer
#if defined(__cplusplus)
extern "C" {
#endif
%for tbl in th.get_pfntables(specs, meta, n, tags):
///////////////////////////////////////////////////////////////////////////////
/// @brief Exported function for filling application's ${tbl['name']} table
/// with current process' addresses
///
/// @returns
/// - ::${X}_RESULT_SUCCESS
/// - ::${X}_RESULT_ERROR_INVALID_NULL_POINTER
/// - ::${X}_RESULT_ERROR_UNSUPPORTED_VERSION
${X}_DLLEXPORT ${x}_result_t ${X}_APICALL
${tbl['export']['name']}(
%for line in th.make_param_lines(n, tags, tbl['export']):
${line}
%endfor
)
{
auto& dditable = tracing_layer::context.${n}DdiTable.${tbl['name']};
if( nullptr == pDdiTable )
return ${X}_RESULT_ERROR_INVALID_NULL_POINTER;
if (tracing_layer::context.version < version)
return ${X}_RESULT_ERROR_UNSUPPORTED_VERSION;
${x}_result_t result = ${X}_RESULT_SUCCESS;
%for obj in tbl['functions']:
if (version >= ${th.get_version(obj)}) {
%if 'condition' in obj:
#if ${th.subt(n, tags, obj['condition'])}
%endif
dditable.${th.append_ws(th.make_pfn_name(n, tags, obj), 43)} = pDdiTable->${th.make_pfn_name(n, tags, obj)};
pDdiTable->${th.append_ws(th.make_pfn_name(n, tags, obj), 41)} = tracing_layer::${th.make_func_name(n, tags, obj)};
%if 'condition' in obj:
#else
dditable.${th.append_ws(th.make_pfn_name(n, tags, obj), 43)} = nullptr;
pDdiTable->${th.append_ws(th.make_pfn_name(n, tags, obj), 41)} = nullptr;
#endif
%endif
}
%endfor
return result;
}
%endfor
#if defined(__cplusplus)
};
#endif