metababel 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/metababel +15 -9
- data/lib/metababel/bt2_stream_classes_generator.rb +29 -5
- data/lib/metababel/version.rb +1 -1
- data/template/downstream.c.erb +28 -3
- data/template/downstream.h.erb +3 -0
- data/template/filter.c.erb +49 -19
- data/template/sink.c.erb +13 -2
- data/template/source.c.erb +20 -4
- metadata +3 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3e44583997647f4d7d9e241dd5e066abc80586445283bd2846fa9fa453542de7
|
|
4
|
+
data.tar.gz: a89855eeb46c35a71325937679b30bc0ef3fe46317cc1239419980b13f43a1b5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8ece21929325026051ef4897d8f9871c19e5af621d963d1fcd8e57e8e481feb460e6fe3a02675eefb0bd44dc64505af329231ea22b52c54acbbfc7d9efcdaf2a
|
|
7
|
+
data.tar.gz: 62fd169ca6e45a414b71228c2b6fc763bd0d18dd83fcbc6266d1663bb7303a8aa608f56863b3bbea0154d5862e4b80f26adbdbd6401b11541a658e200c278704
|
data/bin/metababel
CHANGED
|
@@ -33,7 +33,7 @@ class Hash
|
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
EventInfo = Struct.new(:name, :args, :body, :index_stream_class, :index_event_class) do
|
|
36
|
+
EventInfo = Struct.new(:name, :args, :body, :index_stream_class, :index_event_class, :default_clock_class) do
|
|
37
37
|
def name_sanitized
|
|
38
38
|
name.gsub(/[^0-9A-Za-z-]/, '_')
|
|
39
39
|
end
|
|
@@ -56,7 +56,7 @@ class Babeltrace2Gen::BTTraceClass
|
|
|
56
56
|
def map_event_classes_with_index
|
|
57
57
|
@stream_classes.map.with_index do |s, index_stream_class|
|
|
58
58
|
s.event_classes.map.with_index do |e, index_event_class|
|
|
59
|
-
yield(e, index_stream_class, index_event_class)
|
|
59
|
+
yield(e, index_stream_class, index_event_class, s.default_clock_class)
|
|
60
60
|
end
|
|
61
61
|
end.flatten
|
|
62
62
|
end
|
|
@@ -71,8 +71,10 @@ end
|
|
|
71
71
|
# But we clean the white space empty line afterward \o/
|
|
72
72
|
def wrote_event_dispatchers(folder, t)
|
|
73
73
|
event_name = 'event'
|
|
74
|
-
event_dispatchers = t.map_event_classes_with_index do |e, index_stream_class, index_event_class|
|
|
74
|
+
event_dispatchers = t.map_event_classes_with_index do |e, index_stream_class, index_event_class, default_clock_class|
|
|
75
75
|
arg_variables = []
|
|
76
|
+
arg_variables << GeneratedArg.new("uint64_t", "timestamp") if default_clock_class
|
|
77
|
+
|
|
76
78
|
body = Babeltrace2Gen.context(indent: 1) do
|
|
77
79
|
e.get_getter(event: event_name, arg_variables: arg_variables)
|
|
78
80
|
end
|
|
@@ -88,16 +90,18 @@ end
|
|
|
88
90
|
|
|
89
91
|
def wrote_creates(folder, t)
|
|
90
92
|
event_name = 'event'
|
|
91
|
-
downstream_events = t.map_event_classes_with_index do |e, index_stream_class, index_event_class|
|
|
93
|
+
downstream_events = t.map_event_classes_with_index do |e, index_stream_class, index_event_class, default_clock_class|
|
|
92
94
|
arg_variables = []
|
|
93
95
|
body = Babeltrace2Gen.context(indent: 1) do
|
|
94
96
|
e.get_setter(event: event_name, arg_variables: arg_variables)
|
|
95
97
|
end
|
|
96
|
-
|
|
98
|
+
arg_variables.insert(0,GeneratedArg.new("uint64_t", "timestamp")) if default_clock_class
|
|
99
|
+
|
|
100
|
+
EventInfo.new(e.name, arg_variables, "\n" + body, index_stream_class, index_event_class, default_clock_class)
|
|
97
101
|
end
|
|
98
102
|
|
|
99
103
|
body_declarator_classes = "\n" + Babeltrace2Gen.context(indent: 1) do
|
|
100
|
-
t.get_declarator(variable: 'trace_class')
|
|
104
|
+
t.get_declarator(variable: 'trace_class', self_component: 'self_component')
|
|
101
105
|
end
|
|
102
106
|
|
|
103
107
|
d = { body_declarator_classes: body_declarator_classes,
|
|
@@ -131,12 +135,10 @@ def wrote_component(options, d, folder)
|
|
|
131
135
|
erb_render_and_save(d2.update(d).update(options: options), 'component.c', folder)
|
|
132
136
|
end
|
|
133
137
|
|
|
134
|
-
options = { plugin_name: 'metababel',
|
|
135
|
-
component_name: 'btx' }
|
|
136
|
-
|
|
137
138
|
# Display help if no arguments.
|
|
138
139
|
ARGV << '-h' if ARGV.empty?
|
|
139
140
|
|
|
141
|
+
options = {}
|
|
140
142
|
OptionParser.new do |opts|
|
|
141
143
|
opts.banner = 'Usage: example.rb [options]'
|
|
142
144
|
|
|
@@ -185,6 +187,8 @@ OptionParser.new do |opts|
|
|
|
185
187
|
end.parse!
|
|
186
188
|
|
|
187
189
|
raise OptionParser::MissingArgument if options[:component_type].nil?
|
|
190
|
+
options[:plugin_name] ||= "metababel_#{options[:component_type].downcase}"
|
|
191
|
+
options[:component_name] ||= "btx"
|
|
188
192
|
|
|
189
193
|
# Babeltrace can be extended by plugins, which provide one or more component classes.
|
|
190
194
|
base_folder = options[:folder] || "#{options[:component_type]}.#{options[:plugin_name]}.#{options[:component_name]}"
|
|
@@ -203,6 +207,8 @@ if options.key?(:params)
|
|
|
203
207
|
end
|
|
204
208
|
d[:params_declaration] = c.get_struct_definition('params')
|
|
205
209
|
d[:params_definition] = body
|
|
210
|
+
else
|
|
211
|
+
d[:params_declaration] = "char _dummy;"
|
|
206
212
|
end
|
|
207
213
|
|
|
208
214
|
erb_render_and_save(d, "#{options[:component_type].downcase}.c", base_folder, out_name: "main.c")
|
|
@@ -89,7 +89,8 @@ module Babeltrace2Gen
|
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
-
def get_declarator(variable:)
|
|
92
|
+
def get_declarator(variable:, self_component:)
|
|
93
|
+
pr "#{variable} = bt_trace_class_create(#{self_component});"
|
|
93
94
|
bt_set_conditionally(@assigns_automatic_stream_class_id) do |v|
|
|
94
95
|
pr "bt_trace_class_set_assigns_automatic_stream_class_id(#{variable}, #{v});"
|
|
95
96
|
end
|
|
@@ -98,7 +99,7 @@ module Babeltrace2Gen
|
|
|
98
99
|
stream_class_name = "#{variable}_sc_#{i}"
|
|
99
100
|
scope do
|
|
100
101
|
pr "bt_stream_class *#{stream_class_name};"
|
|
101
|
-
m.get_declarator(
|
|
102
|
+
m.get_declarator(variable: stream_class_name, self_component: self_component, trace_class: variable)
|
|
102
103
|
end
|
|
103
104
|
end
|
|
104
105
|
end
|
|
@@ -109,10 +110,14 @@ module Babeltrace2Gen
|
|
|
109
110
|
include BTPrinter
|
|
110
111
|
include BTLocator
|
|
111
112
|
extend BTFromH
|
|
112
|
-
attr_reader :packet_context_field_class, :event_common_context_field_class, :event_classes, :id, :name
|
|
113
|
+
attr_reader :packet_context_field_class, :event_common_context_field_class, :event_classes, :default_clock_class, :id, :name
|
|
113
114
|
|
|
114
115
|
def initialize(parent:, name: nil, packet_context_field_class: nil, event_common_context_field_class: nil,
|
|
115
|
-
event_classes: [], id: nil, assigns_automatic_event_class_id: nil, assigns_automatic_stream_id: nil
|
|
116
|
+
event_classes: [], id: nil, assigns_automatic_event_class_id: nil, assigns_automatic_stream_id: nil,
|
|
117
|
+
default_clock_class: nil)
|
|
118
|
+
# Handle clock class property:
|
|
119
|
+
# https://babeltrace.org/docs/v2.0/libbabeltrace2/group__api-tir-clock-cls.html#gae0f705eb48cd65784da28b1906ca05a5
|
|
120
|
+
|
|
116
121
|
@parent = parent
|
|
117
122
|
@name = name
|
|
118
123
|
|
|
@@ -137,15 +142,26 @@ module Babeltrace2Gen
|
|
|
137
142
|
end
|
|
138
143
|
@assigns_automatic_stream_id = assigns_automatic_stream_id
|
|
139
144
|
@id = id
|
|
145
|
+
@default_clock_class = default_clock_class
|
|
140
146
|
end
|
|
141
147
|
|
|
142
|
-
def get_declarator(trace_class:,
|
|
148
|
+
def get_declarator(variable:, trace_class:, self_component:)
|
|
143
149
|
if @id
|
|
144
150
|
pr "#{variable} = bt_stream_class_create_with_id(#{trace_class}, #{@id});"
|
|
145
151
|
else
|
|
146
152
|
pr "#{variable} = bt_stream_class_create(#{trace_class});"
|
|
147
153
|
end
|
|
148
154
|
pr "bt_stream_class_set_name(#{variable}, \"#{name}\");" if @name
|
|
155
|
+
if @default_clock_class
|
|
156
|
+
clock_class_name = "#{variable}_dcc"
|
|
157
|
+
scope do
|
|
158
|
+
pr "bt_clock_class *#{clock_class_name};"
|
|
159
|
+
# TODO: @default_clock_class.get_declarator(variable: clock_class_name, self_component: self_component)
|
|
160
|
+
pr "#{clock_class_name} = bt_clock_class_create(#{self_component});"
|
|
161
|
+
pr "bt_stream_class_set_default_clock_class(#{variable}, #{clock_class_name});"
|
|
162
|
+
pr "bt_clock_class_put_ref(#{clock_class_name});"
|
|
163
|
+
end
|
|
164
|
+
end
|
|
149
165
|
|
|
150
166
|
if @packet_context_field_class
|
|
151
167
|
var_pc = "#{variable}_pc_fc"
|
|
@@ -153,6 +169,7 @@ module Babeltrace2Gen
|
|
|
153
169
|
pr "bt_field_class *#{var_pc};"
|
|
154
170
|
@packet_context_field_class.get_declarator(trace_class: trace_class, variable: var_pc)
|
|
155
171
|
pr "bt_stream_class_set_packet_context_field_class(#{variable}, #{var_pc});"
|
|
172
|
+
pr "bt_field_class_put_ref(#{var_pc});"
|
|
156
173
|
end
|
|
157
174
|
end
|
|
158
175
|
|
|
@@ -162,6 +179,7 @@ module Babeltrace2Gen
|
|
|
162
179
|
pr "bt_field_class *#{var_ecc};"
|
|
163
180
|
@event_common_context_field_class.get_declarator(trace_class: trace_class, variable: var_ecc)
|
|
164
181
|
pr "bt_stream_class_set_event_common_context_field_class(#{variable}, #{var_ecc});"
|
|
182
|
+
pr "bt_field_class_put_ref(#{var_ecc});"
|
|
165
183
|
end
|
|
166
184
|
end
|
|
167
185
|
# Need to do is afert packet an devent_common_context because it can refer members to those
|
|
@@ -174,12 +192,15 @@ module Babeltrace2Gen
|
|
|
174
192
|
scope do
|
|
175
193
|
pr "bt_event_class *#{var_name};"
|
|
176
194
|
ec.get_declarator(trace_class: trace_class, variable: var_name, stream_class: variable)
|
|
195
|
+
pr "bt_event_class_put_ref(#{var_name});"
|
|
177
196
|
end
|
|
178
197
|
end
|
|
179
198
|
|
|
180
199
|
bt_set_conditionally(@assigns_automatic_stream_id) do |v|
|
|
181
200
|
pr "bt_stream_class_set_assigns_automatic_stream_id(#{variable}, #{v});"
|
|
182
201
|
end
|
|
202
|
+
|
|
203
|
+
pr "bt_stream_class_put_ref(#{variable});"
|
|
183
204
|
end
|
|
184
205
|
end
|
|
185
206
|
|
|
@@ -218,6 +239,7 @@ module Babeltrace2Gen
|
|
|
218
239
|
pr "bt_field_class *#{var_name};"
|
|
219
240
|
@specific_context_field_class.get_declarator(trace_class: trace_class, variable: var_name)
|
|
220
241
|
pr "bt_event_class_set_specific_context_field_class(#{variable}, #{var_name});"
|
|
242
|
+
pr "bt_field_class_put_ref(#{var_name});"
|
|
221
243
|
end
|
|
222
244
|
end
|
|
223
245
|
|
|
@@ -227,6 +249,7 @@ module Babeltrace2Gen
|
|
|
227
249
|
pr "bt_field_class *#{var_name};"
|
|
228
250
|
@payload_field_class.get_declarator(trace_class: trace_class, variable: var_name)
|
|
229
251
|
pr "bt_event_class_set_payload_field_class(#{variable}, #{var_name});"
|
|
252
|
+
pr "bt_field_class_put_ref(#{var_name});"
|
|
230
253
|
end
|
|
231
254
|
end
|
|
232
255
|
end
|
|
@@ -588,6 +611,7 @@ module Babeltrace2Gen
|
|
|
588
611
|
pr "bt_field_class *#{var_name};"
|
|
589
612
|
m.field_class.get_declarator(trace_class: trace_class, variable: var_name)
|
|
590
613
|
pr "bt_field_class_structure_append_member(#{variable}, \"#{m.name}\", #{var_name});"
|
|
614
|
+
pr "bt_field_class_put_ref(#{var_name});"
|
|
591
615
|
end
|
|
592
616
|
end
|
|
593
617
|
end
|
data/lib/metababel/version.rb
CHANGED
data/template/downstream.c.erb
CHANGED
|
@@ -37,7 +37,7 @@ void btx_downstream_push_message(
|
|
|
37
37
|
|
|
38
38
|
bt_trace_class *
|
|
39
39
|
btx_downstream_trace_class_create_rec(bt_self_component *self_component) {
|
|
40
|
-
bt_trace_class *trace_class
|
|
40
|
+
bt_trace_class *trace_class;
|
|
41
41
|
<%= body_declarator_classes %>
|
|
42
42
|
return trace_class;
|
|
43
43
|
}
|
|
@@ -48,12 +48,32 @@ bt_trace *btx_downstream_trace_create_rec(bt_trace_class *trace_class) {
|
|
|
48
48
|
{
|
|
49
49
|
bt_stream_class *stream_class =
|
|
50
50
|
bt_trace_class_borrow_stream_class_by_index(trace_class, <%= i %>);
|
|
51
|
-
bt_stream_create(stream_class, trace);
|
|
51
|
+
bt_stream_put_ref(bt_stream_create(stream_class, trace));
|
|
52
52
|
}
|
|
53
53
|
<% end %>
|
|
54
54
|
return trace;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
// Workarround of a bug where gepping trace alive (and not the stream) provoke
|
|
58
|
+
// some segfault
|
|
59
|
+
void btx_streams_get_ref(bt_trace *trace) {
|
|
60
|
+
<% stream_classes.each_with_index do |_,i| %>
|
|
61
|
+
{
|
|
62
|
+
bt_stream *stream = bt_trace_borrow_stream_by_index(trace, <%= i %>);
|
|
63
|
+
bt_stream_get_ref(stream);
|
|
64
|
+
}
|
|
65
|
+
<% end %>
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
void btx_streams_put_ref(bt_trace *trace) {
|
|
69
|
+
<% stream_classes.each_with_index do |_,i| %>
|
|
70
|
+
{
|
|
71
|
+
bt_stream *stream = bt_trace_borrow_stream_by_index(trace, <%= i %>);
|
|
72
|
+
bt_stream_put_ref(stream);
|
|
73
|
+
}
|
|
74
|
+
<% end %>
|
|
75
|
+
}
|
|
76
|
+
|
|
57
77
|
void btx_push_messages_stream_beginning(
|
|
58
78
|
bt_self_message_iterator *self_message_iterator,
|
|
59
79
|
btx_message_iterator_t *message_iterator_private_data) {
|
|
@@ -104,9 +124,14 @@ void btx_push_message_<%= e.name_sanitized %>(
|
|
|
104
124
|
bt_stream_class *stream_class = bt_stream_borrow_class(stream);
|
|
105
125
|
bt_event_class *event_class = bt_stream_class_borrow_event_class_by_index(
|
|
106
126
|
stream_class, <%= e.index_event_class %>);
|
|
107
|
-
|
|
127
|
+
<% if !e.default_clock_class %>
|
|
108
128
|
bt_message *message = bt_message_event_create(
|
|
109
129
|
common_data->self_message_iterator, event_class, stream);
|
|
130
|
+
<% else %>
|
|
131
|
+
bt_message *message = bt_message_event_create_with_default_clock_snapshot(
|
|
132
|
+
common_data->self_message_iterator, event_class, stream, timestamp);
|
|
133
|
+
<% end %>
|
|
134
|
+
|
|
110
135
|
bt_event *downstream_event = bt_message_event_borrow_event(message);
|
|
111
136
|
|
|
112
137
|
btx_set_message_<%= e.name_sanitized %>(
|
data/template/downstream.h.erb
CHANGED
|
@@ -17,6 +17,9 @@ btx_downstream_trace_class_create_rec(bt_self_component *self_component);
|
|
|
17
17
|
|
|
18
18
|
bt_trace *btx_downstream_trace_create_rec(bt_trace_class *trace_class);
|
|
19
19
|
|
|
20
|
+
void btx_streams_get_ref(bt_trace *trace);
|
|
21
|
+
void btx_streams_put_ref(bt_trace *trace);
|
|
22
|
+
|
|
20
23
|
void btx_push_messages_stream_beginning(
|
|
21
24
|
bt_self_message_iterator *self_message_iterator,
|
|
22
25
|
btx_message_iterator_t *message_iterator_private_data);
|
data/template/filter.c.erb
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* https://babeltrace.org/docs/v2.0/libbabeltrace2/example-simple-flt-cmp-cls.html
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
static
|
|
12
|
+
static char *get_port_name(uint64_t current) {
|
|
13
13
|
int num_len = snprintf(NULL, 0, "in%ld", current);
|
|
14
14
|
char *result = (char *)malloc(num_len + 1);
|
|
15
15
|
sprintf(result, "in%ld", current);
|
|
@@ -91,9 +91,10 @@ filter_message_iterator_next_processing_reading(
|
|
|
91
91
|
/* We are setting the state, so this function will never being call twice */
|
|
92
92
|
bt_message_iterator_put_ref(
|
|
93
93
|
message_iterator_private_data->head_mi->message_iterator);
|
|
94
|
+
struct el_mi *tmp = message_iterator_private_data->head_mi;
|
|
95
|
+
CDL_DELETE(message_iterator_private_data->head_mi, tmp);
|
|
96
|
+
free(tmp);
|
|
94
97
|
|
|
95
|
-
CDL_DELETE(message_iterator_private_data->head_mi,
|
|
96
|
-
message_iterator_private_data->head_mi);
|
|
97
98
|
if (!message_iterator_private_data->head_mi) {
|
|
98
99
|
/* Call Finalize user callback */
|
|
99
100
|
btx_call_callbacks_finalize_usr_data(
|
|
@@ -240,6 +241,7 @@ filter_initialize(bt_self_component_filter *self_component_filter,
|
|
|
240
241
|
|
|
241
242
|
/* Allocate a private data structure */
|
|
242
243
|
common_data_t *common_data = calloc(1, sizeof(common_data_t));
|
|
244
|
+
common_data->btx_params = calloc(1, sizeof(btx_params_t));
|
|
243
245
|
common_data->params = params;
|
|
244
246
|
// Read parameters
|
|
245
247
|
btx_populate_params(common_data);
|
|
@@ -274,9 +276,12 @@ filter_initialize(bt_self_component_filter *self_component_filter,
|
|
|
274
276
|
const uint64_t current =
|
|
275
277
|
bt_component_filter_get_input_port_count(common_data->component);
|
|
276
278
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
279
|
+
{
|
|
280
|
+
char *name = get_port_name(current);
|
|
281
|
+
bt_self_component_filter_add_input_port(self_component_filter, name, NULL,
|
|
282
|
+
NULL);
|
|
283
|
+
free(name);
|
|
284
|
+
}
|
|
280
285
|
bt_self_component_filter_add_output_port(self_component_filter, "out", NULL,
|
|
281
286
|
NULL);
|
|
282
287
|
|
|
@@ -289,17 +294,26 @@ filter_initialize(bt_self_component_filter *self_component_filter,
|
|
|
289
294
|
/* Instantiate a `downstream_trace` of `trace_class` and all the children
|
|
290
295
|
* stream */
|
|
291
296
|
common_data->downstream_trace = btx_downstream_trace_create_rec(trace_class);
|
|
297
|
+
btx_streams_get_ref(common_data->downstream_trace); // ??
|
|
298
|
+
bt_trace_class_put_ref(trace_class);
|
|
299
|
+
|
|
292
300
|
return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
|
|
293
301
|
}
|
|
294
302
|
|
|
295
303
|
bt_component_class_port_connected_method_status
|
|
296
|
-
filter_input_port_connected(bt_self_component_filter *
|
|
304
|
+
filter_input_port_connected(bt_self_component_filter *self_component_filter,
|
|
297
305
|
bt_self_component_port_input *self_port,
|
|
298
306
|
const bt_port_output *other_port) {
|
|
299
307
|
const uint64_t current = bt_component_filter_get_input_port_count(
|
|
300
|
-
bt_self_component_filter_as_component_filter(
|
|
301
|
-
|
|
302
|
-
|
|
308
|
+
bt_self_component_filter_as_component_filter(self_component_filter));
|
|
309
|
+
|
|
310
|
+
{
|
|
311
|
+
char *name = get_port_name(current);
|
|
312
|
+
bt_self_component_filter_add_input_port(self_component_filter, name, NULL,
|
|
313
|
+
NULL);
|
|
314
|
+
free(name);
|
|
315
|
+
}
|
|
316
|
+
|
|
303
317
|
return BT_COMPONENT_CLASS_PORT_CONNECTED_METHOD_STATUS_OK;
|
|
304
318
|
}
|
|
305
319
|
/*
|
|
@@ -342,6 +356,7 @@ filter_message_iterator_initialize(
|
|
|
342
356
|
el_mi *mi = (el_mi *)malloc(sizeof *mi);
|
|
343
357
|
bt_message_iterator_create_from_message_iterator(
|
|
344
358
|
self_message_iterator, self_port, &mi->message_iterator);
|
|
359
|
+
|
|
345
360
|
CDL_APPEND(message_iterator_private_data->head_mi, mi);
|
|
346
361
|
}
|
|
347
362
|
|
|
@@ -359,6 +374,19 @@ filter_message_iterator_initialize(
|
|
|
359
374
|
static void filter_finalize(bt_self_component_filter *self_component_filter) {
|
|
360
375
|
common_data_t *common_data = bt_self_component_get_data(
|
|
361
376
|
bt_self_component_filter_as_self_component(self_component_filter));
|
|
377
|
+
|
|
378
|
+
btx_streams_put_ref(common_data->downstream_trace); // ??
|
|
379
|
+
// We allocate it, we need to put ref
|
|
380
|
+
bt_trace_put_ref(common_data->downstream_trace);
|
|
381
|
+
|
|
382
|
+
// Delete name_to_dispatcher
|
|
383
|
+
name_to_dispatcher_t *current, *tmp;
|
|
384
|
+
HASH_ITER(hh, common_data->name_to_dispatcher, current, tmp) {
|
|
385
|
+
HASH_DEL(common_data->name_to_dispatcher, current);
|
|
386
|
+
utarray_free(current->callbacks);
|
|
387
|
+
free(current);
|
|
388
|
+
}
|
|
389
|
+
|
|
362
390
|
// We allocate it, we need to free it
|
|
363
391
|
free(common_data->btx_params);
|
|
364
392
|
bt_value_put_ref(common_data->params);
|
|
@@ -371,12 +399,14 @@ static void filter_message_iterator_finalize(
|
|
|
371
399
|
btx_message_iterator_t *message_iterator_private_data =
|
|
372
400
|
bt_self_message_iterator_get_data(self_message_iterator);
|
|
373
401
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
402
|
+
{
|
|
403
|
+
struct el *elt, *tmp;
|
|
404
|
+
DL_FOREACH_SAFE(message_iterator_private_data->pool, elt, tmp) {
|
|
405
|
+
DL_DELETE(message_iterator_private_data->pool, elt);
|
|
406
|
+
free(elt);
|
|
407
|
+
}
|
|
378
408
|
}
|
|
379
|
-
|
|
409
|
+
assert(!message_iterator_private_data->head_mi);
|
|
380
410
|
/* Free the allocated structure */
|
|
381
411
|
free(message_iterator_private_data);
|
|
382
412
|
}
|
|
@@ -388,10 +418,10 @@ BT_PLUGIN(<%= options[:plugin_name] %>);
|
|
|
388
418
|
BT_PLUGIN_FILTER_COMPONENT_CLASS(<%= options[:component_name] %>,
|
|
389
419
|
filter_message_iterator_next);
|
|
390
420
|
|
|
391
|
-
BT_PLUGIN_FILTER_COMPONENT_CLASS_INITIALIZE_METHOD(
|
|
392
|
-
|
|
393
|
-
BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD(
|
|
394
|
-
|
|
421
|
+
BT_PLUGIN_FILTER_COMPONENT_CLASS_INITIALIZE_METHOD(
|
|
422
|
+
<%= options[:component_name] %>, filter_initialize);
|
|
423
|
+
BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD(
|
|
424
|
+
<%= options[:component_name] %>, filter_finalize);
|
|
395
425
|
BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD(
|
|
396
426
|
<%= options[:component_name] %>, filter_message_iterator_initialize);
|
|
397
427
|
BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD(
|
data/template/sink.c.erb
CHANGED
|
@@ -50,6 +50,7 @@ sink_consume(bt_self_component_sink *self_component_sink) {
|
|
|
50
50
|
for (uint64_t i = 0; i < message_count; i++) {
|
|
51
51
|
const bt_message *message = messages[i];
|
|
52
52
|
if (bt_message_get_type(message) != BT_MESSAGE_TYPE_EVENT) {
|
|
53
|
+
bt_message_put_ref(message);
|
|
53
54
|
continue;
|
|
54
55
|
}
|
|
55
56
|
|
|
@@ -79,6 +80,7 @@ sink_initialize(bt_self_component_sink *self_component_sink,
|
|
|
79
80
|
const bt_value *params, void *initialize_method_data) {
|
|
80
81
|
/* Allocate a private data structure */
|
|
81
82
|
common_data_t *common_data = calloc(1, sizeof(common_data_t));
|
|
83
|
+
common_data->btx_params = calloc(1, sizeof(btx_params_t));
|
|
82
84
|
common_data->params = params;
|
|
83
85
|
// Read parameters
|
|
84
86
|
btx_populate_params(common_data);
|
|
@@ -118,6 +120,15 @@ static void sink_finalize(bt_self_component_sink *self_component_sink) {
|
|
|
118
120
|
/* Finalize User Data */
|
|
119
121
|
/* Call Finalize user callback */
|
|
120
122
|
btx_call_callbacks_finalize_usr_data(common_data, common_data->usr_data);
|
|
123
|
+
|
|
124
|
+
// Delete name_to_dispatcher
|
|
125
|
+
name_to_dispatcher_t *current, *tmp;
|
|
126
|
+
HASH_ITER(hh, common_data->name_to_dispatcher, current, tmp) {
|
|
127
|
+
HASH_DEL(common_data->name_to_dispatcher, current);
|
|
128
|
+
utarray_free(current->callbacks);
|
|
129
|
+
free(current);
|
|
130
|
+
}
|
|
131
|
+
|
|
121
132
|
// We allocate it, we need to free it
|
|
122
133
|
free(common_data->btx_params);
|
|
123
134
|
bt_value_put_ref(common_data->params);
|
|
@@ -157,8 +168,8 @@ BT_PLUGIN(<%= options[:plugin_name] %>);
|
|
|
157
168
|
/* Add the output component class */
|
|
158
169
|
BT_PLUGIN_SINK_COMPONENT_CLASS(<%= options[:component_name] %>, sink_consume);
|
|
159
170
|
|
|
160
|
-
BT_PLUGIN_SINK_COMPONENT_CLASS_INITIALIZE_METHOD(
|
|
161
|
-
|
|
171
|
+
BT_PLUGIN_SINK_COMPONENT_CLASS_INITIALIZE_METHOD(
|
|
172
|
+
<%= options[:component_name] %>, sink_initialize);
|
|
162
173
|
BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(<%= options[:component_name] %>,
|
|
163
174
|
sink_finalize);
|
|
164
175
|
|
data/template/source.c.erb
CHANGED
|
@@ -93,6 +93,7 @@ source_initialize(bt_self_component_source *self_component_source,
|
|
|
93
93
|
const bt_value *params, void *initialize_method_data) {
|
|
94
94
|
/* Allocate a private data structure */
|
|
95
95
|
common_data_t *common_data = calloc(1, sizeof(common_data_t));
|
|
96
|
+
common_data->btx_params = calloc(1, sizeof(btx_params_t));
|
|
96
97
|
common_data->params = params;
|
|
97
98
|
// Read parameters
|
|
98
99
|
btx_populate_params(common_data);
|
|
@@ -110,6 +111,8 @@ source_initialize(bt_self_component_source *self_component_source,
|
|
|
110
111
|
/* Instantiate a `downstream_trace` of `trace_class` and all the children
|
|
111
112
|
* stream */
|
|
112
113
|
common_data->downstream_trace = btx_downstream_trace_create_rec(trace_class);
|
|
114
|
+
btx_streams_get_ref(common_data->downstream_trace); // ??
|
|
115
|
+
bt_trace_class_put_ref(trace_class);
|
|
113
116
|
|
|
114
117
|
/* Set the component's user data to our private data structure */
|
|
115
118
|
bt_self_component_set_data(self_component, common_data);
|
|
@@ -161,6 +164,19 @@ source_message_iterator_initialize(
|
|
|
161
164
|
static void source_finalize(bt_self_component_source *self_component_source) {
|
|
162
165
|
common_data_t *common_data = bt_self_component_get_data(
|
|
163
166
|
bt_self_component_source_as_self_component(self_component_source));
|
|
167
|
+
|
|
168
|
+
btx_streams_put_ref(common_data->downstream_trace); // ??
|
|
169
|
+
// We allocate it, we need to put ref
|
|
170
|
+
bt_trace_put_ref(common_data->downstream_trace);
|
|
171
|
+
|
|
172
|
+
// Delete name_to_dispatcher
|
|
173
|
+
name_to_dispatcher_t *current, *tmp;
|
|
174
|
+
HASH_ITER(hh, common_data->name_to_dispatcher, current, tmp) {
|
|
175
|
+
HASH_DEL(common_data->name_to_dispatcher, current);
|
|
176
|
+
utarray_free(current->callbacks);
|
|
177
|
+
free(current);
|
|
178
|
+
}
|
|
179
|
+
|
|
164
180
|
// We allocate it, we need to free it
|
|
165
181
|
free(common_data->btx_params);
|
|
166
182
|
bt_value_put_ref(common_data->params);
|
|
@@ -190,10 +206,10 @@ BT_PLUGIN(<%= options[:plugin_name] %>);
|
|
|
190
206
|
BT_PLUGIN_SOURCE_COMPONENT_CLASS(<%= options[:component_name] %>,
|
|
191
207
|
source_message_iterator_next);
|
|
192
208
|
|
|
193
|
-
BT_PLUGIN_SOURCE_COMPONENT_CLASS_INITIALIZE_METHOD(
|
|
194
|
-
|
|
195
|
-
BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD(
|
|
196
|
-
|
|
209
|
+
BT_PLUGIN_SOURCE_COMPONENT_CLASS_INITIALIZE_METHOD(
|
|
210
|
+
<%= options[:component_name] %>, source_initialize);
|
|
211
|
+
BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD(
|
|
212
|
+
<%= options[:component_name] %>, source_finalize);
|
|
197
213
|
BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD(
|
|
198
214
|
<%= options[:component_name] %>, source_message_iterator_initialize);
|
|
199
215
|
BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD(
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metababel
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thomas Applencourt
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2023-
|
|
13
|
+
date: 2023-05-03 00:00:00.000000000 Z
|
|
14
14
|
dependencies: []
|
|
15
15
|
description:
|
|
16
16
|
email:
|
|
@@ -55,8 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
55
55
|
- !ruby/object:Gem::Version
|
|
56
56
|
version: '0'
|
|
57
57
|
requirements: []
|
|
58
|
-
|
|
59
|
-
rubygems_version: 2.7.6.3
|
|
58
|
+
rubygems_version: 3.3.3
|
|
60
59
|
signing_key:
|
|
61
60
|
specification_version: 4
|
|
62
61
|
summary: Helper for creation Babeltrace plugins
|