Sha256: 180b593e51276c547b37b2874aa1f7dc7b7dacf3b3030fb118c5adb4cec02fb6

Contents?: true

Size: 1.17 KB

Versions: 35

Compression:

Stored size: 1.17 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

35 entries across 35 versions & 1 rubygems

Version Path
ruby-prof-1.4.1-x64-mingw32 bin/ruby-prof-check-trace
ruby-prof-1.4.1 bin/ruby-prof-check-trace
ruby-prof-1.4.0-x64-mingw32 bin/ruby-prof-check-trace
ruby-prof-1.4.0 bin/ruby-prof-check-trace
ruby-prof-1.3.2 bin/ruby-prof-check-trace
ruby-prof-1.3.1-x64-mingw32 bin/ruby-prof-check-trace
ruby-prof-1.3.1 bin/ruby-prof-check-trace
ruby-prof-1.3.0-x64-mingw32 bin/ruby-prof-check-trace
ruby-prof-1.3.0 bin/ruby-prof-check-trace
ruby-prof-1.2.0 bin/ruby-prof-check-trace
ruby-prof-1.1.0-x64-mingw32 bin/ruby-prof-check-trace
ruby-prof-1.1.0 bin/ruby-prof-check-trace
ruby-prof-1.0.0 bin/ruby-prof-check-trace
ruby-prof-0.18.0-x64-mingw32 bin/ruby-prof-check-trace
ruby-prof-0.18.0 bin/ruby-prof-check-trace