mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1014382 - Add nm-symbolicate.py helper script. r=jrmuizel DONTBUILD as NPOTB
This commit is contained in:
parent
bd888e55e9
commit
a0dd636e27
47
tools/profiler/nm-symbolicate.py
Executable file
47
tools/profiler/nm-symbolicate.py
Executable file
@ -0,0 +1,47 @@
|
||||
#!/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
|
||||
|
||||
def NMSymbolicate(library, addresses):
|
||||
args = [
|
||||
"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"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user