Created
April 11, 2023 14:30
-
-
Save itarato/fbb1efccde0774c29616f340af406d16 to your computer and use it in GitHub Desktop.
Extracts a block of subtree from a callgraph of a given function (matched by a substring).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
Extracts a block of subtree from a callgraph of a given function (matched by a substring). | |
Use: | |
jt ruby --cpusampler=calltree -e 'a=[];a.push(1);p(a.size)' | ruby truffle_calltree_find.rb "IO#puts" | |
=end | |
pattern = ARGV[0] | |
in_match = false | |
tab_size = nil | |
STDIN.each_line.with_index do |line, idx| | |
if !in_match | |
if line.index(pattern) != nil | |
in_match = true | |
tab_size = line.match(/^ */)[0].size | |
puts(line) | |
end | |
else | |
current_tab_size = line.match(/^ */)[0].size | |
if current_tab_size == tab_size | |
in_match = false | |
puts("\n\n---\n\n") | |
else | |
puts(line) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment