summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-09 04:26:53 +0000
committerdmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-09 04:26:53 +0000
commitb904c89927bdb4f814d3fb1e6fe4af474447491c (patch)
tree5e50a7dc938cc5c82a74b097ffc58c053f460105
parentaf2a013cf61b7d9f74da51168db2022bde63c6e8 (diff)
downloadchromium_src-b904c89927bdb4f814d3fb1e6fe4af474447491c.zip
chromium_src-b904c89927bdb4f814d3fb1e6fe4af474447491c.tar.gz
chromium_src-b904c89927bdb4f814d3fb1e6fe4af474447491c.tar.bz2
Change the format of reduce_debugline.py.
This script was added in http://crrev.com/192004 at first. BUG=225343 NOTRY=true Review URL: https://chromiumcodereview.appspot.com/13470029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193001 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-xtools/find_runtime_symbols/prepare_symbol_info.py14
-rwxr-xr-xtools/find_runtime_symbols/reduce_debugline.py81
-rwxr-xr-xtools/find_runtime_symbols/tests/reduce_debugline_test.py113
3 files changed, 60 insertions, 148 deletions
diff --git a/tools/find_runtime_symbols/prepare_symbol_info.py b/tools/find_runtime_symbols/prepare_symbol_info.py
index a7d6121..477c674 100755
--- a/tools/find_runtime_symbols/prepare_symbol_info.py
+++ b/tools/find_runtime_symbols/prepare_symbol_info.py
@@ -149,11 +149,11 @@ def prepare_symbol_info(maps_path,
output_dir_path, os.path.basename(entry.name), '.readelf-e')
if not readelf_e_filename:
continue
- readelf_reduced_debugline_filename = None
+ readelf_debug_decodedline_file = None
if use_source_file_name:
- readelf_reduced_debugline_filename = _dump_command_result(
- 'readelf -wLW %s | %s' % (entry.name, REDUCE_DEBUGLINE_PATH),
- output_dir_path, os.path.basename(entry.name), '.readelf-debugline')
+ readelf_debug_decodedline_file = _dump_command_result(
+ 'readelf -wL %s | %s' % (entry.name, REDUCE_DEBUGLINE_PATH),
+ output_dir_path, os.path.basename(entry.name), '.readelf-wL')
files[entry.name] = {}
files[entry.name]['nm'] = {
@@ -162,9 +162,9 @@ def prepare_symbol_info(maps_path,
'mangled': False}
files[entry.name]['readelf-e'] = {
'file': os.path.basename(readelf_e_filename)}
- if readelf_reduced_debugline_filename:
- files[entry.name]['readelf-reduced-debugline'] = {
- 'file': os.path.basename(readelf_reduced_debugline_filename)}
+ if readelf_debug_decodedline_file:
+ files[entry.name]['readelf-debug-decodedline-file'] = {
+ 'file': os.path.basename(readelf_debug_decodedline_file)}
with open(os.path.join(output_dir_path, 'files.json'), 'w') as f:
json.dump(files, f, indent=2, sort_keys=True)
diff --git a/tools/find_runtime_symbols/reduce_debugline.py b/tools/find_runtime_symbols/reduce_debugline.py
index 1a4efaa..75c8c85 100755
--- a/tools/find_runtime_symbols/reduce_debugline.py
+++ b/tools/find_runtime_symbols/reduce_debugline.py
@@ -2,23 +2,11 @@
# Copyright (c) 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.
-"""Reduces result of 'readelf -wL' to just a set of address ranges per file.
+"""Reduces result of 'readelf -wL' to just a list of starting addresses.
-For example:
-
-CU: ../../chrome_main.cc:
-File name Line number Starting address
-chrome_main.cc 30 0xa3be90
-(an empty line)
-chrome_main.cc 31 0xa3bea3
-chrome_main.cc 32 0xa3beaf
-chrome_main.cc 34 0xa3bec9
-chrome_main.cc 32 0xa3bed1
-(an empty line)
-
-The example above is reduced into:
-{'../../chrome_main.cc', [(0xa3be90, 0xa3be90), (0xa3bea3, 0xa3bed1)]}
-where (0xa3bea3, 0xa3bed1) means an address range from 0xa3bea3 to 0xa3bed1.
+It lists up all addresses where the corresponding source files change. The
+list is sorted in ascending order. See tests/reduce_debugline_test.py for
+examples.
This script assumes that the result of 'readelf -wL' ends with an empty line.
@@ -34,35 +22,32 @@ _FILENAME_PATTERN = re.compile('(CU: |)(.+)\:')
def reduce_decoded_debugline(input_file):
filename = ''
- ranges_dict = {}
- starting = None
- ending = None
+ starting_dict = {}
+ started = False
for line in input_file:
line = line.strip()
-
- if line.endswith(':'):
- matched = _FILENAME_PATTERN.match(line)
- if matched:
- filename = matched.group(2)
- continue
-
unpacked = line.split(None, 2)
- if len(unpacked) != 3 or not unpacked[2].startswith('0x'):
- if starting:
- ranges_dict.setdefault(filename, []).append((starting, ending))
- starting = None
- ending = None
- continue
-
- ending = int(unpacked[2], 16)
- if not starting:
- starting = ending
-
- if starting or ending:
- raise ValueError('No new line at last.')
- return ranges_dict
+ if len(unpacked) == 3 and unpacked[2].startswith('0x'):
+ if not started and filename:
+ started = True
+ starting_dict[int(unpacked[2], 16)] = filename
+ else:
+ started = False
+ if line.endswith(':'):
+ matched = _FILENAME_PATTERN.match(line)
+ if matched:
+ filename = matched.group(2)
+
+ starting_list = []
+ prev_filename = ''
+ for address in sorted(starting_dict):
+ curr_filename = starting_dict[address]
+ if prev_filename != curr_filename:
+ starting_list.append((address, starting_dict[address]))
+ prev_filename = curr_filename
+ return starting_list
def main():
@@ -70,15 +55,13 @@ def main():
print >> sys.stderr, 'Unsupported arguments'
return 1
- ranges_dict = reduce_decoded_debugline(sys.stdin)
- for filename, ranges in ranges_dict.iteritems():
- print filename + ':'
- prev = (0, 0)
- for address_range in sorted(ranges):
- if address_range == prev:
- continue
- print ' %x-%x' % (address_range[0], address_range[1])
- prev = address_range
+ starting_list = reduce_decoded_debugline(sys.stdin)
+ bits64 = starting_list[-1][0] > 0xffffffff
+ for address, filename in starting_list:
+ if bits64:
+ print '%016x %s' % (address, filename)
+ else:
+ print '%08x %s' % (address, filename)
if __name__ == '__main__':
diff --git a/tools/find_runtime_symbols/tests/reduce_debugline_test.py b/tools/find_runtime_symbols/tests/reduce_debugline_test.py
index 04488a5..1e3a21a 100755
--- a/tools/find_runtime_symbols/tests/reduce_debugline_test.py
+++ b/tools/find_runtime_symbols/tests/reduce_debugline_test.py
@@ -20,109 +20,38 @@ class ReduceDebuglineTest(unittest.TestCase):
_DECODED_DEBUGLINE = textwrap.dedent("""\
Decoded dump of debug contents of section .debug_line:
- CU: ../../chrome/app/chrome_exe_main_gtk.cc:
+ CU: ../../chrome/service/service_main.cc:
File name Line number Starting address
- chrome_exe_main_gtk.cc 33 0xa3be50
+ service_main.cc 21 0xa41210
- chrome_exe_main_gtk.cc 34 0xa3be66
- chrome_exe_main_gtk.cc 39 0xa3be75
- chrome_exe_main_gtk.cc 42 0xa3be7a
+ service_main.cc 24 0xa4141f
+ service_main.cc 30 0xa4142b
+ service_main.cc 31 0xa4143e
- CU: ../../chrome/app/chrome_main.cc:
- File name Line number Starting address
- chrome_main.cc 30 0xa3be90
-
- chrome_main.cc 31 0xa3bea3
- chrome_main.cc 32 0xa3beaf
- chrome_main.cc 34 0xa3bec9
- chrome_main.cc 32 0xa3bed1
-
- CU: ../../chrome/app/chrome_main_delegate.cc:
- File name Line number Starting address
- chrome_main_delegate.cc 320 0xa3bee0
-
- chrome_main_delegate.cc 320 0xa3bef0
- chrome_main_delegate.cc 321 0xa3bf43
- chrome_main_delegate.cc 322 0xa3bf48
- chrome_main_delegate.cc 324 0xa3bf50
- chrome_main_delegate.cc 324 0xa3bf60
-
- chrome_main_delegate.cc 612 0xa3cd54
- chrome_main_delegate.cc 617 0xa3cd6b
- chrome_main_delegate.cc 299 0xa3d5fd
- chrome_main_delegate.cc 300 0xa3d605
-
- ../../content/public/app/content_main_delegate.h:
- content_main_delegate.h 22 0xa3d620
+ ../../base/message_loop.h:
+ message_loop.h 550 0xa41300
- content_main_delegate.h 22 0xa3d637
+ message_loop.h 551 0xa41310
- ../../chrome/common/chrome_content_client.h:
- chrome_content_client.h 16 0xa3d640
+ ../../base/logging.h:
+ logging.h 246 0xa41710
- chrome_content_client.h 16 0xa3d650
+ logging.h 247 0xa41726
- ../../base/memory/scoped_ptr.h:
- scoped_ptr.h 323 0xa3d680
-
- scoped_ptr.h 323 0xa3d690
-
- ../../base/memory/scoped_ptr.h:
- scoped_ptr.h 323 0xa3d660
-
- scoped_ptr.h 323 0xa3d670
-
- ../../base/memory/scoped_ptr.h:
- scoped_ptr.h 428 0xa3d6a0
-
- scoped_ptr.h 428 0xa3d6b0
-
- CU: ../../something.c:
- File name Line number Starting address
- something.c 57 0x76e2cc0
+ ../../base/logging.h:
+ logging.h 846 0xa3fd90
- something.c 62 0x76e2cd3
- something.c 64 0x76e2cda
- something.c 65 0x76e2ce9
- something.c 66 0x76e2cf8
+ logging.h 846 0xa3fda0
""")
- _EXPECTED_REDUCED_DEBUGLINE = {
- '../../chrome/app/chrome_exe_main_gtk.cc': [
- (0xa3be50, 0xa3be50),
- (0xa3be66, 0xa3be7a),
- ],
- '../../chrome/app/chrome_main.cc': [
- (0xa3be90, 0xa3be90),
- (0xa3bea3, 0xa3bed1),
- ],
- '../../chrome/app/chrome_main_delegate.cc': [
- (0xa3bee0, 0xa3bee0),
- (0xa3bef0, 0xa3bf60),
- (0xa3cd54, 0xa3d605),
- ],
- '../../content/public/app/content_main_delegate.h': [
- (0xa3d620, 0xa3d620),
- (0xa3d637, 0xa3d637),
- ],
- '../../chrome/common/chrome_content_client.h': [
- (0xa3d640, 0xa3d640),
- (0xa3d650, 0xa3d650),
- ],
- '../../base/memory/scoped_ptr.h': [
- (0xa3d680, 0xa3d680),
- (0xa3d690, 0xa3d690),
- (0xa3d660, 0xa3d660),
- (0xa3d670, 0xa3d670),
- (0xa3d6a0, 0xa3d6a0),
- (0xa3d6b0, 0xa3d6b0),
- ],
- '../../something.c': [
- (0x76e2cc0, 0x76e2cc0),
- (0x76e2cd3, 0x76e2cf8),
- ],
- }
+ _EXPECTED_REDUCED_DEBUGLINE = [
+ (0xa3fd90, '../../base/logging.h'),
+ (0xa41210, '../../chrome/service/service_main.cc'),
+ (0xa41300, '../../base/message_loop.h'),
+ (0xa4141f, '../../chrome/service/service_main.cc'),
+ (0xa41710, '../../base/logging.h'),
+ ]
def test(self):
ranges_dict = reduce_debugline.reduce_decoded_debugline(