-
Notifications
You must be signed in to change notification settings - Fork 4
debug trace session
rocky edited this page Nov 7, 2010
·
5 revisions
The below is a sample trepan session showing event tracing
trepan gcd.rb 3 5 -- (gcd.rb:4) def gcd(a, b) (trepan): set events call return line Trace events we may stop on: call, line, return (trepan): set trace trace is on. (trepan): finish -- (gcd.rb:18) a, b = ARGV[0..1].map {|arg| arg.to_i} -- (gcd.rb:18) a, b = ARGV[0..1].map {|arg| arg.to_i} -- (gcd.rb:18) a, b = ARGV[0..1].map {|arg| arg.to_i} -- (gcd.rb:19) puts "The GCD of %d and %d is %d" % [a, b, gcd(a, b)] -> (gcd.rb:4) def gcd(a, b) -- (gcd.rb:6) if a > b -- (gcd.rb:10) return nil if a <= 0 -- (gcd.rb:12) if a == 1 or b-a == 0 -- (gcd.rb:15) return gcd(b-a, a) -> (gcd.rb:4) def gcd(a, b) -- (gcd.rb:6) if a > b -- (gcd.rb:10) return nil if a <= 0 -- (gcd.rb:12) if a == 1 or b-a == 0 -- (gcd.rb:15) return gcd(b-a, a) -> (gcd.rb:4) def gcd(a, b) -- (gcd.rb:6) if a > b -- (gcd.rb:10) return nil if a <= 0 -- (gcd.rb:12) if a == 1 or b-a == 0 -- (gcd.rb:13) return a <- (gcd.rb:13) return a <- (gcd.rb:16) end <- (gcd.rb:16) end The GCD of 3 and 5 is 1 $