aboutsummaryrefslogtreecommitdiff
path: root/debug_info_test/check_icf.py
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2022-09-02 16:59:27 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-07 21:15:07 +0000
commit74bd380a27f4f0e8e90ff2dc1cef0b502d74961b (patch)
treebe028f89ec1e2eca735bb4aa1610530147a53625 /debug_info_test/check_icf.py
parent8448c60a6a2337ec993923837e1d55b41f49dabc (diff)
downloadtoolchain-utils-74bd380a27f4f0e8e90ff2dc1cef0b502d74961b.tar.gz
Autoformat all Python code
This autoformats all Python code with our new Python formatter, `black`. BUG=b:244644217 TEST=None Change-Id: I15ee49233d98fb6295c0c53c129bbf8e78e0d9ff Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3877337 Tested-by: George Burgess <gbiv@chromium.org> Reviewed-by: Jordan Abrahams-Whitehead <ajordanr@google.com> Commit-Queue: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'debug_info_test/check_icf.py')
-rw-r--r--debug_info_test/check_icf.py78
1 files changed, 40 insertions, 38 deletions
diff --git a/debug_info_test/check_icf.py b/debug_info_test/check_icf.py
index a79d5e80..5e92ec13 100644
--- a/debug_info_test/check_icf.py
+++ b/debug_info_test/check_icf.py
@@ -13,41 +13,43 @@ import subprocess
def check_identical_code_folding(dso_path):
- """check whether chrome was built with identical code folding.
-
- Args:
- dso_path: path to the dso.
-
- Returns:
- False if the dso is chrome and it was not built with icf,
- True otherwise.
- """
-
- if not dso_path.endswith('/chrome.debug'):
- return True
-
- # Run 'nm' on the chrome binary and read the output.
- nm = subprocess.Popen(['nm', dso_path],
- stdout=subprocess.PIPE,
- stderr=open(os.devnull, 'w'),
- encoding='utf-8')
- nm_output, _ = nm.communicate()
-
- # Search for addresses of text symbols.
- text_addresses = re.findall('^[0-9a-f]+[ ]+[tT] ', nm_output, re.MULTILINE)
-
- # Calculate number of text symbols in chrome binary.
- num_text_addresses = len(text_addresses)
-
- # Calculate number of unique text symbols in chrome binary.
- num_unique_text_addresses = len(set(text_addresses))
-
- # Check that the number of duplicate symbols is at least 10,000.
- # - https://crbug.com/813272#c18
- if num_text_addresses - num_unique_text_addresses >= 10000:
- return True
-
- print('%s was not built with ICF' % dso_path)
- print(' num_text_addresses = %d' % num_text_addresses)
- print(' num_unique_text_addresses = %d' % num_unique_text_addresses)
- return False
+ """check whether chrome was built with identical code folding.
+
+ Args:
+ dso_path: path to the dso.
+
+ Returns:
+ False if the dso is chrome and it was not built with icf,
+ True otherwise.
+ """
+
+ if not dso_path.endswith("/chrome.debug"):
+ return True
+
+ # Run 'nm' on the chrome binary and read the output.
+ nm = subprocess.Popen(
+ ["nm", dso_path],
+ stdout=subprocess.PIPE,
+ stderr=open(os.devnull, "w"),
+ encoding="utf-8",
+ )
+ nm_output, _ = nm.communicate()
+
+ # Search for addresses of text symbols.
+ text_addresses = re.findall("^[0-9a-f]+[ ]+[tT] ", nm_output, re.MULTILINE)
+
+ # Calculate number of text symbols in chrome binary.
+ num_text_addresses = len(text_addresses)
+
+ # Calculate number of unique text symbols in chrome binary.
+ num_unique_text_addresses = len(set(text_addresses))
+
+ # Check that the number of duplicate symbols is at least 10,000.
+ # - https://crbug.com/813272#c18
+ if num_text_addresses - num_unique_text_addresses >= 10000:
+ return True
+
+ print("%s was not built with ICF" % dso_path)
+ print(" num_text_addresses = %d" % num_text_addresses)
+ print(" num_unique_text_addresses = %d" % num_unique_text_addresses)
+ return False