Bug 886173 - Preserve playbackRate across pause/play. r=cpearce
[gecko.git] / tools / codesighs / nm_wrap_osx.pl
blob129a4ec0281fdf2e9f3a688c3bd69a30ff6d73c6
1 #!/usr/bin/perl -w
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 use strict;
10 # A wrapper for nm that produces output listing symbol size.
12 my($prev_addr) = 0;
13 my($prev_module) = "";
14 my($prev_kind) = "";
15 my($prev_symbol) = "";
17 open(NM_OUTPUT, "nm -fnol $ARGV[0] | c++filt |") or die "nm failed to run on $ARGV[0]\n";
18 while (<NM_OUTPUT>)
20 my($line) = $_;
21 chomp($line);
23 if ($line =~ /^([^:]+):\s*([0-9a-f]{8}) (\w) (.+)$/)
25 my($module) = $1;
26 my($addr) = $2;
27 my($kind) = $3;
28 my($symbol) = $4;
30 #Skip absolute addresses, there should be only a few
31 if ('a' eq lc $kind) {
32 if ('trampoline_size' ne $symbol) {
33 warn "Encountered unknown absolutely addressed symbol '$symbol' in $module";
35 next;
38 # we expect the input to have been piped through c++filt to
39 # demangle symbols. For some reason, it doesn't always demangle
40 # all of them, so push still-mangled symbols back through c++filt again.
41 if ($symbol =~ /^(_[_Z].+)/)
43 # warn "Trying again to unmangle $1\n";
44 $symbol = `c++filt '$1'`;
45 chomp($symbol);
46 # warn "Unmangling again to $symbol\n";
49 my($prev_size) = hex($addr) - hex($prev_addr);
50 # print "Outputting line $line\n";
52 # always print one behind, because only now do we know its size
53 if ($prev_module ne "") {
54 printf "%s:%08x %s %s\n", $prev_module, $prev_size, $prev_kind, $prev_symbol;
57 $prev_addr = $addr;
58 $prev_module = $module;
59 $prev_kind = $kind;
60 $prev_symbol = $symbol;
62 else
64 # warn " Discaring line $line\n";
68 # we don't know how big the last symbol is, so always show 4.
69 if ($prev_module ne "") {
70 printf "%s:%08x %s %s\n", $prev_module, 4, $prev_kind, $prev_symbol;