metababel 1.0.3 → 1.1.0
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/README.md +2 -2
- data/bin/btx_gen_source_callbacks +113 -0
- data/bin/metababel +75 -75
- data/lib/metababel/bt2_trace_class_generator.rb +76 -35
- data/lib/metababel/bt2_values_generator.rb +1 -1
- data/lib/metababel/version.rb +1 -1
- data/shared/stripper.cpp +57 -0
- data/template/component.c.erb +2 -2
- data/template/component.h.erb +10 -10
- data/template/downstream.c.erb +15 -4
- data/template/downstream.h.erb +6 -1
- data/template/filter.c.erb +20 -20
- data/template/metababel.h.erb +2 -2
- data/template/sink.c.erb +8 -11
- data/template/source.c.erb +19 -19
- data/template/upstream.c.erb +3 -3
- metadata +6 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 124ff9daf13cc0153c89747496e05c47c8b62ebead5ff692c0b131ff0f175fa5
|
|
4
|
+
data.tar.gz: 64df9b6129c3063d77bed406379e38c16ff272ad476b900d6ee6b00f1530d1ed
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 96938604f5fc1384574e842b6b5656a04893e666f502fdc3661e793f67081c5008402722eb5d9c5f5d47d52d63b95f854a4d3e5940fd8c43a5bb83d57c29deb4
|
|
7
|
+
data.tar.gz: 39e182c9fff334721aa613325cf6c526c3b392f829337c3bb3d53a876a28c8d8df12b428d11edc676c24ed9425af58c9d6b3070bfed9d9d3de875604efe0fee4
|
data/README.md
CHANGED
|
@@ -38,8 +38,8 @@ stateDiagram-v2
|
|
|
38
38
|
|
|
39
39
|
```mermaid
|
|
40
40
|
stateDiagram-v2
|
|
41
|
-
[*] -->
|
|
42
|
-
|
|
41
|
+
[*] --> BTX_FILTER_STATE_INITIALIZING
|
|
42
|
+
BTX_FILTER_STATE_INITIALIZING --> BTX_FILTER_PROCESSING
|
|
43
43
|
state BTX_FILTER_PROCESSING {
|
|
44
44
|
[*] --> BTX_FILTER_PROCESSING_STATE_READING
|
|
45
45
|
[*] --> BTX_FILTER_PROCESSING_STATE_SENDING
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'optparse'
|
|
4
|
+
require 'yaml'
|
|
5
|
+
require 'erb'
|
|
6
|
+
require 'time'
|
|
7
|
+
|
|
8
|
+
REGEXT_PRETTY = /
|
|
9
|
+
=\s # We are interested to the right of the equal sign
|
|
10
|
+
(
|
|
11
|
+
""| # Empty string
|
|
12
|
+
".*?[^\\]"| # String who can contain space and quoted string
|
|
13
|
+
[^\s,]+ # Anything except space and comma
|
|
14
|
+
)
|
|
15
|
+
/x.freeze
|
|
16
|
+
|
|
17
|
+
SOURCE_TEMPLATE = <<~TEXT.freeze
|
|
18
|
+
/* Code generated by #{__FILE__} */
|
|
19
|
+
|
|
20
|
+
#include <metababel/metababel.h>
|
|
21
|
+
|
|
22
|
+
void btx_push_usr_messages(void *btx_handle, void *usr_data, btx_source_status_t *status) {
|
|
23
|
+
<%- if not data.empty? and not data.first[:hostname].nil? -%>
|
|
24
|
+
btx_downstream_set_environment_hostname(btx_handle, "<%= data.first[:hostname] %>");
|
|
25
|
+
<%- end -%>
|
|
26
|
+
|
|
27
|
+
<%- data.each do | entry | -%>
|
|
28
|
+
<%- entry.fetch(:times,1).times do -%>
|
|
29
|
+
btx_push_message_<%= entry[:name] %>(btx_handle<%= ', ' if not entry[:field_values].empty? %><%= entry[:field_values].join(", ") %>);
|
|
30
|
+
<%- end -%>
|
|
31
|
+
<%- end -%>
|
|
32
|
+
|
|
33
|
+
*status = BTX_SOURCE_END;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void btx_register_usr_callbacks(void *btx_handle) {
|
|
37
|
+
btx_register_callbacks_push_usr_messages(btx_handle, &btx_push_usr_messages);
|
|
38
|
+
}
|
|
39
|
+
TEXT
|
|
40
|
+
|
|
41
|
+
def parse_event(line)
|
|
42
|
+
h = { hostname: nil,
|
|
43
|
+
name: nil,
|
|
44
|
+
field_values: [] }
|
|
45
|
+
# Parse a token one at a time
|
|
46
|
+
head, tail = line.split(nil, 2)
|
|
47
|
+
# Timestamp?
|
|
48
|
+
if head.start_with?('[')
|
|
49
|
+
t = Time.parse(head[1...-1])
|
|
50
|
+
# Need to convert in nasosecond
|
|
51
|
+
h[:field_values] << ((t.to_i * 1_000_000_000) + t.nsec)
|
|
52
|
+
# discard next token, the offset "(+x.xxxxxxxx)", which
|
|
53
|
+
# always follows the bracketed timestamp
|
|
54
|
+
_, head, tail = tail.split(nil, 3)
|
|
55
|
+
end
|
|
56
|
+
# Hostname?
|
|
57
|
+
unless head.end_with?(':')
|
|
58
|
+
h[:hostname] = head
|
|
59
|
+
head, tail = tail.split(nil, 2)
|
|
60
|
+
end
|
|
61
|
+
h[:name] = head.chop.gsub(/[^0-9A-Za-z-]/, '_')
|
|
62
|
+
# Handle the fields
|
|
63
|
+
h[:field_values] += tail.scan(REGEXT_PRETTY).flatten
|
|
64
|
+
h
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def parse_log(input_path)
|
|
68
|
+
File.open(input_path, 'r') do |file|
|
|
69
|
+
file.each_line.map do |line|
|
|
70
|
+
parse_event(line)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def render_and_save(data, output_path)
|
|
76
|
+
renderer = ERB.new(SOURCE_TEMPLATE, trim_mode: '-')
|
|
77
|
+
output = renderer.result(binding)
|
|
78
|
+
File.write(output_path, output, mode: 'w')
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
DOCS = <<-DOCS.freeze
|
|
82
|
+
Usage: #{$0}.rb [options]
|
|
83
|
+
|
|
84
|
+
Example:
|
|
85
|
+
ruby #{$0} -y stream_classes.yaml -i btx_log.txt -o callbacks.c
|
|
86
|
+
DOCS
|
|
87
|
+
|
|
88
|
+
# Display help if no arguments.
|
|
89
|
+
ARGV << '-h' if ARGV.empty?
|
|
90
|
+
|
|
91
|
+
options = {}
|
|
92
|
+
|
|
93
|
+
OptionParser.new do |opts|
|
|
94
|
+
opts.banner = DOCS
|
|
95
|
+
|
|
96
|
+
opts.on('-h', '--help', 'Prints this help') do
|
|
97
|
+
puts opts
|
|
98
|
+
exit
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
opts.on('-i', '--log PATH', '[Mandatory] Path to btx_log.txt.') do |p|
|
|
102
|
+
options[:input_path] = p
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
opts.on('-o', '--output PATH', '[Mandatory] Path to the bt2 SOURCE file.') do |p|
|
|
106
|
+
options[:output_path] = p
|
|
107
|
+
end
|
|
108
|
+
end.parse!
|
|
109
|
+
|
|
110
|
+
raise OptionParser::MissingArgument if options[:output_path].nil?
|
|
111
|
+
|
|
112
|
+
data = options.key?(:input_path) ? parse_log(options[:input_path]) : []
|
|
113
|
+
render_and_save(data, options[:output_path])
|
data/bin/metababel
CHANGED
|
@@ -8,6 +8,7 @@ require 'fileutils'
|
|
|
8
8
|
require 'set'
|
|
9
9
|
require 'ostruct'
|
|
10
10
|
require 'abbrev'
|
|
11
|
+
require 'pathname'
|
|
11
12
|
|
|
12
13
|
class Array
|
|
13
14
|
def join_with_prefix(sep)
|
|
@@ -92,7 +93,7 @@ class DispatchType < BaseDispatch
|
|
|
92
93
|
end
|
|
93
94
|
|
|
94
95
|
class Dispatcher < BaseDispatch
|
|
95
|
-
attr_reader :
|
|
96
|
+
attr_reader :event_name, :event, :name,
|
|
96
97
|
:index_stream_class, :index_event_class,
|
|
97
98
|
:default_clock_class,
|
|
98
99
|
:dispatch_types
|
|
@@ -160,75 +161,51 @@ def parse_argv
|
|
|
160
161
|
# Display help if no arguments.
|
|
161
162
|
ARGV << '-h' if ARGV.empty?
|
|
162
163
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
opts.banner = 'Usage: example.rb [options]'
|
|
169
|
-
|
|
170
|
-
opts.on('-h', '--help', 'Prints this help') do
|
|
171
|
-
puts opts
|
|
172
|
-
exit
|
|
173
|
-
end
|
|
164
|
+
parser = OptionParser.new
|
|
165
|
+
parser.on('-h', '--help', 'Prints this help') do
|
|
166
|
+
puts parser.help
|
|
167
|
+
exit
|
|
168
|
+
end
|
|
174
169
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
170
|
+
parser.on('-v', '--version', 'Prints this help') do
|
|
171
|
+
puts "Ruby: #{RUBY_VERSION}"
|
|
172
|
+
puts "Metababel: #{Metababel::VERSION}"
|
|
173
|
+
exit
|
|
174
|
+
end
|
|
180
175
|
|
|
181
|
-
|
|
176
|
+
parser.on('-t', '--component-type TYPE',
|
|
182
177
|
'[Mandatory] Node within a trace processing graph [one of: SINK, SOURCE, FILTER].') do |p|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
options[:component_type] = h[p.upcase]
|
|
188
|
-
end
|
|
178
|
+
l = %w[SOURCE FILTER SINK]
|
|
179
|
+
h = Abbrev.abbrev(l)
|
|
180
|
+
raise "Invalid component type, should be #{l} (case insensitive)" unless h.include?(p.upcase)
|
|
189
181
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
opts.on('-d', '--downstream PATH', '[Optional] Path to the bt2 YAML file for the downstream model.') do |p|
|
|
195
|
-
options[:downstream] = p
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
opts.on('-p', '--plugin-name PATH', '[Optional] Name of the bt2 plugin created.') do |p|
|
|
199
|
-
options[:plugin_name] = p
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
opts.on('-c', '--component-name PATH', '[Optional] Name of the bt2 componant created.') do |p|
|
|
203
|
-
options[:component_name] = p
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
opts.on('--params PATH', '[Optional] Paht to the bt2 YAML params definition.') do |p|
|
|
207
|
-
options[:params] = p
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
opts.on('-m', '--matching PATH', '[Optional] Path to bt2 YAML matching-callbacks definitions.') do |p|
|
|
211
|
-
options[:matching] = p
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
opts.on('-o', '--output FOLDER', '[Optional] Output folder path.') do |p|
|
|
215
|
-
options[:folder] = p
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
opts.on('-i', '--usr-data-header NAME', '[Optional] User datatypes definitions.') do |p|
|
|
219
|
-
options[:usr_data_header] = p
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
opts.on('--enable-callbacks NAME', Array, '[Optional] Enable some callbacks type') do |p|
|
|
223
|
-
options[:disable_callbaks] -= p.to_set
|
|
224
|
-
end
|
|
225
|
-
end.parse!
|
|
226
|
-
|
|
227
|
-
raise OptionParser::MissingArgument if options[:component_type].nil?
|
|
228
|
-
|
|
229
|
-
options[:plugin_name] ||= "metababel_#{options[:component_type].downcase}"
|
|
230
|
-
options[:component_name] ||= 'btx'
|
|
182
|
+
h[p.upcase]
|
|
183
|
+
end
|
|
231
184
|
|
|
185
|
+
parser.on('-u', '--upstreams PATHS', Array, '[Mandatory] Path to the bt2 YAML files for the upstream model.')
|
|
186
|
+
parser.on('-d', '--downstream PATH', '[Optional] Path to the bt2 YAML file for the downstream model.')
|
|
187
|
+
parser.on('-p', '--plugin-name PATH', '[Optional] Name of the bt2 plugin created.')
|
|
188
|
+
parser.on('-c', '--component-name PATH', '[Optional] Name of the bt2 component created.')
|
|
189
|
+
parser.on('--params PATH', '[Optional] Path to the bt2 YAML params definition.')
|
|
190
|
+
parser.on('-m', '--matching PATH', '[Optional] Path to bt2 YAML matching-callbacks definitions.')
|
|
191
|
+
parser.on('-o', '--output FOLDER', '[Optional] Output folder path.')
|
|
192
|
+
parser.on('-i', '--usr-data-header NAME', '[Optional] User datatypes definitions.')
|
|
193
|
+
parser.on('--enable-callbacks NAME', Array, '[Optional] Enable some callbacks type')
|
|
194
|
+
parser.on('--display-shared-callback PLUGIN') { |plugin|
|
|
195
|
+
path = Dir["#{__dir__}/../shared/*#{plugin}*"].first
|
|
196
|
+
puts File.readlines(path)
|
|
197
|
+
exit
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
options = { 'disable-callbaks': ['on_downstream'].to_set,
|
|
202
|
+
'component-name': 'btx',
|
|
203
|
+
}
|
|
204
|
+
parser.parse!(into: options)
|
|
205
|
+
raise OptionParser::MissingArgument if options[:'component-type'].nil?
|
|
206
|
+
|
|
207
|
+
options[:'plugin-name'] ||= "metababel_#{options[:'component-type'].downcase}"
|
|
208
|
+
options[:'disable-callbaks'] -= (options[:'enable-callbacks'] || []).to_set
|
|
232
209
|
options
|
|
233
210
|
end
|
|
234
211
|
|
|
@@ -313,7 +290,7 @@ class ContextBuilder
|
|
|
313
290
|
|
|
314
291
|
def base_folder
|
|
315
292
|
@base_folder ||= begin
|
|
316
|
-
f = @cli_options[:
|
|
293
|
+
f = @cli_options[:output] || "#{@cli_options[:'component-type']}.#{@cli_options[:'plugin-name']}.#{@cli_options[:'component-name']}"
|
|
317
294
|
FileUtils.mkdir_p(f)
|
|
318
295
|
f
|
|
319
296
|
end
|
|
@@ -377,15 +354,15 @@ class ContextBuilder
|
|
|
377
354
|
[GeneratedArg.new('void *', 'usr_data'),
|
|
378
355
|
GeneratedArg.new('btx_params_t *', 'usr_params')],
|
|
379
356
|
no_btx_handle: true)]
|
|
380
|
-
|
|
381
|
-
if %w[SOURCE FILTER].include?(@cli_options[:
|
|
357
|
+
|
|
358
|
+
if %w[SOURCE FILTER].include?(@cli_options[:'component-type'])
|
|
382
359
|
static_callbacks += [StaticDispatcher.new('initialize_processing',
|
|
383
360
|
[GeneratedArg.new('void *', 'usr_data_p')]),
|
|
384
361
|
StaticDispatcher.new('finalize_processing',
|
|
385
362
|
[GeneratedArg.new('void *', 'usr_data')])]
|
|
386
363
|
end
|
|
387
364
|
|
|
388
|
-
if %w[SOURCE].include?(@cli_options[:
|
|
365
|
+
if %w[SOURCE].include?(@cli_options[:'component-type'])
|
|
389
366
|
static_callbacks << StaticDispatcher.new('push_usr_messages',
|
|
390
367
|
[GeneratedArg.new('void *', 'usr_data'),
|
|
391
368
|
GeneratedArg.new('btx_source_status_t*', 'status')])
|
|
@@ -398,9 +375,11 @@ class ContextBuilder
|
|
|
398
375
|
|
|
399
376
|
def downstream
|
|
400
377
|
@downstream ||= begin
|
|
401
|
-
|
|
378
|
+
unless @cli_options[:downstream] || !@cli_options[:'disable-callbaks'].include?('on_downstream')
|
|
379
|
+
raise 'Missing downstream model'
|
|
380
|
+
end
|
|
402
381
|
|
|
403
|
-
y = load_models(@cli_options[:downstream])
|
|
382
|
+
y = @cli_options[:downstream] ? load_models(@cli_options[:downstream]) : { stream_classes: [] }
|
|
404
383
|
t = Babeltrace2Gen::BTTraceClass.from_h(nil, y)
|
|
405
384
|
|
|
406
385
|
event_name = '_event'
|
|
@@ -412,7 +391,20 @@ class ContextBuilder
|
|
|
412
391
|
t.get_declarator(variable: '_trace_class', self_component: '_self_component')
|
|
413
392
|
end
|
|
414
393
|
|
|
394
|
+
downstream_environements = if t.environment.nil?
|
|
395
|
+
[]
|
|
396
|
+
else
|
|
397
|
+
t.environment.entries.map do |e|
|
|
398
|
+
args = {}
|
|
399
|
+
body = "\n" + Babeltrace2Gen.context(indent: 1) do
|
|
400
|
+
e.get_setter(trace: '_trace', arg_variables: args)
|
|
401
|
+
end
|
|
402
|
+
[args['outputs'].first, body]
|
|
403
|
+
end
|
|
404
|
+
end
|
|
405
|
+
|
|
415
406
|
{ body_declarator_classes: body_declarator_classes,
|
|
407
|
+
downstream_environements: downstream_environements,
|
|
416
408
|
downstream_events: downstream_events,
|
|
417
409
|
stream_classes: t.stream_classes,
|
|
418
410
|
event_name: event_name }
|
|
@@ -421,7 +413,15 @@ class ContextBuilder
|
|
|
421
413
|
|
|
422
414
|
def upstream
|
|
423
415
|
@upstream ||= begin
|
|
424
|
-
|
|
416
|
+
unless @cli_options[:upstreams] || !@cli_options[:'disable-callbaks'].include?('on_downstream')
|
|
417
|
+
raise 'Missing upstreams models'
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
unless @cli_options[:upstreams]
|
|
421
|
+
return { dispatchers: [],
|
|
422
|
+
dispatch_types: [],
|
|
423
|
+
event_name: nil }
|
|
424
|
+
end
|
|
425
425
|
|
|
426
426
|
y = load_models(@cli_options[:upstreams])
|
|
427
427
|
t = Babeltrace2Gen::BTTraceClass.from_h(nil, y)
|
|
@@ -478,7 +478,7 @@ def wrote_component(cb)
|
|
|
478
478
|
end
|
|
479
479
|
|
|
480
480
|
def wrote_main(cb)
|
|
481
|
-
erb_render_and_save(cb.get_context(%w[params options]), "#{cb.cli_options[:
|
|
481
|
+
erb_render_and_save(cb.get_context(%w[params options]), "#{cb.cli_options[:'component-type'].downcase}.c",
|
|
482
482
|
cb.base_folder, out_name: 'main.c')
|
|
483
483
|
end
|
|
484
484
|
|
|
@@ -492,5 +492,5 @@ context_builder = ContextBuilder.new
|
|
|
492
492
|
wrote_header(context_builder)
|
|
493
493
|
wrote_main(context_builder)
|
|
494
494
|
wrote_component(context_builder)
|
|
495
|
-
wrote_downstream(context_builder) if %w[SOURCE FILTER].include?(context_builder.cli_options[:
|
|
496
|
-
wrote_upstream(context_builder) if %w[FILTER SINK].include?(context_builder.cli_options[:
|
|
495
|
+
wrote_downstream(context_builder) if %w[SOURCE FILTER].include?(context_builder.cli_options[:'component-type'])
|
|
496
|
+
wrote_upstream(context_builder) if %w[FILTER SINK].include?(context_builder.cli_options[:'component-type'])
|
|
@@ -41,8 +41,8 @@ module Babeltrace2Gen
|
|
|
41
41
|
is_a?(Babeltrace2Gen::BTEventClass) ? self : @parent.rec_event_class
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
def
|
|
45
|
-
is_a?(Babeltrace2Gen::BTMemberClass) ? self : @parent.
|
|
44
|
+
def rec_member_class
|
|
45
|
+
is_a?(Babeltrace2Gen::BTMemberClass) ? self : @parent.rec_member_class
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def resolve_path(path)
|
|
@@ -100,8 +100,6 @@ module Babeltrace2Gen
|
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
def get_declarator(variable:, self_component:)
|
|
103
|
-
raise NotImplementedError, "':environment' keyword not supported in downstream model" if environment
|
|
104
|
-
|
|
105
103
|
pr "#{variable} = bt_trace_class_create(#{self_component});"
|
|
106
104
|
bt_set_conditionally(@assigns_automatic_stream_class_id) do |v|
|
|
107
105
|
pr "bt_trace_class_set_assigns_automatic_stream_class_id(#{variable}, #{v});"
|
|
@@ -434,7 +432,7 @@ module Babeltrace2Gen
|
|
|
434
432
|
else
|
|
435
433
|
self.class.instance_variable_get(:@bt_type)
|
|
436
434
|
end
|
|
437
|
-
var = GeneratedArg.new(@cast_type || type,
|
|
435
|
+
var = GeneratedArg.new(@cast_type || type, rec_member_class.name)
|
|
438
436
|
|
|
439
437
|
arg_variables.fetch_append('outputs_allocated', var) if is_array
|
|
440
438
|
arg_variables.fetch_append('outputs', var)
|
|
@@ -450,7 +448,7 @@ module Babeltrace2Gen
|
|
|
450
448
|
def get_setter(field:, arg_variables:)
|
|
451
449
|
bt_func_get = self.class.instance_variable_get(:@bt_func) % 'set'
|
|
452
450
|
variable = bt_get_variable(arg_variables).name
|
|
453
|
-
# We always explicitly cast to the proper bebeltrace type when sending
|
|
451
|
+
# We always explicitly cast to the proper bebeltrace type when sending messages.
|
|
454
452
|
pr "#{bt_func_get}(#{field}, (#{self.class.instance_variable_get(:@bt_type)})#{variable});"
|
|
455
453
|
end
|
|
456
454
|
end
|
|
@@ -554,32 +552,69 @@ module Babeltrace2Gen
|
|
|
554
552
|
end
|
|
555
553
|
|
|
556
554
|
module BTFieldClass::Enumeration
|
|
557
|
-
|
|
555
|
+
class BTFieldClass::Enumeration::Mapping
|
|
556
|
+
extend BTFromH
|
|
557
|
+
include BTUtils
|
|
558
|
+
include BTPrinter
|
|
559
|
+
|
|
560
|
+
def initialize(parent:, label:, integer_range_set:)
|
|
561
|
+
@parent = parent
|
|
562
|
+
@label = label
|
|
563
|
+
# Form [ [lower,upper], ...]
|
|
564
|
+
@ranges = integer_range_set
|
|
565
|
+
end
|
|
566
|
+
|
|
567
|
+
def get_declarator(field_class:)
|
|
568
|
+
bt_type_internal = self.class.instance_variable_get(:@bt_type_internal)
|
|
569
|
+
scope do
|
|
570
|
+
pr "bt_integer_range_set_#{bt_type_internal} *#{field_class}_range;"
|
|
571
|
+
pr "#{field_class}_range = bt_integer_range_set_#{bt_type_internal}_create();"
|
|
572
|
+
@ranges.each do |l, u|
|
|
573
|
+
pr "bt_integer_range_set_#{bt_type_internal}_add_range(#{field_class}_range, #{l}, #{u});"
|
|
574
|
+
end
|
|
575
|
+
pr "bt_field_class_enumeration_#{bt_type_internal}_add_mapping(#{field_class}, \"#{@label}\", #{field_class}_range);"
|
|
576
|
+
pr "bt_integer_range_set_#{bt_type_internal}_put_ref(#{field_class}_range);"
|
|
577
|
+
end
|
|
578
|
+
end
|
|
579
|
+
end
|
|
558
580
|
|
|
559
|
-
|
|
581
|
+
def initialize(parent:, mappings:)
|
|
582
|
+
@parent = parent
|
|
583
|
+
@mappings = mappings.map do |mapping|
|
|
584
|
+
# Handle inheritence
|
|
585
|
+
self.class.const_get('Mapping').from_h(self, mapping)
|
|
586
|
+
end
|
|
587
|
+
end
|
|
588
|
+
|
|
589
|
+
def get_declarator(trace_class:, variable:)
|
|
590
|
+
bt_type_internal = self.class.instance_variable_get(:@bt_type_internal)
|
|
591
|
+
pr "#{variable} = bt_field_class_enumeration_#{bt_type_internal}_create(#{trace_class});"
|
|
592
|
+
@mappings.each do |mapping|
|
|
593
|
+
mapping.get_declarator(field_class: variable)
|
|
594
|
+
end
|
|
560
595
|
end
|
|
561
596
|
end
|
|
562
597
|
|
|
563
598
|
class BTFieldClass::Enumeration::Unsigned < BTFieldClass::Integer::Unsigned
|
|
564
599
|
include BTFieldClass::Enumeration
|
|
565
|
-
class Mapping < BTFieldClass::Enumeration::Mapping
|
|
600
|
+
class BTFieldClass::Enumeration::Unsigned::Mapping < BTFieldClass::Enumeration::Mapping
|
|
601
|
+
@bt_type_internal = 'unsigned'
|
|
566
602
|
end
|
|
567
603
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
end
|
|
604
|
+
@bt_type = 'uint64_t'
|
|
605
|
+
@bt_type_internal = 'unsigned'
|
|
606
|
+
@bt_func = 'bt_field_integer_unsigned_%s_value'
|
|
572
607
|
end
|
|
573
608
|
|
|
574
609
|
class BTFieldClass::Enumeration::Signed < BTFieldClass::Integer::Signed
|
|
575
610
|
include BTFieldClass::Enumeration
|
|
576
|
-
class Mapping < BTFieldClass::Enumeration::Mapping
|
|
611
|
+
class BTFieldClass::Enumeration::Signed::Mapping < BTFieldClass::Enumeration::Mapping
|
|
612
|
+
@bt_type_internal = 'signed'
|
|
577
613
|
end
|
|
578
614
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
end
|
|
615
|
+
@bt_type = 'int64_t'
|
|
616
|
+
@bt_type_internal = 'signed'
|
|
617
|
+
@bt_func = 'bt_field_integer_signed_%s_value'
|
|
583
618
|
end
|
|
584
619
|
|
|
585
620
|
class BTFieldClass::String < BTFieldClass
|
|
@@ -599,7 +634,7 @@ module Babeltrace2Gen
|
|
|
599
634
|
bt_func_get = self.class.instance_variable_get(:@bt_func) % 'get'
|
|
600
635
|
variable = bt_get_variable(arg_variables).name
|
|
601
636
|
|
|
602
|
-
pr
|
|
637
|
+
pr '// Dump string data to the struct.'
|
|
603
638
|
pr "memcpy(&#{variable}, #{bt_func_get}(#{field}), sizeof(#{variable}));"
|
|
604
639
|
end
|
|
605
640
|
|
|
@@ -608,12 +643,12 @@ module Babeltrace2Gen
|
|
|
608
643
|
|
|
609
644
|
variable = bt_get_variable(arg_variables).name
|
|
610
645
|
|
|
611
|
-
pr
|
|
646
|
+
pr '// Dump data to a temporal string.'
|
|
612
647
|
pr "char *#{field}_temp = (char *)malloc(sizeof(#{variable}));"
|
|
613
648
|
pr "assert(#{field}_temp != NULL && \"Out of memory\");"
|
|
614
649
|
pr "memcpy(#{field}_temp, &#{variable}, sizeof(#{variable}));"
|
|
615
|
-
pr
|
|
616
|
-
pr
|
|
650
|
+
pr ''
|
|
651
|
+
pr '// Set string field with dumped data.'
|
|
617
652
|
pr "bt_field_string_clear(#{field});"
|
|
618
653
|
pr "bt_field_string_append_status #{field}_status = bt_field_string_append_with_length(#{field}, #{field}_temp, sizeof(#{variable}));"
|
|
619
654
|
pr "assert(#{field}_status == BT_FIELD_STRING_APPEND_STATUS_OK && \"Out of memory\");"
|
|
@@ -673,7 +708,6 @@ module Babeltrace2Gen
|
|
|
673
708
|
@element_field_class.get_getter(field: v, arg_variables: arg_variables)
|
|
674
709
|
end
|
|
675
710
|
end
|
|
676
|
-
|
|
677
711
|
end
|
|
678
712
|
|
|
679
713
|
class BTFieldClass::Array::Dynamic < BTFieldClass::Array
|
|
@@ -761,13 +795,14 @@ module Babeltrace2Gen
|
|
|
761
795
|
def initialize(parent:, field_class: nil, name: nil)
|
|
762
796
|
@parent = parent
|
|
763
797
|
is_match_model = parent.rec_trace_class.match
|
|
764
|
-
raise ArgumentError
|
|
765
|
-
raise ArgumentError
|
|
798
|
+
raise ArgumentError, 'missing keyword: :name' unless name || is_match_model
|
|
799
|
+
raise ArgumentError, 'missing keyword: :field_class' unless field_class || is_match_model
|
|
800
|
+
|
|
766
801
|
@name = name # Name can be nil in the matching callbacks
|
|
767
|
-
@field_class = BTFieldClass.from_h(self, field_class || {}
|
|
802
|
+
@field_class = BTFieldClass.from_h(self, field_class || {})
|
|
768
803
|
end
|
|
769
804
|
|
|
770
|
-
def bt_get_variable
|
|
805
|
+
def bt_get_variable
|
|
771
806
|
@field_class.bt_get_variable({})
|
|
772
807
|
end
|
|
773
808
|
end
|
|
@@ -985,15 +1020,20 @@ module Babeltrace2Gen
|
|
|
985
1020
|
end
|
|
986
1021
|
|
|
987
1022
|
def get_getter(trace:, arg_variables:)
|
|
988
|
-
var_name =
|
|
989
|
-
arg_variables.fetch_append('outputs', bt_get_variable)
|
|
990
|
-
bt_func_get = self.class.instance_variable_get(:@bt_func)
|
|
1023
|
+
var_name = bt_get_variable(arg_variables).name
|
|
991
1024
|
pr "const bt_value *#{var_name}_value = bt_trace_borrow_environment_entry_value_by_name_const(#{trace}, \"#{var_name}\");"
|
|
992
|
-
pr "#{var_name} = #{
|
|
1025
|
+
pr "#{var_name} = bt_value_#{@type}_get(#{var_name}_value);"
|
|
993
1026
|
end
|
|
994
1027
|
|
|
995
|
-
def
|
|
996
|
-
|
|
1028
|
+
def get_setter(trace:, arg_variables:)
|
|
1029
|
+
var_name = bt_get_variable(arg_variables).name
|
|
1030
|
+
bt_type_set = self.class.instance_variable_get(:@bt_type_set)
|
|
1031
|
+
pr "bt_trace_set_environment_entry_#{bt_type_set}(#{trace}, \"#{var_name}\", #{var_name});"
|
|
1032
|
+
end
|
|
1033
|
+
|
|
1034
|
+
def bt_get_variable(arg_variables = {})
|
|
1035
|
+
var = GeneratedArg.new(self.class.instance_variable_get(:@bt_type), @name)
|
|
1036
|
+
arg_variables.fetch_append('outputs', var)
|
|
997
1037
|
end
|
|
998
1038
|
end
|
|
999
1039
|
|
|
@@ -1005,13 +1045,14 @@ module Babeltrace2Gen
|
|
|
1005
1045
|
extend BTFromH
|
|
1006
1046
|
|
|
1007
1047
|
@bt_type = 'const char*'
|
|
1008
|
-
@
|
|
1048
|
+
@bt_type_set = 'string'
|
|
1009
1049
|
end
|
|
1010
1050
|
|
|
1011
1051
|
class BTEntryClass::IntegerSigned < BTEntryClass
|
|
1012
1052
|
extend BTFromH
|
|
1013
1053
|
|
|
1014
1054
|
@bt_type = 'int64_t'
|
|
1015
|
-
|
|
1055
|
+
# Sadly it's ` bt_trace_set_environment_entry_integer() ` and not ` bt_trace_set_environment_entry_integer_signed()`
|
|
1056
|
+
@bt_type_set = 'integer'
|
|
1016
1057
|
end
|
|
1017
1058
|
end
|
data/lib/metababel/version.rb
CHANGED
data/shared/stripper.cpp
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#include <babeltrace2/babeltrace.h>
|
|
2
|
+
#include <metababel/metababel.h>
|
|
3
|
+
#include <unordered_map>
|
|
4
|
+
|
|
5
|
+
typedef std::unordered_map<const bt_stream *, const bt_message *> StreamToMessage_t;
|
|
6
|
+
|
|
7
|
+
static void btx_initialize_usr_data(void **usr_data) { *usr_data = new StreamToMessage_t{}; }
|
|
8
|
+
|
|
9
|
+
static void btx_finalize_usr_data(void *usr_data) { delete ((StreamToMessage_t *)(usr_data)); }
|
|
10
|
+
|
|
11
|
+
static void on_downstream_message_callback(void *btx_handle, void *usr_data,
|
|
12
|
+
const bt_message *message) {
|
|
13
|
+
|
|
14
|
+
auto *h = (StreamToMessage_t *)usr_data;
|
|
15
|
+
switch (bt_message_get_type(message)) {
|
|
16
|
+
// Just forward the first message
|
|
17
|
+
case (BT_MESSAGE_TYPE_STREAM_BEGINNING): {
|
|
18
|
+
const bt_stream *stream = bt_message_stream_beginning_borrow_stream_const(message);
|
|
19
|
+
h->insert({stream, message});
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
case (BT_MESSAGE_TYPE_EVENT): {
|
|
23
|
+
// If required Pop and Push stream_begin message associated with the stream of the current
|
|
24
|
+
// message
|
|
25
|
+
const bt_event *event = bt_message_event_borrow_event_const(message);
|
|
26
|
+
const bt_stream *stream = bt_event_borrow_stream_const(event);
|
|
27
|
+
auto it = h->find(stream);
|
|
28
|
+
if (it != h->end()) {
|
|
29
|
+
btx_push_message(btx_handle, it->second);
|
|
30
|
+
h->erase(it);
|
|
31
|
+
}
|
|
32
|
+
btx_push_message(btx_handle, message);
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
case (BT_MESSAGE_TYPE_STREAM_END): {
|
|
36
|
+
const bt_stream *stream = bt_message_stream_end_borrow_stream_const(message);
|
|
37
|
+
auto it = h->find(stream);
|
|
38
|
+
// Only send stream_end message if begin have been sent, if not drop
|
|
39
|
+
if (it == h->end()) {
|
|
40
|
+
btx_push_message(btx_handle, message);
|
|
41
|
+
} else {
|
|
42
|
+
bt_message_put_ref(message);
|
|
43
|
+
bt_message_put_ref(it->second);
|
|
44
|
+
h->erase(it);
|
|
45
|
+
}
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
default:
|
|
49
|
+
bt_message_put_ref(message);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void btx_register_usr_callbacks(void *btx_handle) {
|
|
54
|
+
btx_register_callbacks_initialize_component(btx_handle, &btx_initialize_usr_data);
|
|
55
|
+
btx_register_callbacks_finalize_component(btx_handle, &btx_finalize_usr_data);
|
|
56
|
+
btx_register_on_downstream_message_callback(btx_handle, &on_downstream_message_callback);
|
|
57
|
+
}
|
data/template/component.c.erb
CHANGED
|
@@ -27,8 +27,8 @@ void btx_call_callbacks_<%= e.name_sanitized %>(
|
|
|
27
27
|
<%= e.name_sanitized %>_static_callback_f *p =
|
|
28
28
|
common_data->static_callbacks-><%= e.name_sanitized %>;
|
|
29
29
|
if (p)
|
|
30
|
-
p(
|
|
31
|
-
|
|
30
|
+
p(<%= "(void *)common_data," unless e.no_btx_handle %>
|
|
31
|
+
<%= e.args.map{ |s| s.name }.join(", ") %>);
|
|
32
32
|
}
|
|
33
33
|
<% end %>
|
|
34
34
|
|
data/template/component.h.erb
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
#include "uthash.h"
|
|
5
5
|
#include <babeltrace2/babeltrace.h>
|
|
6
6
|
#include <stdbool.h>
|
|
7
|
-
<% if options.key?(:
|
|
8
|
-
#include "<%= options[:
|
|
7
|
+
<% if options.key?(:'usr-data-header') %>
|
|
8
|
+
#include "<%= options[:'usr-data-header'] %>"
|
|
9
9
|
<% end %>
|
|
10
10
|
|
|
11
11
|
#ifdef __cplusplus
|
|
@@ -50,7 +50,7 @@ struct name_to_dispatcher_s {
|
|
|
50
50
|
};
|
|
51
51
|
typedef struct name_to_dispatcher_s name_to_dispatcher_t;
|
|
52
52
|
|
|
53
|
-
<% if ['SOURCE', 'FILTER'].include?(options[:
|
|
53
|
+
<% if ['SOURCE', 'FILTER'].include?(options[:'component-type']) %>
|
|
54
54
|
// Structure for Downstream Message
|
|
55
55
|
struct el {
|
|
56
56
|
const bt_message *message;
|
|
@@ -59,11 +59,11 @@ struct el {
|
|
|
59
59
|
|
|
60
60
|
<% end %>
|
|
61
61
|
// Struct stored in the component via `bt_self_component_set_data`
|
|
62
|
-
<% if options[:
|
|
62
|
+
<% if options[:'component-type'] == 'SOURCE' %>
|
|
63
63
|
struct common_data_s {
|
|
64
64
|
name_to_dispatcher_t *name_to_dispatcher;
|
|
65
65
|
static_callbacks_t *static_callbacks;
|
|
66
|
-
<% unless options[:
|
|
66
|
+
<% unless options[:'disable-callbaks'].include?('on_downstream') %>
|
|
67
67
|
void *on_downstream_message_callback;
|
|
68
68
|
<% end %>
|
|
69
69
|
void *usr_data;
|
|
@@ -101,11 +101,11 @@ enum btx_source_status_e {
|
|
|
101
101
|
};
|
|
102
102
|
typedef enum btx_source_status_e btx_source_status_t;
|
|
103
103
|
|
|
104
|
-
<% elsif options[:
|
|
104
|
+
<% elsif options[:'component-type'] == 'FILTER' %>
|
|
105
105
|
struct common_data_s {
|
|
106
106
|
name_to_dispatcher_t *name_to_dispatcher;
|
|
107
107
|
static_callbacks_t *static_callbacks;
|
|
108
|
-
<% unless options[:
|
|
108
|
+
<% unless options[:'disable-callbaks'].include?('on_downstream') %>
|
|
109
109
|
void *on_downstream_message_callback;
|
|
110
110
|
<% end %>
|
|
111
111
|
|
|
@@ -155,7 +155,7 @@ struct btx_message_iterator_s {
|
|
|
155
155
|
};
|
|
156
156
|
typedef struct btx_message_iterator_s btx_message_iterator_t;
|
|
157
157
|
|
|
158
|
-
<% elsif options[:
|
|
158
|
+
<% elsif options[:'component-type'] == 'SINK' %>
|
|
159
159
|
struct common_data_s {
|
|
160
160
|
name_to_dispatcher_t *name_to_dispatcher;
|
|
161
161
|
static_callbacks_t *static_callbacks;
|
|
@@ -173,8 +173,8 @@ void btx_unregister_callbacks(common_data_t *common_data);
|
|
|
173
173
|
|
|
174
174
|
<% static_callback_types.each do |e| %>
|
|
175
175
|
typedef void <%= e.name_sanitized %>_static_callback_f(
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
<%= "void *btx_handle," unless e.no_btx_handle %>
|
|
177
|
+
<%= e.args.map{ |s| s.type }.join(", ") %>);
|
|
178
178
|
|
|
179
179
|
<%# The Function who register the callbacks to the dispatcher %>
|
|
180
180
|
void btx_register_callbacks_<%= e.name_sanitized %>(
|
data/template/downstream.c.erb
CHANGED
|
@@ -35,7 +35,7 @@ _btx_push_message(btx_message_iterator_t *message_iterator_private_data,
|
|
|
35
35
|
DL_APPEND(message_iterator_private_data->queue, elt);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
<% unless options[:
|
|
38
|
+
<% unless options[:'disable-callbaks'].include?('on_downstream') %>
|
|
39
39
|
void btx_push_message(void *btx_handle, const bt_message *message) {
|
|
40
40
|
_btx_push_message((btx_message_iterator_t *)btx_handle, message);
|
|
41
41
|
}
|
|
@@ -46,12 +46,12 @@ void btx_register_on_downstream_message_callback(
|
|
|
46
46
|
(void *)callback;
|
|
47
47
|
}
|
|
48
48
|
<% end %>
|
|
49
|
-
// Used
|
|
49
|
+
// Used internally to push messages downstreams
|
|
50
50
|
void btx_downstream_push_message(
|
|
51
51
|
btx_message_iterator_t *message_iterator_private_data,
|
|
52
52
|
const bt_message *message) {
|
|
53
53
|
|
|
54
|
-
<% unless options[:
|
|
54
|
+
<% unless options[:'disable-callbaks'].include?('on_downstream') %>
|
|
55
55
|
on_downstream_message_callback_f *p =
|
|
56
56
|
(on_downstream_message_callback_f *)message_iterator_private_data
|
|
57
57
|
->common_data->on_downstream_message_callback;
|
|
@@ -84,7 +84,7 @@ bt_trace *btx_downstream_trace_create_rec(bt_trace_class *trace_class) {
|
|
|
84
84
|
return trace;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
//
|
|
87
|
+
// Workaround of a bug where gepping trace alive (and not the stream) provoke
|
|
88
88
|
// some segfault
|
|
89
89
|
void btx_streams_get_ref(bt_trace *trace) {
|
|
90
90
|
<% stream_classes.each_with_index do |_,i| %>
|
|
@@ -118,6 +118,7 @@ void btx_push_messages_stream_beginning(
|
|
|
118
118
|
btx_downstream_push_message(message_iterator_private_data, message);
|
|
119
119
|
}
|
|
120
120
|
<% end %>
|
|
121
|
+
(void)trace;
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
void btx_push_messages_stream_end(
|
|
@@ -134,6 +135,7 @@ void btx_push_messages_stream_end(
|
|
|
134
135
|
btx_downstream_push_message(message_iterator_private_data, message);
|
|
135
136
|
}
|
|
136
137
|
<% end %>
|
|
138
|
+
(void)trace;
|
|
137
139
|
}
|
|
138
140
|
|
|
139
141
|
<% downstream_events.each do |e| %>
|
|
@@ -173,3 +175,12 @@ void btx_push_message_<%= e.name_sanitized %>(
|
|
|
173
175
|
btx_downstream_push_message(_message_iterator_private_data, _message);
|
|
174
176
|
}
|
|
175
177
|
<% end %>
|
|
178
|
+
|
|
179
|
+
<% downstream_environements.each do |arg, body| %>
|
|
180
|
+
void btx_downstream_set_environment_<%= arg.name%>(
|
|
181
|
+
void *btx_handle, <%= arg.type%> <%= arg.name%>) {
|
|
182
|
+
common_data_t *common_data = (common_data_t *)btx_handle;
|
|
183
|
+
bt_trace *_trace = common_data->downstream_trace;
|
|
184
|
+
<%= body %>
|
|
185
|
+
}
|
|
186
|
+
<% end %>
|
data/template/downstream.h.erb
CHANGED
|
@@ -33,7 +33,7 @@ void btx_push_message_<%= e.name_sanitized %>(
|
|
|
33
33
|
btx_handle<%= e.args.map{ |s| "#{s.type} #{s.name}" }.join_with_prefix(", ") %>);
|
|
34
34
|
<% end %>
|
|
35
35
|
|
|
36
|
-
<% unless options[:
|
|
36
|
+
<% unless options[:'disable-callbaks'].include?('on_downstream') %>
|
|
37
37
|
void btx_push_message(void *btx_handle, const bt_message *message);
|
|
38
38
|
|
|
39
39
|
typedef void on_downstream_message_callback_f(void *btx_handle, void *usr_data,
|
|
@@ -42,6 +42,11 @@ void btx_register_on_downstream_message_callback(
|
|
|
42
42
|
void *btx_handle, on_downstream_message_callback_f *callback);
|
|
43
43
|
<% end %>
|
|
44
44
|
|
|
45
|
+
<% downstream_environements.each do |arg, body| %>
|
|
46
|
+
void btx_downstream_set_environment_<%= arg.name%>(
|
|
47
|
+
void *btx_handle, <%= arg.type%> <%= arg.name%>);
|
|
48
|
+
<% end %>
|
|
49
|
+
|
|
45
50
|
#ifdef __cplusplus
|
|
46
51
|
}
|
|
47
52
|
#endif
|
data/template/filter.c.erb
CHANGED
|
@@ -264,7 +264,7 @@ filter_message_iterator_next_initializing(
|
|
|
264
264
|
(btx_message_iterator_t *)bt_self_message_iterator_get_data(
|
|
265
265
|
self_message_iterator);
|
|
266
266
|
|
|
267
|
-
/*
|
|
267
|
+
/* Beginning of Stream */
|
|
268
268
|
btx_push_messages_stream_beginning(self_message_iterator,
|
|
269
269
|
message_iterator_private_data);
|
|
270
270
|
|
|
@@ -347,18 +347,6 @@ filter_initialize(bt_self_component_filter *self_component_filter,
|
|
|
347
347
|
common_data->btx_params = (btx_params_t *)calloc(1, sizeof(btx_params_t));
|
|
348
348
|
common_data->params = params;
|
|
349
349
|
|
|
350
|
-
/* Read parameters */
|
|
351
|
-
btx_populate_params(common_data);
|
|
352
|
-
bt_value_get_ref(common_data->params);
|
|
353
|
-
|
|
354
|
-
/* Register User Callbacks */
|
|
355
|
-
btx_register_usr_callbacks((void *)common_data);
|
|
356
|
-
/* Call initialize_processing*/
|
|
357
|
-
btx_call_callbacks_initialize_component(common_data, &common_data->usr_data);
|
|
358
|
-
/* Call read callbacks */
|
|
359
|
-
btx_call_callbacks_read_params(common_data, common_data->usr_data,
|
|
360
|
-
common_data->btx_params);
|
|
361
|
-
|
|
362
350
|
/* Set the component's user data to our private data structure */
|
|
363
351
|
bt_self_component_set_data(
|
|
364
352
|
bt_self_component_filter_as_self_component(self_component_filter),
|
|
@@ -406,6 +394,18 @@ filter_initialize(bt_self_component_filter *self_component_filter,
|
|
|
406
394
|
btx_streams_get_ref(common_data->downstream_trace); // ??
|
|
407
395
|
bt_trace_class_put_ref(trace_class);
|
|
408
396
|
|
|
397
|
+
/* Read parameters */
|
|
398
|
+
btx_populate_params(common_data);
|
|
399
|
+
bt_value_get_ref(common_data->params);
|
|
400
|
+
|
|
401
|
+
/* Register User Callbacks */
|
|
402
|
+
btx_register_usr_callbacks((void *)common_data);
|
|
403
|
+
/* Call initialize_processing*/
|
|
404
|
+
btx_call_callbacks_initialize_component(common_data, &common_data->usr_data);
|
|
405
|
+
/* Call read callbacks */
|
|
406
|
+
btx_call_callbacks_read_params(common_data, common_data->usr_data,
|
|
407
|
+
common_data->btx_params);
|
|
408
|
+
|
|
409
409
|
return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
|
|
410
410
|
}
|
|
411
411
|
|
|
@@ -519,17 +519,17 @@ static void filter_message_iterator_finalize(
|
|
|
519
519
|
/* Mandatory */
|
|
520
520
|
BT_PLUGIN_MODULE();
|
|
521
521
|
|
|
522
|
-
BT_PLUGIN(<%= options[:
|
|
523
|
-
BT_PLUGIN_FILTER_COMPONENT_CLASS(<%= options[:
|
|
522
|
+
BT_PLUGIN(<%= options[:'plugin-name'] %>);
|
|
523
|
+
BT_PLUGIN_FILTER_COMPONENT_CLASS(<%= options[:'component-name'] %>,
|
|
524
524
|
filter_message_iterator_next);
|
|
525
525
|
|
|
526
526
|
BT_PLUGIN_FILTER_COMPONENT_CLASS_INITIALIZE_METHOD(
|
|
527
|
-
<%= options[:
|
|
527
|
+
<%= options[:'component-name'] %>, filter_initialize);
|
|
528
528
|
BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD(
|
|
529
|
-
<%= options[:
|
|
529
|
+
<%= options[:'component-name'] %>, filter_finalize);
|
|
530
530
|
BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD(
|
|
531
|
-
<%= options[:
|
|
531
|
+
<%= options[:'component-name'] %>, filter_message_iterator_initialize);
|
|
532
532
|
BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD(
|
|
533
|
-
<%= options[:
|
|
533
|
+
<%= options[:'component-name'] %>, filter_message_iterator_finalize);
|
|
534
534
|
BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD(
|
|
535
|
-
<%= options[:
|
|
535
|
+
<%= options[:'component-name'] %>, filter_input_port_connected);
|
data/template/metababel.h.erb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#include <metababel/btx_component.h>
|
|
2
|
-
<% if ['SOURCE', 'FILTER'].include?(options[:
|
|
2
|
+
<% if ['SOURCE', 'FILTER'].include?(options[:'component-type']) %>
|
|
3
3
|
#include <metababel/btx_downstream.h>
|
|
4
4
|
<% end %>
|
|
5
|
-
<% if ['FILTER', 'SINK'].include?(options[:
|
|
5
|
+
<% if ['FILTER', 'SINK'].include?(options[:'component-type']) %>
|
|
6
6
|
#include <metababel/btx_upstream.h>
|
|
7
7
|
<% end %>
|
data/template/sink.c.erb
CHANGED
|
@@ -18,7 +18,7 @@ sink_consume(bt_self_component_sink *self_component_sink) {
|
|
|
18
18
|
BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
|
|
19
19
|
|
|
20
20
|
/* Retrieve our private data from the component's user data */
|
|
21
|
-
/* This
|
|
21
|
+
/* This contain user data and the message iterator */
|
|
22
22
|
common_data_t *common_data = (common_data_t *)bt_self_component_get_data(
|
|
23
23
|
bt_self_component_sink_as_self_component(self_component_sink));
|
|
24
24
|
|
|
@@ -153,7 +153,7 @@ sink_graph_is_configured(bt_self_component_sink *self_component_sink) {
|
|
|
153
153
|
bt_self_component_port_input *in_port =
|
|
154
154
|
bt_self_component_sink_borrow_input_port_by_index(self_component_sink, 0);
|
|
155
155
|
|
|
156
|
-
/* Create the
|
|
156
|
+
/* Create the upstream message iterator */
|
|
157
157
|
bt_message_iterator_create_from_sink_component(
|
|
158
158
|
self_component_sink, in_port, &common_data->message_iterator);
|
|
159
159
|
|
|
@@ -163,15 +163,12 @@ sink_graph_is_configured(bt_self_component_sink *self_component_sink) {
|
|
|
163
163
|
/* Mandatory */
|
|
164
164
|
BT_PLUGIN_MODULE();
|
|
165
165
|
|
|
166
|
-
BT_PLUGIN(<%= options[:
|
|
167
|
-
|
|
168
|
-
/* Add the output component class */
|
|
169
|
-
BT_PLUGIN_SINK_COMPONENT_CLASS(<%= options[:component_name] %>, sink_consume);
|
|
166
|
+
BT_PLUGIN(<%= options[:'plugin-name'] %>);
|
|
167
|
+
BT_PLUGIN_SINK_COMPONENT_CLASS(<%= options[:'component-name'] %>, sink_consume);
|
|
170
168
|
|
|
171
169
|
BT_PLUGIN_SINK_COMPONENT_CLASS_INITIALIZE_METHOD(
|
|
172
|
-
<%= options[:
|
|
173
|
-
BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(
|
|
174
|
-
|
|
175
|
-
|
|
170
|
+
<%= options[:'component-name'] %>, sink_initialize);
|
|
171
|
+
BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(
|
|
172
|
+
<%= options[:'component-name'] %>, sink_finalize);
|
|
176
173
|
BT_PLUGIN_SINK_COMPONENT_CLASS_GRAPH_IS_CONFIGURED_METHOD(
|
|
177
|
-
<%= options[:
|
|
174
|
+
<%= options[:'component-name'] %>, sink_graph_is_configured);
|
data/template/source.c.erb
CHANGED
|
@@ -33,7 +33,7 @@ source_message_iterator_next(bt_self_message_iterator *self_message_iterator,
|
|
|
33
33
|
* not put any message into the message array */
|
|
34
34
|
switch (message_iterator_private_data->state) {
|
|
35
35
|
case BTX_SOURCE_STATE_INITIALIZING:
|
|
36
|
-
/*
|
|
36
|
+
/* Beginning of Stream */
|
|
37
37
|
btx_push_messages_stream_beginning(self_message_iterator,
|
|
38
38
|
message_iterator_private_data);
|
|
39
39
|
/* Call Initialize user callback */
|
|
@@ -96,18 +96,6 @@ source_initialize(bt_self_component_source *self_component_source,
|
|
|
96
96
|
common_data->btx_params = (btx_params_t *)calloc(1, sizeof(btx_params_t));
|
|
97
97
|
common_data->params = params;
|
|
98
98
|
|
|
99
|
-
/* Read parameters */
|
|
100
|
-
btx_populate_params(common_data);
|
|
101
|
-
bt_value_get_ref(common_data->params);
|
|
102
|
-
|
|
103
|
-
/* Register User Callbacks */
|
|
104
|
-
btx_register_usr_callbacks((void *)common_data);
|
|
105
|
-
/* Call initialize_processing*/
|
|
106
|
-
btx_call_callbacks_initialize_component(common_data, &common_data->usr_data);
|
|
107
|
-
/* Call read callbacks */
|
|
108
|
-
btx_call_callbacks_read_params(common_data, common_data->usr_data,
|
|
109
|
-
common_data->btx_params);
|
|
110
|
-
|
|
111
99
|
/* Upcast `self_component_source` to the `bt_self_component` type */
|
|
112
100
|
bt_self_component *self_component =
|
|
113
101
|
bt_self_component_source_as_self_component(self_component_source);
|
|
@@ -134,6 +122,18 @@ source_initialize(bt_self_component_source *self_component_source,
|
|
|
134
122
|
bt_self_component_source_add_output_port(self_component_source, "out", NULL,
|
|
135
123
|
NULL);
|
|
136
124
|
|
|
125
|
+
/* Read parameters */
|
|
126
|
+
btx_populate_params(common_data);
|
|
127
|
+
bt_value_get_ref(common_data->params);
|
|
128
|
+
|
|
129
|
+
/* Register User Callbacks */
|
|
130
|
+
btx_register_usr_callbacks((void *)common_data);
|
|
131
|
+
/* Call initialize_processing*/
|
|
132
|
+
btx_call_callbacks_initialize_component(common_data, &common_data->usr_data);
|
|
133
|
+
/* Call read callbacks */
|
|
134
|
+
btx_call_callbacks_read_params(common_data, common_data->usr_data,
|
|
135
|
+
common_data->btx_params);
|
|
136
|
+
|
|
137
137
|
return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
|
|
138
138
|
}
|
|
139
139
|
|
|
@@ -209,15 +209,15 @@ static void source_message_iterator_finalize(
|
|
|
209
209
|
/* Mandatory */
|
|
210
210
|
BT_PLUGIN_MODULE();
|
|
211
211
|
|
|
212
|
-
BT_PLUGIN(<%= options[:
|
|
213
|
-
BT_PLUGIN_SOURCE_COMPONENT_CLASS(<%= options[:
|
|
212
|
+
BT_PLUGIN(<%= options[:'plugin-name'] %>);
|
|
213
|
+
BT_PLUGIN_SOURCE_COMPONENT_CLASS(<%= options[:'component-name'] %>,
|
|
214
214
|
source_message_iterator_next);
|
|
215
215
|
|
|
216
216
|
BT_PLUGIN_SOURCE_COMPONENT_CLASS_INITIALIZE_METHOD(
|
|
217
|
-
<%= options[:
|
|
217
|
+
<%= options[:'component-name'] %>, source_initialize);
|
|
218
218
|
BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD(
|
|
219
|
-
<%= options[:
|
|
219
|
+
<%= options[:'component-name'] %>, source_finalize);
|
|
220
220
|
BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD(
|
|
221
|
-
<%= options[:
|
|
221
|
+
<%= options[:'component-name'] %>, source_message_iterator_initialize);
|
|
222
222
|
BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD(
|
|
223
|
-
<%= options[:
|
|
223
|
+
<%= options[:'component-name'] %>, source_message_iterator_finalize);
|
data/template/upstream.c.erb
CHANGED
|
@@ -55,9 +55,9 @@ static void btx_dispatch_<%= dispatcher.name_sanitized %>(
|
|
|
55
55
|
|
|
56
56
|
<% end %>
|
|
57
57
|
|
|
58
|
-
static void
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
static void __attribute__((unused))
|
|
59
|
+
bt_register_callbacks(void *btx_handle, const char *dispatcher_name,
|
|
60
|
+
void *btx_dispatch_p, const char *id, void *callback) {
|
|
61
61
|
|
|
62
62
|
name_to_dispatcher_t *s = NULL;
|
|
63
63
|
|
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: 1.0
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thomas Applencourt
|
|
@@ -10,16 +10,18 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2024-
|
|
13
|
+
date: 2024-03-29 00:00:00.000000000 Z
|
|
14
14
|
dependencies: []
|
|
15
15
|
description:
|
|
16
16
|
email:
|
|
17
17
|
executables:
|
|
18
18
|
- metababel
|
|
19
|
+
- btx_gen_source_callbacks
|
|
19
20
|
extensions: []
|
|
20
21
|
extra_rdoc_files: []
|
|
21
22
|
files:
|
|
22
23
|
- README.md
|
|
24
|
+
- bin/btx_gen_source_callbacks
|
|
23
25
|
- bin/metababel
|
|
24
26
|
- lib/metababel.rb
|
|
25
27
|
- lib/metababel/bt2_generator_utils.rb
|
|
@@ -27,6 +29,7 @@ files:
|
|
|
27
29
|
- lib/metababel/bt2_trace_class_generator.rb
|
|
28
30
|
- lib/metababel/bt2_values_generator.rb
|
|
29
31
|
- lib/metababel/version.rb
|
|
32
|
+
- shared/stripper.cpp
|
|
30
33
|
- template/component.c.erb
|
|
31
34
|
- template/component.h.erb
|
|
32
35
|
- template/downstream.c.erb
|
|
@@ -57,8 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
57
60
|
- !ruby/object:Gem::Version
|
|
58
61
|
version: '0'
|
|
59
62
|
requirements: []
|
|
60
|
-
|
|
61
|
-
rubygems_version: 2.7.6.3
|
|
63
|
+
rubygems_version: 3.3.3
|
|
62
64
|
signing_key:
|
|
63
65
|
specification_version: 4
|
|
64
66
|
summary: Helper for creation Babeltrace plugins
|