| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/local/bin/perl -w |
|
2
|
|
|
|
|
|
|
################################################################################ |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# Copyright (c) 2002-2020 Marcus Holland-Moritz. All rights reserved. |
|
5
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify |
|
6
|
|
|
|
|
|
|
# it under the same terms as Perl itself. |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
################################################################################ |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#=============================================================================== |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# Parse perl's header files and play around with the types they define. |
|
13
|
|
|
|
|
|
|
# |
|
14
|
|
|
|
|
|
|
#=============================================================================== |
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
894
|
use Convert::Binary::C; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
50
|
|
|
17
|
1
|
|
|
1
|
|
735
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
7176
|
|
|
|
1
|
|
|
|
|
69
|
|
|
18
|
1
|
|
|
1
|
|
536
|
use File::Spec::Functions qw(rel2abs); |
|
|
1
|
|
|
|
|
943
|
|
|
|
1
|
|
|
|
|
81
|
|
|
19
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
1657
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
4
|
my $base; |
|
22
|
1
|
|
33
|
|
|
27
|
-d "$_/include" and $base = rel2abs("$_/include") and last for qw( tests ../tests ); |
|
|
|
|
50
|
|
|
|
|
|
23
|
1
|
50
|
|
|
|
58
|
defined $base or die <
|
|
24
|
|
|
|
|
|
|
Please run this script from either the 'examples' directory |
|
25
|
|
|
|
|
|
|
or the distribution base directory. |
|
26
|
|
|
|
|
|
|
MSG |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#------------------------------------- |
|
29
|
|
|
|
|
|
|
# Create an object, set configuration. |
|
30
|
|
|
|
|
|
|
#------------------------------------- |
|
31
|
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
574
|
my $cfg = require "$base/config.pl"; |
|
33
|
1
|
|
|
|
|
108
|
my $c = new Convert::Binary::C %$cfg; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#------------------ |
|
36
|
|
|
|
|
|
|
# Parse the C file. |
|
37
|
|
|
|
|
|
|
#------------------ |
|
38
|
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
5
|
eval { $c->parse_file( "$base/include.c" ) }; |
|
|
1
|
|
|
|
|
18414
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#----------------------- |
|
42
|
|
|
|
|
|
|
# Check for parse error. |
|
43
|
|
|
|
|
|
|
#----------------------- |
|
44
|
|
|
|
|
|
|
|
|
45
|
1
|
50
|
|
|
|
10
|
if( $@ ) { |
|
46
|
0
|
|
|
|
|
0
|
die "Parse error: $@"; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
#---------------------------- |
|
50
|
|
|
|
|
|
|
# Dump out the configuration. |
|
51
|
|
|
|
|
|
|
#---------------------------- |
|
52
|
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
85
|
print Dumper( $c->configure ); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
#---------------------------- |
|
56
|
|
|
|
|
|
|
# Print all the enumerations. |
|
57
|
|
|
|
|
|
|
#---------------------------- |
|
58
|
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
464
|
my @enums = $c->enum_names; |
|
60
|
1
|
|
|
|
|
7
|
print "\nenums: @enums\n\n"; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
|
63
|
|
|
|
|
|
|
# Print all structs, sorted by size; skip all structs smaller than 50 bytes. |
|
64
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
|
65
|
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
2
|
print "large structs:\n\n"; |
|
67
|
|
|
|
|
|
|
|
|
68
|
8
|
|
|
|
|
28
|
my @structs = sort { $c->sizeof( $b ) <=> $c->sizeof( $a ) } |
|
69
|
1
|
|
|
|
|
24
|
grep { $c->sizeof( $_ ) >= 50 } |
|
|
19
|
|
|
|
|
112
|
|
|
70
|
|
|
|
|
|
|
$c->struct_names; |
|
71
|
|
|
|
|
|
|
|
|
72
|
1
|
|
|
|
|
5
|
for my $struct ( @structs ) { |
|
73
|
6
|
|
|
|
|
28
|
printf "struct %-20s => %4d bytes\n", $struct, $c->sizeof( $struct ); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
3
|
print "\n"; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#----------------------------------------------- |
|
79
|
|
|
|
|
|
|
# Dump the definition of the __socket_type enum |
|
80
|
|
|
|
|
|
|
#----------------------------------------------- |
|
81
|
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
8
|
print Data::Dumper->Dump( [$c->enum('__socket_type')], ['__socket_type'] ); |