babeltrace 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +7 -0
- data/babeltrace.gemspec +15 -0
- data/ext/babeltrace_c/babeltrace.c +77 -0
- data/ext/babeltrace_c/babeltrace/align.h +82 -0
- data/ext/babeltrace_c/babeltrace/compiler.h +40 -0
- data/ext/babeltrace_c/babeltrace/types.h +565 -0
- data/ext/babeltrace_c/extconf.rb +8 -0
- data/lib/babeltrace.rb +15 -0
- data/lib/babeltrace/clock_type.rb +3 -0
- data/lib/babeltrace/context.rb +33 -0
- data/lib/babeltrace/ctf.rb +10 -0
- data/lib/babeltrace/ctf/callbacks.rb +27 -0
- data/lib/babeltrace/ctf/events.rb +558 -0
- data/lib/babeltrace/ctf/iterator.rb +90 -0
- data/lib/babeltrace/format.rb +54 -0
- data/lib/babeltrace/iterator.rb +62 -0
- data/lib/babeltrace/list.rb +72 -0
- data/lib/babeltrace/trace_handle.rb +28 -0
- data/lib/babeltrace/types.rb +8 -0
- metadata +83 -0
@@ -0,0 +1,90 @@
|
|
1
|
+
module Babeltrace
|
2
|
+
module CTF
|
3
|
+
class Trace
|
4
|
+
def iter_create(begin_pos: nil, end_pos: nil)
|
5
|
+
CTF.bt_ctf_iter_create(@context, begin_pos, end_pos)
|
6
|
+
end
|
7
|
+
|
8
|
+
def iter_create_intersect
|
9
|
+
begin_pos_ptr = FFI::MemoryPointer::new(:pointer)
|
10
|
+
end_pos_ptr = FFI::MemoryPointer::new(:pointer)
|
11
|
+
iter = CTF.bt_ctf_iter_create_intersect(@context, begin_pos_ptr, end_pos_ptr)
|
12
|
+
begin_pos = IterPosManaged::new(begin_pos_ptr.read_pointer)
|
13
|
+
end_pos = IterPosManaged::new(end_pos_ptr.read_pointer)
|
14
|
+
[iter, begin_pos, end_pos]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Iter
|
19
|
+
def self.release(ptr)
|
20
|
+
CTF.bt_ctf_iter_destroy(ptr)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_iter
|
24
|
+
return @iter if @iter
|
25
|
+
@iter = CTF.bt_ctf_get_iter(self)
|
26
|
+
@iter.child = self
|
27
|
+
@iter
|
28
|
+
end
|
29
|
+
|
30
|
+
def read_event
|
31
|
+
CTF.bt_ctf_iter_read_event(self)
|
32
|
+
end
|
33
|
+
|
34
|
+
def read_event_flag
|
35
|
+
ptr = FFI::MemoryPointer::new(:int)
|
36
|
+
event = CTF.bt_ctf_iter_read_event_flags(self, ptr)
|
37
|
+
flags = ptr.read(:int)
|
38
|
+
[event, flags]
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_lost_events_count
|
42
|
+
CTF.bt_ctf_get_lost_events_count(self)
|
43
|
+
end
|
44
|
+
|
45
|
+
def next
|
46
|
+
get_iter.next
|
47
|
+
end
|
48
|
+
|
49
|
+
def get_pos
|
50
|
+
get_iter.get_pos
|
51
|
+
end
|
52
|
+
|
53
|
+
def set_pos(pos)
|
54
|
+
get_iter.set_pos(pos)
|
55
|
+
end
|
56
|
+
|
57
|
+
def rewind
|
58
|
+
get_iter.rewind
|
59
|
+
end
|
60
|
+
|
61
|
+
def create_time_pos(timestamp)
|
62
|
+
get_iter.create_time_pos(timestamp)
|
63
|
+
end
|
64
|
+
|
65
|
+
def each
|
66
|
+
rewind
|
67
|
+
if block_given?
|
68
|
+
loop do
|
69
|
+
e = self.read_event
|
70
|
+
break if e.pointer.null?
|
71
|
+
yield e
|
72
|
+
r = self.next
|
73
|
+
break if r != 0
|
74
|
+
end
|
75
|
+
else
|
76
|
+
return to_enum(:each)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
attach_function :bt_ctf_iter_create, [Context, :pointer, :pointer], Iter.by_ref #pointers to IterPos or IterPosManaged
|
83
|
+
attach_function :bt_ctf_iter_create_intersect, [Context, :pointer, :pointer], Iter.by_ref
|
84
|
+
attach_function :bt_ctf_get_iter, [Iter], Babeltrace::Iter.by_ref
|
85
|
+
attach_function :bt_ctf_iter_destroy, [Iter], :void
|
86
|
+
attach_function :bt_ctf_iter_read_event, [Iter], Event.by_ref
|
87
|
+
attach_function :bt_ctf_iter_read_event_flags, [Iter, :pointer], Event.by_ref
|
88
|
+
attach_function :bt_ctf_get_lost_events_count, [Iter], :uint64
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Babeltrace
|
2
|
+
class Context < FFI::ManagedStruct
|
3
|
+
layout :dummy, :pointer
|
4
|
+
end
|
5
|
+
|
6
|
+
class StreamPos < FFI::Struct
|
7
|
+
layout :dummy, :pointer
|
8
|
+
end
|
9
|
+
|
10
|
+
class MmapStream < FFI::Struct
|
11
|
+
layout :fd, :int,
|
12
|
+
:list, ListHead,
|
13
|
+
:priv, :pointer
|
14
|
+
end
|
15
|
+
|
16
|
+
class MmapStreamList < FFI::Struct
|
17
|
+
layout :head, ListHead
|
18
|
+
end
|
19
|
+
|
20
|
+
class TraceDescriptor < FFI::Struct
|
21
|
+
layout :dummy, :pointer
|
22
|
+
end
|
23
|
+
|
24
|
+
class TraceHandle < FFI::Struct
|
25
|
+
layout :dummy, :pointer
|
26
|
+
end
|
27
|
+
|
28
|
+
callback :packet_seek_callback, [StreamPos, :size_t, :int], :void
|
29
|
+
callback :open_trace_callback, [:string, :int, :packet_seek_callback, :pointer], TraceDescriptor.by_ref
|
30
|
+
callback :open_mmap_trace_callback, [MmapStreamList, :packet_seek_callback, :pointer], TraceDescriptor.by_ref
|
31
|
+
callback :close_trace_callback, [TraceDescriptor], :int
|
32
|
+
callback :set_context_callback, [TraceDescriptor, Context], :void
|
33
|
+
callback :set_handle_callback, [TraceDescriptor, TraceHandle], :void
|
34
|
+
callback :timestamp_begin_callback, [TraceDescriptor, TraceHandle, ClockType], :uint64
|
35
|
+
callback :timestamp_end_callback, [TraceDescriptor, TraceHandle, ClockType], :uint64
|
36
|
+
callback :convert_index_timestamp_callback, [TraceDescriptor], :int
|
37
|
+
|
38
|
+
class Format < FFI::Struct
|
39
|
+
layout :name, :intern_str,
|
40
|
+
:open_trace, :open_trace_callback,
|
41
|
+
:open_mmap_trace, :open_mmap_trace_callback,
|
42
|
+
:close_trace, :close_trace_callback,
|
43
|
+
:set_context, :set_context_callback,
|
44
|
+
:set_handle, :set_handle_callback,
|
45
|
+
:timestamp_begin, :timestamp_begin_callback,
|
46
|
+
:timestamp_end, :timestamp_end_callback,
|
47
|
+
:convert_index_timestamp, :convert_index_timestamp_callback
|
48
|
+
end
|
49
|
+
|
50
|
+
attach_function :bt_lookup_format, [:intern_str], Format
|
51
|
+
attach_function :bt_fprintf_format_list, [:pointer], :int
|
52
|
+
attach_function :bt_register_format, [Format], :int
|
53
|
+
attach_function :bt_unregister_format, [Format], :void
|
54
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Babeltrace
|
2
|
+
IterPosType = enum :SEEK_TIME, :SEEK_RESTORE, :SEEK_CUR, :SEEK_BEGIN, :SEEK_LAST
|
3
|
+
|
4
|
+
class SavedPos < FFI::Struct
|
5
|
+
layout :dummy, :pointer
|
6
|
+
end
|
7
|
+
|
8
|
+
class IterPos < FFI::Struct
|
9
|
+
class SeekUnion < FFI::Union
|
10
|
+
layout :seek_time, :uint64,
|
11
|
+
:restore, SavedPos.ptr
|
12
|
+
end
|
13
|
+
layout :type, IterPosType,
|
14
|
+
:u, SeekUnion
|
15
|
+
end
|
16
|
+
|
17
|
+
class IterPosManaged < FFI::ManagedStruct
|
18
|
+
class SeekUnion < FFI::Union
|
19
|
+
layout :seek_time, :uint64,
|
20
|
+
:restore, SavedPos.ptr
|
21
|
+
end
|
22
|
+
layout :type, IterPosType,
|
23
|
+
:u, SeekUnion
|
24
|
+
|
25
|
+
def self.release(ptr)
|
26
|
+
Babeltrace.bt_iter_free_pos(ptr)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class Iter < FFI::Struct
|
31
|
+
layout :dummy, :pointer
|
32
|
+
attr_accessor :child
|
33
|
+
|
34
|
+
def next
|
35
|
+
Babeltrace.bt_iter_next(self)
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_pos
|
39
|
+
Babeltrace.bt_iter_get_pos(self)
|
40
|
+
end
|
41
|
+
|
42
|
+
def set_pos(pos)
|
43
|
+
Babeltrace.bt_iter_set_pos(self, pos)
|
44
|
+
end
|
45
|
+
|
46
|
+
def rewind
|
47
|
+
pos = IterPos::new
|
48
|
+
pos[:type] = :SEEK_BEGIN
|
49
|
+
set_pos(pos)
|
50
|
+
end
|
51
|
+
|
52
|
+
def create_time_pos(timestamp)
|
53
|
+
Babeltrace.bt_iter_create_time_pos(self, timestamp)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
attach_function :bt_iter_next, [Iter], :int
|
58
|
+
attach_function :bt_iter_get_pos, [Iter], IterPosManaged.by_ref
|
59
|
+
attach_function :bt_iter_free_pos, [IterPosManaged], :void
|
60
|
+
attach_function :bt_iter_set_pos, [Iter, :pointer], :int #pointer to IterPos or IterPosManaged
|
61
|
+
attach_function :bt_iter_create_time_pos, [Iter, :uint64], IterPosManaged.by_ref
|
62
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Babeltrace
|
2
|
+
|
3
|
+
class ListHead < FFI::Struct
|
4
|
+
layout :next, ListHead.ptr,
|
5
|
+
:prev, ListHead.ptr
|
6
|
+
|
7
|
+
def init
|
8
|
+
self[:next] = self[:prev] = self
|
9
|
+
self
|
10
|
+
end
|
11
|
+
|
12
|
+
def add(head)
|
13
|
+
head[:next][:prev] = self
|
14
|
+
self[:next] = head[:next]
|
15
|
+
self[:prev] = head
|
16
|
+
head[:next] = self
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_tail(head)
|
21
|
+
head[:prev][:next] = self
|
22
|
+
self[:next] = head
|
23
|
+
self[:prev] = head[:prev]
|
24
|
+
head[:prev] = self
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.del(p, n)
|
29
|
+
n[:prev] = p
|
30
|
+
n[:next] = n
|
31
|
+
end
|
32
|
+
|
33
|
+
def del
|
34
|
+
ListHead.del(self[:prev], self[:next])
|
35
|
+
self
|
36
|
+
end
|
37
|
+
|
38
|
+
def move(list)
|
39
|
+
ListHead.del(self[:prev], self[:next])
|
40
|
+
self.add(list)
|
41
|
+
self
|
42
|
+
end
|
43
|
+
|
44
|
+
def replace(n)
|
45
|
+
n[:next] = self[:next]
|
46
|
+
n[:prev] = self[:prev]
|
47
|
+
n[:prev][:next] = n
|
48
|
+
n[:next][:prev] = n
|
49
|
+
self
|
50
|
+
end
|
51
|
+
|
52
|
+
def splice(head)
|
53
|
+
if(!empty?)
|
54
|
+
self[:next][:prev] = head
|
55
|
+
self[:prev][:next] = head[:next]
|
56
|
+
head[:next][:prev] = self[:prev]
|
57
|
+
head[:next] = self[:next]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def empty?
|
62
|
+
self.to_ptr == self[:next].to_ptr
|
63
|
+
end
|
64
|
+
|
65
|
+
def replace_init(n)
|
66
|
+
head = self[:next]
|
67
|
+
self.del
|
68
|
+
n.add_tail(head)
|
69
|
+
self.init
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Babeltrace
|
2
|
+
class Trace
|
3
|
+
attr_reader :context
|
4
|
+
attr_reader :handle_id
|
5
|
+
def initialize(context, handle_id)
|
6
|
+
@context = context
|
7
|
+
@handle_id = handle_id
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_path
|
11
|
+
Babeltrace.bt_trace_handle_get_path(@context, @handle_id)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_timestamp_begin(clock_type = :REAL)
|
15
|
+
t = Babeltrace.bt_trace_handle_get_timestamp_begin(@context, @handle_id, clock_type)
|
16
|
+
t = Time.at(0, t, :nsec) if clock_type == :REAL
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_timestamp_end(clock_type = :REAL)
|
20
|
+
t = Babeltrace.bt_trace_handle_get_timestamp_end(@context, @handle_id, clock_type)
|
21
|
+
t = Time.at(0, t, :nsec) if clock_type == :REAL
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
attach_function :bt_trace_handle_get_path, [Context, :int], :string
|
26
|
+
attach_function :bt_trace_handle_get_timestamp_begin, [Context, :int, ClockType], :uint64
|
27
|
+
attach_function :bt_trace_handle_get_timestamp_end, [Context, :int, ClockType], :uint64
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: babeltrace
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brice Videau
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-10-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffi
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.9.3
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.9'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.9.3
|
33
|
+
description: Ruby libbabeltrace ffi bindings
|
34
|
+
email: bvideau@anl.gov
|
35
|
+
executables: []
|
36
|
+
extensions:
|
37
|
+
- ext/babeltrace_c/extconf.rb
|
38
|
+
extra_rdoc_files: []
|
39
|
+
files:
|
40
|
+
- LICENSE
|
41
|
+
- babeltrace.gemspec
|
42
|
+
- ext/babeltrace_c/babeltrace.c
|
43
|
+
- ext/babeltrace_c/babeltrace/align.h
|
44
|
+
- ext/babeltrace_c/babeltrace/compiler.h
|
45
|
+
- ext/babeltrace_c/babeltrace/types.h
|
46
|
+
- ext/babeltrace_c/extconf.rb
|
47
|
+
- lib/babeltrace.rb
|
48
|
+
- lib/babeltrace/clock_type.rb
|
49
|
+
- lib/babeltrace/context.rb
|
50
|
+
- lib/babeltrace/ctf.rb
|
51
|
+
- lib/babeltrace/ctf/callbacks.rb
|
52
|
+
- lib/babeltrace/ctf/events.rb
|
53
|
+
- lib/babeltrace/ctf/iterator.rb
|
54
|
+
- lib/babeltrace/format.rb
|
55
|
+
- lib/babeltrace/iterator.rb
|
56
|
+
- lib/babeltrace/list.rb
|
57
|
+
- lib/babeltrace/trace_handle.rb
|
58
|
+
- lib/babeltrace/types.rb
|
59
|
+
homepage: https://github.com/alcf-perfengr/babeltrace-ruby
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 2.3.0
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.7.6.2
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Ruby libbabeltrace bindings
|
83
|
+
test_files: []
|