tools/fix_b2g_stack.py
def fix_b2g_stacks_in_file(infile, outfile, args={}, **kwargs):
    '''Read lines from infile and output those lines to outfile with their
    stack frames rewritten.

    infile and outfile may be a files or file-like objects.  For example, to
    read/write from strings, pass StringIO objects.

    args or kwargs will be passed to FixB2GStacksOptions (you may not specify
    both).  See the docs on FixB2GStacksOptions for the supported argument
    names.

    '''
    if args and kwargs:
        raise Exception("Can't pass args and kwargs to fix_b2g_stacks_in_file.")
    options = FixB2GStacksOptions(args if args else kwargs)

    if options.remove_cache:
        try:
            os.remove(StackFixerCache.cache_filename())
        except:
            pass

    matcher = re.compile(
        r'''(?P<fn>[^ ][^\]]*)              # either '???' or mangled fn signature
            \[
              (?P<lib>\S+)                  # library name
              \s+
              \+(?P<offset>0x[0-9a-fA-F]+)  # offset into lib
            \]
            \s+
            (?P<pc>0x[0-9a-fA-F]+)          # program counter
            ''',
        re.VERBOSE)

    fixer = StackFixer(options)
    def subfn(match):
        return fixer.translate(match.group('lib'),
                               int(match.group('offset'), 16),
                               int(match.group('pc'), 16),
                               match.group('fn'))

    # Filter our output through c++filt.  Pumping on a separate thread is
    # *much* faster than filtering line-by-line.
    #
    # On Mac OS, the native c++filt doesn't filter our output correctly, so we
    # use the cross-compiled one.  (I don't know if the system c++filt works
    # properly on Linux, though I imagine it does.)
    cppfilt = subprocess.Popen([options.cross_bin('c++filt')],
                               stdin=subprocess.PIPE,
                               stdout=subprocess.PIPE)
    try:
        p = pump(outfile, cppfilt.stdout)
        for line in infile:
            cppfilt.stdin.write(matcher.sub(subfn, line))
    finally:
        cppfilt.stdin.close()
    p.join()
    fixer.close()
Read lines from infile and output those lines to outfile with their
    stack frames rewritten.

    infile and outfile may be a files or file-like objects.  For example, to
    read/write from strings, pass StringIO objects.

    args or kwargs will be passed to FixB2GStacksOptions (you may not specify
    both).  See the docs on FixB2GStacksOptions for the supported argument
    names.

    
Read lines from infile and output those lines to outfile with their
stack frames rewritten.

infile and outfile may be a files or file-like objects.  For example, to
read/write from strings, pass StringIO objects.

args or kwargs will be passed to FixB2GStacksOptions (you may not specify
both).  See the docs on FixB2GStacksOptions for the supported argument
names.
Read lines from infile and output those lines to outfile with their stack frames rewritten . infile and outfile may be a files or file - like objects . For example to read / write from strings pass StringIO objects . args or kwargs will be passed to FixB2GStacksOptions ( you may not specify both ) . See the docs on FixB2GStacksOptions for the supported argument names .
def fix_b2g_stacks_in_file(infile, outfile, args={}, **kwargs):
    if args and kwargs:
        raise Exception("Can't pass args and kwargs to fix_b2g_stacks_in_file.")
    options = FixB2GStacksOptions(args if args else kwargs)
    if options.remove_cache:
        try:
            os.remove(StackFixerCache.cache_filename())
        except:
            pass
    matcher = re.compile(
        r'''(?P<fn>[^ ][^\]]*)               either '???' or mangled fn signature
            \[
              (?P<lib>\S+)                   library name
              \s+
              \+(?P<offset>0x[0-9a-fA-F]+)   offset into lib
            \]
            \s+
            (?P<pc>0x[0-9a-fA-F]+)           program counter
            ''',
        re.VERBOSE)
    fixer = StackFixer(options)
    def subfn(match):
        return fixer.translate(match.group('lib'),
                               int(match.group('offset'), 16),
                               int(match.group('pc'), 16),
                               match.group('fn'))
     On Mac OS, the native c++filt doesn't filter our output correctly, so we
     use the cross-compiled one.  (I don't know if the system c++filt works
     properly on Linux, though I imagine it does.)
    cppfilt = subprocess.Popen([options.cross_bin('c++filt')],
                               stdin=subprocess.PIPE,
                               stdout=subprocess.PIPE)
    try:
        p = pump(outfile, cppfilt.stdout)
        for line in infile:
            cppfilt.stdin.write(matcher.sub(subfn, line))
    finally:
        cppfilt.stdin.close()
    p.join()
    fixer.close()
def fix_b2g_stacks_in_file ( infile , outfile , args = { } , ** kwargs ) : if args and kwargs : raise Exception ( "Can't pass args and kwargs to fix_b2g_stacks_in_file." ) options = FixB2GStacksOptions ( args if args else kwargs ) if options . remove_cache : try : os . remove ( StackFixerCache . cache_filename ( ) ) except : pass matcher = re . compile ( r'''(?P<fn>[^ ][^\]]*)              # either '???' or mangled fn signature
            \[
              (?P<lib>\S+)                  # library name
              \s+
              \+(?P<offset>0x[0-9a-fA-F]+)  # offset into lib
            \]
            \s+
            (?P<pc>0x[0-9a-fA-F]+)          # program counter
            ''' , re . VERBOSE ) fixer = StackFixer ( options ) def subfn ( match ) : return fixer . translate ( match . group ( 'lib' ) , int ( match . group ( 'offset' ) , 16 ) , int ( match . group ( 'pc' ) , 16 ) , match . group ( 'fn' ) ) cppfilt = subprocess . Popen ( [ options . cross_bin ( 'c++filt' ) ] , stdin = subprocess . PIPE , stdout = subprocess . PIPE ) try : p = pump ( outfile , cppfilt . stdout ) for line in infile : cppfilt . stdin . write ( matcher . sub ( subfn , line ) ) finally : cppfilt . stdin . close ( ) p . join ( ) fixer . close ( )
Read lines from infile and output those lines to outfile with their
stack frames rewritten.
Read lines from infile and output those lines to outfile with their stack frames rewritten .
'''Read lines from infile and output those lines to outfile with their
    stack frames rewritten.

    infile and outfile may be a files or file-like objects.  For example, to
    read/write from strings, pass StringIO objects.

    args or kwargs will be passed to FixB2GStacksOptions (you may not specify
    both).  See the docs on FixB2GStacksOptions for the supported argument
    names.

    ''' # Filter our output through c++filt.  Pumping on a separate thread is # *much* faster than filtering line-by-line. # # On Mac OS, the native c++filt doesn't filter our output correctly, so we # use the cross-compiled one.  (I don't know if the system c++filt works # properly on Linux, though I imagine it does.)
infile
outfile
args