See the previously posted link, which contains very good information. I have a few other things that I use.
The XS routines that will call your inline function will be named _XS_package_function, where package is your full Perl package name with double-colons (::) replace with double underscores (__). (At least, that's the symbol name I get here. Use nm on the .so to find out for sure.) If you can get into the debugger after your library has been bootstrapped, you can set a breakpoints by name.
The current value of $@ is often of interest. This isn't guaranteed to work, and depends somewhat on your compile of perl, but I use the following expression to fetch the value:
p ((XPV*) my_perl->Ierrgv->sv_any->xgv_gp->gp_sv->sv_any)->xpv_pv
Isn't that beautiful?
Similarly but much simpler, if you want to see the string value of an SV* that you know has a string in it, use p *(XPV*)var->sv_any. (This may not work if there is anything special about the variable.)
To generate a warning (sometimes useful just to see what line of code you're on, for example if your debugger caught a segmentation fault): p Perl_warner(my_perl, 1, "oops")
This one is helpful for much more than Inline. Use the following code: // Define a BREAKPOINT macro that will send the current process a
// SIGTRAP, causing a drop into the debugger if you're running under
// one. If this is not an i386, then this macro will drop you into the
// debugger deep inside a libc function and you'll have to single-step
// out (si).
#ifdef __i386__
# define BREAKPOINT do { \
int pid = getpid(); \
int signum = SIGTRAP; \
int trapnum = SYS_kill; \
asm("int $0x80" : : "b"(pid), "c"(signum), "a"(trapnum));
+\
} while(0)
#else
# define BREAKPOINT kill(getpid(), SIGTRAP)
#endif
to programmatically create breakpoints that will drop you into the debugger. (That was a fun one to create -- I hadn't done any assembly programming in a few years, and I'd never done inline asm in gcc. Nor used SIGTRAP. I wrote it to be cross-platform, but I've never actually tried it anywhere else.)
|