tools/fix_b2g_stack.py
def _addr2line(self, lib, offset, pc, fn_guess):
        '''Use addr2line to translate the given lib+offset.

        We use pc only for aesthetic purposes; it's not passed to addr2line or
        anything.

        If addr2line can't resolve a lib+offset, you may still have a guess as
        to what function lives there.  (For example, NS_StackWalk is sometimes
        able to resolve function names that addr2line can't.)  fn_guess should
        be this guess, if you have one.

        '''
        def addr_str():
            _pc = ('0x%x ' % pc) if pc != None else ''
            return '(%s%s+0x%x)' % (_pc, lib, offset)
        def fallback_str():
            _fn_guess = fn_guess + ' ' if fn_guess and fn_guess != '???' else ''
            return '%s%s' % (_fn_guess, addr_str())

        if lib not in self._addr2line_procs:
            lib_path = self._find_lib(lib)
            if not lib_path:
                return "%s (can't find lib)" % fallback_str()
            self._addr2line_procs[lib] = subprocess.Popen(
                [self._options.cross_bin('addr2line'), '-Cfe', lib_path],
                stdin=subprocess.PIPE, stdout=subprocess.PIPE)

        proc = self._addr2line_procs[lib]
        try:
            proc.stdin.write('0x%x\n' % offset)
            proc.stdin.flush()

            # addr2line returns two lines for every address we give it.  The
            # first line is of the form "foo()", and the second line is of the
            # form "foo.cpp:123".
            func = proc.stdout.readline().strip()
            file = os.path.normpath(proc.stdout.readline().strip())
            if func == '??' and file == '??:0':
                # addr2line wasn't helpful here.
                return '%s (no addr2line)' % fallback_str()
            return '%s %s %s' % (func, file, addr_str())
        except IOError as e:
            # If our addr2line process dies, don't try to restart it.  Just
            # leave it in a dead state and presumably every time we read/write
            # to/from it, we'll hit this case.
            return '%s (addr2line exception)' % fallback_str()
Use addr2line to translate the given lib+offset.

        We use pc only for aesthetic purposes; it's not passed to addr2line or
        anything.

        If addr2line can't resolve a lib+offset, you may still have a guess as
        to what function lives there.  (For example, NS_StackWalk is sometimes
        able to resolve function names that addr2line can't.)  fn_guess should
        be this guess, if you have one.

        
Use addr2line to translate the given lib+offset.
We use pc only for aesthetic purposes; it's not passed to addr2line or
anything.

If addr2line can't resolve a lib+offset, you may still have a guess as
to what function lives there.  (For example, NS_StackWalk is sometimes
able to resolve function names that addr2line can't.)  fn_guess should
be this guess, if you have one.
Use addr2line to translate the given lib + offset . We use pc only for aesthetic purposes ; it ' s not passed to addr2line or anything . If addr2line can ' t resolve a lib + offset you may still have a guess as to what function lives there . ( For example NS_StackWalk is sometimes able to resolve function names that addr2line can ' t . ) fn_guess should be this guess if you have one .
def _addr2line(self, lib, offset, pc, fn_guess):
        def addr_str():
            _pc = ('0x%x ' % pc) if pc != None else ''
            return '(%s%s+0x%x)' % (_pc, lib, offset)
        def fallback_str():
            _fn_guess = fn_guess + ' ' if fn_guess and fn_guess != '???' else ''
            return '%s%s' % (_fn_guess, addr_str())
        if lib not in self._addr2line_procs:
            lib_path = self._find_lib(lib)
            if not lib_path:
                return "%s (can't find lib)" % fallback_str()
            self._addr2line_procs[lib] = subprocess.Popen(
                [self._options.cross_bin('addr2line'), '-Cfe', lib_path],
                stdin=subprocess.PIPE, stdout=subprocess.PIPE)
        proc = self._addr2line_procs[lib]
        try:
            proc.stdin.write('0x%x\n' % offset)
            proc.stdin.flush()
            func = proc.stdout.readline().strip()
            file = os.path.normpath(proc.stdout.readline().strip())
            if func == '??' and file == '??:0':
                return '%s (no addr2line)' % fallback_str()
            return '%s %s %s' % (func, file, addr_str())
        except IOError as e:
            return '%s (addr2line exception)' % fallback_str()
def _addr2line ( self , lib , offset , pc , fn_guess ) : def addr_str ( ) : _pc = ( '0x%x ' % pc ) if pc != None else '' return '(%s%s+0x%x)' % ( _pc , lib , offset ) def fallback_str ( ) : _fn_guess = fn_guess + ' ' if fn_guess and fn_guess != '???' else '' return '%s%s' % ( _fn_guess , addr_str ( ) ) if lib not in self . _addr2line_procs : lib_path = self . _find_lib ( lib ) if not lib_path : return "%s (can't find lib)" % fallback_str ( ) self . _addr2line_procs [ lib ] = subprocess . Popen ( [ self . _options . cross_bin ( 'addr2line' ) , '-Cfe' , lib_path ] , stdin = subprocess . PIPE , stdout = subprocess . PIPE ) proc = self . _addr2line_procs [ lib ] try : proc . stdin . write ( '0x%x\n' % offset ) proc . stdin . flush ( ) func = proc . stdout . readline ( ) . strip ( ) file = os . path . normpath ( proc . stdout . readline ( ) . strip ( ) ) if func == '??' and file == '??:0' : return '%s (no addr2line)' % fallback_str ( ) return '%s %s %s' % ( func , file , addr_str ( ) ) except IOError as e : return '%s (addr2line exception)' % fallback_str ( )
Use addr2line to translate the given lib+offset.
Use addr2line to translate the given lib + offset .
'''Use addr2line to translate the given lib+offset.

        We use pc only for aesthetic purposes; it's not passed to addr2line or
        anything.

        If addr2line can't resolve a lib+offset, you may still have a guess as
        to what function lives there.  (For example, NS_StackWalk is sometimes
        able to resolve function names that addr2line can't.)  fn_guess should
        be this guess, if you have one.

        ''' # addr2line returns two lines for every address we give it.  The # first line is of the form "foo()", and the second line is of the # form "foo.cpp:123". # addr2line wasn't helpful here. # If our addr2line process dies, don't try to restart it.  Just # leave it in a dead state and presumably every time we read/write # to/from it, we'll hit this case.
self
lib
offset
pc
fn_guess