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,137 @@
1
+ module Babeltrace2
2
+
3
+ attach_function :bt_stream_create,
4
+ [ :bt_stream_class_handle, :bt_trace_handle ],
5
+ :bt_stream_handle
6
+
7
+ attach_function :bt_stream_create_with_id,
8
+ [ :bt_stream_class_handle, :bt_trace_handle, :uint64 ],
9
+ :bt_stream_handle
10
+
11
+ attach_function :bt_stream_borrow_class,
12
+ [ :bt_stream_handle ],
13
+ :bt_stream_class_handle
14
+
15
+ attach_function :bt_stream_borrow_class_const,
16
+ [ :bt_stream_handle ],
17
+ :bt_stream_class_handle
18
+
19
+ attach_function :bt_stream_borrow_trace,
20
+ [ :bt_stream_handle ],
21
+ :bt_trace_handle
22
+
23
+ attach_function :bt_stream_borrow_trace_const,
24
+ [ :bt_stream_handle ],
25
+ :bt_trace_handle
26
+
27
+ attach_function :bt_stream_get_id,
28
+ [ :bt_stream_handle ],
29
+ :uint64
30
+
31
+ BT_STREAM_SET_NAME_STATUS_OK = BT_FUNC_STATUS_OK
32
+ BT_STREAM_SET_NAME_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
33
+ BTStreamSetNameStatus =
34
+ enum :bt_stream_set_name_status,
35
+ [ :BT_STREAM_SET_NAME_STATUS_OK,
36
+ BT_STREAM_SET_NAME_STATUS_OK,
37
+ :BT_STREAM_SET_NAME_STATUS_MEMORY_ERROR,
38
+ BT_STREAM_SET_NAME_STATUS_MEMORY_ERROR ]
39
+
40
+ attach_function :bt_stream_set_name,
41
+ [ :bt_stream_handle, :string ],
42
+ :bt_stream_set_name_status
43
+
44
+ attach_function :bt_stream_get_name,
45
+ [ :bt_stream_handle ],
46
+ :string
47
+
48
+ attach_function :bt_stream_set_user_attributes,
49
+ [ :bt_stream_handle, :bt_value_map_handle ],
50
+ :void
51
+
52
+ attach_function :bt_stream_borrow_user_attributes,
53
+ [ :bt_stream_handle ],
54
+ :bt_value_map_handle
55
+
56
+ attach_function :bt_stream_borrow_user_attributes_const,
57
+ [ :bt_stream_handle ],
58
+ :bt_value_map_handle
59
+
60
+ attach_function :bt_stream_get_ref,
61
+ [ :bt_stream_handle ],
62
+ :void
63
+
64
+ attach_function :bt_stream_put_ref,
65
+ [ :bt_stream_handle ],
66
+ :void
67
+
68
+ class BTStream < BTSharedObject
69
+ SetNameStatus = BTStreamSetNameStatus
70
+ @get_ref = :bt_stream_get_ref
71
+ @put_ref = :bt_stream_put_ref
72
+
73
+ def initialize(handle = nil, retain: true, auto_release: true,
74
+ stream_class: nil, trace: nil, id: nil)
75
+ if handle
76
+ super(handle, retain: retain, auto_release: auto_release)
77
+ else
78
+ handle = if id
79
+ Babeltrace2.bt_stream_create_with_id(stream_class, trace, id)
80
+ else
81
+ Babeltrace2.bt_stream_create(stream_class, trace)
82
+ end
83
+ raise Babeltrace2.process_error if handle.null?
84
+ super(handle)
85
+ end
86
+ end
87
+
88
+ def get_class
89
+ BTStreamClass.new(Babeltrace2.bt_stream_borrow_class(@handle), retain: true)
90
+ end
91
+
92
+ def get_trace
93
+ BTTrace.new(Babeltrace2.bt_stream_borrow_trace(@handle), retain: true)
94
+ end
95
+ alias trace get_trace
96
+
97
+ def get_id
98
+ Babeltrace2.bt_stream_get_id(@handle)
99
+ end
100
+ alias id get_id
101
+
102
+ def set_name(name)
103
+ res = Babeltrace2.bt_stream_set_name(@handle, name)
104
+ raise Babeltrace2.process_error(res) if res != :BT_STREAM_SET_NAME_STATUS_OK
105
+ self
106
+ end
107
+
108
+ def name=(name)
109
+ set_name(name)
110
+ name
111
+ end
112
+
113
+ def get_name
114
+ Babeltrace2.bt_stream_get_name(@handle)
115
+ end
116
+ alias name get_name
117
+
118
+ def set_user_attributes(user_attributes)
119
+ Babeltrace2.bt_stream_set_user_attributes(@handle, BTValue.from_value(user_attributes))
120
+ self
121
+ end
122
+
123
+ def user_attributes=(user_attributes)
124
+ set_user_attributes(user_attributes)
125
+ user_attributes
126
+ end
127
+
128
+ def get_user_attributes
129
+ BTValueMap.new(Babeltrace2.bt_stream_borrow_user_attributes(@handle), retain: true)
130
+ end
131
+ alias user_attributes get_user_attributes
132
+
133
+ def create_packet
134
+ BTPacket.new(stream: @handle)
135
+ end
136
+ end
137
+ end
@@ -0,0 +1,343 @@
1
+ module Babeltrace2
2
+
3
+ attach_function :bt_trace_class_create,
4
+ [ :bt_self_component_handle ],
5
+ :bt_trace_class_handle
6
+
7
+ attach_function :bt_trace_class_get_stream_class_count,
8
+ [ :bt_trace_class_handle ],
9
+ :uint64
10
+
11
+ attach_function :bt_trace_class_borrow_stream_class_by_index,
12
+ [ :bt_trace_class_handle, :uint64 ],
13
+ :bt_stream_class_handle
14
+
15
+ attach_function :bt_trace_class_borrow_stream_class_by_index_const,
16
+ [ :bt_trace_class_handle, :uint64 ],
17
+ :bt_stream_class_handle
18
+
19
+ attach_function :bt_trace_class_borrow_stream_class_by_id,
20
+ [ :bt_trace_class_handle, :uint64 ],
21
+ :bt_stream_class_handle
22
+
23
+ attach_function :bt_trace_class_borrow_stream_class_by_id_const,
24
+ [ :bt_trace_class_handle, :uint64 ],
25
+ :bt_stream_class_handle
26
+
27
+ attach_function :bt_trace_class_set_assigns_automatic_stream_class_id,
28
+ [ :bt_trace_class_handle, :bt_bool ],
29
+ :void
30
+
31
+ attach_function :bt_trace_class_assigns_automatic_stream_class_id,
32
+ [ :bt_trace_class_handle ],
33
+ :bt_bool
34
+
35
+ attach_function :bt_trace_class_set_user_attributes,
36
+ [ :bt_trace_class_handle, :bt_value_map_handle ],
37
+ :void
38
+
39
+ attach_function :bt_trace_class_borrow_user_attributes,
40
+ [ :bt_trace_class_handle ],
41
+ :bt_value_map_handle
42
+
43
+ attach_function :bt_trace_class_borrow_user_attributes_const,
44
+ [ :bt_trace_class_handle ],
45
+ :bt_value_map_handle
46
+
47
+ callback :bt_trace_class_destruction_listener_func,
48
+ [ :bt_trace_class_handle, :pointer],
49
+ :void
50
+
51
+ def self._wrap_trace_class_destruction_listener_func(method)
52
+ method_wrapper = lambda { |trace_class, user_data|
53
+ begin
54
+ method.call(BTTraceClass.new(trace_class,
55
+ retain: false, auto_release: false), user_data)
56
+ rescue Exception => e
57
+ puts e
58
+ end
59
+ }
60
+ method_wrapper
61
+ end
62
+
63
+ BT_TRACE_CLASS_ADD_LISTENER_STATUS_OK = BT_FUNC_STATUS_OK
64
+ BT_TRACE_CLASS_ADD_LISTENER_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
65
+ BTTraceClassAddListenerStatus = enum :bt_trace_class_add_listener_status,
66
+ [ :BT_TRACE_CLASS_ADD_LISTENER_STATUS_OK,
67
+ BT_TRACE_CLASS_ADD_LISTENER_STATUS_OK,
68
+ :BT_TRACE_CLASS_ADD_LISTENER_STATUS_MEMORY_ERROR,
69
+ BT_TRACE_CLASS_ADD_LISTENER_STATUS_MEMORY_ERROR ]
70
+
71
+ attach_function :bt_trace_class_add_destruction_listener,
72
+ [ :bt_trace_class_handle, :bt_trace_class_destruction_listener_func,
73
+ :pointer, :pointer ],
74
+ :bt_trace_class_add_listener_status
75
+
76
+ BT_TRACE_CLASS_REMOVE_LISTENER_STATUS_OK = BT_FUNC_STATUS_OK
77
+ BT_TRACE_CLASS_REMOVE_LISTENER_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
78
+ BTTraceClassRemoveListenerStatus = enum :bt_trace_class_remove_listener_status,
79
+ [ :BT_TRACE_CLASS_REMOVE_LISTENER_STATUS_OK,
80
+ BT_TRACE_CLASS_REMOVE_LISTENER_STATUS_OK,
81
+ :BT_TRACE_CLASS_REMOVE_LISTENER_STATUS_MEMORY_ERROR,
82
+ BT_TRACE_CLASS_REMOVE_LISTENER_STATUS_MEMORY_ERROR ]
83
+
84
+ attach_function :bt_trace_class_remove_destruction_listener,
85
+ [ :bt_trace_class_handle, :bt_listener_id ],
86
+ :bt_trace_class_remove_listener_status
87
+
88
+ attach_function :bt_trace_class_get_ref,
89
+ [ :bt_trace_class_handle ],
90
+ :void
91
+
92
+ attach_function :bt_trace_class_put_ref,
93
+ [ :bt_trace_class_handle ],
94
+ :void
95
+
96
+ class BTTraceClass < BTSharedObject
97
+ AddListenerStatus = BTTraceClassAddListenerStatus
98
+ RemoveListenerStatus = BTTraceClassRemoveListenerStatus
99
+ @get_ref = :bt_trace_class_get_ref
100
+ @put_ref = :bt_trace_class_put_ref
101
+
102
+ def initialize(handle = nil, retain: true, auto_release: true,
103
+ self_component: nil)
104
+ if(handle)
105
+ super(handle, retain: retain, auto_release: auto_release)
106
+ else
107
+ handle = Babeltrace2.bt_trace_class_create(self_component)
108
+ raise Babeltrace2.process_error if handle.null?
109
+ super(handle, retain: false)
110
+ end
111
+ end
112
+
113
+ def get_stream_class_count
114
+ Babeltrace2.bt_trace_class_get_stream_class_count(@handle)
115
+ end
116
+ alias stream_class_count get_stream_class_count
117
+
118
+ def get_stream_class_by_index(index)
119
+ count = get_stream_class_count
120
+ index += count if index < 0
121
+ return nil if index >= count || index < 0
122
+ BTStreamClass.new(
123
+ Babeltrace2.bt_trace_class_borrow_stream_class_by_index(@handle, index))
124
+ end
125
+
126
+ def get_stream_class_by_id(id)
127
+ handle = Babeltrace2.bt_trace_class_borrow_stream_class_by_id(@handle, id)
128
+ return nil if handle.null?
129
+ BTStreamClass.new(handle, retain: true)
130
+ end
131
+
132
+ def set_assigns_automatic_stream_class_id(assigns_automatic_stream_class_id)
133
+ Babeltrace2.bt_trace_class_set_assigns_automatic_stream_class_id(
134
+ @handle, assigns_automatic_stream_class_id ? BT_TRUE : BT_FALSE)
135
+ self
136
+ end
137
+
138
+ def assigns_automatic_stream_class_id=(assigns_automatic_stream_class_id)
139
+ set_assigns_automatic_stream_class_id(assigns_automatic_stream_class_id)
140
+ assigns_automatic_stream_class_id
141
+ end
142
+
143
+ def assigns_automatic_stream_class_id
144
+ Babeltrace2.bt_trace_class_assigns_automatic_stream_class_id(@handle) != BT_FALSE
145
+ end
146
+ alias assigns_automatic_stream_class_id? assigns_automatic_stream_class_id
147
+
148
+ def set_user_attributes(user_attributes)
149
+ Babeltrace2.bt_trace_class_set_user_attributes(@handle, BTValue.from_value(user_attributes))
150
+ self
151
+ end
152
+
153
+ def user_attributes=(user_attributes)
154
+ set_user_attributes(user_attributes)
155
+ user_attributes
156
+ end
157
+
158
+ def get_user_attributes
159
+ BTValueMap.new(Babeltrace2.bt_trace_class_borrow_user_attributes(@handle), retain: true)
160
+ end
161
+ alias user_attributes get_user_attributes
162
+
163
+ def add_destruction_listener(user_func, user_data: nil)
164
+ user_func = Babeltrace2._wrap_trace_class_destruction_listener_func(user_func)
165
+ id = @handle.to_i
166
+ ptr = FFI::MemoryPointer.new(:uint64)
167
+ res = Babeltrace2.bt_trace_class_add_destruction_listener(@handle, user_func, user_data, ptr)
168
+ raise Babeltrace2.process_error(res) if res != :BT_TRACE_CLASS_ADD_LISTENER_STATUS_OK
169
+ listener_id = ptr.read_uint64
170
+ h = Babeltrace2._callbacks[id][:destruction_listener_funcs]
171
+ if h.nil?
172
+ h = {}
173
+ Babeltrace2._callbacks[id][:destruction_listener_funcs] = h
174
+ end
175
+ h[listener_id] = [user_func, user_data]
176
+ listener_id
177
+ end
178
+
179
+ def remove_destruction_listener(listener_id)
180
+ res = Babeltrace2.bt_trace_class_remove_destruction_listener(@handle, listener_id)
181
+ raise Babeltrace2.process_error(res) if res != :BT_TRACE_CLASS_REMOVE_LISTENER_STATUS_OK
182
+ Babeltrace2._callbacks[@handle.to_i][:destruction_listener_funcs].delete(listener_id)
183
+ self
184
+ end
185
+
186
+ def create_stream_class(id: nil)
187
+ BTStreamClass.new(trace_class: @handle, id: id)
188
+ end
189
+
190
+ def create_trace
191
+ BTTrace.new(trace_class: @handle)
192
+ end
193
+
194
+ def create_field_class_bool
195
+ BTFieldClassBool.new(trace_class: @handle)
196
+ end
197
+ alias create_bool_class create_field_class_bool
198
+ alias create_bool create_field_class_bool
199
+
200
+ def create_field_class_bit_array(length)
201
+ BTFieldClassBitArray.new(trace_class: @handle, length: length)
202
+ end
203
+ alias create_bit_array_class create_field_class_bit_array
204
+ alias create_bit_array create_field_class_bit_array
205
+
206
+ def create_field_class_integer_unsigned
207
+ BTFieldClassIntegerUnsigned.new(trace_class: @handle)
208
+ end
209
+ alias create_unsigned_integer_class create_field_class_integer_unsigned
210
+ alias create_unsigned create_field_class_integer_unsigned
211
+
212
+ def create_field_class_integer_signed
213
+ BTFieldClassIntegerSigned.new(trace_class: @handle)
214
+ end
215
+ alias create_signed_integer_class create_field_class_integer_signed
216
+ alias create_signed create_field_class_integer_signed
217
+
218
+ def create_field_class_real_single_precision
219
+ BTFieldClassRealSinglePrecision.new(trace_class: @handle)
220
+ end
221
+ alias create_single_precision_real_class create_field_class_real_single_precision
222
+ alias create_single create_field_class_real_single_precision
223
+
224
+ def create_field_class_real_double_precision
225
+ BTFieldClassRealDoublePrecision.new(trace_class: @handle)
226
+ end
227
+ alias create_double_precision_real_class create_field_class_real_double_precision
228
+ alias create_double create_field_class_real_double_precision
229
+
230
+ def create_field_class_enumeration_unsigned
231
+ BTFieldClassEnumerationUnsigned.new(trace_class: @handle)
232
+ end
233
+ alias create_unsigned_enumeration_class create_field_class_enumeration_unsigned
234
+ alias create_unsigned_enum create_field_class_enumeration_unsigned
235
+
236
+ def create_field_class_enumeration_signed
237
+ BTFieldClassEnumerationSigned.new(trace_class: @handle)
238
+ end
239
+ alias create_signed_enumeration_class create_field_class_enumeration_signed
240
+ alias create_signed_enum create_field_class_enumeration_signed
241
+
242
+ def create_field_class_string
243
+ BTFieldClassString.new(trace_class: @handle)
244
+ end
245
+ alias create_string_class create_field_class_string
246
+ alias create_string create_field_class_string
247
+
248
+ def create_field_class_array_static(element_field_class, length)
249
+ BTFieldClassArrayStatic.new(trace_class: @handle,
250
+ element_field_class: element_field_class,
251
+ length: length)
252
+ end
253
+ alias create_static_array_class create_field_class_array_static
254
+ alias create_static_array create_field_class_array_static
255
+
256
+ def create_field_class_array_dynamic(element_field_class, length_field_class: nil)
257
+ BTFieldClassArrayDynamic.new(trace_class: @handle,
258
+ element_field_class: element_field_class,
259
+ length_field_class: length_field_class)
260
+ end
261
+ alias create_dynamic_array_class create_field_class_array_dynamic
262
+ alias create_dynamic_array create_field_class_array_dynamic
263
+
264
+ def create_field_class_array(element_field_class, length: nil)
265
+ case length
266
+ when Integer
267
+ create_field_class_array_static(element_field_class, length)
268
+ when nil, BTFieldClassIntegerUnsigned
269
+ create_field_class_array_dynamic(element_field_class, length_field_class: length)
270
+ else
271
+ raise "invalid length type"
272
+ end
273
+ end
274
+ alias create_array_class create_field_class_array
275
+ alias create_array create_field_class_array
276
+
277
+ def create_field_class_structure
278
+ BTFieldClassStructure.new(trace_class: @handle)
279
+ end
280
+ alias create_structure_class create_field_class_structure
281
+ alias create_structure create_field_class_structure
282
+
283
+ def create_field_class_option_without_selector(optional_field_class)
284
+ BTFieldClassOptionWithoutSelectorField.new(
285
+ trace_class: @handle,
286
+ optional_field_class: optional_field_class)
287
+ end
288
+ alias create_option_without_selector_class create_field_class_option_without_selector
289
+ alias create_option_without create_field_class_option_without_selector
290
+
291
+ def create_field_class_option_with_selector_field_bool(optional_field_class, selector_field_class)
292
+ BTFieldClassOptionWithSelectorFieldBool.new(
293
+ trace_class: @handle,
294
+ optional_field_class: optional_field_class,
295
+ selector_field_class: selector_field_class)
296
+ end
297
+ alias create_option_with_bool_selector_field_class create_field_class_option_with_selector_field_bool
298
+ alias create_option_with_bool_selector_field create_field_class_option_with_selector_field_bool
299
+
300
+ def create_field_class_option_with_selector_field_integer_unsigned(optional_field_class, selector_field_class, ranges)
301
+ BTFieldClassOptionWithSelectorFieldIntegerUnsigned.new(
302
+ trace_class: @handle,
303
+ optional_field_class: optional_field_class,
304
+ selector_field_class: selector_field_class,
305
+ ranges: ranges)
306
+ end
307
+ alias create_option_with_unsigned_integer_selector_field_class create_field_class_option_with_selector_field_integer_unsigned
308
+ alias create_option_with_unsigned_integer_selector_field create_field_class_option_with_selector_field_integer_unsigned
309
+
310
+ def create_field_class_option_with_selector_field_integer_signed(optional_field_class, selector_field_class, ranges)
311
+ BTFieldClassOptionWithSelectorFieldIntegerSigned.new(
312
+ trace_class: @handle,
313
+ optional_field_class: optional_field_class,
314
+ selector_field_class: selector_field_class,
315
+ ranges: ranges)
316
+ end
317
+ alias create_option_with_signed_integer_selector_field_class create_field_class_option_with_selector_field_integer_signed
318
+ alias create_option_with_signed_integer_selector_field create_field_class_option_with_selector_field_integer_signed
319
+
320
+ def create_field_class_option(optional_field_class, selector_field_class: nil, ranges: nil)
321
+ case selector_field_class
322
+ when nil
323
+ create_field_class_option_without_selector(optional_field_class)
324
+ when BTFieldClassBool
325
+ create_field_class_option_with_selector_field_bool(optional_field_class, selector_field_class)
326
+ when BTFieldClassIntegerUnsigned
327
+ create_field_class_option_with_selector_field_integer_unsigned(optional_field_class, selector_field_class, ranges)
328
+ when BTFieldClassIntegerSigned
329
+ create_field_class_option_with_selector_field_integer_signed(optional_field_class, selector_field_class, ranges)
330
+ else
331
+ raise "invalid selector field class"
332
+ end
333
+ end
334
+ alias create_option_class create_field_class_option
335
+ alias create_option create_field_class_option
336
+
337
+ def create_field_class_variant(selector_field_class: nil)
338
+ BTFieldClassVariant.new(trace_class: @handle, selector_field_class: selector_field_class)
339
+ end
340
+ alias create_variant_class create_field_class_variant
341
+ alias create_variant create_field_class_variant
342
+ end
343
+ end