From: Joel VanderWerf Date: 2007-07-13T07:25:40+09:00 Subject: Re: getting gdb backtrace from ruby exception ara.t.howard wrote: > > On Jul 12, 2007, at 8:10 AM, Alex Fenton wrote: > >> Hi >> >> I'm working on a C extension and somewhere in itsomething is raising a >> NoMethodError. The exception is reported with the line of ruby code >> that triggered the bad call in the C extension. >> >> As the C code is large and complex (it's a big SWIG project), I'm >> having trouble finding the problem in the C code. I would use gdb or >> Microsoft's debugger to look at the stack if it was a C error - but >> when a Ruby exception is raised, the process exits and there's no >> stack to inspect. >> >> Ruby's debugger isn't helpful because it only knows about ruby written >> in ruby. >> >> Is there any way I can get at the C stack at the point of ruby 'raise' >> from a C extension? >> >> Thanks >> alex >> > > > cfp:~ > cat core.rb > BEGIN{ at_exit{ Process.kill 'SIGSEGV', Process.pid if $! } } > > > cfp:~ > cat a.rb > #! /usr/bin/env ruby > require 'core' > p 42 > cfp:~ > ruby a.rb > 42 > > > cfp:~ > cat b.rb > #! /usr/bin/env ruby > require 'core' > raise > > > cfp:~ > ruby b.rb > ./core.rb:1: [BUG] Segmentation fault > ruby 1.8.6 (2007-03-13) [i686-darwin8.9.1] > > Abort trap (core dumped) Doesn't that only give you the C stack at the time the ruby process exits, not at the time the exception is raised? -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407