Skip to content

Instantly share code, notes, and snippets.

@brennovich
Last active August 29, 2015 14:26
Show Gist options
  • Save brennovich/569dabff049635bc1b27 to your computer and use it in GitHub Desktop.
Save brennovich/569dabff049635bc1b27 to your computer and use it in GitHub Desktop.
Snipet used by Avid in RubyTapas #327
require "rake"
include FileUtils
indent = 0
trace = TracePoint.new(:call, :c_call, :return, :c_return) do |tp|
if [:return, :c_return].include?(tp.event) && indent.nonzero?
indent -= 1
else
puts "#{' ' * indent}#{tp.inspect}"
indent += 1
end
end
trace.enable
ruby "-v"
trace.disable
max_stack_frames = 100
TooManyStackFrames = Class.new(StandardError)
TracePoint.new(:call) do |tp|
if caller.size >= max_stack_frames
raise TooManyStackFrames, "Stack
has exceeded #{max_stack_frames}
frames"
end
end.enable
foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment