Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

chromatic (983)

  (email not shown publicly)

Blog Information [] Profile for chr0matic []

Journal of chromatic (983)

Sunday January 08, 2006
04:16 AM

It Wasn't the C Code Breaking...

[ #28282 ]

I'm writing Perl Hacks (<TorgoX>All must buy!</TorgoX>) and in the process I'm coming across some really dusty corners of Perl.

One of my long-planned hacks was on tracing your code down at the opcode dispatch level -- who needs a debugger when you have something this cool -- using pure Perl. Of course, if I want to make this work correctly, I can't write pure Perl. That's fine. I'm a polyglot. I can handle a little C and XS.

When I hit the part tonight where my Perl callback was somehow, in some circumstances, getting a null op instead of the B::* object I expected, I started to debug my XS code, trying all sorts of permutations of creating the object, throwing in the magic XS incantations to manage the stack and reference count, and so on. I even went as far as to use the Devel::Peek equivalent in C.

I had no luck until I looked at the Perl code again and realized I was accidentally calling my callback from Perl without passing any values. ~bonk~

I can only defend myself by explaining that not only is figuring out exactly when this code takes over from the normal Perl runloop a bit tricky (as if the description alone weren't enough to scare almost everyone else away), but dodging segfaults always makes me woozy, and oh yeah is this difficult to test in process.

Look for Devel::TraceOps on the CPAN in the next couple of weeks, followed perhaps by ExtUtils::NCI.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.