OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Symbolizes and prints live objects as recorded by tcmalloc's | 6 """Symbolizes and prints live objects as recorded by tcmalloc's |
7 HeapProfilerDumpLiveObjects. | 7 HeapProfilerDumpLiveObjects. |
8 """ | 8 """ |
9 | 9 |
10 import os | 10 import os |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 if len(argv) != 3: | 73 if len(argv) != 3: |
74 usage() | 74 usage() |
75 sys.exit(1) | 75 sys.exit(1) |
76 | 76 |
77 traces = LoadDump(argv[2]) | 77 traces = LoadDump(argv[2]) |
78 Symbolize(argv[1], traces) | 78 Symbolize(argv[1], traces) |
79 | 79 |
80 if not traces: | 80 if not traces: |
81 print "No leaks found!" | 81 print "No leaks found!" |
82 | 82 |
83 for trace in traces: | 83 for trace in sorted(traces, key=lambda x: -x["size"]): |
84 print "Leak of %d bytes at address %s" % (trace["size"], trace["address"]) | 84 print "Leak of %d bytes at address %s" % (trace["size"], trace["address"]) |
85 for frame in trace["frames"]: | 85 for frame in trace["frames"]: |
86 print " %s (%s)" % (frame["name"], frame["location"]) | 86 print " %s (%s)" % (frame["name"], frame["location"]) |
87 print "" | 87 print "" |
88 | 88 |
89 | 89 |
90 if __name__ == '__main__': | 90 if __name__ == '__main__': |
91 Main(sys.argv) | 91 Main(sys.argv) |
OLD | NEW |