Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(614)

Unified Diff: tools/deep_memory_profiler/subcommands/stacktrace.py

Issue 19346002: Refactor dmprof: Split dmprof.py into modules. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/deep_memory_profiler/subcommands/pprof.py ('k') | tools/deep_memory_profiler/subcommands/upload.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/deep_memory_profiler/subcommands/stacktrace.py
diff --git a/tools/deep_memory_profiler/subcommands/stacktrace.py b/tools/deep_memory_profiler/subcommands/stacktrace.py
new file mode 100644
index 0000000000000000000000000000000000000000..72b850981a06edc2f84483d0a9fb974636249292
--- /dev/null
+++ b/tools/deep_memory_profiler/subcommands/stacktrace.py
@@ -0,0 +1,41 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import sys
+
+from lib.bucket import BUCKET_ID
+from lib.subcommand import SubCommand
+
+
+class StacktraceCommand(SubCommand):
+ def __init__(self):
+ super(StacktraceCommand, self).__init__(
+ 'Usage: %prog stacktrace <dump>')
+
+ def do(self, sys_argv):
+ _, args = self._parse_args(sys_argv, 1)
+ dump_path = args[1]
+ (bucket_set, dump) = SubCommand.load_basic_files(dump_path, False)
+
+ StacktraceCommand._output(dump, bucket_set, sys.stdout)
+ return 0
+
+ @staticmethod
+ def _output(dump, bucket_set, out):
+ """Outputs a given stacktrace.
+
+ Args:
+ bucket_set: A BucketSet object.
+ out: A file object to output.
+ """
+ for line in dump.iter_stacktrace:
+ words = line.split()
+ bucket = bucket_set.get(int(words[BUCKET_ID]))
+ if not bucket:
+ continue
+ for i in range(0, BUCKET_ID - 1):
+ out.write(words[i] + ' ')
+ for frame in bucket.symbolized_stackfunction:
+ out.write(frame + ' ')
+ out.write('\n')
« no previous file with comments | « tools/deep_memory_profiler/subcommands/pprof.py ('k') | tools/deep_memory_profiler/subcommands/upload.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698