parameters: ()
docstring: Merge two traces for code in specified library and write to stdout.
  
    Merges the two traces and coverts the virtual addresses to the offsets in the
    library.  First line of merged trace has dummy virtual address of 0-ffffffff
    so that symbolizing the addresses uses the addresses in the log, since the
    addresses have already been converted to static offsets.
docstring_summary: Merge two traces for code in specified library and write to stdout.
docstring_tokens: Merge two traces for code in specified library and write to stdout .
function: def Main():
    """Merge two traces for code in specified library and write to stdout.
  
    Merges the two traces and coverts the virtual addresses to the offsets in the
    library.  First line of merged trace has dummy virtual address of 0-ffffffff
    so that symbolizing the addresses uses the addresses in the log, since the
    addresses have already been converted to static offsets.
    """
    parser = optparse.OptionParser('usage: %prog trace1 ... traceN')
    (_, args) = parser.parse_args()
    if len(args) <= 1:
      parser.error('expected at least the following args: trace1 trace2')
  
    step = 0
  
    # Maps function addresses to their corresponding trace entry.
    tracemap = dict()
  
    for trace_file in args:
      step += 1
      sys.stderr.write("    " + str(step) + "/" + str(len(args)) +
                       ": " + trace_file + ":\n")
  
      trace_lines = map(string.rstrip, open(trace_file).readlines())
      (trace_calls, trace_start, trace_end) = ParseLogLines(trace_lines)
      CheckTimestamps(trace_calls)
      sys.stderr.write("Len: " + str(len(trace_calls)) +
                       ". Start: " + hex(trace_start) +
                       ", end: " + hex(trace_end) + '\n')
  
      trace_calls = Convert(trace_calls, trace_start, trace_end)
      sys.stderr.write("Converted len: " + str(len(trace_calls)) + "\n")
  
      AddTrace(tracemap, trace_calls)
      sys.stderr.write("Merged len: " + str(len(tracemap)) + "\n")
  
    # Extract the resulting trace from the tracemap
    merged_trace = []
    for call in tracemap:
      merged_trace.append(tracemap[call])
    merged_trace.sort(key=Timestamp)
  
    grouped_trace = GroupByProcessAndThreadId(merged_trace)
  
    print "0-ffffffff r-xp 00000000 xx:00 00000 ./"
    print "secs\tusecs\tpid:threadid\tfunc"
    for call in grouped_trace:
      print (str(call[0]) + "\t" + str(call[1]) + "\t" + call[2] + "\t" +
             hex(call[3]))
function_tokens: def Main ( ) : parser = optparse . OptionParser ( 'usage: %prog trace1 ... traceN' ) ( _ , args ) = parser . parse_args ( ) if len ( args ) <= 1 : parser . error ( 'expected at least the following args: trace1 trace2' ) step = 0 # Maps function addresses to their corresponding trace entry. tracemap = dict ( ) for trace_file in args : step += 1 sys . stderr . write ( "    " + str ( step ) + "/" + str ( len ( args ) ) + ": " + trace_file + ":\n" ) trace_lines = map ( string . rstrip , open ( trace_file ) . readlines ( ) ) ( trace_calls , trace_start , trace_end ) = ParseLogLines ( trace_lines ) CheckTimestamps ( trace_calls ) sys . stderr . write ( "Len: " + str ( len ( trace_calls ) ) + ". Start: " + hex ( trace_start ) + ", end: " + hex ( trace_end ) + '\n' ) trace_calls = Convert ( trace_calls , trace_start , trace_end ) sys . stderr . write ( "Converted len: " + str ( len ( trace_calls ) ) + "\n" ) AddTrace ( tracemap , trace_calls ) sys . stderr . write ( "Merged len: " + str ( len ( tracemap ) ) + "\n" ) # Extract the resulting trace from the tracemap merged_trace = [ ] for call in tracemap : merged_trace . append ( tracemap [ call ] ) merged_trace . sort ( key = Timestamp ) grouped_trace = GroupByProcessAndThreadId ( merged_trace ) print "0-ffffffff r-xp 00000000 xx:00 00000 ./" print "secs\tusecs\tpid:threadid\tfunc" for call in grouped_trace : print ( str ( call [ 0 ] ) + "\t" + str ( call [ 1 ] ) + "\t" + call [ 2 ] + "\t" + hex ( call [ 3 ] ) )