Chromium Code Reviews| Index: tools/deep_memory_profiler/dmprof |
| diff --git a/tools/deep_memory_profiler/dmprof b/tools/deep_memory_profiler/dmprof |
| index 358427759533382280b730235bfd39d47e962c02..1de9732b5ce32efa8b75f0f6fac12cb0a9e1811b 100755 |
| --- a/tools/deep_memory_profiler/dmprof |
| +++ b/tools/deep_memory_profiler/dmprof |
| @@ -13,6 +13,14 @@ import subprocess |
| import sys |
| import tempfile |
| +FIND_RUNTIME_SYMBOLS_PATH = os.path.join(os.path.dirname(__file__), |
|
M-A Ruel
2012/07/22 19:51:07
os.path.dirname(os.path.abspath(__file__))
is safe
Dai Mikurube (NOT FULLTIME)
2012/07/23 00:48:45
Done.
|
| + os.pardir, |
| + 'find_runtime_symbols') |
| +sys.path.append(FIND_RUNTIME_SYMBOLS_PATH) |
| + |
| +from prepare_symbol_info import prepare_symbol_info |
| +from find_runtime_symbols import find_runtime_symbols_list |
| + |
| BUCKET_ID = 5 |
| VIRTUAL = 0 |
| COMMITTED = 1 |
| @@ -20,23 +28,6 @@ ALLOC_COUNT = 2 |
| FREE_COUNT = 3 |
| NULL_REGEX = re.compile('') |
| -# If an executable pprof script is in the directory of deep_memory_profiler, |
| -# use it. Otherwise, use tcmalloc's pprof. |
| -# |
| -# A pprof script in deep_memory_profiler/ is prioritized to allow packaging |
| -# deep_memory_profiler files with a pprof script. The packaged |
| -# deep_memory_profiler is downloaded with pprof by using download.sh. |
| -PPROF_PATH = os.path.join(os.path.dirname(__file__), 'pprof') |
| -if not (os.path.isfile(PPROF_PATH) and os.access(PPROF_PATH, os.X_OK)): |
| - PPROF_PATH = os.path.join(os.path.dirname(__file__), |
| - os.pardir, |
| - os.pardir, |
| - 'third_party', |
| - 'tcmalloc', |
| - 'chromium', |
| - 'src', |
| - 'pprof') |
| - |
| # Heap Profile Dump versions |
| # DUMP_DEEP_1 is OBSOLETE. |
| @@ -570,7 +561,7 @@ class Log(object): |
| sys.stderr.write('total: %d\n' % (total)) |
| -def update_symbols(symbol_path, mapping_lines, chrome_path): |
| +def update_symbols(symbol_path, mapping_lines, maps_path): |
| """Updates address/symbol mapping on memory and in a .symbol cache file. |
| It reads cached address/symbol mapping from a .symbol file if it exists. |
| @@ -586,8 +577,11 @@ def update_symbols(symbol_path, mapping_lines, chrome_path): |
| Args: |
| symbol_path: A string representing a path for a .symbol file. |
| mapping_lines: A list of strings containing /proc/.../maps. |
| - chrome_path: A string representing a path for a Chrome binary. |
| + maps_path: A string of the path of /proc/.../maps. |
| """ |
| + prepared_data_dir = tempfile.mkdtemp() |
|
M-A Ruel
2012/07/22 19:49:06
Is it wanted that this directory is leaked?
Dai Mikurube (NOT FULLTIME)
2012/07/23 00:48:45
Ah, no. Moved these calls and used shutil.rmtree.
|
| + prepare_symbol_info(maps_path, prepared_data_dir) |
| + |
| with open(symbol_path, mode='a+') as symbol_f: |
| symbol_lines = symbol_f.readlines() |
| if symbol_lines: |
| @@ -599,30 +593,13 @@ def update_symbols(symbol_path, mapping_lines, chrome_path): |
| a for a in appeared_addresses if a not in address_symbol_dict) |
| if unresolved_addresses: |
| - with tempfile.NamedTemporaryFile( |
| - suffix='maps', prefix="dmprof", mode='w+') as pprof_in: |
| - with tempfile.NamedTemporaryFile( |
| - suffix='symbols', prefix="dmprof", mode='w+') as pprof_out: |
| - for line in mapping_lines: |
| - pprof_in.write(line) |
| - |
| - for address in unresolved_addresses: |
| - pprof_in.write(address + '\n') |
| - |
| - pprof_in.seek(0) |
| - |
| - p = subprocess.Popen( |
| - '%s --symbols %s' % (PPROF_PATH, chrome_path), |
| - shell=True, stdin=pprof_in, stdout=pprof_out) |
| - p.wait() |
| + symbols = find_runtime_symbols_list( |
| + prepared_data_dir, unresolved_addresses) |
| - pprof_out.seek(0) |
| - symbols = pprof_out.readlines() |
| - symbol_f.seek(0, 2) |
| - for address, symbol in zip(unresolved_addresses, symbols): |
| - stripped_symbol = symbol.strip() |
| - address_symbol_dict[address] = stripped_symbol |
| - symbol_f.write('%s %s\n' % (address, symbol.strip())) |
| + for address, symbol in zip(unresolved_addresses, symbols): |
| + stripped_symbol = symbol.strip() |
| + address_symbol_dict[address] = stripped_symbol |
| + symbol_f.write('%s %s\n' % (address, symbol.strip())) |
|
M-A Ruel
2012/07/22 19:51:07
I don't see why you are making a local variable an
Dai Mikurube (NOT FULLTIME)
2012/07/23 00:48:45
Done.
|
| def parse_policy(policy_path): |
| @@ -769,7 +746,7 @@ Examples: |
| logs.append(new_log) |
| sys.stderr.write('getting symbols\n') |
| - update_symbols(symbol_path, maps_lines, chrome_path) |
| + update_symbols(symbol_path, maps_lines, maps_path) |
| # TODO(dmikurube): Many modes now. Split them into separete functions. |
| if action == '--stacktrace': |