I (ok, Joshua ben Jore) have an XS module that wants to initialize the
debugger when a module is loaded. It calls Perl_init_debugger in its
BOOT section, and then manually loads perl5db.pl. The load succeeds,
and printing *DB::DB{CODE} shows that the subroutine exists. However,
I still get the error message "No DB::DB routine defined" (emitted
from pp_ctl.c's pp_dbstate function.)

Why? How can I get something loaded? I tried adding this code to the
end of the BOOT section, after the call to Perl_init_debugger:

        eval_pv("sub DB::DB { print \"dude\" }", 0);
        GV* gv = PL_DBgv;
        CV* ccv = GvCV(gv);
        fprintf(stderr, "init: gv=%p cv=%p\n", gv, ccv);

It prints out cv=(nil). So apparently the GvCV isn't doing what I
thought it was doing.

If I break in the above code and call Perl_sv_dump(my_perl, gv), I get:

SV = PVGV(0x8a0d510) at 0x8a91b14
  REFCNT = 1
  FLAGS = (GMG,SMG,MULTI)
  IV = 0
  NV = 0
  MAGIC = 0x8a71538
    MG_VIRTUAL = &PL_vtbl_glob
    MG_TYPE = PERL_MAGIC_glob(*)
    MG_OBJ = 0x8a91b14
  NAME = "DB"
  NAMELEN = 2
  GvSTASH = 0x8908eec   "DynaLoader"
  GP = 0x8a212d0
    SV = 0x8a91b20
    REFCNT = 1
    IO = 0x0
    FORM = 0x0
    AV = 0x0
    HV = 0x0
    CV = 0x0
    CVGEN = 0x0
    GPFLAGS = 0x0
    LINE = 249
    FILE = "/usr/lib/perl5/5.8.0/i386-linux-thread-multi/DynaLoader.pm"
    FLAGS = 0x2
    EGV = 0x8a91b14     "DB"

Reply via email to