aboutsummaryrefslogtreecommitdiff
path: root/debug_info_test/check_cus.py
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-02-14 03:08:18 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-02-14 03:08:18 +0000
commitdb729d703a0bf8fc92f011d160abd063c338b2f3 (patch)
tree35fa0fbaeaaddd9cc2a126a05eee3527b51e83a8 /debug_info_test/check_cus.py
parentdddbf2c6f79f2334de6d41b86d63698714ba1124 (diff)
parentb75f321fc8978b92ce3db6886ccb966768f0c7a8 (diff)
downloadtoolchain-utils-android11-s1-release.tar.gz
Snap for 6206568 from b75f321fc8978b92ce3db6886ccb966768f0c7a8 to rvc-releaseandroid-vts-11.0_r9android-vts-11.0_r8android-vts-11.0_r7android-vts-11.0_r6android-vts-11.0_r5android-vts-11.0_r4android-vts-11.0_r3android-vts-11.0_r2android-vts-11.0_r16android-vts-11.0_r15android-vts-11.0_r14android-vts-11.0_r13android-vts-11.0_r12android-vts-11.0_r11android-vts-11.0_r10android-vts-11.0_r1android-security-11.0.0_r76android-security-11.0.0_r75android-security-11.0.0_r74android-security-11.0.0_r73android-security-11.0.0_r72android-security-11.0.0_r71android-security-11.0.0_r70android-security-11.0.0_r69android-security-11.0.0_r68android-security-11.0.0_r67android-security-11.0.0_r66android-security-11.0.0_r65android-security-11.0.0_r64android-security-11.0.0_r63android-security-11.0.0_r62android-security-11.0.0_r61android-security-11.0.0_r60android-security-11.0.0_r59android-security-11.0.0_r58android-security-11.0.0_r57android-security-11.0.0_r56android-security-11.0.0_r55android-security-11.0.0_r54android-security-11.0.0_r53android-security-11.0.0_r52android-security-11.0.0_r51android-security-11.0.0_r50android-security-11.0.0_r49android-security-11.0.0_r1android-platform-11.0.0_r9android-platform-11.0.0_r8android-platform-11.0.0_r7android-platform-11.0.0_r6android-platform-11.0.0_r5android-platform-11.0.0_r4android-platform-11.0.0_r3android-platform-11.0.0_r2android-platform-11.0.0_r13android-platform-11.0.0_r12android-platform-11.0.0_r11android-platform-11.0.0_r10android-platform-11.0.0_r1android-cts-11.0_r9android-cts-11.0_r8android-cts-11.0_r7android-cts-11.0_r6android-cts-11.0_r5android-cts-11.0_r4android-cts-11.0_r3android-cts-11.0_r2android-cts-11.0_r16android-cts-11.0_r15android-cts-11.0_r14android-cts-11.0_r13android-cts-11.0_r12android-cts-11.0_r11android-cts-11.0_r10android-cts-11.0_r1android-11.0.0_r6android-11.0.0_r5android-11.0.0_r4android-11.0.0_r3android-11.0.0_r25android-11.0.0_r2android-11.0.0_r17android-11.0.0_r1android11-tests-releaseandroid11-security-releaseandroid11-s1-releaseandroid11-releaseandroid11-platform-releaseandroid11-gsi
Change-Id: I997cf91dd612b5e50d502271baf665232843c30a
Diffstat (limited to 'debug_info_test/check_cus.py')
-rw-r--r--debug_info_test/check_cus.py102
1 files changed, 55 insertions, 47 deletions
diff --git a/debug_info_test/check_cus.py b/debug_info_test/check_cus.py
index f68fe9cb..d3cd6365 100644
--- a/debug_info_test/check_cus.py
+++ b/debug_info_test/check_cus.py
@@ -1,7 +1,12 @@
+# -*- coding: utf-8 -*-
# Copyright 2018 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+"""check compile units."""
+
+from __future__ import print_function
+
import os
import subprocess
@@ -9,59 +14,62 @@ import check_ngcc
cu_checks = [check_ngcc.not_by_gcc]
+
def check_compile_unit(dso_path, producer, comp_path):
- """check all compiler flags used to build the compile unit.
+ """check all compiler flags used to build the compile unit.
+
+ Args:
+ dso_path: path to the elf/dso.
+ producer: DW_AT_producer contains the compiler command line.
+ comp_path: DW_AT_comp_dir + DW_AT_name.
- Args:
- dso_path: path to the elf/dso
- producer: DW_AT_producer contains the compiler command line.
- comp_path: DW_AT_comp_dir + DW_AT_name
+ Returns:
+ A set of failed tests.
+ """
+ failed = set()
+ for c in cu_checks:
+ if not c(dso_path, producer, comp_path):
+ failed.add(c.__module__)
- Returns:
- A set of failed tests.
- """
- failed = set()
- for c in cu_checks:
- if not c(dso_path, producer, comp_path):
- failed.add(c.__module__)
+ return failed
- return failed
def check_compile_units(dso_path):
- """check all compile units in the given dso.
-
- Args:
- dso_path: path to the dso
- Return:
- True if everything looks fine otherwise False.
- """
-
- failed = set()
- producer = ''
- comp_path = ''
-
- readelf = subprocess.Popen(['readelf', '--debug-dump=info',
- '--dwarf-depth=1', dso_path],
- stdout=subprocess.PIPE,
- stderr=open(os.devnull, 'w'))
- for l in readelf.stdout:
- if 'DW_TAG_compile_unit' in l:
- if producer:
- failed = failed.union(check_compile_unit(dso_path, producer,
- comp_path))
- producer = ''
- comp_path = ''
- elif 'DW_AT_producer' in l:
- producer = l
- elif 'DW_AT_name' in l:
- comp_path = os.path.join(comp_path, l.split(':')[-1].strip())
- elif 'DW_AT_comp_dir' in l:
- comp_path = os.path.join(l.split(':')[-1].strip(), comp_path)
- if producer:
+ """check all compile units in the given dso.
+
+ Args:
+ dso_path: path to the dso.
+
+ Returns:
+ True if everything looks fine otherwise False.
+ """
+
+ failed = set()
+ producer = ''
+ comp_path = ''
+
+ readelf = subprocess.Popen(
+ ['readelf', '--debug-dump=info', '--dwarf-depth=1', dso_path],
+ stdout=subprocess.PIPE,
+ stderr=open(os.devnull, 'w'),
+ encoding='utf-8')
+ for l in readelf.stdout:
+ if 'DW_TAG_compile_unit' in l:
+ if producer:
failed = failed.union(check_compile_unit(dso_path, producer, comp_path))
+ producer = ''
+ comp_path = ''
+ elif 'DW_AT_producer' in l:
+ producer = l
+ elif 'DW_AT_name' in l:
+ comp_path = os.path.join(comp_path, l.split(':')[-1].strip())
+ elif 'DW_AT_comp_dir' in l:
+ comp_path = os.path.join(l.split(':')[-1].strip(), comp_path)
+ if producer:
+ failed = failed.union(check_compile_unit(dso_path, producer, comp_path))
- if failed:
- print('%s failed check: %s' % (dso_path, ' '.join(failed)))
- return False
+ if failed:
+ print('%s failed check: %s' % (dso_path, ' '.join(failed)))
+ return False
- return True
+ return True