2012-11-13 01:13:39 -05:00
|
|
|
#!/usr/bin/ruby
|
2012-11-16 12:02:39 -05:00
|
|
|
# -*- coding: us-ascii -*-
|
2012-11-13 01:13:39 -05:00
|
|
|
|
|
|
|
text = ARGF.read
|
|
|
|
|
2013-01-10 01:39:55 -05:00
|
|
|
# remove comments
|
2013-03-11 01:25:06 -04:00
|
|
|
text.gsub!(%r'(?:^ *)?/\*.*?\*/\n?'m, '')
|
2013-01-10 01:39:55 -05:00
|
|
|
|
2012-11-13 01:13:39 -05:00
|
|
|
# remove the pragma declarations
|
2013-03-11 01:25:06 -04:00
|
|
|
text.gsub!(/^#pragma.*\n/, '')
|
2012-11-13 01:13:39 -05:00
|
|
|
|
|
|
|
# replace the provider section with the start of the header file
|
2016-03-26 21:18:10 -04:00
|
|
|
text.gsub!(/provider ruby \{/, "#ifndef\t_PROBES_H\n#define\t_PROBES_H\n#define DTRACE_PROBES_DISABLED 1\n")
|
2012-11-13 01:13:39 -05:00
|
|
|
|
|
|
|
# finish up the #ifndef sandwich
|
2013-03-11 01:25:06 -04:00
|
|
|
text.gsub!(/\};/, "\n#endif\t/* _PROBES_H */")
|
2012-11-13 01:13:39 -05:00
|
|
|
|
2016-03-26 21:18:10 -04:00
|
|
|
# expand probes to DTRACE macros
|
|
|
|
text.gsub!(/^ *probe ([^\(]*)\(([^\)]*)\);/) {
|
|
|
|
name, args = $1, $2
|
|
|
|
name.upcase!
|
|
|
|
name.gsub!(/__/, '_')
|
|
|
|
args.gsub!(/(\A|, *)[^,]*\b(?=\w+(?=,|\z))/, '\1')
|
|
|
|
"#define RUBY_DTRACE_#{name}_ENABLED() 0\n" \
|
|
|
|
"#define RUBY_DTRACE_#{name}(#{args}) do {} while (0)"
|
2013-03-11 01:25:06 -04:00
|
|
|
}
|
2012-11-13 01:13:39 -05:00
|
|
|
|
2012-12-01 10:25:31 -05:00
|
|
|
puts "/* -*- c -*- */"
|
2012-11-13 01:13:39 -05:00
|
|
|
print text
|