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

Unified Diff: tools/binary_size/run_binary_size_analysis.py

Issue 302633003: binary_size: Check debug data format before starting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/binary_size/run_binary_size_analysis.py
diff --git a/tools/binary_size/run_binary_size_analysis.py b/tools/binary_size/run_binary_size_analysis.py
index 7647a22dcb69b351b429f0e6e35911dd39e1b8be..ab93ecfc5a100c5c1cabb80b97c405fdc3733544 100755
--- a/tools/binary_size/run_binary_size_analysis.py
+++ b/tools/binary_size/run_binary_size_analysis.py
@@ -544,6 +544,34 @@ def _find_in_system_path(binary):
return binary_path
return None
+def CheckDebugFormatSupport(library, addr2line_binary, nm_binary):
+ """There are two common versions of the DWARF debug formats and
Primiano Tucci (use gerrit) 2014/05/27 09:40:10 Nit: docstring format (1 line + blank line + descr
Daniel Bratell 2014/06/04 13:31:02 Done.
+ 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)
Primiano Tucci (use gerrit) 2014/05/27 09:40:10 Please be consistent with quotes (double vs single
Daniel Bratell 2014/06/04 13:31:02 Done.
+ 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("""\
Primiano Tucci (use gerrit) 2014/05/27 09:40:10 From code style: Yes: print ("This is much nice
Daniel Bratell 2014/06/04 13:31:02 Will fix, but the suggested format is really bad i
+The supplied tools only support DWARF2 debug data but the binary
+uses DWARF%d. Update the tools or compile the binary with -gdwarf-2.""" %
+ version)
+ sys.exit(1)
+
def main():
usage = """%prog [options]
@@ -638,8 +666,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, nm_binary)
symbols = GetNmSymbols(opts.nm_in, opts.nm_out, opts.library,
opts.jobs, opts.verbose is True,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698