def testSameCtorOrDtorNames(self): if not os.path.exists(symbol.ToolPath('c++filt')): print 'Skipping test dependent on missing c++filt binary.' return self.assertTrue(cyglog_to_orderfile._SameCtorOrDtorNames( '_ZNSt3__119istreambuf_iteratorIcNS_11char_traitsIcEEEC1Ev', '_ZNSt3__119istreambuf_iteratorIcNS_11char_traitsIcEEEC2Ev')) self.assertTrue(cyglog_to_orderfile._SameCtorOrDtorNames( '_ZNSt3__119istreambuf_iteratorIcNS_11char_traitsIcEEED1Ev', '_ZNSt3__119istreambuf_iteratorIcNS_11char_traitsIcEEED2Ev')) self.assertFalse(cyglog_to_orderfile._SameCtorOrDtorNames( '_ZNSt3__119istreambuf_iteratorIcNS_11char_traitsIcEEEC1Ev', '_ZNSt3__119foo_iteratorIcNS_11char_traitsIcEEEC1Ev')) self.assertFalse(cyglog_to_orderfile._SameCtorOrDtorNames( '_ZNSt3__119istreambuf_iteratorIcNS_11char_traitsIcEEE', '_ZNSt3__119istreambuf_iteratorIcNS_11char_traitsIcEEE'))
def SymbolInfosFromBinary(binary_filename): """Runs objdump to get all the symbols from a binary. Args: binary_filename: path to the binary. Returns: A list of SymbolInfo from the binary. """ command = (symbol.ToolPath('objdump'), '-t', '-w', binary_filename) p = subprocess.Popen(command, shell=False, stdout=subprocess.PIPE) try: result = _SymbolInfosFromStream(p.stdout) return result finally: p.wait()
def setUp(self): self._old_demangle = None if not os.path.exists(symbol.ToolPath('c++filt')): print 'Using fake demangling due to missing c++filt binary' self._old_demangle = symbol_extractor.DemangleSymbol symbol_extractor.DemangleSymbol = _FakeDemangle
import os import re import struct import subprocess import sys # Python has a symbol builtin module, so the android one needs to be first in # the import path. _SRC_PATH = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir) sys.path.insert( 0, os.path.join(_SRC_PATH, 'third_party', 'android_platform', 'development', 'scripts')) import symbol _OBJDUMP = symbol.ToolPath('objdump') _STRIP = symbol.ToolPath('strip') class SymbolData(object): """Data about a symbol, extracted from objdump output.""" SYMBOL_RE = re.compile('^([0-9a-f]{8}) <(.*)>:$') assert SYMBOL_RE.match('002dcc84 <_ZN3net8QuicTime5Delta11FromSecondsEx>:') _BLX_RE = re.compile('^ {1,2}([0-9a-f]{6,7}):.*blx\t[0-9a-f]{6,7} <(.*)>') assert _BLX_RE.match( ' 2dd03e: f3f3 ee16 ' 'blx\t6d0c6c <_ZN16content_settings14PolicyProvider27UpdateManaged' 'DefaultSettingERKNS0_30PrefsForManagedDefaultMapEntryE+0x120>') _BL_ENTER_RE = re.compile('^ {1,2}([0-9a-f]{6,7}):.*bl\t[0-9a-f]{6,7} ' '<__cyg_profile_func_enter>')
def Disassemble(self, args): """Generates a disassemble command, appending the given args.""" return ([symbol.ToolPath(DISASSEMBLE)] + self.options.get(DISASSEMBLE, []) + args)
def Link(self, args): """Generates a link command, appending the given args.""" return [symbol.ToolPath(LINK)] + self.options.get(LINK, []) + args
def Assemble(self, args): """Generates an assembler command, appending the given args.""" return [symbol.ToolPath(ASSEMBLE)] + self.options.get(ASSEMBLE, []) + args