summaryrefslogtreecommitdiffstats
path: root/tools/profiler/nm-symbolicate.py
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /tools/profiler/nm-symbolicate.py
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'tools/profiler/nm-symbolicate.py')
-rwxr-xr-xtools/profiler/nm-symbolicate.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/tools/profiler/nm-symbolicate.py b/tools/profiler/nm-symbolicate.py
new file mode 100755
index 000000000..f51d7f75f
--- /dev/null
+++ b/tools/profiler/nm-symbolicate.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import sys, subprocess, os
+
+def NMSymbolicate(library, addresses):
+ target_tools_prefix = os.environ.get("TARGET_TOOLS_PREFIX", "")
+ args = [
+ target_tools_prefix + "nm", "-D", "-S", library
+ ]
+ nm_lines = subprocess.check_output(args).split("\n")
+ symbol_table = []
+ for line in nm_lines:
+ pieces = line.split(" ", 4)
+ if len(pieces) != 4 or pieces[2] != "T":
+ continue
+ start = int(pieces[0], 16)
+ end = int(pieces[1], 16)
+ symbol = pieces[3]
+ symbol_table.append({
+ "start": int(pieces[0], 16),
+ "end": int(pieces[0], 16) + int(pieces[1], 16),
+ "funcName": pieces[3]
+ });
+
+ for addressStr in addresses:
+ address = int(addressStr, 16)
+ symbolForAddress = None
+ for symbol in symbol_table:
+ if address >= symbol["start"] and address <= symbol["end"]:
+ symbolForAddress = symbol
+ break
+ if symbolForAddress:
+ print symbolForAddress["funcName"]
+ else:
+ print "??" # match addr2line
+ print ":0" # no line information from nm
+
+if len(sys.argv) > 1:
+ NMSymbolicate(sys.argv[1], sys.argv[2:])
+ sys.exit(0)
+
+print "Usage: nm-symbolicate.py <library> <addresses> > merged.sym"
+
+