2012-11-13 10:13:39 +04:00
|
|
|
#!/usr/bin/ruby
|
2012-11-16 21:02:39 +04:00
|
|
|
# -*- coding: us-ascii -*-
|
2012-11-13 10:13:39 +04:00
|
|
|
|
2016-07-03 00:01:04 +03:00
|
|
|
# Used to create dummy probes (as for systemtap and DTrace) by Makefiles.
|
|
|
|
# See common.mk.
|
|
|
|
|
2012-11-13 10:13:39 +04:00
|
|
|
text = ARGF.read
|
|
|
|
|
2013-01-10 10:39:55 +04:00
|
|
|
# remove comments
|
2013-03-11 09:25:06 +04:00
|
|
|
text.gsub!(%r'(?:^ *)?/\*.*?\*/\n?'m, '')
|
2013-01-10 10:39:55 +04:00
|
|
|
|
2016-07-06 08:03:14 +03:00
|
|
|
# remove the pragma declarations and ifdefs
|
|
|
|
text.gsub!(/^#(?:pragma|include|if|endif).*\n/, '')
|
2012-11-13 10:13:39 +04:00
|
|
|
|
|
|
|
# replace the provider section with the start of the header file
|
2016-03-27 04:18:10 +03:00
|
|
|
text.gsub!(/provider ruby \{/, "#ifndef\t_PROBES_H\n#define\t_PROBES_H\n#define DTRACE_PROBES_DISABLED 1\n")
|
2012-11-13 10:13:39 +04:00
|
|
|
|
|
|
|
# finish up the #ifndef sandwich
|
2013-03-11 09:25:06 +04:00
|
|
|
text.gsub!(/\};/, "\n#endif\t/* _PROBES_H */")
|
2012-11-13 10:13:39 +04:00
|
|
|
|
2016-03-27 04:18:10 +03: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 09:25:06 +04:00
|
|
|
}
|
2012-11-13 10:13:39 +04:00
|
|
|
|
2012-12-01 19:25:31 +04:00
|
|
|
puts "/* -*- c -*- */"
|
2012-11-13 10:13:39 +04:00
|
|
|
print text
|