babeltrace2 0.1.0 → 0.1.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/babeltrace2.gemspec +1 -1
- data/lib/babeltrace2/error-reporting.rb +13 -3
- data/lib/babeltrace2/graph/graph.rb +9 -6
- data/lib/babeltrace2/graph/message-iterator-class.rb +1 -1
- data/lib/babeltrace2/graph/message-iterator.rb +0 -1
- data/lib/babeltrace2/graph/query-executor.rb +2 -1
- data/lib/babeltrace2/trace-ir/clock-class.rb +30 -1
- data/lib/babeltrace2/trace-ir/event-class.rb +29 -1
- data/lib/babeltrace2/trace-ir/event.rb +4 -0
- data/lib/babeltrace2/trace-ir/field-class.rb +349 -5
- data/lib/babeltrace2/trace-ir/field-path.rb +24 -0
- data/lib/babeltrace2/trace-ir/field.rb +29 -4
- data/lib/babeltrace2/trace-ir/stream-class.rb +83 -1
- data/lib/babeltrace2/trace-ir/stream.rb +2 -1
- data/lib/babeltrace2/trace-ir/trace-class.rb +21 -1
- data/lib/babeltrace2/trace-ir/trace.rb +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '0239b5e18b776cf7b8d6907e35c6a71aa22f9c6164a38269a629c4a2a1867687'
|
|
4
|
+
data.tar.gz: 0fa88f1bf9c68147a24c401cb447a21e16d6c6c89262125cb7796aa41087f51b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b9d1a6d4f31fb45027d3f1cca7ffc3f1e994178c9781f1dfa9cedc0687e2186cce4b882629e1d635394e07f371c7d4e89d354e762b3e3185f1380d2ab2104155
|
|
7
|
+
data.tar.gz: 8a12153ae9b69012021889f462d7d233728b43c9aca6bc586f2cfe0d9625770fed24ab967af1591cb396d5dc64f3704d5f1f9cd6b56c5af3dec0cc1ea1db3215
|
data/babeltrace2.gemspec
CHANGED
|
@@ -6,6 +6,16 @@ module Babeltrace2
|
|
|
6
6
|
:BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS, 1 << 2,
|
|
7
7
|
:BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR, 1 << 3]
|
|
8
8
|
|
|
9
|
+
def self.verbose?
|
|
10
|
+
!!@verbose
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.verbose=(val)
|
|
14
|
+
@verbose = !!val
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
@verbose = ENV["VERBOSE"]
|
|
18
|
+
|
|
9
19
|
class BTError < BTObject
|
|
10
20
|
end
|
|
11
21
|
|
|
@@ -347,14 +357,14 @@ module Babeltrace2
|
|
|
347
357
|
item = ""
|
|
348
358
|
item << c.file_name << ":"
|
|
349
359
|
item << c.line_number.to_s
|
|
350
|
-
item << (mess.match(/:in /) ? mess : ".")
|
|
360
|
+
item << (mess.match(/:in /) ? mess : Babeltrace2.verbose? ? " :: " << mess : ".")
|
|
351
361
|
backtrace.push(item)
|
|
352
362
|
cs[1..-1].each { |c|
|
|
353
363
|
item = ""
|
|
354
364
|
item << c.file_name << ":"
|
|
355
365
|
item << c.line_number.to_s
|
|
356
366
|
mess = c.message
|
|
357
|
-
item << (mess.match(/:in /) ? mess : ".")
|
|
367
|
+
item << (mess.match(/:in /) ? mess : Babeltrace2.verbose? ? " :: " << mess : ".")
|
|
358
368
|
backtrace.push(item)
|
|
359
369
|
}
|
|
360
370
|
[klass, message, backtrace]
|
|
@@ -424,7 +434,7 @@ module Babeltrace2
|
|
|
424
434
|
e = klass.new(message)
|
|
425
435
|
else
|
|
426
436
|
message = "#{code}" unless message
|
|
427
|
-
e = Error.new
|
|
437
|
+
e = Error.new(message)
|
|
428
438
|
end
|
|
429
439
|
e.set_backtrace(backtrace+caller_locations.collect(&:to_s))
|
|
430
440
|
e
|
|
@@ -347,13 +347,14 @@ module Babeltrace2
|
|
|
347
347
|
logging_level: BTLogging.default_level,
|
|
348
348
|
initialize_method_data: nil)
|
|
349
349
|
ptr = FFI::MemoryPointer.new(:pointer)
|
|
350
|
+
bt_params = BTValue.from_value(params)
|
|
350
351
|
res = if initialize_method_data
|
|
351
352
|
Babeltrace2.bt_graph_add_source_component_with_initialize_method_data(
|
|
352
|
-
@handle, component_class, name,
|
|
353
|
+
@handle, component_class, name, bt_params,
|
|
353
354
|
initialize_method_data, logging_level, ptr)
|
|
354
355
|
else
|
|
355
356
|
Babeltrace2.bt_graph_add_source_component(
|
|
356
|
-
@handle, component_class, name,
|
|
357
|
+
@handle, component_class, name, bt_params,
|
|
357
358
|
logging_level, ptr)
|
|
358
359
|
end
|
|
359
360
|
raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_COMPONENT_STATUS_OK
|
|
@@ -365,13 +366,14 @@ module Babeltrace2
|
|
|
365
366
|
logging_level: BTLogging.default_level,
|
|
366
367
|
initialize_method_data: nil)
|
|
367
368
|
ptr = FFI::MemoryPointer.new(:pointer)
|
|
369
|
+
bt_params = BTValue.from_value(params)
|
|
368
370
|
res = if initialize_method_data
|
|
369
371
|
Babeltrace2.bt_graph_add_filter_component_with_initialize_method_data(
|
|
370
|
-
@handle, component_class, name,
|
|
372
|
+
@handle, component_class, name, bt_params,
|
|
371
373
|
initialize_method_data, logging_level, ptr)
|
|
372
374
|
else
|
|
373
375
|
Babeltrace2.bt_graph_add_filter_component(
|
|
374
|
-
@handle, component_class, name,
|
|
376
|
+
@handle, component_class, name, bt_params,
|
|
375
377
|
logging_level, ptr)
|
|
376
378
|
end
|
|
377
379
|
raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_COMPONENT_STATUS_OK
|
|
@@ -383,13 +385,14 @@ module Babeltrace2
|
|
|
383
385
|
logging_level: BTLogging.default_level,
|
|
384
386
|
initialize_method_data: nil)
|
|
385
387
|
ptr = FFI::MemoryPointer.new(:pointer)
|
|
388
|
+
bt_params = BTValue.from_value(params)
|
|
386
389
|
res = if initialize_method_data
|
|
387
390
|
Babeltrace2.bt_graph_add_sink_component_with_initialize_method_data(
|
|
388
|
-
@handle, component_class, name,
|
|
391
|
+
@handle, component_class, name, bt_params,
|
|
389
392
|
initialize_method_data, logging_level, ptr)
|
|
390
393
|
else
|
|
391
394
|
Babeltrace2.bt_graph_add_sink_component(
|
|
392
|
-
@handle, component_class, name,
|
|
395
|
+
@handle, component_class, name, bt_params,
|
|
393
396
|
logging_level, ptr)
|
|
394
397
|
end
|
|
395
398
|
raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_COMPONENT_STATUS_OK
|
|
@@ -159,7 +159,7 @@ module Babeltrace2
|
|
|
159
159
|
mess = method.call(BTSelfMessageIterator.new(self_message_iterator,
|
|
160
160
|
retain: false, auto_release: false),
|
|
161
161
|
capacity)
|
|
162
|
-
if mess.size
|
|
162
|
+
if mess.size <= capacity
|
|
163
163
|
mess.each { |m| bt_message_get_ref(m.handle) }
|
|
164
164
|
messages.write_array_of_pointer(mess.collect(&:handle))
|
|
165
165
|
count.write_uint64(mess.size)
|
|
@@ -190,7 +190,6 @@ module Babeltrace2
|
|
|
190
190
|
ptr_messages = FFI::MemoryPointer.new(:pointer)
|
|
191
191
|
ptr_count = FFI::MemoryPointer.new(:uint64)
|
|
192
192
|
while ((res = Babeltrace2.bt_message_iterator_next(@handle, ptr_messages, ptr_count)) == :BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN)
|
|
193
|
-
puts "waiting"
|
|
194
193
|
sleep BT_SLEEP_TIME
|
|
195
194
|
end
|
|
196
195
|
case res
|
|
@@ -87,8 +87,9 @@ module Babeltrace2
|
|
|
87
87
|
if handle
|
|
88
88
|
super(handle, retain: retain, auto_release: auto_release)
|
|
89
89
|
else
|
|
90
|
+
bt_params = BTValue.from_value(params)
|
|
90
91
|
handle = Babeltrace2.bt_query_executor_create_with_method_data(
|
|
91
|
-
component_class, object_name,
|
|
92
|
+
component_class, object_name, bt_params, method_data)
|
|
92
93
|
raise Babeltrace2.process_error if handle.null?
|
|
93
94
|
super(handle)
|
|
94
95
|
end
|
|
@@ -233,7 +233,8 @@ module Babeltrace2
|
|
|
233
233
|
alias uuid get_uuid
|
|
234
234
|
|
|
235
235
|
def set_user_attributes(user_attributes)
|
|
236
|
-
|
|
236
|
+
bt_user_attributes = BTValue.from_value(user_attributes)
|
|
237
|
+
Babeltrace2.bt_clock_class_set_user_attributes(@handle, bt_user_attributes)
|
|
237
238
|
self
|
|
238
239
|
end
|
|
239
240
|
|
|
@@ -254,5 +255,33 @@ module Babeltrace2
|
|
|
254
255
|
raise Babeltrace2.process_error(res) if res != :BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OK
|
|
255
256
|
ptr.read_int64
|
|
256
257
|
end
|
|
258
|
+
|
|
259
|
+
def to_h
|
|
260
|
+
res = {}
|
|
261
|
+
res[:name] = name if name
|
|
262
|
+
res[:description] = description if description
|
|
263
|
+
res[:frequency] = frequency
|
|
264
|
+
res[:precision] = precision
|
|
265
|
+
res[:offset] = offset
|
|
266
|
+
res[:origin_is_unix_epoch] = origin_is_unix_epoch?
|
|
267
|
+
res[:uuid] = uuid.to_s if uuid
|
|
268
|
+
user_attributes_value = user_attributes.value
|
|
269
|
+
res[:user_attributes] = user_attributes_value if !user_attributes_value.empty?
|
|
270
|
+
res
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
def self.from_h(self_component, h)
|
|
274
|
+
o = self_component.create_clock_class
|
|
275
|
+
o.name = h[:name] if h[:name]
|
|
276
|
+
o.description = h[:description] if h[:description]
|
|
277
|
+
o.frequency = h[:frequency] if h[:frequency]
|
|
278
|
+
o.precision = h[:precision] if h[:precision]
|
|
279
|
+
o.set_offset(*h[:offset]) if h[:offset]
|
|
280
|
+
o.origin_is_unix_epoch = h[:origin_is_unix_epoch]
|
|
281
|
+
o.uuid = BTUUID.from_string(h[:uuid]) if h[:uuid]
|
|
282
|
+
o.user_attributes = h[:user_attributes] if h[:user_attributes]
|
|
283
|
+
h[:bt_clock_class] = o
|
|
284
|
+
o
|
|
285
|
+
end
|
|
257
286
|
end
|
|
258
287
|
end
|
|
@@ -275,7 +275,8 @@ module Babeltrace2
|
|
|
275
275
|
alias specific_context_field_class get_specific_context_field_class
|
|
276
276
|
|
|
277
277
|
def set_user_attributes(user_attributes)
|
|
278
|
-
|
|
278
|
+
bt_user_attributes = BTValue.from_value(user_attributes)
|
|
279
|
+
Babeltrace2.bt_event_class_set_user_attributes(@handle, bt_user_attributes)
|
|
279
280
|
self
|
|
280
281
|
end
|
|
281
282
|
|
|
@@ -288,5 +289,32 @@ module Babeltrace2
|
|
|
288
289
|
BTValueMap.new(Babeltrace2.bt_event_class_borrow_user_attributes(@handle), retain: true)
|
|
289
290
|
end
|
|
290
291
|
alias user_attributes get_user_attributes
|
|
292
|
+
|
|
293
|
+
def to_h
|
|
294
|
+
res = { id: id }
|
|
295
|
+
res[:name] = name if name
|
|
296
|
+
res[:log_level] = log_level if log_level
|
|
297
|
+
res[:emf_uri] = emf_uri if emf_uri
|
|
298
|
+
res[:specific_context_field_class] = specific_context_field_class.to_h if specific_context_field_class
|
|
299
|
+
res[:payload_field_class] = payload_field_class.to_h if payload_field_class
|
|
300
|
+
user_attributes_value = user_attributes.value
|
|
301
|
+
res[:user_attributes] = user_attributes_value if !user_attributes_value.empty?
|
|
302
|
+
res
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
def self.from_h(trace_class, stream_class, h, stream_class_h)
|
|
306
|
+
id = stream_class.assigns_automatic_event_class_id? ? nil : h[:id]
|
|
307
|
+
o = self.new(stream_class: stream_class, id: id)
|
|
308
|
+
o.name = h[:name] if h[:name]
|
|
309
|
+
o.log_level = h[:log_level] if h[:log_level]
|
|
310
|
+
o.emf_uri = h[:emf_uri] if h[:emf_uri]
|
|
311
|
+
o.specific_context_field_class = BTFieldClass.from_h(trace_class,
|
|
312
|
+
h[:specific_context_field_class], stream_class_h) if h[:specific_context_field_class]
|
|
313
|
+
o.payload_field_class = BTFieldClass.from_h(trace_class,
|
|
314
|
+
h[:payload_field_class], stream_class_h) if h[:payload_field_class]
|
|
315
|
+
o.user_attributes = h[:user_attributes] if h[:user_attributes]
|
|
316
|
+
h[:bt_event_class] = o
|
|
317
|
+
o
|
|
318
|
+
end
|
|
291
319
|
end
|
|
292
320
|
end
|
|
@@ -159,7 +159,8 @@ module Babeltrace2
|
|
|
159
159
|
alias type? type_is
|
|
160
160
|
|
|
161
161
|
def set_user_attributes(user_attributes)
|
|
162
|
-
|
|
162
|
+
bt_user_attributes = BTValue.from_value(user_attributes)
|
|
163
|
+
Babeltrace2.bt_field_class_set_user_attributes(@handle, bt_user_attributes)
|
|
163
164
|
self
|
|
164
165
|
end
|
|
165
166
|
|
|
@@ -172,6 +173,36 @@ module Babeltrace2
|
|
|
172
173
|
BTValueMap.new(Babeltrace2.bt_field_class_borrow_user_attributes(@handle), retain: true)
|
|
173
174
|
end
|
|
174
175
|
alias user_attributes get_user_attributes
|
|
176
|
+
|
|
177
|
+
def to_h
|
|
178
|
+
res = { type: class_snake_case_name }
|
|
179
|
+
user_attributes_value = user_attributes.value
|
|
180
|
+
res[:user_attributes] = user_attributes_value if !user_attributes_value.empty?
|
|
181
|
+
res
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
|
185
|
+
Babeltrace2.const_get(snake_case_to_class(h[:type])).from_h(
|
|
186
|
+
trace_class, h, stream_class_h)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def from_h(h)
|
|
190
|
+
self.user_attributes = h[:user_attributes] if h[:user_attributes]
|
|
191
|
+
self
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
private
|
|
195
|
+
|
|
196
|
+
def class_snake_case_name
|
|
197
|
+
str = self.class.name.gsub(/::/, '')
|
|
198
|
+
str.match(/BTFieldClass(.*)/)[1].
|
|
199
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
|
200
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def self.snake_case_to_class(str)
|
|
204
|
+
"BTFieldClass" << str.split("_").collect(&:capitalize).join
|
|
205
|
+
end
|
|
175
206
|
end
|
|
176
207
|
|
|
177
208
|
attach_function :bt_field_class_bool_create,
|
|
@@ -189,6 +220,12 @@ module Babeltrace2
|
|
|
189
220
|
super(handle, retain: false)
|
|
190
221
|
end
|
|
191
222
|
end
|
|
223
|
+
|
|
224
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
|
225
|
+
o = self.new(trace_class: trace_class).from_h(h)
|
|
226
|
+
h[:bt_field_class] = o
|
|
227
|
+
o
|
|
228
|
+
end
|
|
192
229
|
end
|
|
193
230
|
BTFieldClassBool = BTFieldClass::Bool
|
|
194
231
|
BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_BOOL] = [
|
|
@@ -219,6 +256,18 @@ module Babeltrace2
|
|
|
219
256
|
Babeltrace2.bt_field_class_bit_array_get_length(@handle)
|
|
220
257
|
end
|
|
221
258
|
alias length get_length
|
|
259
|
+
|
|
260
|
+
def to_h
|
|
261
|
+
res = super
|
|
262
|
+
res[:length] = length
|
|
263
|
+
res
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
|
267
|
+
o = self.new(trace_class: trace_class, length: h[:length]).from_h(h)
|
|
268
|
+
h[:bt_field_class] = o
|
|
269
|
+
o
|
|
270
|
+
end
|
|
222
271
|
end
|
|
223
272
|
BTFieldClassBitArray = BTFieldClass::BitArray
|
|
224
273
|
BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_BIT_ARRAY] = [
|
|
@@ -260,7 +309,7 @@ module Babeltrace2
|
|
|
260
309
|
class BTFieldClass::Integer < BTFieldClass
|
|
261
310
|
|
|
262
311
|
def set_field_value_range(n)
|
|
263
|
-
raise "invalid range" if n < 0 || n >
|
|
312
|
+
raise "invalid range" if n < 0 || n > 64
|
|
264
313
|
Babeltrace2.bt_field_class_integer_set_field_value_range(@handle, n)
|
|
265
314
|
self
|
|
266
315
|
end
|
|
@@ -305,6 +354,20 @@ module Babeltrace2
|
|
|
305
354
|
preferred_display_base
|
|
306
355
|
end
|
|
307
356
|
end
|
|
357
|
+
|
|
358
|
+
def to_h
|
|
359
|
+
res = super
|
|
360
|
+
res[:field_value_range] = field_value_range
|
|
361
|
+
res[:preferred_display_base] = preferred_display_base_integer
|
|
362
|
+
res
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
def from_h(h)
|
|
366
|
+
super
|
|
367
|
+
self.field_value_range = h[:field_value_range] if h[:field_value_range]
|
|
368
|
+
self.preferred_display_base = h[:preferred_display_base] if h[:preferred_display_base]
|
|
369
|
+
self
|
|
370
|
+
end
|
|
308
371
|
end
|
|
309
372
|
BTFieldClassInteger = BTFieldClass::Integer
|
|
310
373
|
|
|
@@ -323,6 +386,12 @@ module Babeltrace2
|
|
|
323
386
|
super(handle, retain: false)
|
|
324
387
|
end
|
|
325
388
|
end
|
|
389
|
+
|
|
390
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
|
391
|
+
o = self.new(trace_class: trace_class).from_h(h)
|
|
392
|
+
h[:bt_field_class] = o
|
|
393
|
+
o
|
|
394
|
+
end
|
|
326
395
|
end
|
|
327
396
|
BTFieldClass::IntegerUnsigned = BTFieldClass::Integer::Unsigned
|
|
328
397
|
BTFieldClassIntegerUnsigned = BTFieldClass::Integer::Unsigned
|
|
@@ -345,6 +414,12 @@ module Babeltrace2
|
|
|
345
414
|
super(handle, retain: false)
|
|
346
415
|
end
|
|
347
416
|
end
|
|
417
|
+
|
|
418
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
|
419
|
+
o = self.new(trace_class: trace_class).from_h(h)
|
|
420
|
+
h[:bt_field_class] = o
|
|
421
|
+
o
|
|
422
|
+
end
|
|
348
423
|
end
|
|
349
424
|
BTFieldClass::IntegerSigned = BTFieldClass::Integer::Signed
|
|
350
425
|
BTFieldClassIntegerSigned = BTFieldClass::Integer::Signed
|
|
@@ -371,6 +446,12 @@ module Babeltrace2
|
|
|
371
446
|
super(handle, retain: false)
|
|
372
447
|
end
|
|
373
448
|
end
|
|
449
|
+
|
|
450
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
|
451
|
+
o = self.new(trace_class: trace_class).from_h(h)
|
|
452
|
+
h[:bt_field_class] = o
|
|
453
|
+
o
|
|
454
|
+
end
|
|
374
455
|
end
|
|
375
456
|
BTFieldClass::RealSinglePrecision = BTFieldClass::Real::SinglePrecision
|
|
376
457
|
BTFieldClassRealSinglePrecision = BTFieldClass::Real::SinglePrecision
|
|
@@ -393,6 +474,12 @@ module Babeltrace2
|
|
|
393
474
|
super(handle, retain: false)
|
|
394
475
|
end
|
|
395
476
|
end
|
|
477
|
+
|
|
478
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
|
479
|
+
o = self.new(trace_class: trace_class).from_h(h)
|
|
480
|
+
h[:bt_field_class] = o
|
|
481
|
+
o
|
|
482
|
+
end
|
|
396
483
|
end
|
|
397
484
|
BTFieldClass::RealDoublePrecision = BTFieldClass::Real::DoublePrecision
|
|
398
485
|
BTFieldClassRealDoublePrecision = BTFieldClass::Real::DoublePrecision
|
|
@@ -448,6 +535,25 @@ module Babeltrace2
|
|
|
448
535
|
end
|
|
449
536
|
alias mapping get_mapping
|
|
450
537
|
|
|
538
|
+
def to_h
|
|
539
|
+
res = super
|
|
540
|
+
res[:mappings] = get_mapping_count.times.collect { |i|
|
|
541
|
+
mapping = get_mapping_by_index(i)
|
|
542
|
+
[mapping.label, mapping.ranges.each.collect { |r| [r.lower, r.upper] }]
|
|
543
|
+
}.to_h
|
|
544
|
+
res
|
|
545
|
+
end
|
|
546
|
+
|
|
547
|
+
def from_h(h)
|
|
548
|
+
super
|
|
549
|
+
if h[:mappings]
|
|
550
|
+
h[:mappings].each { |name, ranges|
|
|
551
|
+
add_mapping(name, ranges)
|
|
552
|
+
}
|
|
553
|
+
end
|
|
554
|
+
self
|
|
555
|
+
end
|
|
556
|
+
|
|
451
557
|
class Mapping < BTObject
|
|
452
558
|
def get_label
|
|
453
559
|
label = Babeltrace2.bt_field_class_enumeration_mapping_get_label(@handle)
|
|
@@ -511,6 +617,12 @@ module Babeltrace2
|
|
|
511
617
|
end
|
|
512
618
|
end
|
|
513
619
|
|
|
620
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
|
621
|
+
o = self.new(trace_class: trace_class).from_h(h)
|
|
622
|
+
h[:bt_field_class] = o
|
|
623
|
+
o
|
|
624
|
+
end
|
|
625
|
+
|
|
514
626
|
def add_mapping(label, ranges)
|
|
515
627
|
label = label.inspect if label.kind_of?(Symbol)
|
|
516
628
|
ranges = BTIntegerRangeSetUnsigned.from_value(ranges)
|
|
@@ -608,6 +720,12 @@ module Babeltrace2
|
|
|
608
720
|
end
|
|
609
721
|
end
|
|
610
722
|
|
|
723
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
|
724
|
+
o = self.new(trace_class: trace_class).from_h(h)
|
|
725
|
+
h[:bt_field_class] = o
|
|
726
|
+
o
|
|
727
|
+
end
|
|
728
|
+
|
|
611
729
|
def add_mapping(label, ranges)
|
|
612
730
|
label = label.inspect if label.kind_of?(Symbol)
|
|
613
731
|
ranges = BTIntegerRangeSetSigned.from_value(ranges)
|
|
@@ -672,6 +790,12 @@ module Babeltrace2
|
|
|
672
790
|
super(handle, retain: false)
|
|
673
791
|
end
|
|
674
792
|
end
|
|
793
|
+
|
|
794
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
|
795
|
+
o = self.new(trace_class: trace_class).from_h(h)
|
|
796
|
+
h[:bt_field_class] = o
|
|
797
|
+
o
|
|
798
|
+
end
|
|
675
799
|
end
|
|
676
800
|
BTFieldClassString = BTFieldClass::String
|
|
677
801
|
BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_STRING] = [
|
|
@@ -692,6 +816,12 @@ module Babeltrace2
|
|
|
692
816
|
Babeltrace2.bt_field_class_array_borrow_element_field_class(@handle))
|
|
693
817
|
end
|
|
694
818
|
alias element_field_class get_element_field_class
|
|
819
|
+
|
|
820
|
+
def to_h
|
|
821
|
+
res = super
|
|
822
|
+
res[:element_field_class] = element_field_class.to_h
|
|
823
|
+
res
|
|
824
|
+
end
|
|
695
825
|
end
|
|
696
826
|
BTFieldClassArray = BTFieldClass::Array
|
|
697
827
|
|
|
@@ -721,6 +851,22 @@ module Babeltrace2
|
|
|
721
851
|
end
|
|
722
852
|
alias length get_length
|
|
723
853
|
alias size get_length
|
|
854
|
+
|
|
855
|
+
def to_h
|
|
856
|
+
res = super
|
|
857
|
+
res[:length] = length
|
|
858
|
+
res
|
|
859
|
+
end
|
|
860
|
+
|
|
861
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
|
862
|
+
o = self.new(trace_class: trace_class,
|
|
863
|
+
element_field_class: BTFieldClass.from_h(trace_class,
|
|
864
|
+
h[:element_field_class],
|
|
865
|
+
stream_class_h),
|
|
866
|
+
length: h[:length]).from_h(h)
|
|
867
|
+
h[:bt_field_class] = o
|
|
868
|
+
o
|
|
869
|
+
end
|
|
724
870
|
end
|
|
725
871
|
BTFieldClassArrayStatic = BTFieldClass::Array::Static
|
|
726
872
|
BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_STATIC_ARRAY] = [
|
|
@@ -744,6 +890,12 @@ module Babeltrace2
|
|
|
744
890
|
BTFieldPath.new(handle, retain: true)
|
|
745
891
|
end
|
|
746
892
|
alias length_field_path get_length_field_path
|
|
893
|
+
|
|
894
|
+
def to_h
|
|
895
|
+
res = super
|
|
896
|
+
res[:length_field_path] = length_field_path.to_s
|
|
897
|
+
res
|
|
898
|
+
end
|
|
747
899
|
end
|
|
748
900
|
def initialize(handle = nil, retain: true, auto_release: true,
|
|
749
901
|
trace_class: nil, element_field_class: nil, length_field_class: nil)
|
|
@@ -759,6 +911,22 @@ module Babeltrace2
|
|
|
759
911
|
super(handle, retain: false)
|
|
760
912
|
end
|
|
761
913
|
end
|
|
914
|
+
|
|
915
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
|
916
|
+
if (stream_class_h && h[:length_field_path])
|
|
917
|
+
length_field_class = BTStreamClass.locate_field_class(
|
|
918
|
+
BTFieldPath.path_from_s_to_h(h[:length_field_path]), stream_class_h)
|
|
919
|
+
else
|
|
920
|
+
length_field_class = nil
|
|
921
|
+
end
|
|
922
|
+
o = self.new(trace_class: trace_class,
|
|
923
|
+
element_field_class: BTFieldClass.from_h(trace_class,
|
|
924
|
+
h[:element_field_class],
|
|
925
|
+
stream_class_h),
|
|
926
|
+
length_field_class: length_field_class).from_h(h)
|
|
927
|
+
h[:bt_field_class] = o
|
|
928
|
+
o
|
|
929
|
+
end
|
|
762
930
|
end
|
|
763
931
|
BTFieldClassArrayDynamic = BTFieldClass::Array::Dynamic
|
|
764
932
|
BTFieldClassArrayDynamicWithLengthField = BTFieldClass::Array::Dynamic::WithLengthField
|
|
@@ -845,7 +1013,8 @@ module Babeltrace2
|
|
|
845
1013
|
alias field_class get_field_class
|
|
846
1014
|
|
|
847
1015
|
def set_user_attributes(user_attributes)
|
|
848
|
-
|
|
1016
|
+
bt_user_attributes = BTValue.from_value(user_attributes)
|
|
1017
|
+
Babeltrace2.bt_field_class_structure_member_set_user_attributes(@handle, bt_user_attributes)
|
|
849
1018
|
self
|
|
850
1019
|
end
|
|
851
1020
|
|
|
@@ -858,6 +1027,18 @@ module Babeltrace2
|
|
|
858
1027
|
BTValueMap.new(Babeltrace2.bt_field_class_structure_member_borrow_user_attributes(@handle), retain: true)
|
|
859
1028
|
end
|
|
860
1029
|
alias user_attributes get_user_attributes
|
|
1030
|
+
|
|
1031
|
+
def to_h
|
|
1032
|
+
res = { name: name, field_class: field_class.to_h }
|
|
1033
|
+
user_attributes_value = user_attributes.value
|
|
1034
|
+
res[:user_attributes] = user_attributes_value if !user_attributes_value.empty?
|
|
1035
|
+
res
|
|
1036
|
+
end
|
|
1037
|
+
|
|
1038
|
+
def from_h(h)
|
|
1039
|
+
self.user_attributes = h[:user_attributes] if h[:user_attributes]
|
|
1040
|
+
self
|
|
1041
|
+
end
|
|
861
1042
|
end
|
|
862
1043
|
|
|
863
1044
|
def initialize(handle = nil, retain: true, auto_release: true,
|
|
@@ -911,6 +1092,23 @@ module Babeltrace2
|
|
|
911
1092
|
end
|
|
912
1093
|
end
|
|
913
1094
|
alias [] get_member
|
|
1095
|
+
|
|
1096
|
+
def to_h
|
|
1097
|
+
res = super
|
|
1098
|
+
res[:members] = member_count.times.collect { |i| get_member_by_index(i).to_h }
|
|
1099
|
+
res
|
|
1100
|
+
end
|
|
1101
|
+
|
|
1102
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
|
1103
|
+
o = self.new(trace_class: trace_class).from_h(h)
|
|
1104
|
+
h[:members].each_with_index { |v, i|
|
|
1105
|
+
o.append_member(v[:name],
|
|
1106
|
+
BTFieldClass.from_h(trace_class, v[:field_class], stream_class_h))
|
|
1107
|
+
o.get_member_by_index(i).from_h(v)
|
|
1108
|
+
}
|
|
1109
|
+
h[:bt_field_class] = o
|
|
1110
|
+
o
|
|
1111
|
+
end
|
|
914
1112
|
end
|
|
915
1113
|
BTFieldClassStructure = BTFieldClass::Structure
|
|
916
1114
|
BTFieldClassStructureMember = BTFieldClass::Structure::Member
|
|
@@ -932,6 +1130,12 @@ module Babeltrace2
|
|
|
932
1130
|
Babeltrace2.bt_field_class_option_borrow_field_class(@handle))
|
|
933
1131
|
end
|
|
934
1132
|
alias field_class get_field_class
|
|
1133
|
+
|
|
1134
|
+
def to_h
|
|
1135
|
+
res = super
|
|
1136
|
+
res[:field_class] = field_class.to_h
|
|
1137
|
+
res
|
|
1138
|
+
end
|
|
935
1139
|
end
|
|
936
1140
|
BTFieldClassOption = BTFieldClass::Option
|
|
937
1141
|
|
|
@@ -951,6 +1155,15 @@ module Babeltrace2
|
|
|
951
1155
|
super(handle, retain: false)
|
|
952
1156
|
end
|
|
953
1157
|
end
|
|
1158
|
+
|
|
1159
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
|
1160
|
+
o = self.new(trace_class: trace_class,
|
|
1161
|
+
optional_field_class: BTFieldClass.from_h(trace_class,
|
|
1162
|
+
h[:field_class],
|
|
1163
|
+
stream_class_h)).from_h(h)
|
|
1164
|
+
h[:bt_field_class] = o
|
|
1165
|
+
o
|
|
1166
|
+
end
|
|
954
1167
|
end
|
|
955
1168
|
BTFieldClassOptionWithoutSelectorField = BTFieldClass::Option::WithoutSelectorField
|
|
956
1169
|
BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD] = [
|
|
@@ -968,6 +1181,12 @@ module Babeltrace2
|
|
|
968
1181
|
BTFieldPath.new(handle, retain: true)
|
|
969
1182
|
end
|
|
970
1183
|
alias selector_field_path get_selector_field_path
|
|
1184
|
+
|
|
1185
|
+
def to_h
|
|
1186
|
+
res = super
|
|
1187
|
+
res[:selector_field_path] = selector_field_path.to_s if selector_field_path
|
|
1188
|
+
res
|
|
1189
|
+
end
|
|
971
1190
|
end
|
|
972
1191
|
BTFieldClassOptionWithSelectorField = BTFieldClass::Option::WithSelectorField
|
|
973
1192
|
|
|
@@ -1014,6 +1233,29 @@ module Babeltrace2
|
|
|
1014
1233
|
@handle) != BT_FALSE
|
|
1015
1234
|
end
|
|
1016
1235
|
alias selector_is_reversed? selector_is_reversed
|
|
1236
|
+
|
|
1237
|
+
def to_h
|
|
1238
|
+
res = super
|
|
1239
|
+
res[:selector_is_reversed] = selector_is_reversed?
|
|
1240
|
+
res
|
|
1241
|
+
end
|
|
1242
|
+
|
|
1243
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
|
1244
|
+
if (stream_class_h && h[:selector_field_path])
|
|
1245
|
+
selector_field_class = BTStreamClass.locate_field_class(
|
|
1246
|
+
BTFieldPath.path_from_s_to_h(h[:selector_field_path]), stream_class_h)
|
|
1247
|
+
else
|
|
1248
|
+
selector_field_class = nil
|
|
1249
|
+
end
|
|
1250
|
+
o = self.new(trace_class: trace_class,
|
|
1251
|
+
optional_field_class: BTFieldClass.from_h(trace_class,
|
|
1252
|
+
h[:field_class],
|
|
1253
|
+
stream_class_h),
|
|
1254
|
+
selector_field_class: selector_field_class).from_h(h)
|
|
1255
|
+
o.selector_is_reversed = h[:selector_is_reversed] if h[:selector_is_reversed]
|
|
1256
|
+
h[:bt_field_class] = o
|
|
1257
|
+
o
|
|
1258
|
+
end
|
|
1017
1259
|
end
|
|
1018
1260
|
BTFieldClassOptionWithSelectorFieldBool = BTFieldClass::Option::WithSelectorField::Bool
|
|
1019
1261
|
BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD] = [
|
|
@@ -1051,6 +1293,29 @@ module Babeltrace2
|
|
|
1051
1293
|
@handle), retain: true)
|
|
1052
1294
|
end
|
|
1053
1295
|
alias selector_ranges get_selector_ranges
|
|
1296
|
+
|
|
1297
|
+
def to_h
|
|
1298
|
+
res = super
|
|
1299
|
+
res[:selector_ranges] = selector_ranges.each.collect { |r| [r.lower, r.upper] }
|
|
1300
|
+
res
|
|
1301
|
+
end
|
|
1302
|
+
|
|
1303
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
|
1304
|
+
if (stream_class_h && h[:selector_field_path])
|
|
1305
|
+
selector_field_class = BTStreamClass.locate_field_class(
|
|
1306
|
+
BTFieldPath.path_from_s_to_h(h[:selector_field_path]), stream_class_h)
|
|
1307
|
+
else
|
|
1308
|
+
selector_field_class = nil
|
|
1309
|
+
end
|
|
1310
|
+
o = self.new(trace_class: trace_class,
|
|
1311
|
+
optional_field_class: BTFieldClass.from_h(trace_class,
|
|
1312
|
+
h[:field_class],
|
|
1313
|
+
stream_class_h),
|
|
1314
|
+
selector_field_class: selector_field_class,
|
|
1315
|
+
ranges: h[:selector_ranges]).from_h(h)
|
|
1316
|
+
h[:bt_field_class] = o
|
|
1317
|
+
o
|
|
1318
|
+
end
|
|
1054
1319
|
end
|
|
1055
1320
|
BTFieldClassOptionWithSelectorFieldIntegerUnsigned = BTFieldClass::Option::WithSelectorField::IntegerUnsigned
|
|
1056
1321
|
BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD] = [
|
|
@@ -1088,6 +1353,29 @@ module Babeltrace2
|
|
|
1088
1353
|
@handle), retain: true)
|
|
1089
1354
|
end
|
|
1090
1355
|
alias selector_ranges get_selector_ranges
|
|
1356
|
+
|
|
1357
|
+
def to_h
|
|
1358
|
+
res = super
|
|
1359
|
+
res[:selector_ranges] = selector_ranges.each.collect { |r| [r.lower, r.upper] }
|
|
1360
|
+
res
|
|
1361
|
+
end
|
|
1362
|
+
|
|
1363
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
|
1364
|
+
if (stream_class_h && h[:selector_field_path])
|
|
1365
|
+
selector_field_class = BTStreamClass.locate_field_class(
|
|
1366
|
+
BTFieldPath.path_from_s_to_h(h[:selector_field_path]), stream_class_h)
|
|
1367
|
+
else
|
|
1368
|
+
selector_field_class = nil
|
|
1369
|
+
end
|
|
1370
|
+
o = self.new(trace_class: trace_class,
|
|
1371
|
+
optional_field_class: BTFieldClass.from_h(trace_class,
|
|
1372
|
+
h[:field_class],
|
|
1373
|
+
stream_class_h),
|
|
1374
|
+
selector_field_class: selector_field_class,
|
|
1375
|
+
ranges: h[:selector_ranges]).from_h(h)
|
|
1376
|
+
h[:bt_field_class] = o
|
|
1377
|
+
o
|
|
1378
|
+
end
|
|
1091
1379
|
end
|
|
1092
1380
|
BTFieldClassOptionWithSelectorFieldIntegerSigned = BTFieldClass::Option::WithSelectorField::IntegerSigned
|
|
1093
1381
|
BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD] = [
|
|
@@ -1158,8 +1446,8 @@ module Babeltrace2
|
|
|
1158
1446
|
alias field_class get_field_class
|
|
1159
1447
|
|
|
1160
1448
|
def set_user_attributes(user_attributes)
|
|
1161
|
-
|
|
1162
|
-
|
|
1449
|
+
bt_user_attributes = BTValue.from_value(user_attributes)
|
|
1450
|
+
Babeltrace2.bt_field_class_variant_option_set_user_attributes(@handle, bt_user_attributes)
|
|
1163
1451
|
self
|
|
1164
1452
|
end
|
|
1165
1453
|
|
|
@@ -1174,6 +1462,13 @@ module Babeltrace2
|
|
|
1174
1462
|
@handle), retain: true)
|
|
1175
1463
|
end
|
|
1176
1464
|
alias user_attributes get_user_attributes
|
|
1465
|
+
|
|
1466
|
+
def to_h
|
|
1467
|
+
res = { name: name, field_class: field_class.to_h }
|
|
1468
|
+
user_attributes_value = user_attributes.value
|
|
1469
|
+
res[:user_attributes] = user_attributes_value if !user_attributes_value.empty?
|
|
1470
|
+
res
|
|
1471
|
+
end
|
|
1177
1472
|
end
|
|
1178
1473
|
end
|
|
1179
1474
|
BTFieldClassVariantOption = BTFieldClass::Variant::Option
|
|
@@ -1259,6 +1554,13 @@ module Babeltrace2
|
|
|
1259
1554
|
BTFieldPath.new(handle, retain: true)
|
|
1260
1555
|
end
|
|
1261
1556
|
alias selector_field_path get_selector_field_path
|
|
1557
|
+
|
|
1558
|
+
def to_h
|
|
1559
|
+
res = super
|
|
1560
|
+
res[:selector_field_path] = selector_field_path.to_s
|
|
1561
|
+
res
|
|
1562
|
+
end
|
|
1563
|
+
|
|
1262
1564
|
module IntegerUnsigned
|
|
1263
1565
|
class Option < BTFieldClassVariantOption
|
|
1264
1566
|
def get_ranges
|
|
@@ -1267,6 +1569,12 @@ module Babeltrace2
|
|
|
1267
1569
|
@handle), retain: true)
|
|
1268
1570
|
end
|
|
1269
1571
|
alias ranges get_ranges
|
|
1572
|
+
|
|
1573
|
+
def to_h
|
|
1574
|
+
res = super
|
|
1575
|
+
res[:ranges] = ranges.each.collect { |r| [r.lower, r.upper] }
|
|
1576
|
+
res
|
|
1577
|
+
end
|
|
1270
1578
|
end
|
|
1271
1579
|
include WithSelectorField
|
|
1272
1580
|
def append_option(name, option_field_class, ranges)
|
|
@@ -1303,6 +1611,12 @@ module Babeltrace2
|
|
|
1303
1611
|
@handle), retain: true)
|
|
1304
1612
|
end
|
|
1305
1613
|
alias ranges get_ranges
|
|
1614
|
+
|
|
1615
|
+
def to_h
|
|
1616
|
+
res = super
|
|
1617
|
+
res[:ranges] = ranges.each.collect { |r| [r.lower, r.upper] }
|
|
1618
|
+
res
|
|
1619
|
+
end
|
|
1306
1620
|
end
|
|
1307
1621
|
include WithSelectorField
|
|
1308
1622
|
def append_option(name, option_field_class, ranges)
|
|
@@ -1395,6 +1709,36 @@ module Babeltrace2
|
|
|
1395
1709
|
end
|
|
1396
1710
|
alias [] get_option
|
|
1397
1711
|
|
|
1712
|
+
def to_h
|
|
1713
|
+
res = super
|
|
1714
|
+
res[:options] = option_count.times.collect { |i|
|
|
1715
|
+
get_option_by_index(i).to_h
|
|
1716
|
+
}
|
|
1717
|
+
res
|
|
1718
|
+
end
|
|
1719
|
+
|
|
1720
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
|
1721
|
+
if (stream_class_h && h[:selector_field_path])
|
|
1722
|
+
selector_field_class = BTStreamClass.locate_field_class(
|
|
1723
|
+
BTFieldPath.path_from_s_to_h(h[:selector_field_path]), stream_class_h)
|
|
1724
|
+
else
|
|
1725
|
+
selector_field_class = nil
|
|
1726
|
+
end
|
|
1727
|
+
o = self.new(trace_class: trace_class,
|
|
1728
|
+
selector_field_class: selector_field_class).from_h(h)
|
|
1729
|
+
if selector_field_class
|
|
1730
|
+
h[:options].each { |v|
|
|
1731
|
+
o.append_option(v[:name],
|
|
1732
|
+
BTFieldClass.from_h(trace_class, v[:field_class], stream_class_h),
|
|
1733
|
+
v[:ranges]) }
|
|
1734
|
+
else
|
|
1735
|
+
h[:options].each { |v|
|
|
1736
|
+
o.append_option(v[:name],
|
|
1737
|
+
BTFieldClass.from_h(trace_class, v[:field_class], stream_class_h)) }
|
|
1738
|
+
end
|
|
1739
|
+
h[:bt_field_class] = o
|
|
1740
|
+
o
|
|
1741
|
+
end
|
|
1398
1742
|
end
|
|
1399
1743
|
BTFieldClassVariantWithoutSelectorField =
|
|
1400
1744
|
BTFieldClass::Variant::WithoutSelectorField
|
|
@@ -85,6 +85,30 @@ module Babeltrace2
|
|
|
85
85
|
}
|
|
86
86
|
path
|
|
87
87
|
end
|
|
88
|
+
|
|
89
|
+
def self.path_from_s_to_h(str)
|
|
90
|
+
str_orig = str
|
|
91
|
+
m = str.match(/\A(PACKET_CONTEXT|EVENT_COMMON_CONTEXT|EVENT_SPECIFIC_CONTEXT|EVENT_PAYLOAD)/)
|
|
92
|
+
raise "invalid path #{str}" if !m
|
|
93
|
+
path = [(m[1].downcase << "_field_class").to_sym]
|
|
94
|
+
str = str.sub(m[1], "")
|
|
95
|
+
while !str.empty?
|
|
96
|
+
case str
|
|
97
|
+
when /\A\[(\d+)\]/
|
|
98
|
+
path.push :members, $1.to_i, :field_class
|
|
99
|
+
str = str.sub("[#{$1}]", "")
|
|
100
|
+
when /\A->/
|
|
101
|
+
path.push :element_field_class
|
|
102
|
+
str = str.sub("->", "")
|
|
103
|
+
when /\A=>/
|
|
104
|
+
path.push :field_class
|
|
105
|
+
str = str.sub("=>", "")
|
|
106
|
+
else
|
|
107
|
+
raise "invalid path #{str_orig}"
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
path
|
|
111
|
+
end
|
|
88
112
|
end
|
|
89
113
|
|
|
90
114
|
BT_FIELD_PATH_ITEM_TYPE_INDEX = 1 << 0
|
|
@@ -421,7 +421,7 @@ module Babeltrace2
|
|
|
421
421
|
:bt_field_string_append_status
|
|
422
422
|
|
|
423
423
|
attach_function :bt_field_string_append_with_length,
|
|
424
|
-
[ :bt_field_string_handle, :
|
|
424
|
+
[ :bt_field_string_handle, :pointer, :uint64 ],
|
|
425
425
|
:bt_field_string_append_status
|
|
426
426
|
|
|
427
427
|
attach_function :bt_field_string_clear,
|
|
@@ -460,7 +460,9 @@ module Babeltrace2
|
|
|
460
460
|
|
|
461
461
|
def append(value, length: nil)
|
|
462
462
|
res = if length
|
|
463
|
-
|
|
463
|
+
ptr = FFI::MemoryPointer.new(length)
|
|
464
|
+
ptr.write_bytes(value, 0, length)
|
|
465
|
+
Babeltrace2.bt_field_string_append_with_length(@handle, ptr, length)
|
|
464
466
|
else
|
|
465
467
|
Babeltrace2.bt_field_string_append(@handle, value)
|
|
466
468
|
end
|
|
@@ -521,12 +523,25 @@ module Babeltrace2
|
|
|
521
523
|
end
|
|
522
524
|
|
|
523
525
|
def value
|
|
524
|
-
each.collect
|
|
526
|
+
each.collect(&:value)
|
|
527
|
+
end
|
|
528
|
+
|
|
529
|
+
def set_value(values)
|
|
530
|
+
raise "invalid value size" if values.size != length
|
|
531
|
+
values.each_with_index { |e, i|
|
|
532
|
+
get_element_field_by_index(i).set_value(e)
|
|
533
|
+
}
|
|
534
|
+
self
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
def value=(values)
|
|
538
|
+
set_value(values)
|
|
539
|
+
values
|
|
525
540
|
end
|
|
526
541
|
|
|
527
542
|
def to_s
|
|
528
543
|
s = "["
|
|
529
|
-
s << each.collect
|
|
544
|
+
s << each.collect(&:to_s).join(", ")
|
|
530
545
|
s << "]"
|
|
531
546
|
end
|
|
532
547
|
end
|
|
@@ -634,6 +649,11 @@ module Babeltrace2
|
|
|
634
649
|
end
|
|
635
650
|
alias [] get_member_field
|
|
636
651
|
|
|
652
|
+
def []=(member_field, value)
|
|
653
|
+
get_member_field(member_field).set_value(value)
|
|
654
|
+
value
|
|
655
|
+
end
|
|
656
|
+
|
|
637
657
|
def each
|
|
638
658
|
if block_given?
|
|
639
659
|
get_member_count.times { |i|
|
|
@@ -653,6 +673,11 @@ module Babeltrace2
|
|
|
653
673
|
v
|
|
654
674
|
end
|
|
655
675
|
|
|
676
|
+
def field_names
|
|
677
|
+
klass = get_class
|
|
678
|
+
get_member_count.times.collect { |i| klass.get_member_by_index(i).name }
|
|
679
|
+
end
|
|
680
|
+
|
|
656
681
|
def to_s
|
|
657
682
|
s = "{"
|
|
658
683
|
klass = get_class
|
|
@@ -400,7 +400,8 @@ module Babeltrace2
|
|
|
400
400
|
alias discarded_packets_have_default_clock_snapshots? discarded_packets_have_default_clock_snapshots
|
|
401
401
|
|
|
402
402
|
def set_user_attributes(user_attributes)
|
|
403
|
-
|
|
403
|
+
bt_user_attributes = BTValue.from_value(user_attributes)
|
|
404
|
+
Babeltrace2.bt_stream_class_set_user_attributes(@handle, bt_user_attributes)
|
|
404
405
|
self
|
|
405
406
|
end
|
|
406
407
|
|
|
@@ -414,6 +415,87 @@ module Babeltrace2
|
|
|
414
415
|
end
|
|
415
416
|
alias user_attributes get_user_attributes
|
|
416
417
|
|
|
418
|
+
def to_h
|
|
419
|
+
res = {
|
|
420
|
+
id: id,
|
|
421
|
+
supports_packets: supports_packets? }
|
|
422
|
+
if supports_packets?
|
|
423
|
+
res[:packets_have_beginning_default_clock_snapshot] =
|
|
424
|
+
packets_have_beginning_default_clock_snapshot?
|
|
425
|
+
res[:packets_have_end_default_clock_snapshot] =
|
|
426
|
+
packets_have_end_default_clock_snapshot?
|
|
427
|
+
end
|
|
428
|
+
res[:supports_discarded_events] = supports_discarded_events?
|
|
429
|
+
res[:discarded_events_have_default_clock_snapshots] =
|
|
430
|
+
discarded_events_have_default_clock_snapshots? if supports_discarded_events?
|
|
431
|
+
if supports_packets?
|
|
432
|
+
res[:supports_discarded_packets] = supports_discarded_packets?
|
|
433
|
+
if supports_discarded_packets?
|
|
434
|
+
res[:discarded_packets_have_default_clock_snapshots] = discarded_packets_have_default_clock_snapshots?
|
|
435
|
+
end
|
|
436
|
+
end
|
|
437
|
+
if default_clock_class
|
|
438
|
+
res[:default_clock_class] = default_clock_class.to_h
|
|
439
|
+
end
|
|
440
|
+
if supports_packets? && packet_context_field_class
|
|
441
|
+
res[:packet_context_field_class] = packet_context_field_class.to_h
|
|
442
|
+
end
|
|
443
|
+
if event_common_context_field_class
|
|
444
|
+
res[:event_common_context_field_class] = event_common_context_field_class.to_h
|
|
445
|
+
end
|
|
446
|
+
res[:assigns_automatic_event_class_id] = assigns_automatic_event_class_id?
|
|
447
|
+
res[:assigns_automatic_stream_id] = assigns_automatic_stream_id?
|
|
448
|
+
res[:event_classes] = event_class_count.times.collect { |i|
|
|
449
|
+
get_event_class_by_index(i).to_h
|
|
450
|
+
}
|
|
451
|
+
user_attributes_value = user_attributes.value
|
|
452
|
+
res[:user_attributes] = user_attributes_value if !user_attributes_value.empty?
|
|
453
|
+
res
|
|
454
|
+
end
|
|
455
|
+
|
|
456
|
+
def self.from_h(self_component, trace_class, h)
|
|
457
|
+
id = trace_class.assigns_automatic_stream_class_id? ? nil : h[:id]
|
|
458
|
+
o = trace_class.create_stream_class(id: id)
|
|
459
|
+
o.default_clock_class = BTClockClass.from_h(self_component,
|
|
460
|
+
h[:default_clock_class]) if h[:default_clock_class]
|
|
461
|
+
o.set_supports_packets( h[:supports_packets],
|
|
462
|
+
with_beginning_default_clock_snapshot:
|
|
463
|
+
h[:packets_have_beginning_default_clock_snapshot],
|
|
464
|
+
with_end_default_clock_snapshot:
|
|
465
|
+
h[:packets_have_end_default_clock_snapshot])
|
|
466
|
+
o.set_supports_discarded_events(h[:supports_discarded_events],
|
|
467
|
+
with_default_clock_snapshots:
|
|
468
|
+
h[:discarded_events_have_default_clock_snapshots])
|
|
469
|
+
o.set_supports_discarded_packets(h[:supports_discarded_packets],
|
|
470
|
+
with_default_clock_snapshots:
|
|
471
|
+
h[:discarded_packets_have_default_clock_snapshots]) if h[:supports_packets]
|
|
472
|
+
o.packet_context_field_class = BTFieldClass.from_h(trace_class,
|
|
473
|
+
h[:packet_context_field_class], h) if h[:packet_context_field_class]
|
|
474
|
+
o.event_common_context_field_class = BTFieldClass.from_h(trace_class,
|
|
475
|
+
h[:event_common_context_field_class], h) if h[:event_common_context_field_class]
|
|
476
|
+
o.assigns_automatic_event_class_id = h[:assigns_automatic_event_class_id] unless h[:assigns_automatic_event_class_id].nil?
|
|
477
|
+
o.assigns_automatic_stream_id = h[:assigns_automatic_stream_id] unless h[:assigns_automatic_stream_id].nil?
|
|
478
|
+
h[:event_classes].each_with_index { |v, i|
|
|
479
|
+
h[:bt_current_event] = i;
|
|
480
|
+
BTEventClass.from_h(trace_class, o, v, h)
|
|
481
|
+
}
|
|
482
|
+
h.delete(:bt_current_event)
|
|
483
|
+
o.user_attributes = h[:user_attributes] if h[:user_attributes]
|
|
484
|
+
h[:bt_stream_class] = o
|
|
485
|
+
o
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
def self.locate_field_class(path, h)
|
|
489
|
+
case path[0]
|
|
490
|
+
when :event_payload_field_class
|
|
491
|
+
h[:event_classes][h[:bt_current_event]][:payload_field_class].dig(*path[1..-1])[:bt_field_class]
|
|
492
|
+
when :event_specific_context_field_class
|
|
493
|
+
h[:event_classes][h[:bt_current_event]][:specific_context_field_class].dig(*path[1..-1])[:bt_field_class]
|
|
494
|
+
else
|
|
495
|
+
h.dig(*path)[:bt_field_class]
|
|
496
|
+
end
|
|
497
|
+
end
|
|
498
|
+
|
|
417
499
|
def create_stream(trace, id: nil)
|
|
418
500
|
BTStream.new(stream_class: @handle, trace: trace, id: nil)
|
|
419
501
|
end
|
|
@@ -116,7 +116,8 @@ module Babeltrace2
|
|
|
116
116
|
alias name get_name
|
|
117
117
|
|
|
118
118
|
def set_user_attributes(user_attributes)
|
|
119
|
-
|
|
119
|
+
bt_user_attributes = BTValue.from_value(user_attributes)
|
|
120
|
+
Babeltrace2.bt_stream_set_user_attributes(@handle, bt_user_attributes)
|
|
120
121
|
self
|
|
121
122
|
end
|
|
122
123
|
|
|
@@ -146,7 +146,8 @@ module Babeltrace2
|
|
|
146
146
|
alias assigns_automatic_stream_class_id? assigns_automatic_stream_class_id
|
|
147
147
|
|
|
148
148
|
def set_user_attributes(user_attributes)
|
|
149
|
-
|
|
149
|
+
bt_user_attributes = BTValue.from_value(user_attributes)
|
|
150
|
+
Babeltrace2.bt_trace_class_set_user_attributes(@handle, bt_user_attributes)
|
|
150
151
|
self
|
|
151
152
|
end
|
|
152
153
|
|
|
@@ -339,5 +340,24 @@ module Babeltrace2
|
|
|
339
340
|
end
|
|
340
341
|
alias create_variant_class create_field_class_variant
|
|
341
342
|
alias create_variant create_field_class_variant
|
|
343
|
+
|
|
344
|
+
def to_h
|
|
345
|
+
res = {
|
|
346
|
+
assigns_automatic_stream_class_id: assigns_automatic_stream_class_id?,
|
|
347
|
+
stream_classes: stream_class_count.times.collect { |i| get_stream_class_by_index(i).to_h } }
|
|
348
|
+
user_attributes_value = user_attributes.value
|
|
349
|
+
res[:user_attributes] = user_attributes_value if !user_attributes_value.empty?
|
|
350
|
+
res
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
def self.from_h(self_component, h)
|
|
354
|
+
o = self_component.create_trace_class
|
|
355
|
+
o.assigns_automatic_stream_class_id = h[:assigns_automatic_stream_class_id] unless h[:assigns_automatic_stream_class_id].nil?
|
|
356
|
+
h[:stream_classes].each { |v| BTStreamClass.from_h(self_component, o, v) }
|
|
357
|
+
o.user_attributes = h[:user_attributes] if h[:user_attributes]
|
|
358
|
+
h[:bt_trace_class] = o
|
|
359
|
+
o
|
|
360
|
+
end
|
|
361
|
+
|
|
342
362
|
end
|
|
343
363
|
end
|
|
@@ -281,7 +281,8 @@ module Babeltrace2
|
|
|
281
281
|
end
|
|
282
282
|
|
|
283
283
|
def set_user_attributes(user_attributes)
|
|
284
|
-
|
|
284
|
+
bt_user_attributes = BTValue.from_value(user_attributes)
|
|
285
|
+
Babeltrace2.bt_trace_set_user_attributes(@handle, bt_user_attributes)
|
|
285
286
|
self
|
|
286
287
|
end
|
|
287
288
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: babeltrace2
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brice Videau
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-05-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ffi
|
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
98
98
|
- !ruby/object:Gem::Version
|
|
99
99
|
version: '0'
|
|
100
100
|
requirements: []
|
|
101
|
-
rubygems_version: 3.
|
|
101
|
+
rubygems_version: 3.3.5
|
|
102
102
|
signing_key:
|
|
103
103
|
specification_version: 4
|
|
104
104
|
summary: Ruby Babeltrace 2 bindings
|