develooper Front page | perl.perl5.porters | Postings from October 2003

Re: How to tell if Perl has -DDEBUGGING?

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
October 25, 2003 02:54
Subject:
Re: How to tell if Perl has -DDEBUGGING?
Message ID:
20031025095346.GE52109@plum.flirble.org
On Fri, Oct 24, 2003 at 04:15:05PM -0600, Jim Cromie wrote:
> and without $^D set, its difficult to get at hidden/obfuscated code.
> If they do monkey with $^D on a non-debugging perl, it still wouldnt
> give them what they want.

I'm not so sure about that. The perl debugger works on a non-"debugging"
perl. If you run under the -d switch this code in toke.c is activated:

        /* debugger active and we're not compiling the debugger code,
         * so store the line into the debugger's array of lines
         */
        if (PERLDB_LINE && PL_curstash != PL_debstash) {
            SV *sv = NEWSV(85,0);

            sv_upgrade(sv, SVt_PVMG);
            sv_setpvn(sv,PL_bufptr,PL_bufend-PL_bufptr);
            (void)SvIOK_on(sv);
            SvIVX(sv) = 0;
            av_store(CopFILEAV(PL_curcop),(I32)CopLINE(PL_curcop),sv);
        }

You don't even have to use the perl debugger - you can write your own
which would dump source back out from the array of source lines.

It can't be this easy. If it is I'm surprised that no-one has commented
on this before.

Nicholas Clark

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About