Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / third_party / codesighs / nm_wrap_osx.pl
blobcf1181fe0ad102d4146a7a64cc7362a98b8268f8
1 #!/usr/bin/perl -w
3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
14 # License.
16 # The Original Code is autosummary.linx.bash code, released
17 # Oct 10, 2002.
19 # The Initial Developer of the Original Code is
20 # Netscape Communications Corporation.
21 # Portions created by the Initial Developer are Copyright (C) 2002
22 # the Initial Developer. All Rights Reserved.
24 # Contributor(s):
25 # Simon Fraser <sfraser@netscape.com>
27 # Alternatively, the contents of this file may be used under the terms of
28 # either the GNU General Public License Version 2 or later (the "GPL"), or
29 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 # in which case the provisions of the GPL or the LGPL are applicable instead
31 # of those above. If you wish to allow use of your version of this file only
32 # under the terms of either the GPL or the LGPL, and not to allow others to
33 # use your version of this file under the terms of the MPL, indicate your
34 # decision by deleting the provisions above and replace them with the notice
35 # and other provisions required by the GPL or the LGPL. If you do not delete
36 # the provisions above, a recipient may use your version of this file under
37 # the terms of any one of the MPL, the GPL or the LGPL.
39 # ***** END LICENSE BLOCK *****
41 use strict;
44 # A wrapper for nm that produces output listing symbol size.
46 my($prev_addr) = 0;
47 my($prev_module) = "";
48 my($prev_kind) = "";
49 my($prev_symbol) = "";
51 open(NM_OUTPUT, "nm -fnol $ARGV[0] | c++filt |") or die "nm failed to run on $ARGV[0]\n";
52 while (<NM_OUTPUT>)
54 my($line) = $_;
55 chomp($line);
57 if ($line =~ /^([^:]+):\s*([0-9a-f]{8}) (\w) (.+)$/)
59 my($module) = $1;
60 my($addr) = $2;
61 my($kind) = $3;
62 my($symbol) = $4;
64 #Skip absolute addresses, there should be only a few
65 if ('a' eq lc $kind) {
66 if ('trampoline_size' ne $symbol) {
67 warn "Encountered unknown absolutely addressed symbol '$symbol' in $module";
69 next;
72 # we expect the input to have been piped through c++filt to
73 # demangle symbols. For some reason, it doesn't always demangle
74 # all of them, so push still-mangled symbols back through c++filt again.
75 if ($symbol =~ /^(_[_Z].+)/)
77 # warn "Trying again to unmangle $1\n";
78 $symbol = `c++filt '$1'`;
79 chomp($symbol);
80 # warn "Unmangling again to $symbol\n";
83 my($prev_size) = hex($addr) - hex($prev_addr);
84 # print "Outputting line $line\n";
86 # always print one behind, because only now do we know its size
87 if ($prev_module ne "") {
88 printf "%s:%08x %s %s\n", $prev_module, $prev_size, $prev_kind, $prev_symbol;
91 $prev_addr = $addr;
92 $prev_module = $module;
93 $prev_kind = $kind;
94 $prev_symbol = $symbol;
96 else
98 # warn " Discaring line $line\n";
102 # we don't know how big the last symbol is, so always show 4.
103 if ($prev_module ne "") {
104 printf "%s:%08x %s %s\n", $prev_module, 4, $prev_kind, $prev_symbol;