babeltrace 0.1.1 → 0.1.2
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/babeltrace.gemspec +2 -1
- data/ext/babeltrace_c/babeltrace.c +6 -2
- data/lib/babeltrace/context.rb +27 -2
- data/lib/babeltrace/ctf/events.rb +46 -38
- data/lib/babeltrace/ctf/iterator.rb +13 -13
- data/lib/babeltrace/types.rb +21 -0
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9a7ce6aedb3ba33fb52eda3fa2b6801a61aa473760b0e6544796e7fc8df4ebf
|
4
|
+
data.tar.gz: 122c685bd2c4c6c53e3c82f6252b76b14b35add6cbb21323a2b05694e4da69ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35aefb30265483879e836c0bf60aef7651b02d1d4bba2d2292aba1721ad2834f41eab4c2c8f69ffcf82a440fc5047d73d0f978c0fc8bd297074c5b6c05d19185
|
7
|
+
data.tar.gz: 569f92c75a651ee470c7d144635261e024a5618dc6460bb3fa675bce6dd09539ca4d1bc8e73d4a5a637e53603bc38d579fa4fe4af469b5b354c4986ba7d3f123
|
data/babeltrace.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'babeltrace'
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.2"
|
4
4
|
s.author = "Brice Videau"
|
5
5
|
s.email = "bvideau@anl.gov"
|
6
6
|
s.homepage = "https://github.com/alcf-perfengr/babeltrace-ruby"
|
@@ -12,4 +12,5 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.license = 'MIT'
|
13
13
|
s.required_ruby_version = '>= 2.3.0'
|
14
14
|
s.add_dependency 'ffi', '~> 1.9', '>=1.9.3'
|
15
|
+
s.add_dependency 'walk', '~> 0.1', '>=0.1.0'
|
15
16
|
end
|
@@ -7,6 +7,8 @@
|
|
7
7
|
static VALUE m_babeltrace;
|
8
8
|
static VALUE m_ctf;
|
9
9
|
static VALUE m_internal;
|
10
|
+
static VALUE c_definition;
|
11
|
+
static VALUE c_declaration;
|
10
12
|
static VALUE c_internal_declaration;
|
11
13
|
static VALUE c_internal_definition;
|
12
14
|
static VALUE c_ctf_declaration;
|
@@ -66,8 +68,10 @@ void Init_babeltrace_c() {
|
|
66
68
|
m_ffi = rb_const_get(rb_cObject, rb_intern("FFI"));
|
67
69
|
c_ffi_pointer = rb_const_get(m_ffi, rb_intern("Pointer"));
|
68
70
|
c_ffi_struct = rb_const_get(m_ffi, rb_intern("Struct"));
|
69
|
-
|
70
|
-
|
71
|
+
c_definition = rb_define_class_under(m_babeltrace, "Definition", c_ffi_struct);
|
72
|
+
c_declaration = rb_define_class_under(m_babeltrace, "Declaration", c_ffi_struct);
|
73
|
+
c_internal_declaration = rb_define_class_under(m_internal, "Declaration", c_declaration);
|
74
|
+
c_internal_definition = rb_define_class_under(m_internal, "Definition", c_definition);
|
71
75
|
c_ctf_declaration = rb_define_class_under(m_ctf, "Declaration", rb_cObject);
|
72
76
|
c_ctf_array_declaration = rb_define_class_under(m_ctf, "ArrayDecl", c_ctf_declaration);
|
73
77
|
c_ctf_sequence_declaration = rb_define_class_under(m_ctf, "SequenceDecl", c_ctf_declaration);
|
data/lib/babeltrace/context.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
require 'walk'
|
2
|
+
|
1
3
|
module Babeltrace
|
2
4
|
|
3
5
|
class Context # < ManagedStruct
|
6
|
+
attr_reader :traces
|
4
7
|
def initialize(ptr = Babeltrace.bt_context_create)
|
5
8
|
super(ptr)
|
9
|
+
@traces = []
|
6
10
|
end
|
7
11
|
|
8
12
|
def self.release(ptr)
|
@@ -13,15 +17,36 @@ module Babeltrace
|
|
13
17
|
handle_id = Babeltrace.bt_context_add_trace(self, path, format, nil, nil, nil)
|
14
18
|
case format
|
15
19
|
when "ctf"
|
16
|
-
|
20
|
+
trace = CTF::Trace::new(self, handle_id)
|
17
21
|
else
|
18
|
-
|
22
|
+
trace = Trace::new(self, handle_id)
|
23
|
+
end
|
24
|
+
@traces.push trace
|
25
|
+
trace
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_traces(path:, format: "ctf")
|
29
|
+
traces = []
|
30
|
+
Walk.walk(path) do |path, dirs, files|
|
31
|
+
trace = add_trace(path: path, format: format) if files.include?("metadata")
|
32
|
+
traces.push trace if trace
|
19
33
|
end
|
34
|
+
traces
|
20
35
|
end
|
21
36
|
|
22
37
|
def remove_trace(trace_id)
|
23
38
|
Babeltrace.bt_context_remove_trace(self, trace_id)
|
24
39
|
end
|
40
|
+
|
41
|
+
def get_timestamp_begin(clock_type = :REAL)
|
42
|
+
return nil if traces.empty?
|
43
|
+
traces.collect { |t| t.get_timestamp_begin(clock_type) }.min
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_timestamp_end(clock_type = :REAL)
|
47
|
+
return nil if traces.empty?
|
48
|
+
traces.collect { |t| t.get_timestamp_end(clock_type) }.max
|
49
|
+
end
|
25
50
|
end
|
26
51
|
|
27
52
|
attach_function :bt_context_create, [], Context
|
@@ -24,7 +24,7 @@ module Babeltrace
|
|
24
24
|
:UNKNOWN
|
25
25
|
|
26
26
|
module Internal
|
27
|
-
class Declaration # < FFI::Struct
|
27
|
+
class Declaration # < Babeltrace::Declaration < FFI::Struct
|
28
28
|
layout :dummy, :pointer
|
29
29
|
|
30
30
|
def field_type
|
@@ -60,13 +60,13 @@ module Babeltrace
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
63
|
-
attach_function :bt_ctf_field_type, [
|
64
|
-
attach_function :bt_ctf_get_int_signedness, [
|
65
|
-
attach_function :bt_ctf_get_int_base, [
|
66
|
-
attach_function :bt_ctf_get_int_byte_order, [
|
67
|
-
attach_function :bt_ctf_get_int_len, [
|
68
|
-
attach_function :bt_ctf_get_encoding, [
|
69
|
-
attach_function :bt_ctf_get_array_len, [
|
63
|
+
attach_function :bt_ctf_field_type, [Babeltrace::Declaration], TypeID
|
64
|
+
attach_function :bt_ctf_get_int_signedness, [Babeltrace::Declaration], :int
|
65
|
+
attach_function :bt_ctf_get_int_base, [Babeltrace::Declaration], :int
|
66
|
+
attach_function :bt_ctf_get_int_byte_order, [Babeltrace::Declaration], :int
|
67
|
+
attach_function :bt_ctf_get_int_len, [Babeltrace::Declaration], :ssize_t
|
68
|
+
attach_function :bt_ctf_get_encoding, [Babeltrace::Declaration], StringEncoding
|
69
|
+
attach_function :bt_ctf_get_array_len, [Babeltrace::Declaration], :int
|
70
70
|
|
71
71
|
module Internal
|
72
72
|
class FieldDecl < FFI::Struct
|
@@ -89,7 +89,7 @@ module Babeltrace
|
|
89
89
|
attach_function :bt_ctf_get_decl_field_name, [Internal::FieldDecl], :string
|
90
90
|
|
91
91
|
module Internal
|
92
|
-
class Definition # < FFI::Struct
|
92
|
+
class Definition # < Babeltrace::Definition < FFI::Struct
|
93
93
|
layout :dummy, :pointer
|
94
94
|
|
95
95
|
def field_name
|
@@ -149,18 +149,18 @@ module Babeltrace
|
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
-
attach_function :bt_ctf_field_name, [
|
153
|
-
attach_function :bt_ctf_get_decl_from_def, [
|
154
|
-
attach_function :bt_ctf_get_struct_field_count, [
|
155
|
-
attach_function :bt_ctf_get_uint64, [
|
156
|
-
attach_function :bt_ctf_get_int64, [
|
157
|
-
attach_function :bt_ctf_get_enum_int, [
|
158
|
-
attach_function :bt_ctf_get_enum_str, [
|
159
|
-
attach_function :bt_ctf_get_char_array, [
|
160
|
-
attach_function :bt_ctf_get_string, [
|
161
|
-
attach_function :bt_ctf_get_float, [
|
162
|
-
attach_function :bt_ctf_get_variant, [
|
163
|
-
attach_function :bt_ctf_get_struct_field_index, [
|
152
|
+
attach_function :bt_ctf_field_name, [Babeltrace::Definition], :string
|
153
|
+
attach_function :bt_ctf_get_decl_from_def, [Babeltrace::Definition], Internal::Declaration.by_ref
|
154
|
+
attach_function :bt_ctf_get_struct_field_count, [Babeltrace::Definition], :uint64
|
155
|
+
attach_function :bt_ctf_get_uint64, [Babeltrace::Definition], :uint64
|
156
|
+
attach_function :bt_ctf_get_int64, [Babeltrace::Definition], :int64
|
157
|
+
attach_function :bt_ctf_get_enum_int, [Babeltrace::Definition], Internal::Definition.by_ref
|
158
|
+
attach_function :bt_ctf_get_enum_str, [Babeltrace::Definition], :string
|
159
|
+
attach_function :bt_ctf_get_char_array, [Babeltrace::Definition], :pointer
|
160
|
+
attach_function :bt_ctf_get_string, [Babeltrace::Definition], :string
|
161
|
+
attach_function :bt_ctf_get_float, [Babeltrace::Definition], :double
|
162
|
+
attach_function :bt_ctf_get_variant, [Babeltrace::Definition], Internal::Definition.by_ref
|
163
|
+
attach_function :bt_ctf_get_struct_field_index, [Babeltrace::Definition, :uint64], Internal::Definition.by_ref
|
164
164
|
|
165
165
|
module Internal
|
166
166
|
class EventDecl < FFI::Struct
|
@@ -176,9 +176,14 @@ module Babeltrace
|
|
176
176
|
list = FFI::MemoryPointer::new(:pointer)
|
177
177
|
res = CTF.bt_ctf_get_decl_fields(self, scope, list, count)
|
178
178
|
count = count.read(:uint)
|
179
|
-
|
180
|
-
|
179
|
+
if count > 0
|
180
|
+
list = list.read_pointer.read_array_of_pointer(count)
|
181
|
+
list.collect { |p| FieldDecl::new(p) }
|
182
|
+
else
|
183
|
+
[]
|
184
|
+
end
|
181
185
|
end
|
186
|
+
alias decl_fields get_decl_fields
|
182
187
|
end
|
183
188
|
end
|
184
189
|
|
@@ -199,6 +204,15 @@ module Babeltrace
|
|
199
204
|
attach_function :bt_ctf_get_event_decl_list, [:int, Context, :pointer, :pointer], :int
|
200
205
|
|
201
206
|
class Event
|
207
|
+
|
208
|
+
def get_id
|
209
|
+
defi = self.top_level_scope(:STREAM_EVENT_HEADER).value
|
210
|
+
id = defi["id"][0]
|
211
|
+
id = defi["v"]["id"] if id == 65535
|
212
|
+
id
|
213
|
+
end
|
214
|
+
alias id get_id
|
215
|
+
|
202
216
|
def get_context
|
203
217
|
c = CTF.bt_ctf_event_get_context(self)
|
204
218
|
Babeltrace.bt_context_get(c)
|
@@ -276,13 +290,9 @@ module Babeltrace
|
|
276
290
|
attach_function :bt_ctf_event_name, [Event], :string
|
277
291
|
attach_function :bt_ctf_get_cycles, [Event], :uint64
|
278
292
|
attach_function :bt_ctf_get_timestamp, [Event], :uint64
|
279
|
-
attach_function :bt_ctf_get_field_list, [Event,
|
280
|
-
attach_function :bt_ctf_get_field, [Event,
|
281
|
-
attach_function :bt_ctf_get_index, [Event,
|
282
|
-
# Hack
|
283
|
-
attach_function :bt_array_index, [Internal::Definition, :uint64], Internal::Definition.by_ref
|
284
|
-
attach_function :bt_sequence_len, [Internal::Definition], :uint64
|
285
|
-
attach_function :bt_sequence_index, [Internal::Definition, :uint64], Internal::Definition.by_ref
|
293
|
+
attach_function :bt_ctf_get_field_list, [Event, Babeltrace::Definition, :pointer, :pointer], :int
|
294
|
+
attach_function :bt_ctf_get_field, [Event, Babeltrace::Definition, :string], Internal::Definition.by_ref
|
295
|
+
attach_function :bt_ctf_get_index, [Event, Babeltrace::Definition, :uint], Internal::Definition.by_ref
|
286
296
|
|
287
297
|
class Definition
|
288
298
|
attr_reader :definition
|
@@ -346,7 +356,7 @@ module Babeltrace
|
|
346
356
|
end
|
347
357
|
|
348
358
|
def value
|
349
|
-
|
359
|
+
[ int.value, string ]
|
350
360
|
end
|
351
361
|
end
|
352
362
|
|
@@ -383,8 +393,7 @@ module Babeltrace
|
|
383
393
|
end
|
384
394
|
|
385
395
|
def index(i)
|
386
|
-
|
387
|
-
return Definition.create(d)
|
396
|
+
return Definition.create(@definition.array_index(i))
|
388
397
|
end
|
389
398
|
|
390
399
|
def value
|
@@ -404,12 +413,11 @@ module Babeltrace
|
|
404
413
|
|
405
414
|
class SequenceDef < Definition
|
406
415
|
def len
|
407
|
-
|
416
|
+
@definition.sequence_len
|
408
417
|
end
|
409
418
|
|
410
419
|
def index(i)
|
411
|
-
|
412
|
-
return Definition.create(d)
|
420
|
+
return Definition.create(@definition.sequence_index(i))
|
413
421
|
end
|
414
422
|
|
415
423
|
def value
|
@@ -419,11 +427,11 @@ module Babeltrace
|
|
419
427
|
|
420
428
|
class SequenceTextDef < Definition
|
421
429
|
def len
|
422
|
-
|
430
|
+
@definition.sequence_len
|
423
431
|
end
|
424
432
|
|
425
433
|
def value
|
426
|
-
return
|
434
|
+
return "" if len == 0
|
427
435
|
@definition.get_char_sequence.read_bytes(len)
|
428
436
|
end
|
429
437
|
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
module Babeltrace
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
end
|
2
|
+
class Context
|
3
|
+
def iter_create(begin_pos: nil, end_pos: nil)
|
4
|
+
CTF.bt_ctf_iter_create(self, begin_pos, end_pos)
|
5
|
+
end
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
7
|
+
def iter_create_intersect
|
8
|
+
begin_pos_ptr = FFI::MemoryPointer::new(:pointer)
|
9
|
+
end_pos_ptr = FFI::MemoryPointer::new(:pointer)
|
10
|
+
iter = CTF.bt_ctf_iter_create_intersect(@context, begin_pos_ptr, end_pos_ptr)
|
11
|
+
begin_pos = IterPosManaged::new(begin_pos_ptr.read_pointer)
|
12
|
+
end_pos = IterPosManaged::new(end_pos_ptr.read_pointer)
|
13
|
+
[iter, begin_pos, end_pos]
|
16
14
|
end
|
15
|
+
end
|
17
16
|
|
17
|
+
module CTF
|
18
18
|
class Iter
|
19
19
|
def self.release(ptr)
|
20
20
|
CTF.bt_ctf_iter_destroy(ptr)
|
data/lib/babeltrace/types.rb
CHANGED
@@ -5,4 +5,25 @@ module Babeltrace
|
|
5
5
|
typedef orig, add
|
6
6
|
}
|
7
7
|
|
8
|
+
attach_function :bt_array_index, [Definition, :uint64], :pointer #Returns a definition
|
9
|
+
attach_function :bt_sequence_len, [Definition], :uint64
|
10
|
+
attach_function :bt_sequence_index, [Definition, :uint64], :pointer #Returns a definition
|
11
|
+
class Definition #< FFI::Struct
|
12
|
+
def array_index(i)
|
13
|
+
d = Babeltrace.bt_array_index(self, i)
|
14
|
+
return nil if d.null?
|
15
|
+
self.class.new(d)
|
16
|
+
end
|
17
|
+
|
18
|
+
def sequence_len
|
19
|
+
Babeltrace.bt_sequence_len(self)
|
20
|
+
end
|
21
|
+
|
22
|
+
def sequence_index(i)
|
23
|
+
d = Babeltrace.bt_sequence_index(self, i)
|
24
|
+
return nil if d.null?
|
25
|
+
self.class.new(d)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
8
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: babeltrace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brice Videau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -30,6 +30,26 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 1.9.3
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: walk
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.1'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.1.0
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.1'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.1.0
|
33
53
|
description: Ruby libbabeltrace ffi bindings
|
34
54
|
email: bvideau@anl.gov
|
35
55
|
executables: []
|