babeltrace2 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/babeltrace2.gemspec +13 -0
  4. data/lib/babeltrace2.rb +49 -0
  5. data/lib/babeltrace2/error-reporting.rb +432 -0
  6. data/lib/babeltrace2/func-status.rb +26 -0
  7. data/lib/babeltrace2/graph/component-class-dev.rb +801 -0
  8. data/lib/babeltrace2/graph/component-class.rb +134 -0
  9. data/lib/babeltrace2/graph/component-descriptor-set.rb +78 -0
  10. data/lib/babeltrace2/graph/component.rb +362 -0
  11. data/lib/babeltrace2/graph/connection.rb +35 -0
  12. data/lib/babeltrace2/graph/graph.rb +523 -0
  13. data/lib/babeltrace2/graph/interrupter.rb +57 -0
  14. data/lib/babeltrace2/graph/message-iterator-class.rb +374 -0
  15. data/lib/babeltrace2/graph/message-iterator.rb +253 -0
  16. data/lib/babeltrace2/graph/message.rb +721 -0
  17. data/lib/babeltrace2/graph/port.rb +124 -0
  18. data/lib/babeltrace2/graph/private-query-executor.rb +4 -0
  19. data/lib/babeltrace2/graph/query-executor.rb +142 -0
  20. data/lib/babeltrace2/graph/self-component-class.rb +37 -0
  21. data/lib/babeltrace2/graph/self-component-port.rb +35 -0
  22. data/lib/babeltrace2/graph/self-component.rb +264 -0
  23. data/lib/babeltrace2/graph/self-message-iterator.rb +147 -0
  24. data/lib/babeltrace2/integer-range-set.rb +275 -0
  25. data/lib/babeltrace2/logging-defs.rb +19 -0
  26. data/lib/babeltrace2/logging.rb +77 -0
  27. data/lib/babeltrace2/plugin/plugin-dev.rb +335 -0
  28. data/lib/babeltrace2/plugin/plugin-loading.rb +459 -0
  29. data/lib/babeltrace2/trace-ir/clock-class.rb +258 -0
  30. data/lib/babeltrace2/trace-ir/clock-snapshot.rb +45 -0
  31. data/lib/babeltrace2/trace-ir/event-class.rb +292 -0
  32. data/lib/babeltrace2/trace-ir/event.rb +91 -0
  33. data/lib/babeltrace2/trace-ir/field-class.rb +1416 -0
  34. data/lib/babeltrace2/trace-ir/field-path.rb +123 -0
  35. data/lib/babeltrace2/trace-ir/field.rb +871 -0
  36. data/lib/babeltrace2/trace-ir/packet.rb +57 -0
  37. data/lib/babeltrace2/trace-ir/stream-class.rb +425 -0
  38. data/lib/babeltrace2/trace-ir/stream.rb +137 -0
  39. data/lib/babeltrace2/trace-ir/trace-class.rb +343 -0
  40. data/lib/babeltrace2/trace-ir/trace.rb +321 -0
  41. data/lib/babeltrace2/types.rb +667 -0
  42. data/lib/babeltrace2/util.rb +23 -0
  43. data/lib/babeltrace2/value.rb +869 -0
  44. data/lib/babeltrace2/version.rb +126 -0
  45. metadata +105 -0
@@ -0,0 +1,321 @@
1
+ module Babeltrace2
2
+
3
+ attach_function :bt_trace_create,
4
+ [ :bt_trace_class_handle ],
5
+ :bt_trace_handle
6
+
7
+ attach_function :bt_trace_borrow_class,
8
+ [ :bt_trace_handle ],
9
+ :bt_trace_class_handle
10
+
11
+ attach_function :bt_trace_borrow_class_const,
12
+ [ :bt_trace_handle ],
13
+ :bt_trace_class_handle
14
+
15
+ attach_function :bt_trace_get_stream_count,
16
+ [ :bt_trace_handle ],
17
+ :uint64
18
+
19
+ attach_function :bt_trace_borrow_stream_by_index,
20
+ [ :bt_trace_handle, :uint64 ],
21
+ :bt_stream_handle
22
+
23
+ attach_function :bt_trace_borrow_stream_by_index_const,
24
+ [ :bt_trace_handle, :uint64 ],
25
+ :bt_stream_handle
26
+
27
+ attach_function :bt_trace_borrow_stream_by_id,
28
+ [ :bt_trace_handle, :uint64 ],
29
+ :bt_stream_handle
30
+
31
+ attach_function :bt_trace_borrow_stream_by_id_const,
32
+ [ :bt_trace_handle, :uint64 ],
33
+ :bt_stream_handle
34
+
35
+ attach_function :bt_trace_get_name,
36
+ [ :bt_trace_handle ],
37
+ :string
38
+
39
+ BT_TRACE_SET_NAME_STATUS_OK = BT_FUNC_STATUS_OK
40
+ BT_TRACE_SET_NAME_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
41
+ BTTraceSetNameStatus = enum :bt_trace_set_name_status,
42
+ [ :BT_TRACE_SET_NAME_STATUS_OK,
43
+ BT_TRACE_SET_NAME_STATUS_OK,
44
+ :BT_TRACE_SET_NAME_STATUS_MEMORY_ERROR,
45
+ BT_TRACE_SET_NAME_STATUS_MEMORY_ERROR ]
46
+
47
+ attach_function :bt_trace_set_name,
48
+ [ :bt_trace_handle, :string ],
49
+ :bt_trace_set_name_status
50
+
51
+ attach_function :bt_trace_set_uuid,
52
+ [ :bt_trace_handle, :bt_uuid ],
53
+ :void
54
+
55
+ attach_function :bt_trace_get_uuid,
56
+ [ :bt_trace_handle ],
57
+ :bt_uuid
58
+
59
+ BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_OK = BT_FUNC_STATUS_OK
60
+ BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
61
+ BTTraceSetEnvironmentEntryStatus = enum :bt_trace_set_environment_entry_status,
62
+ [ :BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_OK,
63
+ BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_OK,
64
+ :BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR,
65
+ BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR ]
66
+
67
+ attach_function :bt_trace_set_environment_entry_integer,
68
+ [ :bt_trace_handle, :string, :int64 ],
69
+ :bt_trace_set_environment_entry_status
70
+
71
+ attach_function :bt_trace_set_environment_entry_string,
72
+ [ :bt_trace_handle, :string, :string ],
73
+ :bt_trace_set_environment_entry_status
74
+
75
+ attach_function :bt_trace_get_environment_entry_count,
76
+ [ :bt_trace_handle ],
77
+ :uint64
78
+
79
+ attach_function :bt_trace_borrow_environment_entry_by_index_const,
80
+ [ :bt_trace_handle, :uint64, :pointer, :pointer ],
81
+ :void
82
+
83
+ attach_function :bt_trace_borrow_environment_entry_value_by_name_const,
84
+ [ :bt_trace_handle, :string ],
85
+ :bt_value_handle
86
+
87
+ attach_function :bt_trace_set_user_attributes,
88
+ [ :bt_trace_handle, :bt_value_map_handle ],
89
+ :void
90
+
91
+ attach_function :bt_trace_borrow_user_attributes,
92
+ [ :bt_trace_handle ],
93
+ :bt_value_map_handle
94
+
95
+ attach_function :bt_trace_borrow_user_attributes_const,
96
+ [ :bt_trace_handle ],
97
+ :bt_value_map_handle
98
+
99
+ callback :bt_trace_destruction_listener_func,
100
+ [ :bt_trace_handle, :pointer],
101
+ :void
102
+
103
+ def self._wrap_trace_destruction_listener_func(method)
104
+ method_wrapper = lambda { |trace, user_data|
105
+ begin
106
+ method.call(BTTrace.new(trace,
107
+ retain: false, auto_release: false), user_data)
108
+ rescue Exception => e
109
+ puts e
110
+ end
111
+ }
112
+ method_wrapper
113
+ end
114
+
115
+ BT_TRACE_ADD_LISTENER_STATUS_OK = BT_FUNC_STATUS_OK
116
+ BT_TRACE_ADD_LISTENER_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
117
+ BTTraceAddListenerStatus = enum :bt_trace_add_listener_status,
118
+ [ :BT_TRACE_ADD_LISTENER_STATUS_OK,
119
+ BT_TRACE_ADD_LISTENER_STATUS_OK,
120
+ :BT_TRACE_ADD_LISTENER_STATUS_MEMORY_ERROR,
121
+ BT_TRACE_ADD_LISTENER_STATUS_MEMORY_ERROR ]
122
+
123
+ attach_function :bt_trace_add_destruction_listener,
124
+ [ :bt_trace_handle, :bt_trace_destruction_listener_func,
125
+ :pointer, :pointer ],
126
+ :bt_trace_add_listener_status
127
+
128
+ BT_TRACE_REMOVE_LISTENER_STATUS_OK = BT_FUNC_STATUS_OK
129
+ BT_TRACE_REMOVE_LISTENER_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
130
+ BTTraceRemoveListenerStatus = enum :bt_trace_remove_listener_status,
131
+ [ :BT_TRACE_REMOVE_LISTENER_STATUS_OK,
132
+ BT_TRACE_REMOVE_LISTENER_STATUS_OK,
133
+ :BT_TRACE_REMOVE_LISTENER_STATUS_MEMORY_ERROR,
134
+ BT_TRACE_REMOVE_LISTENER_STATUS_MEMORY_ERROR ]
135
+
136
+ attach_function :bt_trace_remove_destruction_listener,
137
+ [ :bt_trace_handle, :bt_listener_id ],
138
+ :bt_trace_remove_listener_status
139
+
140
+ attach_function :bt_trace_get_ref,
141
+ [ :bt_trace_handle ],
142
+ :void
143
+
144
+ attach_function :bt_trace_put_ref,
145
+ [ :bt_trace_handle ],
146
+ :void
147
+
148
+ class BTTrace < BTSharedObject
149
+ SetNameStatus = BTTraceSetNameStatus
150
+ SetEnvironmentEntryStatus = BTTraceSetEnvironmentEntryStatus
151
+ AddListenerStatus = BTTraceAddListenerStatus
152
+ RemoveListenerStatus = BTTraceRemoveListenerStatus
153
+ @get_ref = :bt_trace_get_ref
154
+ @put_ref = :bt_trace_put_ref
155
+
156
+ def initialize(handle = nil, retain: true, auto_release: true,
157
+ trace_class: nil)
158
+ if(handle)
159
+ super(handle, retain: retain, auto_release: auto_release)
160
+ else
161
+ handle = Babeltrace2.bt_trace_create(trace_class)
162
+ raise Babeltrace2.process_error if handle.null?
163
+ super(handle, retain: false)
164
+ end
165
+ end
166
+
167
+ def get_class
168
+ BTTraceClass.new(
169
+ Babeltrace2.bt_trace_borrow_class(@handle), retain: true)
170
+ end
171
+
172
+ def get_stream_count
173
+ Babeltrace2.bt_trace_get_stream_count(@handle)
174
+ end
175
+ alias stream_count get_stream_count
176
+
177
+ def get_stream_by_index(index)
178
+ return nil if index >= get_stream_count
179
+ BTStream.new(
180
+ Babeltrace2.bt_trace_borrow_stream_by_index(@handle, index), retain: true)
181
+ end
182
+
183
+ def get_stream_by_id(id)
184
+ handle = Babeltrace2.bt_trace_borrow_stream_by_id(@handle, id)
185
+ return nil if handle.null?
186
+ BTStream.new(handle, retain: true)
187
+ end
188
+
189
+ def set_name(name)
190
+ res = Babeltrace2.bt_trace_set_name(@handle, name)
191
+ raise Babeltrace2.process_error(res) if res != :BT_TRACE_SET_NAME_STATUS_OK
192
+ self
193
+ end
194
+
195
+ def name=(name)
196
+ set_name(name)
197
+ name
198
+ end
199
+
200
+ def get_name
201
+ Babeltrace2.bt_trace_get_name(@handle)
202
+ end
203
+ alias name get_name
204
+
205
+ def set_uuid(uuid)
206
+ Babeltrace2.bt_trace_set_uuid(@handle, uuid)
207
+ self
208
+ end
209
+
210
+ def uuid=(uuid)
211
+ set_uuid(uuid)
212
+ uuid
213
+ end
214
+
215
+ def get_uuid
216
+ uuid = Babeltrace2.bt_trace_get_uuid(@handle)
217
+ return nil if uuid.null?
218
+ uuid
219
+ end
220
+ alias uuid get_uuid
221
+
222
+ def set_environment_entry_integer(name, value)
223
+ res = Babeltrace2.bt_trace_set_environment_entry_integer(@handle, name, value)
224
+ raise Babeltrace2.process_error(res) if res != :BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_OK
225
+ self
226
+ end
227
+
228
+ def set_environment_entry_string(name, value)
229
+ res = Babeltrace2.bt_trace_set_environment_entry_string(@handle, name, value)
230
+ raise Babeltrace2.process_error(res) if res != :BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_OK
231
+ self
232
+ end
233
+
234
+ def get_environment_entry_count
235
+ Babeltrace2.bt_trace_get_environment_entry_count(@handle)
236
+ end
237
+ alias environment_entry_count get_environment_entry_count
238
+
239
+ def get_environement_entry_by_index(index)
240
+ return nil if index >= get_environment_entry_count
241
+ ptr1 = FFI::MemoryPointer.new(:pointer)
242
+ ptr2 = FFI::MemoryPointer.new(:pointer)
243
+ Babeltrace2.bt_trace_borrow_environment_entry_by_index_const(
244
+ @handle, index, ptr1, ptr2)
245
+ name = ptr1.read_pointer.read_string
246
+ value = BTValue.from_handle(BTValueHandle.new(ptr2.read_pointer))
247
+ return [name, value]
248
+ end
249
+
250
+ def get_environment_entry_value_by_name(name)
251
+ handle = Babeltrace2.bt_trace_borrow_environment_entry_value_by_name_const(
252
+ @handle, name)
253
+ return nil if handle.null?
254
+ BTValue.from_handle(handle)
255
+ end
256
+
257
+ def get_environment
258
+ get_environment_entry_count.times.collect { |index|
259
+ get_environement_entry_by_index(index)
260
+ }.collect { |name, value| [name, value.value] }.to_h
261
+ end
262
+ alias environment get_environment
263
+
264
+ def set_environement(hash)
265
+ hash.each { |k, v|
266
+ case v
267
+ when String
268
+ set_environment_entry_string(k, v)
269
+ when Integer
270
+ set_environment_entry_integer(k, v)
271
+ else
272
+ raise "invalid value type"
273
+ end
274
+ }
275
+ self
276
+ end
277
+
278
+ def environment=(hash)
279
+ set_environement(hash)
280
+ hash
281
+ end
282
+
283
+ def set_user_attributes(user_attributes)
284
+ Babeltrace2.bt_trace_set_user_attributes(@handle, BTValue.from_value(user_attributes))
285
+ self
286
+ end
287
+
288
+ def user_attributes=(user_attributes)
289
+ set_user_attributes(user_attributes)
290
+ user_attributes
291
+ end
292
+
293
+ def get_user_attributes
294
+ BTValueMap.new(Babeltrace2.bt_trace_borrow_user_attributes(@handle), retain: true)
295
+ end
296
+ alias user_attributes get_user_attributes
297
+
298
+ def add_destruction_listener(user_func, user_data: nil)
299
+ user_func = Babeltrace2._wrap_trace_destruction_listener_func(user_func)
300
+ id = @handle.to_i
301
+ ptr = FFI::MemoryPointer.new(:uint64)
302
+ res = Babeltrace2.bt_trace_add_destruction_listener(@handle, user_func, user_data, ptr)
303
+ raise Babeltrace2.process_error(res) if res != :BT_TRACE_ADD_LISTENER_STATUS_OK
304
+ listener_id = ptr.read_uint64
305
+ h = Babeltrace2._callbacks[id][:destruction_listener_funcs]
306
+ if h.nil?
307
+ h = {}
308
+ Babeltrace2._callbacks[id][:destruction_listener_funcs] = h
309
+ end
310
+ h[listener_id] = [user_func, user_data]
311
+ listener_id
312
+ end
313
+
314
+ def remove_destruction_listener(listener_id)
315
+ res = Babeltrace2.bt_trace_remove_destruction_listener(@handle, listener_id)
316
+ raise Babeltrace2.process_error(res) if res != :BT_TRACE_REMOVE_LISTENER_STATUS_OK
317
+ Babeltrace2._callbacks[@handle.to_i][:destruction_listener_funcs].delete(listener_id)
318
+ self
319
+ end
320
+ end
321
+ end
@@ -0,0 +1,667 @@
1
+ module Babeltrace2
2
+
3
+ class BTHandle < FFI::Pointer
4
+ extend FFI::DataConverter
5
+ class << self
6
+ def native_type
7
+ FFI::Type::POINTER
8
+ end
9
+
10
+ def from_native(value, context)
11
+ new(value) #value.null? ? nil : new(value)
12
+ end
13
+
14
+ def to_native(value, context)
15
+ unless value.nil?
16
+ p = value.to_ptr
17
+ raise "invalid type #{p.class}, expected #{self}" unless p.kind_of?(self)
18
+ p
19
+ else
20
+ nil
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ class BTClockClassHandle < BTHandle; end
27
+ typedef BTClockClassHandle, :bt_clock_class_handle
28
+
29
+ class BTClockSnapshotHandle < BTHandle; end
30
+ typedef BTClockSnapshotHandle, :bt_clock_snapshot_handle
31
+
32
+ class BTComponentClassHandle < BTHandle; end
33
+ typedef BTComponentClassHandle, :bt_component_class_handle
34
+
35
+ class BTComponentClassFilterHandle < BTComponentClassHandle; end
36
+ typedef BTComponentClassFilterHandle, :bt_component_class_filter_handle
37
+
38
+ class BTComponentClassSinkHandle < BTComponentClassHandle; end
39
+ typedef BTComponentClassSinkHandle, :bt_component_class_sink_handle
40
+
41
+ class BTComponentClassSourceHandle < BTComponentClassHandle; end
42
+ typedef BTComponentClassSourceHandle, :bt_component_class_source_handle
43
+
44
+ class BTComponentDescriptorSetHandle < BTHandle; end
45
+ typedef BTComponentDescriptorSetHandle, :bt_component_descriptor_set_handle
46
+
47
+ class BTComponentHandle < BTHandle; end
48
+ typedef BTComponentHandle, :bt_component_handle
49
+
50
+ class BTComponentFilterHandle < BTComponentHandle; end
51
+ typedef BTComponentFilterHandle, :bt_component_filter_handle
52
+
53
+ class BTComponentSinkHandle < BTComponentHandle; end
54
+ typedef BTComponentSinkHandle, :bt_component_sink_handle
55
+
56
+ class BTComponentSourceHandle < BTComponentHandle; end
57
+ typedef BTComponentSourceHandle, :bt_component_source_handle
58
+
59
+ class BTConnectionHandle < BTHandle; end
60
+ typedef BTConnectionHandle, :bt_connection_handle
61
+
62
+ class BTErrorHandle < BTHandle; end
63
+ typedef BTErrorHandle, :bt_error_handle
64
+
65
+ class BTErrorCauseHandle < BTHandle; end
66
+ typedef BTErrorCauseHandle, :bt_error_cause_handle
67
+
68
+ class BTEventHandle < BTHandle; end
69
+ typedef BTEventHandle, :bt_event_handle
70
+
71
+ class BTEventClassHandle < BTHandle; end
72
+ typedef BTEventClassHandle, :bt_event_class_handle
73
+
74
+ class BTEventHeaderFieldHandle < BTHandle; end
75
+ typedef BTEventHeaderFieldHandle, :bt_event_header_field_handle
76
+
77
+ class BTFieldHandle < BTHandle; end
78
+ typedef BTFieldHandle, :bt_field_handle
79
+
80
+ class BTFieldClassHandle < BTHandle; end
81
+ typedef BTFieldClassHandle, :bt_field_class_handle
82
+
83
+ class BTFieldClassEnumerationMappingHandle < BTHandle; end
84
+ typedef BTFieldClassEnumerationMappingHandle,
85
+ :bt_field_class_enumeration_mapping_handle
86
+
87
+ class BTFieldClassEnumerationSignedMappingHandle <
88
+ BTFieldClassEnumerationMappingHandle; end
89
+ typedef BTFieldClassEnumerationSignedMappingHandle,
90
+ :bt_field_class_enumeration_signed_mapping_handle
91
+
92
+ class BTFieldClassEnumerationUnsignedMappingHandle <
93
+ BTFieldClassEnumerationMappingHandle; end
94
+ typedef BTFieldClassEnumerationUnsignedMappingHandle,
95
+ :bt_field_class_enumeration_unsigned_mapping_handle
96
+
97
+ class BTFieldClassStructureMemberHandle < BTHandle; end
98
+ typedef BTFieldClassStructureMemberHandle, :bt_field_class_structure_member_handle
99
+
100
+ class BTFieldClassVariantOptionHandle < BTHandle; end
101
+ typedef BTFieldClassVariantOptionHandle, :bt_field_class_variant_option_handle
102
+
103
+ class BTFieldClassVariantWithSelectorFieldIntegerSignedOptionHandle <
104
+ BTFieldClassVariantOptionHandle; end
105
+ typedef BTFieldClassVariantWithSelectorFieldIntegerSignedOptionHandle,
106
+ :bt_field_class_variant_with_selector_field_integer_signed_option_handle
107
+
108
+ class BTFieldClassVariantWithSelectorFieldIntegerUnsignedOptionHandle <
109
+ BTFieldClassVariantOptionHandle; end
110
+ typedef BTFieldClassVariantWithSelectorFieldIntegerUnsignedOptionHandle,
111
+ :bt_field_class_variant_with_selector_field_integer_unsigned_option_handle
112
+
113
+ class BTFieldPathHandle < BTHandle; end
114
+ typedef BTFieldPathHandle, :bt_field_path_handle
115
+
116
+ class BTFieldPathItemHandle < BTHandle; end
117
+ typedef BTFieldPathItemHandle, :bt_field_path_item_handle
118
+
119
+ class BTGraphHandle < BTHandle; end
120
+ typedef BTGraphHandle, :bt_graph_handle
121
+
122
+ class BTIntegerRangeSetHandle < BTHandle; end
123
+ typedef BTIntegerRangeSetHandle, :bt_integer_range_set_handle
124
+
125
+ class BTIntegerRangeSetSignedHandle < BTIntegerRangeSetHandle; end
126
+ typedef BTIntegerRangeSetSignedHandle, :bt_integer_range_set_signed_handle
127
+
128
+ class BTIntegerRangeSetUnsignedHandle < BTIntegerRangeSetHandle; end
129
+ typedef BTIntegerRangeSetUnsignedHandle, :bt_integer_range_set_unsigned_handle
130
+
131
+ class BTIntegerRangeSignedHandle < BTHandle; end
132
+ typedef BTIntegerRangeSignedHandle, :bt_integer_range_signed_handle
133
+
134
+ class BTIntegerRangeUnsignedHandle < BTHandle; end
135
+ typedef BTIntegerRangeUnsignedHandle, :bt_integer_range_unsigned_handle
136
+
137
+ class BTInterrupterHandle < BTHandle; end
138
+ typedef BTInterrupterHandle, :bt_interrupter_handle
139
+
140
+ class BTMessageHandle < BTHandle; end
141
+ typedef BTMessageHandle, :bt_message_handle
142
+
143
+ class BTMessageIteratorHandle < BTHandle; end
144
+ typedef BTMessageIteratorHandle, :bt_message_iterator_handle
145
+
146
+ class BTMessageIteratorClassHandle < BTHandle; end
147
+ typedef BTMessageIteratorClassHandle, :bt_message_iterator_class_handle
148
+
149
+ class BTObjectHandle < BTHandle; end
150
+ typedef BTObjectHandle, :bt_object_handle
151
+
152
+ class BTPacketHandle < BTHandle; end
153
+ typedef BTPacketHandle, :bt_packet_handle
154
+
155
+ class BTPortHandle < BTHandle; end
156
+ typedef BTPortHandle, :bt_port_handle
157
+
158
+ class BTPortInputHandle < BTPortHandle; end
159
+ typedef BTPortInputHandle, :bt_port_input_handle
160
+
161
+ class BTPortOutputHandle < BTPortHandle; end
162
+ typedef BTPortOutputHandle, :bt_port_output_handle
163
+
164
+ class BTPortOutputMessageIteratorHandle < BTMessageIteratorHandle; end
165
+ typedef BTPortOutputMessageIteratorHandle, :bt_port_output_message_iterator_handle
166
+
167
+ class BTQueryExecutorHandle < BTHandle; end
168
+ typedef BTQueryExecutorHandle, :bt_query_executor_handle
169
+
170
+ class BTPrivateQueryExecutorHandle < BTQueryExecutorHandle; end
171
+ typedef BTPrivateQueryExecutorHandle, :bt_private_query_executor_handle
172
+
173
+ module BTSelfComponentHandle; end
174
+ class BTSelfComponentHandleCls < BTComponentHandle
175
+ include BTSelfComponentHandle
176
+ class << self
177
+ def to_native(value, context)
178
+ unless value.nil?
179
+ p = value.to_ptr
180
+ raise "invalid type #{p.class}, expected #{BTSelfComponentHandle}" unless p.kind_of?(BTSelfComponentHandle)
181
+ p
182
+ else
183
+ nil
184
+ end
185
+ end
186
+ end
187
+ end
188
+ typedef BTSelfComponentHandleCls, :bt_self_component_handle
189
+
190
+ class BTSelfComponentFilterHandle < BTComponentFilterHandle
191
+ include BTSelfComponentHandle
192
+ end
193
+ typedef BTSelfComponentFilterHandle, :bt_self_component_filter_handle
194
+
195
+ class BTSelfComponentFilterConfigurationHandle < BTHandle; end
196
+ typedef BTSelfComponentFilterConfigurationHandle,
197
+ :bt_self_component_filter_configuration_handle
198
+
199
+ class BTSelfComponentSinkHandle < BTComponentSinkHandle
200
+ include BTSelfComponentHandle
201
+ end
202
+ typedef BTSelfComponentSinkHandle, :bt_self_component_sink_handle
203
+
204
+ class BTSelfComponentSinkConfigurationHandle < BTHandle; end
205
+ typedef BTSelfComponentSinkConfigurationHandle,
206
+ :bt_self_component_sink_configuration_handle
207
+
208
+ class BTSelfComponentSourceHandle < BTComponentSourceHandle
209
+ include BTSelfComponentHandle
210
+ end
211
+ typedef BTSelfComponentSourceHandle, :bt_self_component_source_handle
212
+
213
+ class BTSelfComponentSourceConfigurationHandle < BTHandle; end
214
+ typedef BTSelfComponentSourceConfigurationHandle,
215
+ :bt_self_component_source_configuration_handle
216
+
217
+ module BTSelfComponentClassHandle; end
218
+ class BTSelfComponentClassHandleCls < BTComponentClassHandle
219
+ include BTSelfComponentClassHandle
220
+ class << self
221
+ def to_native(value, context)
222
+ unless value.nil?
223
+ p = value.to_ptr
224
+ raise "invalid type #{p.class}, expected #{BTSelfComponentClassHandle}" unless p.kind_of?(BTSelfComponentClassHandle)
225
+ p
226
+ else
227
+ nil
228
+ end
229
+ end
230
+ end
231
+ end
232
+ typedef BTSelfComponentClassHandleCls,
233
+ :bt_self_component_class_handle
234
+
235
+ class BTSelfComponentClassFilterHandle < BTComponentClassFilterHandle
236
+ include BTSelfComponentClassHandle
237
+ end
238
+ typedef BTSelfComponentClassFilterHandle,
239
+ :bt_self_component_class_filter_handle
240
+
241
+ class BTSelfComponentClassSinkHandle < BTComponentClassSinkHandle
242
+ include BTSelfComponentClassHandle
243
+ end
244
+ typedef BTSelfComponentClassSinkHandle,
245
+ :bt_self_component_class_sink_handle
246
+
247
+ class BTSelfComponentClassSourceHandle < BTComponentClassSourceHandle
248
+ include BTSelfComponentClassHandle
249
+ end
250
+ typedef BTSelfComponentClassSourceHandle,
251
+ :bt_self_component_class_source_handle
252
+
253
+ module BTSelfComponentPortHandle; end
254
+ class BTSelfComponentPortHandleCls < BTPortHandle
255
+ include BTSelfComponentPortHandle
256
+ class << self
257
+ def to_native(value, context)
258
+ unless value.nil?
259
+ p = value.to_ptr
260
+ raise "invalid type #{p.class}, expected #{BTSelfComponentPortHandle}" unless p.kind_of?(BTSelfComponentPortHandle)
261
+ p
262
+ else
263
+ nil
264
+ end
265
+ end
266
+ end
267
+ end
268
+ typedef BTSelfComponentPortHandleCls, :bt_self_component_port_handle
269
+
270
+ class BTSelfComponentPortInputHandle < BTPortInputHandle
271
+ include BTSelfComponentPortHandle
272
+ end
273
+ typedef BTSelfComponentPortInputHandle, :bt_self_component_port_input_handle
274
+
275
+ class BTSelfComponentPortOutputHandle < BTPortOutputHandle
276
+ include BTSelfComponentPortHandle
277
+ end
278
+ typedef BTSelfComponentPortOutputHandle, :bt_self_component_port_output_handle
279
+
280
+ class BTMessageIteratorHandle < BTHandle; end
281
+ typedef BTMessageIteratorHandle, :bt_message_iterator_handle
282
+
283
+ class BTSelfMessageIteratorHandle < BTMessageIteratorHandle; end
284
+ typedef BTSelfMessageIteratorHandle, :bt_self_message_iterator_handle
285
+
286
+ class BTSelfMessageIteratorConfigurationHandle < BTHandle; end
287
+ typedef BTSelfMessageIteratorConfigurationHandle, :bt_self_message_iterator_configuration_handle
288
+
289
+ class BTPluginHandle < BTHandle; end
290
+ typedef BTPluginHandle, :bt_plugin_handle
291
+
292
+ class BTPluginSetHandle < BTHandle; end
293
+ typedef BTPluginSetHandle, :bt_plugin_set_handle
294
+
295
+ class BTPluginSoSharedLibHandleHandle < BTHandle; end
296
+ typedef BTPluginSoSharedLibHandleHandle, :bt_plugin_so_shared_lib_handle_handle
297
+
298
+ class BTSelfPluginHandle < BTPluginHandle; end
299
+ typedef BTSelfPluginHandle, :bt_self_plugin_handle
300
+
301
+ class BTStreamHandle < BTHandle; end
302
+ typedef BTStreamHandle, :bt_stream_handle
303
+
304
+ class BTStreamClassHandle < BTHandle; end
305
+ typedef BTStreamClassHandle, :bt_stream_class_handle
306
+
307
+ class BTTraceHandle < BTHandle; end
308
+ typedef BTTraceHandle, :bt_trace_handle
309
+
310
+ class BTTraceClassHandle < BTHandle; end
311
+ typedef BTTraceClassHandle, :bt_trace_class_handle
312
+
313
+ class BTValueHandle < BTHandle; end
314
+ typedef BTValueHandle, :bt_value_handle
315
+
316
+ # Additional types for type checking
317
+ class BTValueNullHandle < BTValueHandle; end
318
+ typedef BTValueNullHandle, :bt_value_null_handle
319
+
320
+ class BTValueBoolHandle < BTValueHandle; end
321
+ typedef BTValueBoolHandle, :bt_value_bool_handle
322
+
323
+ class BTValueIntegerHandle < BTValueHandle; end
324
+ typedef BTValueIntegerHandle, :bt_value_integer_handle
325
+
326
+ class BTValueIntegerUnsignedHandle < BTValueIntegerHandle; end
327
+ typedef BTValueIntegerUnsignedHandle, :bt_value_integer_unsigned_handle
328
+
329
+ class BTValueIntegerSignedHandle < BTValueIntegerHandle; end
330
+ typedef BTValueIntegerSignedHandle, :bt_value_integer_signed_handle
331
+
332
+ class BTValueRealHandle < BTValueHandle; end
333
+ typedef BTValueRealHandle, :bt_value_real_handle
334
+
335
+ class BTValueStringHandle < BTValueHandle; end
336
+ typedef BTValueStringHandle, :bt_value_string_handle
337
+
338
+ class BTValueArrayHandle < BTValueHandle; end
339
+ typedef BTValueArrayHandle, :bt_value_array_handle
340
+
341
+ class BTValueMapHandle < BTValueHandle; end
342
+ typedef BTValueMapHandle, :bt_value_map_handle
343
+
344
+ class BTFieldClassBoolHandle < BTFieldClassHandle; end
345
+ typedef BTFieldClassBoolHandle, :bt_field_class_bool_handle
346
+
347
+ class BTFieldBoolHandle < BTFieldHandle; end
348
+ typedef BTFieldBoolHandle, :bt_field_bool_handle
349
+
350
+ class BTFieldClassBitArrayHandle < BTFieldClassHandle; end
351
+ typedef BTFieldClassBitArrayHandle, :bt_field_class_bit_array_handle
352
+
353
+ class BTFieldBitArrayHandle < BTFieldHandle; end
354
+ typedef BTFieldBitArrayHandle, :bt_field_bit_array_handle
355
+
356
+ class BTFieldClassIntegerHandle < BTFieldClassHandle; end
357
+ typedef BTFieldClassIntegerHandle, :bt_field_class_integer_handle
358
+
359
+ class BTFieldIntegerHandle < BTFieldHandle; end
360
+ typedef BTFieldIntegerHandle, :bt_field_integer_handle
361
+
362
+ class BTFieldClassIntegerUnsignedHandle < BTFieldClassIntegerHandle; end
363
+ typedef BTFieldClassIntegerUnsignedHandle, :bt_field_class_integer_unsigned_handle
364
+
365
+ class BTFieldIntegerUnsignedHandle < BTFieldIntegerHandle; end
366
+ typedef BTFieldIntegerUnsignedHandle, :bt_field_integer_unsigned_handle
367
+
368
+ class BTFieldClassIntegerSignedHandle < BTFieldClassIntegerHandle; end
369
+ typedef BTFieldClassIntegerSignedHandle, :bt_field_class_integer_signed_handle
370
+
371
+ class BTFieldIntegerSignedHandle < BTFieldIntegerHandle; end
372
+ typedef BTFieldIntegerSignedHandle, :bt_field_integer_signed_handle
373
+
374
+ class BTFieldClassRealSinglePrecisionHandle < BTFieldClassHandle; end
375
+ typedef BTFieldClassRealSinglePrecisionHandle,
376
+ :bt_field_class_real_single_precision_handle
377
+
378
+ class BTFieldRealSinglePrecisionHandle < BTFieldHandle; end
379
+ typedef BTFieldRealSinglePrecisionHandle,
380
+ :bt_field_real_single_precision_handle
381
+
382
+ class BTFieldClassRealDoublePrecisionHandle < BTFieldClassHandle; end
383
+ typedef BTFieldClassRealDoublePrecisionHandle,
384
+ :bt_field_class_real_double_precision_handle
385
+
386
+ class BTFieldRealDoublePrecisionHandle < BTFieldHandle; end
387
+ typedef BTFieldRealDoublePrecisionHandle,
388
+ :bt_field_real_double_precision_handle
389
+
390
+ module BTFieldClassEnumerationHandle; end
391
+ class BTFieldClassEnumerationHandleCls < BTFieldClassIntegerHandle
392
+ include BTFieldClassEnumerationHandle
393
+ class << self
394
+ def to_native(value, context)
395
+ unless value.nil?
396
+ p = value.to_ptr
397
+ raise "invalid type #{p.class}, expected #{BTFieldClassEnumerationHandle}" unless p.kind_of?(BTFieldClassEnumerationHandle)
398
+ p
399
+ else
400
+ nil
401
+ end
402
+ end
403
+ end
404
+ end
405
+ typedef BTFieldClassEnumerationHandleCls, :bt_field_class_enumeration_handle
406
+
407
+ module BTFieldEnumerationHandle; end
408
+ class BTFieldEnumerationHandleCls < BTFieldIntegerHandle
409
+ include BTFieldEnumerationHandle
410
+ class << self
411
+ def to_native(value, context)
412
+ unless value.nil?
413
+ p = value.to_ptr
414
+ raise "invalid type #{p.class}, expected #{BTFieldEnumerationHandle}" unless p.kind_of?(BTFieldEnumerationHandle)
415
+ p
416
+ else
417
+ nil
418
+ end
419
+ end
420
+ end
421
+ end
422
+ typedef BTFieldEnumerationHandleCls, :bt_field_enumeration_handle
423
+
424
+ class BTFieldClassEnumerationUnsignedHandle < BTFieldClassIntegerUnsignedHandle
425
+ include BTFieldClassEnumerationHandle
426
+ end
427
+ typedef BTFieldClassEnumerationUnsignedHandle,
428
+ :bt_field_class_enumeration_unsigned_handle
429
+
430
+ class BTFieldEnumerationUnsignedHandle < BTFieldIntegerUnsignedHandle
431
+ include BTFieldEnumerationHandle
432
+ end
433
+ typedef BTFieldEnumerationUnsignedHandle,
434
+ :bt_field_enumeration_unsigned_handle
435
+
436
+ class BTFieldClassEnumerationSignedHandle < BTFieldClassIntegerSignedHandle
437
+ include BTFieldClassEnumerationHandle
438
+ end
439
+ typedef BTFieldClassEnumerationSignedHandle,
440
+ :bt_field_class_enumeration_signed_handle
441
+
442
+ class BTFieldEnumerationSignedHandle < BTFieldIntegerSignedHandle
443
+ include BTFieldClassEnumerationHandle
444
+ end
445
+ typedef BTFieldEnumerationSignedHandle,
446
+ :bt_field_enumeration_signed_handle
447
+
448
+ class BTFieldClassStringHandle < BTFieldClassHandle; end
449
+ typedef BTFieldClassStringHandle, :bt_field_class_string_handle
450
+
451
+ class BTFieldStringHandle < BTFieldHandle; end
452
+ typedef BTFieldStringHandle, :bt_field_string_handle
453
+
454
+ class BTFieldClassArrayHandle < BTFieldClassHandle; end
455
+ typedef BTFieldClassArrayHandle, :bt_field_class_array_handle
456
+
457
+ class BTFieldArrayHandle < BTFieldHandle; end
458
+ typedef BTFieldArrayHandle, :bt_field_array_handle
459
+
460
+ class BTFieldClassArrayStaticHandle < BTFieldClassArrayHandle; end
461
+ typedef BTFieldClassArrayStaticHandle, :bt_field_class_array_static_handle
462
+
463
+ class BTFieldArrayStaticHandle < BTFieldArrayHandle; end
464
+ typedef BTFieldArrayStaticHandle, :bt_field_array_static_handle
465
+
466
+ class BTFieldClassArrayDynamicHandle < BTFieldClassArrayHandle; end
467
+ typedef BTFieldClassArrayDynamicHandle, :bt_field_class_array_dynamic_handle
468
+
469
+ class BTFieldArrayDynamicHandle < BTFieldArrayHandle; end
470
+ typedef BTFieldArrayDynamicHandle, :bt_field_array_dynamic_handle
471
+
472
+ class BTFieldClassStructureHandle < BTFieldClassHandle; end
473
+ typedef BTFieldClassStructureHandle, :bt_field_class_structure_handle
474
+
475
+ class BTFieldStructureHandle < BTFieldHandle; end
476
+ typedef BTFieldStructureHandle, :bt_field_structure_handle
477
+
478
+ class BTFieldClassOptionHandle < BTFieldClassHandle; end
479
+ typedef BTFieldClassOptionHandle, :bt_field_class_option_handle
480
+
481
+ class BTFieldOptionHandle < BTFieldHandle; end
482
+ typedef BTFieldOptionHandle, :bt_field_option_handle
483
+
484
+ class BTFieldClassOptionWithoutSelectorFieldHandle < BTFieldClassOptionHandle; end
485
+ typedef BTFieldClassOptionWithoutSelectorFieldHandle,
486
+ :bt_field_class_option_without_selector_field_handle
487
+
488
+ class BTFieldOptionWithoutSelectorFieldHandle < BTFieldOptionHandle; end
489
+ typedef BTFieldOptionWithoutSelectorFieldHandle,
490
+ :bt_field_option_without_selector_field_handle
491
+
492
+ class BTFieldClassOptionWithSelectorFieldHandle < BTFieldClassOptionHandle; end
493
+ typedef BTFieldClassOptionWithSelectorFieldHandle,
494
+ :bt_field_class_option_with_selector_field_handle
495
+
496
+ class BTFieldOptionWithSelectorFieldHandle < BTFieldOptionHandle; end
497
+ typedef BTFieldOptionWithSelectorFieldHandle,
498
+ :bt_field_option_with_selector_field_handle
499
+
500
+ class BTFieldClassOptionWithSelectorFieldBoolHandle <
501
+ BTFieldClassOptionWithSelectorFieldHandle; end
502
+ typedef BTFieldClassOptionWithSelectorFieldBoolHandle,
503
+ :bt_field_class_option_with_selector_field_bool_handle
504
+
505
+ class BTFieldOptionWithSelectorFieldBoolHandle <
506
+ BTFieldOptionWithSelectorFieldHandle; end
507
+ typedef BTFieldOptionWithSelectorFieldBoolHandle,
508
+ :bt_field_option_with_selector_field_bool_handle
509
+
510
+ class BTFieldClassOptionWithSelectorFieldIntegerUnsignedHandle <
511
+ BTFieldClassOptionWithSelectorFieldHandle; end
512
+ typedef BTFieldClassOptionWithSelectorFieldIntegerUnsignedHandle,
513
+ :bt_field_class_option_with_selector_field_integer_unsigned_handle
514
+
515
+ class BTFieldOptionWithSelectorFieldIntegerUnsignedHandle <
516
+ BTFieldOptionWithSelectorFieldHandle; end
517
+ typedef BTFieldOptionWithSelectorFieldIntegerUnsignedHandle,
518
+ :bt_field_option_with_selector_field_integer_unsigned_handle
519
+
520
+ class BTFieldClassOptionWithSelectorFieldIntegerSignedHandle <
521
+ BTFieldClassOptionWithSelectorFieldHandle; end
522
+ typedef BTFieldClassOptionWithSelectorFieldIntegerSignedHandle,
523
+ :bt_field_class_option_with_selector_field_integer_signed_handle
524
+
525
+ class BTFieldOptionWithSelectorFieldIntegerSignedHandle <
526
+ BTFieldOptionWithSelectorFieldHandle; end
527
+ typedef BTFieldOptionWithSelectorFieldIntegerSignedHandle,
528
+ :bt_field_option_with_selector_field_integer_signed_handle
529
+
530
+ class BTFieldClassVariantHandle < BTFieldClassHandle; end
531
+ typedef BTFieldClassVariantHandle, :bt_field_class_variant_handle
532
+
533
+ class BTFieldVariantHandle < BTFieldHandle; end
534
+ typedef BTFieldVariantHandle, :bt_field_variant_handle
535
+
536
+ class BTFieldVariantWithoutSelectorFieldHandle < BTFieldVariantHandle; end
537
+ typedef BTFieldVariantWithoutSelectorFieldHandle,
538
+ :bt_field_variant_without_selector_field_handle
539
+
540
+ class BTFieldVariantWithSelectorFieldHandle < BTFieldVariantHandle; end
541
+ typedef BTFieldVariantWithSelectorFieldHandle,
542
+ :bt_field_variant_with_selector_field_handle
543
+
544
+ class BTFieldVariantWithSelectorFieldIntegerUnsignedHandle <
545
+ BTFieldVariantWithSelectorFieldHandle; end
546
+ typedef BTFieldVariantWithSelectorFieldIntegerUnsignedHandle,
547
+ :bt_field_variant_with_selector_field_integer_unsigned_handle
548
+
549
+ class BTFieldVariantWithSelectorFieldIntegerSignedHandle <
550
+ BTFieldVariantWithSelectorFieldHandle; end
551
+ typedef BTFieldVariantWithSelectorFieldIntegerSignedHandle,
552
+ :bt_field_variant_with_selector_field_integer_signed_handle
553
+
554
+ typedef :int, :bt_bool
555
+ typedef :uint64, :bt_listener_id
556
+ typedef :pointer, :bt_object
557
+
558
+ class Error < StandardError
559
+ end
560
+
561
+ class BTObject
562
+ attr_reader :handle
563
+
564
+ def initialize(handle)
565
+ raise "Invalid handle" if !handle
566
+ @handle = handle
567
+ end
568
+
569
+ def to_ptr
570
+ @handle
571
+ end
572
+
573
+ def ==(other)
574
+ @handle == other.handle
575
+ end
576
+ end
577
+
578
+ class BTSharedObject < BTObject
579
+ class Releaser
580
+ def initialize(handle, releaser)
581
+ @handle = handle
582
+ @releaser = releaser
583
+ end
584
+
585
+ def call(id)
586
+ begin
587
+ Babeltrace2.method(@releaser).call(@handle)
588
+ rescue Exception => e
589
+ puts e
590
+ end
591
+ end
592
+ end
593
+ @get_ref = nil
594
+ @put_ref = nil
595
+ def self.inherited(child)
596
+ child.instance_variable_set(:@get_ref, @get_ref)
597
+ child.instance_variable_set(:@put_ref, @put_ref)
598
+ end
599
+ class << self
600
+ attr_reader :get_ref
601
+ attr_reader :put_ref
602
+ end
603
+
604
+ def initialize(handle, retain: false, auto_release: true)
605
+ super(handle)
606
+ Babeltrace2.method(self.class.get_ref).call(handle) if retain
607
+ ObjectSpace.define_finalizer(self, Releaser.new(handle, self.class.put_ref)) if auto_release
608
+ end
609
+ end
610
+
611
+ class BTUUID < FFI::Struct
612
+ layout :id, [ :uint8_t, 16 ]
613
+ def to_s
614
+ a = self[:id].to_a
615
+ s = ""
616
+ s << "%02x" % a[15]
617
+ s << "%02x" % a[14]
618
+ s << "%02x" % a[13]
619
+ s << "%02x" % a[12]
620
+ s << "-"
621
+ s << "%02x" % a[11]
622
+ s << "%02x" % a[10]
623
+ s << "-"
624
+ s << "%02x" % a[9]
625
+ s << "%02x" % a[8]
626
+ s << "-"
627
+ s << "%02x" % a[7]
628
+ s << "%02x" % a[6]
629
+ s << "-"
630
+ s << "%02x" % a[5]
631
+ s << "%02x" % a[4]
632
+ s << "%02x" % a[3]
633
+ s << "%02x" % a[2]
634
+ s << "%02x" % a[1]
635
+ s << "%02x" % a[0]
636
+ end
637
+
638
+ def self.from_string(uuid)
639
+ new.from_string(uuid)
640
+ end
641
+
642
+ def from_string(uuid)
643
+ m = uuid.match(/(\h\h)(\h\h)(\h\h)(\h\h)-(\h\h)(\h\h)-(\h\h)(\h\h)-(\h\h)(\h\h)-(\h\h)(\h\h)(\h\h)(\h\h)(\h\h)(\h\h)/)
644
+ raise "invalid format" unless m
645
+ 16.times { |i|
646
+ self[:id][15-i] = m[i+1].to_i(16)
647
+ }
648
+ self
649
+ end
650
+ end
651
+ typedef BTUUID.by_ref, :bt_uuid
652
+
653
+ BTPropertyAvailability = enum :bt_property_availability,
654
+ [ :BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE, 0,
655
+ :BT_PROPERTY_AVAILABILITY_AVAILABLE, 1 ]
656
+
657
+ typedef :pointer, :bt_message_array_const
658
+
659
+ BT_TRUE = 1
660
+ BT_FALSE = 0
661
+ BT_SLEEP_TIME = 0.1
662
+
663
+ @@callbacks = Hash.new { |h, k| h[k] = {} }
664
+ def self._callbacks
665
+ @@callbacks
666
+ end
667
+ end