Jim Cromie wrote:

{snip}

3. It appears that the 'err: coderef $foo has no START' is result of calling _sizeCV on an XS function. Does that sound right ? Are there any other causes ? if Yes, no, then Ill send a patch to blead.


With this minor patch to t/glob.t (w indent chgs looks bigger than it is), I get more corroboration for above supposition:


[EMAIL PROTECTED] latest]$ perl -Ilib t/glob.t Digest::MD5
1..1
ok 1 - use Devel::Size;
# foo SCALAR 36
# foo ARRAY 68
# foo HASH 148
# foo CODE 12
# foo IO 12
# foo GLOB 494
Digest::MD5
 at t/glob.t line 66
 at /usr/local/lib/perl5/5.8.6/Carp.pm line 271
# Digest::MD5 hexdigest.SCALAR => 12
# Digest::MD5 hexdigest CODE: is probably XS code
# Digest::MD5 __ANON__.SCALAR => 12
# Digest::MD5 add.SCALAR => 12
# Digest::MD5 add CODE: is probably XS code
# Digest::MD5 md5_hex.SCALAR => 12
# Digest::MD5 md5_hex CODE: is probably XS code
# Digest::MD5 b64digest.SCALAR => 12
# Digest::MD5 b64digest CODE: is probably XS code
# Digest::MD5 bootstrap.SCALAR => 12
# Digest::MD5 bootstrap CODE: is probably XS code
# Digest::MD5 clone.SCALAR => 12
# Digest::MD5 clone CODE: is probably XS code
# Digest::MD5 reset.SCALAR => 12
# Digest::MD5 reset CODE: is probably XS code
# Digest::MD5 add_bits.SCALAR => 12
# Digest::MD5 BEGIN.SCALAR => 12
# Digest::MD5 new.SCALAR => 12
# Digest::MD5 new CODE: is probably XS code
# Digest::MD5 dl_load_flags.SCALAR => 12
# Digest::MD5 addfile.SCALAR => 12
# Digest::MD5 addfile CODE: is probably XS code
# Digest::MD5 md5_base64.SCALAR => 12
# Digest::MD5 md5_base64 CODE: is probably XS code
# Digest::MD5 EXPORT.SCALAR => 12
# Digest::MD5 EXPORT.ARRAY => 56
# Digest::MD5 DESTROY.SCALAR => 12
# Digest::MD5 DESTROY CODE: is probably XS code
# Digest::MD5 EXPORT_OK.SCALAR => 12
# Digest::MD5 EXPORT_OK.ARRAY => 68
# Digest::MD5 import.SCALAR => 12
# Digest::MD5 import.CODE => 10466
# Digest::MD5 EXPORT_FAIL.SCALAR => 12
# Digest::MD5 EXPORT_FAIL.ARRAY => 56
# Digest::MD5 ISA.SCALAR => 12
# Digest::MD5 ISA.ARRAY => 120
# Digest::MD5 digest.SCALAR => 12
# Digest::MD5 digest CODE: is probably XS code
# Digest::MD5 VERSION.SCALAR => 29
# Digest::MD5 md5.SCALAR => 12
# Digest::MD5 md5 CODE: is probably XS code
[EMAIL PROTECTED] latest]$


wrt the SCALAR lines above, IIUC, these are autovivified cuz Im doing a symbolic reference to the scalars ?

I tried supressing them, it appears this is illegal:

            next unless exists *{$pkg.'::'.$sym}{$thing};

exists argument is not a HASH or ARRAY element at t/glob.t line 69.

and this is also unhelpful (but no error)

        next unless defined *{$pkg.'::'.$sym}{$thing};

I'll concede this is drifting off XS topic, Im still hoping there are
interested parties here.



4. any point in computing size of binary functions ?
I could imagine doing it with `nm -S` but this is horribly unportable.
It also opens a whole nuther can of worms, since each function
is likely to call lots of others.


Im thinking this is beyond the scope of _sizeofCV, since its not perl code being sized.


size of object code probably should include everything it links to,
which sounds like a nightmare given portability reqs and my current level of compiling/linking fu.



thanks in advance,
Jim Cromie

Only in latest/: blib
Only in latest/: blibdirs.ts
Only in latest/: Makefile
Only in latest/: pm_to_blib.ts
Only in latest/: Size.bs
Only in latest/: Size.c
Only in latest/: Size.o
Only in latest/: Size.pm~
Only in latest/t: cvsize.t~
diff -ru Devel-Size-0.60_06/t/glob.t latest/t/glob.t
--- Devel-Size-0.60_06/t/glob.t 2005-03-12 08:11:07.415052503 -0700
+++ latest/t/glob.t     2005-03-12 08:19:52.714579484 -0700
@@ -3,6 +3,13 @@
 # run either `make test`,
 # or `perl -I blib/lib -I blib/arch  t/cvsize.t`
 
+=head1
+
+No actual tests yet.  It scans the package symbol-table, and runs
+Devel::Size on each thingy (see perlref) of each glob in the table.
+
+=cut
+
 use Test::More;
 plan tests => 1;
 
@@ -40,35 +47,50 @@
 }
 
 
-# package Devel::Size;
+# silence this err from B::Concise
+# err: coderef B::CV=SCALAR(0x833c670) has no START
 
-for $sym (keys %Devel::Size:: ) {
-    for $thing (qw( SCALAR ARRAY HASH CODE IO GLOB)) {
-       next unless *{'Devel::Size::'.$sym}{$thing};
-       eval {
-           # print "$sym.$thing => ", size(*$sym{$thing}),"\n";
-           diag("$sym.$thing => ",
-                size(*{'Devel::Size::'.$sym}{$thing}),"\n");
-       };
-
-       if ($@ =~ /has no START/) {
-           # std err from B::Concise
-           diag "$sym $thing: is probably XS code\n";
+use Carp;
 
-       }
-       elsif ($@ =~ /via package "B::NULL"/) {
-           # but since Ive hacked my local copy, B::Concise only warns
-           # then dies with err above
-           diag "$sym $thing: is probably XS code\n";
+local $SIG{__WARN__} = sub {
+    # silence this
+    $_[0] =~ /START/ and return;
+    carp(@_);
+    return @_;
+};
 
-       }
-       elsif ($@) {
-           warn "$sym.$thing: [EMAIL PROTECTED]";
+my @pkgs = @ARGV;
[EMAIL PROTECTED] = qw( Devel::Size ) unless @pkgs;
+
+for $pkg (@pkgs) {
+    eval "use $pkg" or carp("$pkg [EMAIL PROTECTED]");
+    for $sym (keys %{$pkg.'::'} ) {
+       for $thing (qw( SCALAR ARRAY HASH CODE IO )) {
+           next unless *{$pkg.'::'.$sym}{$thing};
+           eval {
+               # print "$sym.$thing => ", size(*$sym{$thing}),"\n";
+               diag("$pkg $sym.$thing => ",
+                    size(*{$pkg.'::'.$sym}{$thing}),"\n");
+           };
+           
+           if ($@ =~ /has no START/) {
+               # std err from B::Concise
+               diag "$pkg $sym $thing: is probably XS code\n";
+               
+           }
+           elsif ($@ =~ /via package "B::NULL"/) {
+               # but since Ive hacked my local copy, B::Concise only warns
+               # then dies with err above
+               diag "$pkg $sym $thing: is probably XS code\n";
+               
+           }
+           elsif ($@) {
+               warn "$pkg $sym.$thing: [EMAIL PROTECTED]";
+           }
        }
     }
 }
 
-
 } # skip
 
 __END__
Only in latest/t: glob.t~

Reply via email to