Last active
August 29, 2015 14:26
-
-
Save brennovich/569dabff049635bc1b27 to your computer and use it in GitHub Desktop.
Snipet used by Avid in RubyTapas #327
This file contains hidden or 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
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 |
This file contains hidden or 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
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