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.7.1-x64-mingw-ucrt bin/ruby-prof-check-trace
ruby-prof-1.7.1 bin/ruby-prof-check-trace
ruby-prof-1.7.0-x64-mingw-ucrt bin/ruby-prof-check-trace
ruby-prof-1.7.0 bin/ruby-prof-check-trace
ruby-prof-1.6.3-x64-mingw-ucrt bin/ruby-prof-check-trace
ruby-prof-1.6.3 bin/ruby-prof-check-trace
ruby-prof-1.6.2-x64-mingw-ucrt bin/ruby-prof-check-trace
ruby-prof-1.6.2 bin/ruby-prof-check-trace
ruby-prof-1.6.1 bin/ruby-prof-check-trace
ruby-prof-1.6.1-x64-mingw-ucrt bin/ruby-prof-check-trace
ruby-prof-1.5.0-x64-mingw-ucrt bin/ruby-prof-check-trace
ruby-prof-1.5.0 bin/ruby-prof-check-trace
ruby-prof-1.4.5-x64-mingw-ucrt bin/ruby-prof-check-trace
ruby-prof-1.4.5 bin/ruby-prof-check-trace
ruby-prof-1.4.4-x64-mingw-ucrt bin/ruby-prof-check-trace
ruby-prof-1.4.4 bin/ruby-prof-check-trace
ruby-prof-1.4.3-x64-mingw32 bin/ruby-prof-check-trace
ruby-prof-1.4.3 bin/ruby-prof-check-trace
ruby-prof-1.4.2-x64-mingw32 bin/ruby-prof-check-trace
ruby-prof-1.4.2 bin/ruby-prof-check-trace