Sha256: 3440c48086439b99fa1682de8262f58c3eb6e987c175b99bb843e11237ad7946

Contents?: true

Size: 1.13 KB

Versions: 19

Compression:

Stored size: 1.13 KB

Contents

#!/usr/bin/env ruby

stacks = Hash.new{|h,k| h[k] = Hash.new{|h,k| h[k] = []}}
i = 0
File.open(ARGV[0]).each_line do |l|
  i += 1
  unless l =~ /^(\d+):(\d+): *\d+ms *([^ ]+) *(.*): *(\d+) *(.+)$/
    next if l =~/^ *$/
    puts "line doesn't match: #{l}"
    next
  end
  details = $1.to_i, $2.to_i, $3, $4, $5.to_i, $6
  thread, fiber, event, file, line, method = *details
  # puts method
  stack = stacks[thread][fiber]
  case event
  when 'call', 'c-call'
    stack << method
  when 'return', 'c-return'
    last_method = stack.pop
    if last_method != method
      puts "LINE #{i}: return event without call: #{method}"
      puts "STACK: #{stack.inspect}"
      if stack.find(method)
        puts "fixing stack"
        while (popped = stack.pop) && (popped != method)
          puts "popped #{popped}"
        end
      else
        raise "stack unfixable"
      end
      # stack << last_method
    end
  when 'line'
    last_method = stack[-1]
    if last_method != method
      unless stack.find(method)
        raise "LINE #{i}: line event without call: #{method}"
      end
    end
  else
    puts "unkown event"
  end
end
puts stacks.inspect

Version data entries

19 entries across 19 versions & 3 rubygems

Version Path
ruby-prof-0.17.0 bin/ruby-prof-check-trace
airbnb-ruby-prof-0.0.1 bin/ruby-prof-check-trace
ruby-prof-0.16.2 bin/ruby-prof-check-trace
ruby-prof-0.16.1 bin/ruby-prof-check-trace
ruby-prof-0.16.0 bin/ruby-prof-check-trace
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/ruby-prof-0.15.9/bin/ruby-prof-check-trace
ruby-prof-0.15.9 bin/ruby-prof-check-trace
ruby-prof-0.15.8 bin/ruby-prof-check-trace
ruby-prof-0.15.7 bin/ruby-prof-check-trace
ruby-prof-0.15.6 bin/ruby-prof-check-trace
ruby-prof-0.15.5 bin/ruby-prof-check-trace
ruby-prof-0.15.4 bin/ruby-prof-check-trace
ruby-prof-0.15.3 bin/ruby-prof-check-trace
ruby-prof-0.15.2 bin/ruby-prof-check-trace
ruby-prof-0.15.1 bin/ruby-prof-check-trace
ruby-prof-0.15.0 bin/ruby-prof-check-trace
ruby-prof-0.14.2 bin/ruby-prof-check-trace
ruby-prof-0.14.1 bin/ruby-prof-check-trace
ruby-prof-0.14.0 bin/ruby-prof-check-trace