Project

General

Profile

Feature #2565 ยป 0001-Generate-probes.h-from-probes.d.patch

dummy_probe_gen.rb which generates probes.h from probes.d - vo.x (Vit Ondruch), 05/11/2012 11:28 PM

View differences:

tool/dummy_probe_gen.rb
1
system("dtrace -o probes.h -h -s probes.d")
2
funcs = File.readlines('probes.h').grep(/^#define\s*(RUBY_.*?)\s*\\$/) {
3
  function = $1
4
  if function =~ /\(\)$/
5
    "#define #{function} 0"
6
  else
7
    "#defune #{function}"
8
  end
9
}
1
def funcs
2
  comment = nil
3
  provider = nil
4

  
5
  File.readlines('probes.d').collect do |line|
6
    case line
7
    when %r{/\*}; comment = true; nil
8
    when %r{\*/}; comment = nil
9
    when %r{provider}; provider = line.split[1].upcase; nil
10
    when %r{\}}; provider = nil; ""
11
    else
12
      if !comment and provider
13
        if line =~ /probe/
14
          probe_name, probe_args = line.match(/probe (.*)\((.*)\)/)[1..2]
15

  
16
          macro_name = probe_name.gsub('__', '_').upcase
17
          args = probe_args.split(',').enum_for(:each_with_index).collect {|item, index| "arg#{index}"}.join(', ')
18

  
19
          "#define #{provider}_#{macro_name}_ENABLED() 0\n" \
20
          "#define #{provider}_#{macro_name}(#{args})"
21
        else
22
          ""
23
        end
24
      end
25
    end
26
  end.compact
27
end
10 28

  
11 29
puts <<-eoheader
12 30
#ifndef	_PROBES_H
13
-