| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # Use: ../mergetraces.py `ls cyglog.* -Sr` > merged_cyglog | 6 # Use: ../mergetraces.py `ls cyglog.* -Sr` > merged_cyglog |
| 7 | 7 |
| 8 """"Merge multiple logs files from different processes into a single log. | 8 """"Merge multiple logs files from different processes into a single log. |
| 9 | 9 |
| 10 Given two log files of execution traces, merge the traces into a single trace. | 10 Given two log files of execution traces, merge the traces into a single trace. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 """Converts the call addresses to static offsets and removes invalid calls. | 94 """Converts the call addresses to static offsets and removes invalid calls. |
| 95 | 95 |
| 96 Removes profiled calls not in shared library using start and end virtual | 96 Removes profiled calls not in shared library using start and end virtual |
| 97 addresses, converts strings to integer values, coverts virtual addresses to | 97 addresses, converts strings to integer values, coverts virtual addresses to |
| 98 address in shared library. | 98 address in shared library. |
| 99 | 99 |
| 100 Returns: | 100 Returns: |
| 101 list of calls as tuples (sec, usec, pid:tid, callee) | 101 list of calls as tuples (sec, usec, pid:tid, callee) |
| 102 """ | 102 """ |
| 103 converted_calls = [] | 103 converted_calls = [] |
| 104 call_addresses = [] | 104 call_addresses = set() |
| 105 for fields in call_lines: | 105 for fields in call_lines: |
| 106 secs = int (fields[0]) | 106 secs = int (fields[0]) |
| 107 usecs = int (fields[1]) | 107 usecs = int (fields[1]) |
| 108 callee = int (fields[3], 16) | 108 callee = int (fields[3], 16) |
| 109 # print ("callee: " + hex (callee) + " start: " + hex (startAddr) + " end: " | 109 # print ("callee: " + hex (callee) + " start: " + hex (startAddr) + " end: " |
| 110 # + hex (endAddr)) | 110 # + hex (endAddr)) |
| 111 if (callee >= startAddr and callee < endAddr | 111 if (callee >= startAddr and callee < endAddr |
| 112 and (not callee in call_addresses)): | 112 and (not callee in call_addresses)): |
| 113 converted_calls.append((secs, usecs, fields[2], (callee - startAddr))) | 113 converted_calls.append((secs, usecs, fields[2], (callee - startAddr))) |
| 114 call_addresses.append(callee) | 114 call_addresses.add(callee) |
| 115 return converted_calls | 115 return converted_calls |
| 116 | 116 |
| 117 def Timestamp(trace_entry): | 117 def Timestamp(trace_entry): |
| 118 return int (trace_entry[0]) * 1000000 + int(trace_entry[1]) | 118 return int (trace_entry[0]) * 1000000 + int(trace_entry[1]) |
| 119 | 119 |
| 120 def AddTrace (tracemap, trace): | 120 def AddTrace (tracemap, trace): |
| 121 """Adds a trace to the tracemap. | 121 """Adds a trace to the tracemap. |
| 122 | 122 |
| 123 Adds entries in the trace to the tracemap. All new calls will be added to | 123 Adds entries in the trace to the tracemap. All new calls will be added to |
| 124 the tracemap. If the calls already exist in the tracemap then they will be | 124 the tracemap. If the calls already exist in the tracemap then they will be |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 grouped_trace = GroupByProcessAndThreadId(merged_trace) | 229 grouped_trace = GroupByProcessAndThreadId(merged_trace) |
| 230 | 230 |
| 231 print "0-ffffffff r-xp 00000000 xx:00 00000 ./" | 231 print "0-ffffffff r-xp 00000000 xx:00 00000 ./" |
| 232 print "secs\tusecs\tpid:threadid\tfunc" | 232 print "secs\tusecs\tpid:threadid\tfunc" |
| 233 for call in grouped_trace: | 233 for call in grouped_trace: |
| 234 print (str(call[0]) + "\t" + str(call[1]) + "\t" + call[2] + "\t" + | 234 print (str(call[0]) + "\t" + str(call[1]) + "\t" + call[2] + "\t" + |
| 235 hex(call[3])) | 235 hex(call[3])) |
| 236 | 236 |
| 237 if __name__ == '__main__': | 237 if __name__ == '__main__': |
| 238 main() | 238 main() |
| OLD | NEW |