babeltrace2 0.1.0 → 0.1.1
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/message-iterator-class.rb +1 -1
- data/lib/babeltrace2/trace-ir/clock-class.rb +28 -0
- data/lib/babeltrace2/trace-ir/event-class.rb +27 -0
- data/lib/babeltrace2/trace-ir/event.rb +4 -0
- data/lib/babeltrace2/trace-ir/field-class.rb +343 -1
- 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 +81 -0
- data/lib/babeltrace2/trace-ir/trace-class.rb +19 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30c884954dad0ab10697ad6131778122c6b91e54334993c10f6ac8d62e99b46b
|
4
|
+
data.tar.gz: a0badd8fced31e5be2a69ad1dded4196964a52ab1a2865895001ea37011d6ebc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44edd1b1a0bca7b23e701748474289f3e7db73b8291b88324a650e41780b62dd1b1320330028f5b1c4f31f66ca05d590fb7a879f705b84a597178b60495cabe2
|
7
|
+
data.tar.gz: c5cd7d590bf6d81d0672c27901fc46ef6802cb004d7936e73c36afe6ca13b99e92cb84d43889d2a7ee87a77e01f0a5cea7f70e4cab68d0566a82d5920fa0ab61
|
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
|
@@ -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)
|
@@ -254,5 +254,33 @@ module Babeltrace2
|
|
254
254
|
raise Babeltrace2.process_error(res) if res != :BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OK
|
255
255
|
ptr.read_int64
|
256
256
|
end
|
257
|
+
|
258
|
+
def to_h
|
259
|
+
res = {}
|
260
|
+
res[:name] = name if name
|
261
|
+
res[:description] = description if description
|
262
|
+
res[:frequency] = frequency
|
263
|
+
res[:precision] = precision
|
264
|
+
res[:offset] = offset
|
265
|
+
res[:origin_is_unix_epoch] = origin_is_unix_epoch?
|
266
|
+
res[:uuid] = uuid.to_s if uuid
|
267
|
+
user_attributes_value = user_attributes.value
|
268
|
+
res[:user_attributes] = user_attributes_value if !user_attributes_value.empty?
|
269
|
+
res
|
270
|
+
end
|
271
|
+
|
272
|
+
def self.from_h(self_component, h)
|
273
|
+
o = self_component.create_clock_class
|
274
|
+
o.name = h[:name] if h[:name]
|
275
|
+
o.description = h[:description] if h[:description]
|
276
|
+
o.frequency = h[:frequency] if h[:frequency]
|
277
|
+
o.precision = h[:precision] if h[:precision]
|
278
|
+
o.set_offset(*h[:offset]) if h[:offset]
|
279
|
+
o.origin_is_unix_epoch = h[:origin_is_unix_epoch]
|
280
|
+
o.uuid = BTUUID.from_string(h[:uuid]) if h[:uuid]
|
281
|
+
o.user_attributes = h[:user_attributes] if h[:user_attributes]
|
282
|
+
h[:bt_clock_class] = o
|
283
|
+
o
|
284
|
+
end
|
257
285
|
end
|
258
286
|
end
|
@@ -288,5 +288,32 @@ module Babeltrace2
|
|
288
288
|
BTValueMap.new(Babeltrace2.bt_event_class_borrow_user_attributes(@handle), retain: true)
|
289
289
|
end
|
290
290
|
alias user_attributes get_user_attributes
|
291
|
+
|
292
|
+
def to_h
|
293
|
+
res = { id: id }
|
294
|
+
res[:name] = name if name
|
295
|
+
res[:log_level] = log_level if log_level
|
296
|
+
res[:emf_uri] = emf_uri if emf_uri
|
297
|
+
res[:specific_context_field_class] = specific_context_field_class.to_h if specific_context_field_class
|
298
|
+
res[:payload_field_class] = payload_field_class.to_h if payload_field_class
|
299
|
+
user_attributes_value = user_attributes.value
|
300
|
+
res[:user_attributes] = user_attributes_value if !user_attributes_value.empty?
|
301
|
+
res
|
302
|
+
end
|
303
|
+
|
304
|
+
def self.from_h(trace_class, stream_class, h, stream_class_h)
|
305
|
+
id = stream_class.assigns_automatic_event_class_id? ? nil : h[:id]
|
306
|
+
o = self.new(stream_class: stream_class, id: id)
|
307
|
+
o.name = h[:name] if h[:name]
|
308
|
+
o.log_level = h[:log_level] if h[:log_level]
|
309
|
+
o.emf_uri = h[:emf_uri] if h[:emf_uri]
|
310
|
+
o.specific_context_field_class = BTFieldClass.from_h(trace_class,
|
311
|
+
h[:specific_context_field_class], stream_class_h) if h[:specific_context_field_class]
|
312
|
+
o.payload_field_class = BTFieldClass.from_h(trace_class,
|
313
|
+
h[:payload_field_class], stream_class_h) if h[:payload_field_class]
|
314
|
+
o.user_attributes = h[:user_attributes] if h[:user_attributes]
|
315
|
+
h[:bt_event_class] = o
|
316
|
+
o
|
317
|
+
end
|
291
318
|
end
|
292
319
|
end
|
@@ -172,6 +172,36 @@ module Babeltrace2
|
|
172
172
|
BTValueMap.new(Babeltrace2.bt_field_class_borrow_user_attributes(@handle), retain: true)
|
173
173
|
end
|
174
174
|
alias user_attributes get_user_attributes
|
175
|
+
|
176
|
+
def to_h
|
177
|
+
res = { type: class_snake_case_name }
|
178
|
+
user_attributes_value = user_attributes.value
|
179
|
+
res[:user_attributes] = user_attributes_value if !user_attributes_value.empty?
|
180
|
+
res
|
181
|
+
end
|
182
|
+
|
183
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
184
|
+
Babeltrace2.const_get(snake_case_to_class(h[:type])).from_h(
|
185
|
+
trace_class, h, stream_class_h)
|
186
|
+
end
|
187
|
+
|
188
|
+
def from_h(h)
|
189
|
+
self.user_attributes = h[:user_attributes] if h[:user_attributes]
|
190
|
+
self
|
191
|
+
end
|
192
|
+
|
193
|
+
private
|
194
|
+
|
195
|
+
def class_snake_case_name
|
196
|
+
str = self.class.name.gsub(/::/, '')
|
197
|
+
str.match(/BTFieldClass(.*)/)[1].
|
198
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
199
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
|
200
|
+
end
|
201
|
+
|
202
|
+
def self.snake_case_to_class(str)
|
203
|
+
"BTFieldClass" << str.split("_").collect(&:capitalize).join
|
204
|
+
end
|
175
205
|
end
|
176
206
|
|
177
207
|
attach_function :bt_field_class_bool_create,
|
@@ -189,6 +219,12 @@ module Babeltrace2
|
|
189
219
|
super(handle, retain: false)
|
190
220
|
end
|
191
221
|
end
|
222
|
+
|
223
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
224
|
+
o = self.new(trace_class: trace_class).from_h(h)
|
225
|
+
h[:bt_field_class] = o
|
226
|
+
o
|
227
|
+
end
|
192
228
|
end
|
193
229
|
BTFieldClassBool = BTFieldClass::Bool
|
194
230
|
BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_BOOL] = [
|
@@ -219,6 +255,18 @@ module Babeltrace2
|
|
219
255
|
Babeltrace2.bt_field_class_bit_array_get_length(@handle)
|
220
256
|
end
|
221
257
|
alias length get_length
|
258
|
+
|
259
|
+
def to_h
|
260
|
+
res = super
|
261
|
+
res[:length] = length
|
262
|
+
res
|
263
|
+
end
|
264
|
+
|
265
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
266
|
+
o = self.new(trace_class: trace_class, length: h[:length]).from_h(h)
|
267
|
+
h[:bt_field_class] = o
|
268
|
+
o
|
269
|
+
end
|
222
270
|
end
|
223
271
|
BTFieldClassBitArray = BTFieldClass::BitArray
|
224
272
|
BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_BIT_ARRAY] = [
|
@@ -260,7 +308,7 @@ module Babeltrace2
|
|
260
308
|
class BTFieldClass::Integer < BTFieldClass
|
261
309
|
|
262
310
|
def set_field_value_range(n)
|
263
|
-
raise "invalid range" if n < 0 || n >
|
311
|
+
raise "invalid range" if n < 0 || n > 64
|
264
312
|
Babeltrace2.bt_field_class_integer_set_field_value_range(@handle, n)
|
265
313
|
self
|
266
314
|
end
|
@@ -305,6 +353,20 @@ module Babeltrace2
|
|
305
353
|
preferred_display_base
|
306
354
|
end
|
307
355
|
end
|
356
|
+
|
357
|
+
def to_h
|
358
|
+
res = super
|
359
|
+
res[:field_value_range] = field_value_range
|
360
|
+
res[:preferred_display_base] = preferred_display_base_integer
|
361
|
+
res
|
362
|
+
end
|
363
|
+
|
364
|
+
def from_h(h)
|
365
|
+
super
|
366
|
+
self.field_value_range = h[:field_value_range] if h[:field_value_range]
|
367
|
+
self.preferred_display_base = h[:preferred_display_base] if h[:preferred_display_base]
|
368
|
+
self
|
369
|
+
end
|
308
370
|
end
|
309
371
|
BTFieldClassInteger = BTFieldClass::Integer
|
310
372
|
|
@@ -323,6 +385,12 @@ module Babeltrace2
|
|
323
385
|
super(handle, retain: false)
|
324
386
|
end
|
325
387
|
end
|
388
|
+
|
389
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
390
|
+
o = self.new(trace_class: trace_class).from_h(h)
|
391
|
+
h[:bt_field_class] = o
|
392
|
+
o
|
393
|
+
end
|
326
394
|
end
|
327
395
|
BTFieldClass::IntegerUnsigned = BTFieldClass::Integer::Unsigned
|
328
396
|
BTFieldClassIntegerUnsigned = BTFieldClass::Integer::Unsigned
|
@@ -345,6 +413,12 @@ module Babeltrace2
|
|
345
413
|
super(handle, retain: false)
|
346
414
|
end
|
347
415
|
end
|
416
|
+
|
417
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
418
|
+
o = self.new(trace_class: trace_class).from_h(h)
|
419
|
+
h[:bt_field_class] = o
|
420
|
+
o
|
421
|
+
end
|
348
422
|
end
|
349
423
|
BTFieldClass::IntegerSigned = BTFieldClass::Integer::Signed
|
350
424
|
BTFieldClassIntegerSigned = BTFieldClass::Integer::Signed
|
@@ -371,6 +445,12 @@ module Babeltrace2
|
|
371
445
|
super(handle, retain: false)
|
372
446
|
end
|
373
447
|
end
|
448
|
+
|
449
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
450
|
+
o = self.new(trace_class: trace_class).from_h(h)
|
451
|
+
h[:bt_field_class] = o
|
452
|
+
o
|
453
|
+
end
|
374
454
|
end
|
375
455
|
BTFieldClass::RealSinglePrecision = BTFieldClass::Real::SinglePrecision
|
376
456
|
BTFieldClassRealSinglePrecision = BTFieldClass::Real::SinglePrecision
|
@@ -393,6 +473,12 @@ module Babeltrace2
|
|
393
473
|
super(handle, retain: false)
|
394
474
|
end
|
395
475
|
end
|
476
|
+
|
477
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
478
|
+
o = self.new(trace_class: trace_class).from_h(h)
|
479
|
+
h[:bt_field_class] = o
|
480
|
+
o
|
481
|
+
end
|
396
482
|
end
|
397
483
|
BTFieldClass::RealDoublePrecision = BTFieldClass::Real::DoublePrecision
|
398
484
|
BTFieldClassRealDoublePrecision = BTFieldClass::Real::DoublePrecision
|
@@ -448,6 +534,25 @@ module Babeltrace2
|
|
448
534
|
end
|
449
535
|
alias mapping get_mapping
|
450
536
|
|
537
|
+
def to_h
|
538
|
+
res = super
|
539
|
+
res[:mappings] = get_mapping_count.times.collect { |i|
|
540
|
+
mapping = get_mapping_by_index(i)
|
541
|
+
[mapping.label, mapping.ranges.each.collect { |r| [r.lower, r.upper] }]
|
542
|
+
}.to_h
|
543
|
+
res
|
544
|
+
end
|
545
|
+
|
546
|
+
def from_h(h)
|
547
|
+
super
|
548
|
+
if h[:mappings]
|
549
|
+
h[:mappings].each { |name, ranges|
|
550
|
+
add_mapping(name, ranges)
|
551
|
+
}
|
552
|
+
end
|
553
|
+
self
|
554
|
+
end
|
555
|
+
|
451
556
|
class Mapping < BTObject
|
452
557
|
def get_label
|
453
558
|
label = Babeltrace2.bt_field_class_enumeration_mapping_get_label(@handle)
|
@@ -511,6 +616,12 @@ module Babeltrace2
|
|
511
616
|
end
|
512
617
|
end
|
513
618
|
|
619
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
620
|
+
o = self.new(trace_class: trace_class).from_h(h)
|
621
|
+
h[:bt_field_class] = o
|
622
|
+
o
|
623
|
+
end
|
624
|
+
|
514
625
|
def add_mapping(label, ranges)
|
515
626
|
label = label.inspect if label.kind_of?(Symbol)
|
516
627
|
ranges = BTIntegerRangeSetUnsigned.from_value(ranges)
|
@@ -608,6 +719,12 @@ module Babeltrace2
|
|
608
719
|
end
|
609
720
|
end
|
610
721
|
|
722
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
723
|
+
o = self.new(trace_class: trace_class).from_h(h)
|
724
|
+
h[:bt_field_class] = o
|
725
|
+
o
|
726
|
+
end
|
727
|
+
|
611
728
|
def add_mapping(label, ranges)
|
612
729
|
label = label.inspect if label.kind_of?(Symbol)
|
613
730
|
ranges = BTIntegerRangeSetSigned.from_value(ranges)
|
@@ -672,6 +789,12 @@ module Babeltrace2
|
|
672
789
|
super(handle, retain: false)
|
673
790
|
end
|
674
791
|
end
|
792
|
+
|
793
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
794
|
+
o = self.new(trace_class: trace_class).from_h(h)
|
795
|
+
h[:bt_field_class] = o
|
796
|
+
o
|
797
|
+
end
|
675
798
|
end
|
676
799
|
BTFieldClassString = BTFieldClass::String
|
677
800
|
BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_STRING] = [
|
@@ -692,6 +815,12 @@ module Babeltrace2
|
|
692
815
|
Babeltrace2.bt_field_class_array_borrow_element_field_class(@handle))
|
693
816
|
end
|
694
817
|
alias element_field_class get_element_field_class
|
818
|
+
|
819
|
+
def to_h
|
820
|
+
res = super
|
821
|
+
res[:element_field_class] = element_field_class.to_h
|
822
|
+
res
|
823
|
+
end
|
695
824
|
end
|
696
825
|
BTFieldClassArray = BTFieldClass::Array
|
697
826
|
|
@@ -721,6 +850,22 @@ module Babeltrace2
|
|
721
850
|
end
|
722
851
|
alias length get_length
|
723
852
|
alias size get_length
|
853
|
+
|
854
|
+
def to_h
|
855
|
+
res = super
|
856
|
+
res[:length] = length
|
857
|
+
res
|
858
|
+
end
|
859
|
+
|
860
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
861
|
+
o = self.new(trace_class: trace_class,
|
862
|
+
element_field_class: BTFieldClass.from_h(trace_class,
|
863
|
+
h[:element_field_class],
|
864
|
+
stream_class_h),
|
865
|
+
length: h[:length]).from_h(h)
|
866
|
+
h[:bt_field_class] = o
|
867
|
+
o
|
868
|
+
end
|
724
869
|
end
|
725
870
|
BTFieldClassArrayStatic = BTFieldClass::Array::Static
|
726
871
|
BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_STATIC_ARRAY] = [
|
@@ -744,6 +889,12 @@ module Babeltrace2
|
|
744
889
|
BTFieldPath.new(handle, retain: true)
|
745
890
|
end
|
746
891
|
alias length_field_path get_length_field_path
|
892
|
+
|
893
|
+
def to_h
|
894
|
+
res = super
|
895
|
+
res[:length_field_path] = length_field_path.to_s
|
896
|
+
res
|
897
|
+
end
|
747
898
|
end
|
748
899
|
def initialize(handle = nil, retain: true, auto_release: true,
|
749
900
|
trace_class: nil, element_field_class: nil, length_field_class: nil)
|
@@ -759,6 +910,22 @@ module Babeltrace2
|
|
759
910
|
super(handle, retain: false)
|
760
911
|
end
|
761
912
|
end
|
913
|
+
|
914
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
915
|
+
if (stream_class_h && h[:length_field_path])
|
916
|
+
length_field_class = BTStreamClass.locate_field_class(
|
917
|
+
BTFieldPath.path_from_s_to_h(h[:length_field_path]), stream_class_h)
|
918
|
+
else
|
919
|
+
length_field_class = nil
|
920
|
+
end
|
921
|
+
o = self.new(trace_class: trace_class,
|
922
|
+
element_field_class: BTFieldClass.from_h(trace_class,
|
923
|
+
h[:element_field_class],
|
924
|
+
stream_class_h),
|
925
|
+
length_field_class: length_field_class).from_h(h)
|
926
|
+
h[:bt_field_class] = o
|
927
|
+
o
|
928
|
+
end
|
762
929
|
end
|
763
930
|
BTFieldClassArrayDynamic = BTFieldClass::Array::Dynamic
|
764
931
|
BTFieldClassArrayDynamicWithLengthField = BTFieldClass::Array::Dynamic::WithLengthField
|
@@ -858,6 +1025,18 @@ module Babeltrace2
|
|
858
1025
|
BTValueMap.new(Babeltrace2.bt_field_class_structure_member_borrow_user_attributes(@handle), retain: true)
|
859
1026
|
end
|
860
1027
|
alias user_attributes get_user_attributes
|
1028
|
+
|
1029
|
+
def to_h
|
1030
|
+
res = { name: name, field_class: field_class.to_h }
|
1031
|
+
user_attributes_value = user_attributes.value
|
1032
|
+
res[:user_attributes] = user_attributes_value if !user_attributes_value.empty?
|
1033
|
+
res
|
1034
|
+
end
|
1035
|
+
|
1036
|
+
def from_h(h)
|
1037
|
+
self.user_attributes = h[:user_attributes] if h[:user_attributes]
|
1038
|
+
self
|
1039
|
+
end
|
861
1040
|
end
|
862
1041
|
|
863
1042
|
def initialize(handle = nil, retain: true, auto_release: true,
|
@@ -911,6 +1090,23 @@ module Babeltrace2
|
|
911
1090
|
end
|
912
1091
|
end
|
913
1092
|
alias [] get_member
|
1093
|
+
|
1094
|
+
def to_h
|
1095
|
+
res = super
|
1096
|
+
res[:members] = member_count.times.collect { |i| get_member_by_index(i).to_h }
|
1097
|
+
res
|
1098
|
+
end
|
1099
|
+
|
1100
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
1101
|
+
o = self.new(trace_class: trace_class).from_h(h)
|
1102
|
+
h[:members].each_with_index { |v, i|
|
1103
|
+
o.append_member(v[:name],
|
1104
|
+
BTFieldClass.from_h(trace_class, v[:field_class], stream_class_h))
|
1105
|
+
o.get_member_by_index(i).from_h(v)
|
1106
|
+
}
|
1107
|
+
h[:bt_field_class] = o
|
1108
|
+
o
|
1109
|
+
end
|
914
1110
|
end
|
915
1111
|
BTFieldClassStructure = BTFieldClass::Structure
|
916
1112
|
BTFieldClassStructureMember = BTFieldClass::Structure::Member
|
@@ -932,6 +1128,12 @@ module Babeltrace2
|
|
932
1128
|
Babeltrace2.bt_field_class_option_borrow_field_class(@handle))
|
933
1129
|
end
|
934
1130
|
alias field_class get_field_class
|
1131
|
+
|
1132
|
+
def to_h
|
1133
|
+
res = super
|
1134
|
+
res[:field_class] = field_class.to_h
|
1135
|
+
res
|
1136
|
+
end
|
935
1137
|
end
|
936
1138
|
BTFieldClassOption = BTFieldClass::Option
|
937
1139
|
|
@@ -951,6 +1153,15 @@ module Babeltrace2
|
|
951
1153
|
super(handle, retain: false)
|
952
1154
|
end
|
953
1155
|
end
|
1156
|
+
|
1157
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
1158
|
+
o = self.new(trace_class: trace_class,
|
1159
|
+
optional_field_class: BTFieldClass.from_h(trace_class,
|
1160
|
+
h[:field_class],
|
1161
|
+
stream_class_h)).from_h(h)
|
1162
|
+
h[:bt_field_class] = o
|
1163
|
+
o
|
1164
|
+
end
|
954
1165
|
end
|
955
1166
|
BTFieldClassOptionWithoutSelectorField = BTFieldClass::Option::WithoutSelectorField
|
956
1167
|
BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD] = [
|
@@ -968,6 +1179,12 @@ module Babeltrace2
|
|
968
1179
|
BTFieldPath.new(handle, retain: true)
|
969
1180
|
end
|
970
1181
|
alias selector_field_path get_selector_field_path
|
1182
|
+
|
1183
|
+
def to_h
|
1184
|
+
res = super
|
1185
|
+
res[:selector_field_path] = selector_field_path.to_s if selector_field_path
|
1186
|
+
res
|
1187
|
+
end
|
971
1188
|
end
|
972
1189
|
BTFieldClassOptionWithSelectorField = BTFieldClass::Option::WithSelectorField
|
973
1190
|
|
@@ -1014,6 +1231,29 @@ module Babeltrace2
|
|
1014
1231
|
@handle) != BT_FALSE
|
1015
1232
|
end
|
1016
1233
|
alias selector_is_reversed? selector_is_reversed
|
1234
|
+
|
1235
|
+
def to_h
|
1236
|
+
res = super
|
1237
|
+
res[:selector_is_reversed] = selector_is_reversed?
|
1238
|
+
res
|
1239
|
+
end
|
1240
|
+
|
1241
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
1242
|
+
if (stream_class_h && h[:selector_field_path])
|
1243
|
+
selector_field_class = BTStreamClass.locate_field_class(
|
1244
|
+
BTFieldPath.path_from_s_to_h(h[:selector_field_path]), stream_class_h)
|
1245
|
+
else
|
1246
|
+
selector_field_class = nil
|
1247
|
+
end
|
1248
|
+
o = self.new(trace_class: trace_class,
|
1249
|
+
optional_field_class: BTFieldClass.from_h(trace_class,
|
1250
|
+
h[:field_class],
|
1251
|
+
stream_class_h),
|
1252
|
+
selector_field_class: selector_field_class).from_h(h)
|
1253
|
+
o.selector_is_reversed = h[:selector_is_reversed] if h[:selector_is_reversed]
|
1254
|
+
h[:bt_field_class] = o
|
1255
|
+
o
|
1256
|
+
end
|
1017
1257
|
end
|
1018
1258
|
BTFieldClassOptionWithSelectorFieldBool = BTFieldClass::Option::WithSelectorField::Bool
|
1019
1259
|
BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD] = [
|
@@ -1051,6 +1291,29 @@ module Babeltrace2
|
|
1051
1291
|
@handle), retain: true)
|
1052
1292
|
end
|
1053
1293
|
alias selector_ranges get_selector_ranges
|
1294
|
+
|
1295
|
+
def to_h
|
1296
|
+
res = super
|
1297
|
+
res[:selector_ranges] = selector_ranges.each.collect { |r| [r.lower, r.upper] }
|
1298
|
+
res
|
1299
|
+
end
|
1300
|
+
|
1301
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
1302
|
+
if (stream_class_h && h[:selector_field_path])
|
1303
|
+
selector_field_class = BTStreamClass.locate_field_class(
|
1304
|
+
BTFieldPath.path_from_s_to_h(h[:selector_field_path]), stream_class_h)
|
1305
|
+
else
|
1306
|
+
selector_field_class = nil
|
1307
|
+
end
|
1308
|
+
o = self.new(trace_class: trace_class,
|
1309
|
+
optional_field_class: BTFieldClass.from_h(trace_class,
|
1310
|
+
h[:field_class],
|
1311
|
+
stream_class_h),
|
1312
|
+
selector_field_class: selector_field_class,
|
1313
|
+
ranges: h[:selector_ranges]).from_h(h)
|
1314
|
+
h[:bt_field_class] = o
|
1315
|
+
o
|
1316
|
+
end
|
1054
1317
|
end
|
1055
1318
|
BTFieldClassOptionWithSelectorFieldIntegerUnsigned = BTFieldClass::Option::WithSelectorField::IntegerUnsigned
|
1056
1319
|
BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD] = [
|
@@ -1088,6 +1351,29 @@ module Babeltrace2
|
|
1088
1351
|
@handle), retain: true)
|
1089
1352
|
end
|
1090
1353
|
alias selector_ranges get_selector_ranges
|
1354
|
+
|
1355
|
+
def to_h
|
1356
|
+
res = super
|
1357
|
+
res[:selector_ranges] = selector_ranges.each.collect { |r| [r.lower, r.upper] }
|
1358
|
+
res
|
1359
|
+
end
|
1360
|
+
|
1361
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
1362
|
+
if (stream_class_h && h[:selector_field_path])
|
1363
|
+
selector_field_class = BTStreamClass.locate_field_class(
|
1364
|
+
BTFieldPath.path_from_s_to_h(h[:selector_field_path]), stream_class_h)
|
1365
|
+
else
|
1366
|
+
selector_field_class = nil
|
1367
|
+
end
|
1368
|
+
o = self.new(trace_class: trace_class,
|
1369
|
+
optional_field_class: BTFieldClass.from_h(trace_class,
|
1370
|
+
h[:field_class],
|
1371
|
+
stream_class_h),
|
1372
|
+
selector_field_class: selector_field_class,
|
1373
|
+
ranges: h[:selector_ranges]).from_h(h)
|
1374
|
+
h[:bt_field_class] = o
|
1375
|
+
o
|
1376
|
+
end
|
1091
1377
|
end
|
1092
1378
|
BTFieldClassOptionWithSelectorFieldIntegerSigned = BTFieldClass::Option::WithSelectorField::IntegerSigned
|
1093
1379
|
BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD] = [
|
@@ -1174,6 +1460,13 @@ module Babeltrace2
|
|
1174
1460
|
@handle), retain: true)
|
1175
1461
|
end
|
1176
1462
|
alias user_attributes get_user_attributes
|
1463
|
+
|
1464
|
+
def to_h
|
1465
|
+
res = { name: name, field_class: field_class.to_h }
|
1466
|
+
user_attributes_value = user_attributes.value
|
1467
|
+
res[:user_attributes] = user_attributes_value if !user_attributes_value.empty?
|
1468
|
+
res
|
1469
|
+
end
|
1177
1470
|
end
|
1178
1471
|
end
|
1179
1472
|
BTFieldClassVariantOption = BTFieldClass::Variant::Option
|
@@ -1259,6 +1552,13 @@ module Babeltrace2
|
|
1259
1552
|
BTFieldPath.new(handle, retain: true)
|
1260
1553
|
end
|
1261
1554
|
alias selector_field_path get_selector_field_path
|
1555
|
+
|
1556
|
+
def to_h
|
1557
|
+
res = super
|
1558
|
+
res[:selector_field_path] = selector_field_path.to_s
|
1559
|
+
res
|
1560
|
+
end
|
1561
|
+
|
1262
1562
|
module IntegerUnsigned
|
1263
1563
|
class Option < BTFieldClassVariantOption
|
1264
1564
|
def get_ranges
|
@@ -1267,6 +1567,12 @@ module Babeltrace2
|
|
1267
1567
|
@handle), retain: true)
|
1268
1568
|
end
|
1269
1569
|
alias ranges get_ranges
|
1570
|
+
|
1571
|
+
def to_h
|
1572
|
+
res = super
|
1573
|
+
res[:ranges] = ranges.each.collect { |r| [r.lower, r.upper] }
|
1574
|
+
res
|
1575
|
+
end
|
1270
1576
|
end
|
1271
1577
|
include WithSelectorField
|
1272
1578
|
def append_option(name, option_field_class, ranges)
|
@@ -1303,6 +1609,12 @@ module Babeltrace2
|
|
1303
1609
|
@handle), retain: true)
|
1304
1610
|
end
|
1305
1611
|
alias ranges get_ranges
|
1612
|
+
|
1613
|
+
def to_h
|
1614
|
+
res = super
|
1615
|
+
res[:ranges] = ranges.each.collect { |r| [r.lower, r.upper] }
|
1616
|
+
res
|
1617
|
+
end
|
1306
1618
|
end
|
1307
1619
|
include WithSelectorField
|
1308
1620
|
def append_option(name, option_field_class, ranges)
|
@@ -1395,6 +1707,36 @@ module Babeltrace2
|
|
1395
1707
|
end
|
1396
1708
|
alias [] get_option
|
1397
1709
|
|
1710
|
+
def to_h
|
1711
|
+
res = super
|
1712
|
+
res[:options] = option_count.times.collect { |i|
|
1713
|
+
get_option_by_index(i).to_h
|
1714
|
+
}
|
1715
|
+
res
|
1716
|
+
end
|
1717
|
+
|
1718
|
+
def self.from_h(trace_class, h, stream_class_h = nil)
|
1719
|
+
if (stream_class_h && h[:selector_field_path])
|
1720
|
+
selector_field_class = BTStreamClass.locate_field_class(
|
1721
|
+
BTFieldPath.path_from_s_to_h(h[:selector_field_path]), stream_class_h)
|
1722
|
+
else
|
1723
|
+
selector_field_class = nil
|
1724
|
+
end
|
1725
|
+
o = self.new(trace_class: trace_class,
|
1726
|
+
selector_field_class: selector_field_class).from_h(h)
|
1727
|
+
if selector_field_class
|
1728
|
+
h[:options].each { |v|
|
1729
|
+
o.append_option(v[:name],
|
1730
|
+
BTFieldClass.from_h(trace_class, v[:field_class], stream_class_h),
|
1731
|
+
v[:ranges]) }
|
1732
|
+
else
|
1733
|
+
h[:options].each { |v|
|
1734
|
+
o.append_option(v[:name],
|
1735
|
+
BTFieldClass.from_h(trace_class, v[:field_class], stream_class_h)) }
|
1736
|
+
end
|
1737
|
+
h[:bt_field_class] = o
|
1738
|
+
o
|
1739
|
+
end
|
1398
1740
|
end
|
1399
1741
|
BTFieldClassVariantWithoutSelectorField =
|
1400
1742
|
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
|
@@ -414,6 +414,87 @@ module Babeltrace2
|
|
414
414
|
end
|
415
415
|
alias user_attributes get_user_attributes
|
416
416
|
|
417
|
+
def to_h
|
418
|
+
res = {
|
419
|
+
id: id,
|
420
|
+
supports_packets: supports_packets? }
|
421
|
+
if supports_packets?
|
422
|
+
res[:packets_have_beginning_default_clock_snapshot] =
|
423
|
+
packets_have_beginning_default_clock_snapshot?
|
424
|
+
res[:packets_have_end_default_clock_snapshot] =
|
425
|
+
packets_have_end_default_clock_snapshot?
|
426
|
+
end
|
427
|
+
res[:supports_discarded_events] = supports_discarded_events?
|
428
|
+
res[:discarded_events_have_default_clock_snapshots] =
|
429
|
+
discarded_events_have_default_clock_snapshots? if supports_discarded_events?
|
430
|
+
if supports_packets?
|
431
|
+
res[:supports_discarded_packets] = supports_discarded_packets?
|
432
|
+
if supports_discarded_packets?
|
433
|
+
res[:discarded_packets_have_default_clock_snapshots] = discarded_packets_have_default_clock_snapshots?
|
434
|
+
end
|
435
|
+
end
|
436
|
+
if default_clock_class
|
437
|
+
res[:default_clock_class] = default_clock_class.to_h
|
438
|
+
end
|
439
|
+
if supports_packets? && packet_context_field_class
|
440
|
+
res[:packet_context_field_class] = packet_context_field_class.to_h
|
441
|
+
end
|
442
|
+
if event_common_context_field_class
|
443
|
+
res[:event_common_context_field_class] = event_common_context_field_class.to_h
|
444
|
+
end
|
445
|
+
res[:assigns_automatic_event_class_id] = assigns_automatic_event_class_id?
|
446
|
+
res[:assigns_automatic_stream_id] = assigns_automatic_stream_id?
|
447
|
+
res[:event_classes] = event_class_count.times.collect { |i|
|
448
|
+
get_event_class_by_index(i).to_h
|
449
|
+
}
|
450
|
+
user_attributes_value = user_attributes.value
|
451
|
+
res[:user_attributes] = user_attributes_value if !user_attributes_value.empty?
|
452
|
+
res
|
453
|
+
end
|
454
|
+
|
455
|
+
def self.from_h(self_component, trace_class, h)
|
456
|
+
id = trace_class.assigns_automatic_stream_class_id? ? nil : h[:id]
|
457
|
+
o = trace_class.create_stream_class(id: id)
|
458
|
+
o.default_clock_class = BTClockClass.from_h(self_component,
|
459
|
+
h[:default_clock_class]) if h[:default_clock_class]
|
460
|
+
o.set_supports_packets( h[:supports_packets],
|
461
|
+
with_beginning_default_clock_snapshot:
|
462
|
+
h[:packets_have_beginning_default_clock_snapshot],
|
463
|
+
with_end_default_clock_snapshot:
|
464
|
+
h[:packets_have_end_default_clock_snapshot])
|
465
|
+
o.set_supports_discarded_events(h[:supports_discarded_events],
|
466
|
+
with_default_clock_snapshots:
|
467
|
+
h[:discarded_events_have_default_clock_snapshots])
|
468
|
+
o.set_supports_discarded_packets(h[:supports_discarded_packets],
|
469
|
+
with_default_clock_snapshots:
|
470
|
+
h[:discarded_packets_have_default_clock_snapshots]) if h[:supports_packets]
|
471
|
+
o.packet_context_field_class = BTFieldClass.from_h(trace_class,
|
472
|
+
h[:packet_context_field_class], h) if h[:packet_context_field_class]
|
473
|
+
o.event_common_context_field_class = BTFieldClass.from_h(trace_class,
|
474
|
+
h[:event_common_context_field_class], h) if h[:event_common_context_field_class]
|
475
|
+
o.assigns_automatic_event_class_id = h[:assigns_automatic_event_class_id] unless h[:assigns_automatic_event_class_id].nil?
|
476
|
+
o.assigns_automatic_stream_id = h[:assigns_automatic_stream_id] unless h[:assigns_automatic_stream_id].nil?
|
477
|
+
h[:event_classes].each_with_index { |v, i|
|
478
|
+
h[:bt_current_event] = i;
|
479
|
+
BTEventClass.from_h(trace_class, o, v, h)
|
480
|
+
}
|
481
|
+
h.delete(:bt_current_event)
|
482
|
+
o.user_attributes = h[:user_attributes] if h[:user_attributes]
|
483
|
+
h[:bt_stream_class] = o
|
484
|
+
o
|
485
|
+
end
|
486
|
+
|
487
|
+
def self.locate_field_class(path, h)
|
488
|
+
case path[0]
|
489
|
+
when :event_payload_field_class
|
490
|
+
h[:event_classes][h[:bt_current_event]][:payload_field_class].dig(*path[1..-1])[:bt_field_class]
|
491
|
+
when :event_specific_context_field_class
|
492
|
+
h[:event_classes][h[:bt_current_event]][:specific_context_field_class].dig(*path[1..-1])[:bt_field_class]
|
493
|
+
else
|
494
|
+
h.dig(*path)[:bt_field_class]
|
495
|
+
end
|
496
|
+
end
|
497
|
+
|
417
498
|
def create_stream(trace, id: nil)
|
418
499
|
BTStream.new(stream_class: @handle, trace: trace, id: nil)
|
419
500
|
end
|
@@ -339,5 +339,24 @@ module Babeltrace2
|
|
339
339
|
end
|
340
340
|
alias create_variant_class create_field_class_variant
|
341
341
|
alias create_variant create_field_class_variant
|
342
|
+
|
343
|
+
def to_h
|
344
|
+
res = {
|
345
|
+
assigns_automatic_stream_class_id: assigns_automatic_stream_class_id?,
|
346
|
+
stream_classes: stream_class_count.times.collect { |i| get_stream_class_by_index(i).to_h } }
|
347
|
+
user_attributes_value = user_attributes.value
|
348
|
+
res[:user_attributes] = user_attributes_value if !user_attributes_value.empty?
|
349
|
+
res
|
350
|
+
end
|
351
|
+
|
352
|
+
def self.from_h(self_component, h)
|
353
|
+
o = self_component.create_trace_class
|
354
|
+
o.assigns_automatic_stream_class_id = h[:assigns_automatic_stream_class_id] unless h[:assigns_automatic_stream_class_id].nil?
|
355
|
+
h[:stream_classes].each { |v| BTStreamClass.from_h(self_component, o, v) }
|
356
|
+
o.user_attributes = h[:user_attributes] if h[:user_attributes]
|
357
|
+
h[:bt_trace_class] = o
|
358
|
+
o
|
359
|
+
end
|
360
|
+
|
342
361
|
end
|
343
362
|
end
|
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.1
|
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: 2021-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|