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

Unified Diff: tools/memory_inspector/memory_inspector/backends/android/native_heap_dump_parser.py

Issue 574663002: [Android] memory_inspector: move backends one folder up. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 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
Index: tools/memory_inspector/memory_inspector/backends/android/native_heap_dump_parser.py
diff --git a/tools/memory_inspector/memory_inspector/backends/android/native_heap_dump_parser.py b/tools/memory_inspector/memory_inspector/backends/android/native_heap_dump_parser.py
deleted file mode 100644
index eb6a0d873d9b0691c127a24ab1483901aa56ca63..0000000000000000000000000000000000000000
--- a/tools/memory_inspector/memory_inspector/backends/android/native_heap_dump_parser.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright 2014 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.
-
-"""This parser turns the heap_dump output into a |NativeHeap| object."""
-
-import json
-
-from memory_inspector.core import native_heap
-from memory_inspector.core import stacktrace
-
-
-# These are defined in heap_profiler/heap_profiler.h
-FLAGS_MALLOC = 1
-FLAGS_MMAP = 2
-FLAGS_MMAP_FILE = 4
-FLAGS_IN_ZYGOTE = 8
-
-
-def Parse(content):
- """Parses the output of the heap_dump binary (part of libheap_profiler).
-
- heap_dump provides a conveniente JSON output.
- See the header of tools/android/heap_profiler/heap_dump.c for more details.
-
- Args:
- content: string containing the command output.
-
- Returns:
- An instance of |native_heap.NativeHeap|.
- """
- data = json.loads(content)
- assert('allocs' in data), 'Need to run heap_dump with the -x (extended) arg.'
- nativeheap = native_heap.NativeHeap()
- strace_by_index = {} # index (str) -> |stacktrace.Stacktrace|
-
- for index, entry in data['stacks'].iteritems():
- strace = stacktrace.Stacktrace()
- for absolute_addr in entry['f']:
- strace.Add(nativeheap.GetStackFrame(absolute_addr))
- strace_by_index[index] = strace
-
- for start_addr, entry in data['allocs'].iteritems():
- flags = int(entry['f'])
- # TODO(primiano): For the moment we just skip completely the allocations
- # made in the Zygote (pre-fork) because this is usually reasonable. In the
- # near future we will expose them with some UI to selectively filter them.
- if flags & FLAGS_IN_ZYGOTE:
- continue
- nativeheap.Add(native_heap.Allocation(
- size=entry['l'],
- stack_trace=strace_by_index[entry['s']],
- start=int(start_addr, 16),
- flags=flags))
-
- return nativeheap

Powered by Google App Engine
This is Rietveld 408576698