mirror of https://github.com/pret/pokeemerald.git
Sync calcrom fixes
This commit is contained in:
parent
e5260c9aa1
commit
dc24fde7f6
|
@ -1,5 +1,11 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
# Usage:
|
||||||
|
# calcrom.pl <mapfile> [--data]
|
||||||
|
#
|
||||||
|
# mapfile: path to .map file output by LD
|
||||||
|
# data: set to output % breakdown of data
|
||||||
|
|
||||||
use IPC::Cmd qw[ run ];
|
use IPC::Cmd qw[ run ];
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
|
|
||||||
|
@ -65,12 +71,13 @@ my $base_cmd = "nm $elffname | awk '{print \$3}' | grep '^[^_].\\{4\\}' | uniq";
|
||||||
|
|
||||||
# This looks for Unknown_, Unknown_, or sub_, followed by an address. Note that
|
# This looks for Unknown_, Unknown_, or sub_, followed by an address. Note that
|
||||||
# it matches even if stuff precedes the unknown, like sUnknown/gUnknown.
|
# it matches even if stuff precedes the unknown, like sUnknown/gUnknown.
|
||||||
my $undoc_cmd = "grep '[Uu]nknown_[0-9a-fA-F]\\{5,7\\}\\|sub_[0-9a-fA-F]\\{5,7\\}'";
|
my $undoc_regex = "'[Uu]nknown_[0-9a-fA-F]\\{5,7\\}\\|sub_[0-9a-fA-F]\\{5,7\\}'";
|
||||||
|
|
||||||
# This looks for every symbol with an address at the end of it. Some things are
|
# This looks for every symbol with an address at the end of it. Some things are
|
||||||
# given a name based on their type / location, but still have an unknown purpose.
|
# given a name based on their type / location, but still have an unknown purpose.
|
||||||
# For example, FooMap_EventScript_FFFFFFF.
|
# For example, FooMap_EventScript_FFFFFFF.
|
||||||
my $partial_doc_cmd = "grep '_[0-28][0-9a-fA-F]\\{5,7\\}'";
|
# The above may be double counted here, and will need to be filtered out.
|
||||||
|
my $partial_doc_regex = "'_[0-28][0-9a-fA-F]\\{5,7\\}'";
|
||||||
|
|
||||||
my $count_cmd = "wc -l";
|
my $count_cmd = "wc -l";
|
||||||
|
|
||||||
|
@ -87,7 +94,7 @@ my $total_syms_as_string;
|
||||||
|
|
||||||
my $undocumented_as_string;
|
my $undocumented_as_string;
|
||||||
(run (
|
(run (
|
||||||
command => "$base_cmd | $undoc_cmd | $count_cmd",
|
command => "$base_cmd | grep $undoc_regex | $count_cmd",
|
||||||
buffer => \$undocumented_as_string,
|
buffer => \$undocumented_as_string,
|
||||||
timeout => 60
|
timeout => 60
|
||||||
))
|
))
|
||||||
|
@ -95,7 +102,7 @@ my $undocumented_as_string;
|
||||||
|
|
||||||
my $partial_documented_as_string;
|
my $partial_documented_as_string;
|
||||||
(run (
|
(run (
|
||||||
command => "$base_cmd | $partial_doc_cmd | $count_cmd",
|
command => "$base_cmd | grep $partial_doc_regex | grep -v $undoc_regex | $count_cmd",
|
||||||
buffer => \$partial_documented_as_string,
|
buffer => \$partial_documented_as_string,
|
||||||
timeout => 60
|
timeout => 60
|
||||||
))
|
))
|
||||||
|
@ -126,9 +133,6 @@ my $total = $src + $asm;
|
||||||
my $srcPct = sprintf("%.4f", 100 * $src / $total);
|
my $srcPct = sprintf("%.4f", 100 * $src / $total);
|
||||||
my $asmPct = sprintf("%.4f", 100 * $asm / $total);
|
my $asmPct = sprintf("%.4f", 100 * $asm / $total);
|
||||||
|
|
||||||
# partial_documented is double-counting the unknown_* and sub_* symbols.
|
|
||||||
$partial_documented = $partial_documented - $undocumented;
|
|
||||||
|
|
||||||
my $documented = $total_syms - ($undocumented + $partial_documented);
|
my $documented = $total_syms - ($undocumented + $partial_documented);
|
||||||
my $docPct = sprintf("%.4f", 100 * $documented / $total_syms);
|
my $docPct = sprintf("%.4f", 100 * $documented / $total_syms);
|
||||||
my $partialPct = sprintf("%.4f", 100 * $partial_documented / $total_syms);
|
my $partialPct = sprintf("%.4f", 100 * $partial_documented / $total_syms);
|
||||||
|
|
Loading…
Reference in New Issue