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

Re: How to tell if Perl has -DDEBUGGING?

Thread Previous | Thread Next
Nicholas Clark
October 24, 2003 09:13
Re: How to tell if Perl has -DDEBUGGING?
Message ID:
On Fri, Oct 24, 2003 at 05:00:30PM +0100, Steve Hay wrote:
> which is all well and good, but some devious miscreant could easily edit 
> their file to lie about whether the Perl has DEBUGGING or not.
> Is there no way for Perl itself to tell us?
> The end of the "perl -V" output contains this:
>    Characteristics of this binary (from libperl):
>      Compile-time options: DEBUGGING
>      Built under MSWin32
>      Compiled at Oct 24 2003 15:50:11
> That doesn't come from  Instead, as it says, it comes from 
> Perl (libperl) itself.  That's what I want.  Can I get at *that* 
> DEBUGGING setting (other than by the obvious and undesirable means of 
> doing a "perl -V" system call and parsing the output)?

Not that I'm aware of. However, based on the useful feature that you can
change $^D at runtime to flip the -DDEBUGGING switches, and a perusal of
perlrun for something to hijack, try this:

$ perl5.8.0 -le  'sub D {local $^D = 8192; my %a = (1=>2); $^D=8192; (values %a)[0] == 2 ? 0 : 1}; print &D ? "DDEBUGGING" : "not"'
$ perl5.8.0-g -le  'sub D {local $^D = 8192; my %a = (1=>2); $^D=8192; (values %a)[0] == 2 ? 0 : 1}; print &D ? "DDEBUGGING" : "not"'

I think that it should be possible to execute my sub D as a string eval from
inside XS, which should give you an idea of what your host perl can really
do, independent of what it claims to do.

[until someone escalates the arms race by hacking their perl source to
disable $^D]

Nicholas Clark

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About