babeltrace_ze.in 800 Bytes
Newer Older
Brice Videau's avatar
Brice Videau committed
1
#!/usr/bin/env ruby
Brice Videau's avatar
Brice Videau committed
2
3
4
DATADIR = File.join("@prefix@", "share")
$:.unshift(DATADIR) if File::directory?(DATADIR)
$:.unshift("./")
Brice Videau's avatar
Brice Videau committed
5
6
7
8
require 'babeltrace'
require 'babeltrace/ctf'
require 'yaml'
require 'pp'
Brice Videau's avatar
Brice Videau committed
9
require 'babeltrace_ze_lib'
Brice Videau's avatar
Brice Videau committed
10
11
12
13
14
15

c = Babeltrace::Context::new
traces = c.add_traces(path: ARGV[0])

puts "#{c.get_timestamp_begin.strftime("%Y-%m-%d %H:%M:%S.%9L %z")} -- #{c.get_timestamp_end.strftime("%Y-%m-%d %H:%M:%S.%9L %z")}"

Brice Videau's avatar
Brice Videau committed
16
17
18
19
20
events = {}
traces.each { |t|
  events[t.handle_id] = t.get_event_decl_list.collect(&:name)
}

Brice Videau's avatar
Brice Videau committed
21
22
it = c.iter_create
it.each { |ev|
Brice Videau's avatar
Brice Videau committed
23
24
  name = events[ev.handle_id][ev.id]
  print "#{ev.timestamp.strftime("%H:%M:%S.%9L")} - #{name}: "
Brice Videau's avatar
Brice Videau committed
25
  defi = ev.top_level_scope(:EVENT_FIELDS)
Brice Videau's avatar
Brice Videau committed
26
27
28
29
30
31
  l = $event_lambdas[name]
  if l
    puts l.call(defi.value)
  else
    puts defi.value
  end
Brice Videau's avatar
Brice Videau committed
32
33
}