Skip to content

Instantly share code, notes, and snippets.

@zbskii
Created May 20, 2011 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zbskii/982386 to your computer and use it in GitHub Desktop.
Save zbskii/982386 to your computer and use it in GitHub Desktop.
require 'ruby-debug'
module Debugger
class << self
def post_mortem
self.post_mortem = true
debug_at_exit do
handle_post_mortem($!) if $! && post_mortem?
end
end
def handle_post_mortem(exp)
return if !exp || !exp.__debug_context ||
exp.__debug_context.stack_size == 0
Debugger.suspend
orig_tracing = Debugger.tracing, Debugger.current_context.tracing
Debugger.tracing = Debugger.current_context.tracing = false
Debugger.last_exception = exp
doit(exp)
ensure
Debugger.tracing, Debugger.current_context.tracing = orig_tracing
Debugger.resume
end
end
end
def doit(exp)
context = exp.__debug_context
p exp.__debug_file
p context.stack_size
p context.dead?
file = context.frame_file(0)
end
Debugger.start({:post_mortem => true})
[1,1,1,0,1,1,1].each do |i|
1/i
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment