Index: tools/deep_memory_profiler/dmprof.py |
diff --git a/tools/deep_memory_profiler/dmprof.py b/tools/deep_memory_profiler/dmprof.py |
index 0ac3bf486f05f73ec4f49a3bc73e8c8dbbeaca81..08d6acc06c3d34d2c7db5bcce9e2e898baa8607d 100644 |
--- a/tools/deep_memory_profiler/dmprof.py |
+++ b/tools/deep_memory_profiler/dmprof.py |
@@ -41,6 +41,7 @@ NULL_REGEX = re.compile('') |
LOGGER = logging.getLogger('dmprof') |
POLICIES_JSON_PATH = os.path.join(BASE_PATH, 'policies.json') |
+CHROME_SRC_PATH = os.path.join(BASE_PATH, os.pardir, os.pardir) |
# Heap Profile Dump versions |
@@ -1050,6 +1051,8 @@ class Command(object): |
See COMMANDS in main(). |
""" |
+ _DEVICE_LIB_PATTERN = re.compile(r'(/data/app-lib/.*-[0-9])/.*') |
+ |
def __init__(self, usage): |
self._parser = optparse.OptionParser(usage) |
@@ -1057,7 +1060,19 @@ class Command(object): |
def load_basic_files( |
dump_path, multiple, no_dump=False, fake_directories=None): |
prefix = Command._find_prefix(dump_path) |
- symbol_data_sources = SymbolDataSources(prefix, fake_directories or {}) |
+ |
+ # Auto-estimating the binary with symbol information located on the host |
bulach
2013/05/14 14:44:44
nit, I think this would be clearer:
# Translate th
Dai Mikurube (NOT FULLTIME)
2013/05/14 17:21:47
To make it clear that it's an estimation,
1) Rena
|
+ # from the binary path on the Android device. |
+ if not fake_directories: |
+ fake_directories = {} |
+ lib_on_device = Command._suppose_fake_directories(prefix) |
bulach
2013/05/14 14:44:44
nit: perhaps
device_lib = Command._get_device_lib(
Dai Mikurube (NOT FULLTIME)
2013/05/14 17:21:47
Finally, it's _estimate_alternative_dirs.
|
+ if lib_on_device: |
+ fake_directories[lib_on_device] = os.path.join( |
+ CHROME_SRC_PATH, 'out', 'Debug', 'lib') |
+ if fake_directories: |
+ for device, host in fake_directories.iteritems(): |
+ LOGGER.info('Assuming %s on device as %s on host' % (device, host)) |
+ symbol_data_sources = SymbolDataSources(prefix, fake_directories) |
symbol_data_sources.prepare() |
bucket_set = BucketSet() |
bucket_set.load(prefix) |
@@ -1092,6 +1107,22 @@ class Command(object): |
return re.sub('\.[0-9][0-9][0-9][0-9]\.heap', '', path) |
@staticmethod |
+ def _suppose_fake_directories(prefix): |
bulach
2013/05/14 14:44:44
nit: perhaps a comment
"""Return the path for the
Dai Mikurube (NOT FULLTIME)
2013/05/14 17:21:47
As written above.
|
+ device_lib_path_candidates = set() |
+ |
+ with open(prefix + '.maps') as maps_f: |
+ maps = proc_maps.ProcMaps.load(maps_f) |
+ for entry in maps: |
+ matched = Command._DEVICE_LIB_PATTERN.match(entry.as_dict()['name']) |
+ if matched: |
+ device_lib_path_candidates.add(matched.group(1)) |
+ |
+ if len(device_lib_path_candidates) == 1: |
+ return device_lib_path_candidates.pop() |
+ else: |
+ return None |
+ |
+ @staticmethod |
def _find_all_dumps(dump_path): |
prefix = Command._find_prefix(dump_path) |
dump_path_list = [dump_path] |