summaryrefslogtreecommitdiffstats
path: root/tools/binary_size
diff options
context:
space:
mode:
authorbratell@opera.com <bratell@opera.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-09 22:48:19 +0000
committerbratell@opera.com <bratell@opera.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-09 22:48:19 +0000
commit0118084bff852fa6d58bd0a55b8bb73915422968 (patch)
tree858436a2feb89f4790c123878f0b587cd2a8846f /tools/binary_size
parent90afd1ba680b57e4ce812949a4d5accdb1309b42 (diff)
downloadchromium_src-0118084bff852fa6d58bd0a55b8bb73915422968.zip
chromium_src-0118084bff852fa6d58bd0a55b8bb73915422968.tar.gz
chromium_src-0118084bff852fa6d58bd0a55b8bb73915422968.tar.bz2
binary_size: Check debug data format before starting.
If the debug data format is DWARF4 and binutils is not new enough the output will be more or less useless (no files will be detected). Detect that case early instead of having the user wait for many hours for something that can't be used. BUG=370378 Review URL: https://codereview.chromium.org/302633003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275866 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/binary_size')
-rwxr-xr-xtools/binary_size/run_binary_size_analysis.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/tools/binary_size/run_binary_size_analysis.py b/tools/binary_size/run_binary_size_analysis.py
index 4168874..aefc85d 100755
--- a/tools/binary_size/run_binary_size_analysis.py
+++ b/tools/binary_size/run_binary_size_analysis.py
@@ -561,6 +561,35 @@ def _find_in_system_path(binary):
return binary_path
return None
+def CheckDebugFormatSupport(library, addr2line_binary):
+ """Kills the program if debug data is in an unsupported format.
+
+ There are two common versions of the DWARF debug formats and
+ since we are right now transitioning from DWARF2 to newer formats,
+ it's possible to have a mix of tools that are not compatible. Detect
+ that and abort rather than produce meaningless output."""
+ tool_output = subprocess.check_output([addr2line_binary, '--version'])
+ version_re = re.compile(r'^GNU [^ ]+ .* (\d+).(\d+).*?$', re.M)
+ parsed_output = version_re.match(tool_output)
+ major = int(parsed_output.group(1))
+ minor = int(parsed_output.group(2))
+ supports_dwarf4 = major > 2 or major == 2 and minor > 22
+
+ if supports_dwarf4:
+ return
+
+ print('Checking version of debug information in %s.' % library)
+ debug_info = subprocess.check_output(['readelf', '--debug-dump=info',
+ '--dwarf-depth=1', library])
+ dwarf_version_re = re.compile(r'^\s+Version:\s+(\d+)$', re.M)
+ parsed_dwarf_format_output = dwarf_version_re.search(debug_info)
+ version = int(parsed_dwarf_format_output.group(1))
+ if version > 2:
+ print('The supplied tools only support DWARF2 debug data but the binary\n' +
+ 'uses DWARF%d. Update the tools or compile the binary\n' % version +
+ 'with -gdwarf-2.')
+ sys.exit(1)
+
def main():
usage = """%prog [options]
@@ -655,8 +684,10 @@ def main():
assert nm_binary, 'Unable to find nm in the path. Use --nm-binary '\
'to specify location.'
- print('nm: %s' % nm_binary)
print('addr2line: %s' % addr2line_binary)
+ print('nm: %s' % nm_binary)
+
+ CheckDebugFormatSupport(opts.library, addr2line_binary)
symbols = GetNmSymbols(opts.nm_in, opts.nm_out, opts.library,
opts.jobs, opts.verbose is True,