summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhlosioneer <mattmdrr2@gmail.com>2019-03-01 01:06:27 -0500
committerPhlosioneer <mattmdrr2@gmail.com>2019-03-01 01:06:27 -0500
commit2d0e0083bb454880765a8cff7e45f250f6f22284 (patch)
tree9b7695404c18c8e2b4a93617fb40b4b6d638192c
parent9ed0f775289d574a792f20ec37fe24f26e765117 (diff)
Improve OK bot's symbol counting
-rwxr-xr-x.travis/calcrom/calcrom.pl49
1 files changed, 40 insertions, 9 deletions
diff --git a/.travis/calcrom/calcrom.pl b/.travis/calcrom/calcrom.pl
index 9eff1c064..696d228fe 100755
--- a/.travis/calcrom/calcrom.pl
+++ b/.travis/calcrom/calcrom.pl
@@ -1,5 +1,7 @@
#!/usr/bin/perl
+use IPC::Cmd qw[ run ];
+
(@ARGV == 1)
or die "ERROR: no map file specified.\n";
open(my $file, $ARGV[0])
@@ -7,7 +9,6 @@ open(my $file, $ARGV[0])
my $src = 0;
my $asm = 0;
-my $undocumented = 0;
while (my $line = <$file>)
{
if ($line =~ /^ \.(\w+)\s+0x[0-9a-f]+\s+(0x[0-9a-f]+) (\w+)\/.+\.o/)
@@ -28,19 +29,49 @@ while (my $line = <$file>)
}
}
}
- if($line =~ /^\s+0x([0-9A-f]+)\s+[A-z_]+([0-9A-f]+)/) {
- my $thing1 = sprintf("%08X", hex($1));
- my $thing2 = sprintf("%08X", hex($2));
- if($thing1 eq $thing2) {
- $undocumented += 1;
- }
- }
}
+# It sucks that we have to objdump twice, but I can't figure out how to get
+# stdin working for subcommands in perl while still having a timeout.
+my $total_syms_as_string;
+(run (
+ command => "arm-none-eabi-nm pokeemerald.elf | wc -l",
+ buffer => \$total_syms_as_string,
+ timeout => 30
+))
+ or die "ERROR: Error while getting all symbols: $?";
+
+my $undocumented_as_string;
+(run (
+ command => "arm-none-eabi-nm pokeemerald.elf | grep \"Unknown_\\|sub_\" | wc -l",
+ buffer => \$undocumented_as_string,
+ timeout => 30
+))
+ or die "ERROR: Error while filtering for undocumented symbols: $?";
+
+my $undocumented = $undocumented_as_string + 0;
+(($undocumented != 0) and ($undocumented_as_string ne "0"))
+ or die "ERROR: Cannot convert string to num: '$undocumented_as_string'";
+
+my $total_syms = $total_syms_as_string + 0;
+(($total_syms != 0) and ($total_syms_as_string ne "0"))
+ or die "ERROR: Cannot convert string to num: '$total_syms_as_string'";
+
+($total_syms != 0)
+ or die "ERROR: No symbols found.";
+
my $total = $src + $asm;
my $srcPct = sprintf("%.4f", 100 * $src / $total);
my $asmPct = sprintf("%.4f", 100 * $asm / $total);
+
+my $documented = $total_syms - $undocumented;
+my $docPct = sprintf("%.4f", 100 * $documented / $total_syms);
+my $undocPct = sprintf("%.4f", 100 * $undocumented / $total_syms);
+
print "$total total bytes of code\n";
print "$src bytes of code in src ($srcPct%)\n";
print "$asm bytes of code in asm ($asmPct%)\n";
-print "$undocumented global symbols undocumented\n";
+print "\n";
+print "$total_syms total symbols\n";
+print "$documented symbols documented ($docPct%)\n";
+print "$undocumented symbols undocumented ($undocPct%)\n";