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.
7 from lib
.subcommand
import SubCommand
10 class StacktraceCommand(SubCommand
):
12 super(StacktraceCommand
, self
).__init
__(
13 'Usage: %prog stacktrace <dump>')
15 def do(self
, sys_argv
):
16 _
, args
= self
._parse
_args
(sys_argv
, 1)
18 (bucket_set
, dump
) = SubCommand
.load_basic_files(dump_path
, False)
20 StacktraceCommand
._output
(dump
, bucket_set
, sys
.stdout
)
24 def _output(dump
, bucket_set
, out
):
25 """Outputs a given stacktrace.
28 bucket_set: A BucketSet object.
29 out: A file object to output.
31 for bucket_id
, virtual
, committed
, allocs
, frees
in dump
.iter_stacktrace
:
32 bucket
= bucket_set
.get(bucket_id
)
35 out
.write('%d %d %d %d ' % (virtual
, committed
, allocs
, frees
))
36 for frame
in bucket
.symbolized_stackfunction
:
37 out
.write(frame
+ ' ')