Make the position of 'n files selected' label synced with the width of navigation...
[chromium-blink-merge.git] / tools / deep_memory_profiler / subcommands / stacktrace.py
blob327a1a57fc32b89f253ed3d8f831b413e91bdf7c
1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import sys
7 from lib.subcommand import SubCommand
10 class StacktraceCommand(SubCommand):
11 def __init__(self):
12 super(StacktraceCommand, self).__init__(
13 'Usage: %prog stacktrace <dump>')
15 def do(self, sys_argv):
16 _, args = self._parse_args(sys_argv, 1)
17 dump_path = args[1]
18 (bucket_set, dump) = SubCommand.load_basic_files(dump_path, False)
20 StacktraceCommand._output(dump, bucket_set, sys.stdout)
21 return 0
23 @staticmethod
24 def _output(dump, bucket_set, out):
25 """Outputs a given stacktrace.
27 Args:
28 bucket_set: A BucketSet object.
29 out: A file object to output.
30 """
31 for bucket_id, virtual, committed, allocs, frees in dump.iter_stacktrace:
32 bucket = bucket_set.get(bucket_id)
33 if not bucket:
34 continue
35 out.write('%d %d %d %d ' % (virtual, committed, allocs, frees))
36 for frame in bucket.symbolized_stackfunction:
37 out.write(frame + ' ')
38 out.write('\n')