tags:

views:

197

answers:

1

I want to use rb_p() to aid in debugging a ruby C extension, but everytime i use it i get a SIGTRAP in gdb!

here's an example:

(gdb) p user_defaults

$3 = 137559900

(gdb) call rb_p(user_defaults)

{:fill=>true, :texture=>#}

(gdb) n

Program received signal SIGTRAP, Trace/breakpoint trap. is_a_hash (try_hash=137560420) at utils.c:65 (gdb)

why does this happen? how can i stop it happening??

+1  A: 

SIGTRAP is caused by a breakpoint exception, specifically by the int3 instruction on x86 (interrupt 3). Your code is probably executing an int3. Take a look where gdb is telling you -- at utils.c line 65 in the is_a_hash() function. If you don't have access to the source code, you can at least get the disassembly from gdb by typing

disas try_hash

at the gdb prompt.

Adam Rosenfield
what does this exception mean exactly? what's the purpose of it? do you hazard a guess why the code is executing that instruction?
banister