Trim extra underscores.
authordbaron@dbaron.org
Mon, 13 Aug 2007 22:06:05 -0700
changeset 4615 e3a7354da1704557c6c5d96dfd5aaf81a0fff317
parent 4614 acd585817d61f9ff2d21e34a260111921f2f85b4
child 4616 6a9d5c6f2a094fbaa10da2ec328c275ef84f9bb6
push idunknown
push userunknown
push dateunknown
milestone1.9a8pre
Trim extra underscores.
tools/rb/fix-macosx-stack.pl
--- a/tools/rb/fix-macosx-stack.pl
+++ b/tools/rb/fix-macosx-stack.pl
@@ -31,17 +31,17 @@
 # use your version of this file under the terms of the MPL, indicate your
 # decision by deleting the provisions above and replace them with the notice
 # and other provisions required by the GPL or the LGPL. If you do not delete
 # the provisions above, a recipient may use your version of this file under
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK *****
 
-# $Id: fix-macosx-stack.pl,v 1.4 2007/08/14 04:44:33 dbaron%dbaron.org Exp $
+# $Id: fix-macosx-stack.pl,v 1.5 2007/08/14 05:06:05 dbaron%dbaron.org Exp $
 #
 # This script processes the output of nsTraceRefcnt's Mac OS X stack
 # walking code.  This is useful for two things:
 #  (1) Getting line number information out of
 #      |nsTraceRefcntImpl::WalkTheStack|'s output in debug builds.
 #  (2) Getting function names out of |nsTraceRefcntImpl::WalkTheStack|'s
 #      output on all builds (where it mostly prints UNKNOWN because only
 #      a handful of symbols are exported from component libraries).
@@ -112,17 +112,23 @@ sub nmstruct_for($) {
         $debug_file = $file if ($debug_file eq '');
 
         open(NM, '-|', 'nm', '-an', $debug_file);
         while (<NM>) {
             chomp;
             my ($addr, $ty, $rest) = ($_ =~ /^([0-9a-f ]{8}) (.) (.*)$/);
             $addr = hex($addr);
             if ($ty eq 't' || $ty eq 'T') {
-                add_info($nmstruct->{symbols}, $addr, $rest);
+                my $sym = $rest;
+                if ($ty eq 'T' && substr($sym, 0, 1) eq '_' &&
+                                  substr($sym, 1, 1) ne '_') {
+                    # Public symbols have an extra leading _
+                    $sym = substr($sym, 1);
+                }
+                add_info($nmstruct->{symbols}, $addr, $sym);
             } elsif ($ty eq '-') {
                 # nm gives us stabs debugging information
                 my ($n1, $n2, $ty2, $rest2) =
                     ($rest =~ /^([0-9a-f]{2}) ([0-9a-f]{4}) (.{5}) (.*)$/);
                 # ignore $ty2 == '  FUN'
                 if ($ty2 eq 'SLINE') {
                     add_info($nmstruct->{lines}, $addr, hex($n2));
                 } elsif ($ty2 eq '  SOL') {