From 2124be5caee6803d5bfe6f7cdc8e3367cb375807 Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Thu, 21 Apr 2022 10:27:37 -0700 Subject: toolchain_utils: s/Cr OS/CrOS/g Result of running `sed -ri 's/Chrom(ium|e) OS/Chrom\1OS/g' $(find -type f)`. BUG=None TEST=None Change-Id: I59be92537aa19bc989f52b585e307e76dbde401b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3600147 Reviewed-by: Manoj Gupta Commit-Queue: George Burgess Tested-by: George Burgess --- afdo_redaction/remove_indirect_calls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'afdo_redaction/remove_indirect_calls.py') diff --git a/afdo_redaction/remove_indirect_calls.py b/afdo_redaction/remove_indirect_calls.py index 0dc15077..a72e43b5 100755 --- a/afdo_redaction/remove_indirect_calls.py +++ b/afdo_redaction/remove_indirect_calls.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# Copyright 2019 The Chromium OS Authors. All rights reserved. +# Copyright 2019 The ChromiumOS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -- cgit v1.2.3 From 74bd380a27f4f0e8e90ff2dc1cef0b502d74961b Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Fri, 2 Sep 2022 16:59:27 -0700 Subject: 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 Reviewed-by: Jordan Abrahams-Whitehead Commit-Queue: George Burgess --- afdo_redaction/remove_indirect_calls.py | 87 ++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 40 deletions(-) (limited to 'afdo_redaction/remove_indirect_calls.py') diff --git a/afdo_redaction/remove_indirect_calls.py b/afdo_redaction/remove_indirect_calls.py index a72e43b5..6d77ba7a 100755 --- a/afdo_redaction/remove_indirect_calls.py +++ b/afdo_redaction/remove_indirect_calls.py @@ -17,21 +17,22 @@ objects as Chrome, this can become problematic, and lead to NaCl doubling in size (or worse). See crbug.com/1005023 and crbug.com/916130. """ -from __future__ import division, print_function +from __future__ import division +from __future__ import print_function import argparse import re def _remove_indirect_call_targets(lines): - # Lines with indirect call targets look like: - # 1.1: 1234 foo:111 bar:122 - # - # Where 1.1 is the line info/discriminator, 1234 is the total number of - # samples seen for that line/discriminator, foo:111 is "111 of the calls here - # went to foo," and bar:122 is "122 of the calls here went to bar." - call_target_re = re.compile( - r""" + # Lines with indirect call targets look like: + # 1.1: 1234 foo:111 bar:122 + # + # Where 1.1 is the line info/discriminator, 1234 is the total number of + # samples seen for that line/discriminator, foo:111 is "111 of the calls here + # went to foo," and bar:122 is "122 of the calls here went to bar." + call_target_re = re.compile( + r""" ^\s+ # Top-level lines are function records. \d+(?:\.\d+)?: # Line info/discriminator \s+ @@ -39,42 +40,48 @@ def _remove_indirect_call_targets(lines): \s+ ((?:[^\s:]+:\d+\s*)+) # Indirect call target(s) $ - """, re.VERBOSE) - for line in lines: - line = line.rstrip() + """, + re.VERBOSE, + ) + for line in lines: + line = line.rstrip() - match = call_target_re.match(line) - if not match: - yield line + '\n' - continue + match = call_target_re.match(line) + if not match: + yield line + "\n" + continue - group_start, group_end = match.span(1) - assert group_end == len(line) - yield line[:group_start].rstrip() + '\n' + group_start, group_end = match.span(1) + assert group_end == len(line) + yield line[:group_start].rstrip() + "\n" def run(input_stream, output_stream): - for line in _remove_indirect_call_targets(input_stream): - output_stream.write(line) + for line in _remove_indirect_call_targets(input_stream): + output_stream.write(line) def main(): - parser = argparse.ArgumentParser( - description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) - parser.add_argument( - '--input', - default='/dev/stdin', - help='File to read from. Defaults to stdin.') - parser.add_argument( - '--output', - default='/dev/stdout', - help='File to write to. Defaults to stdout.') - args = parser.parse_args() - - with open(args.input) as stdin: - with open(args.output, 'w') as stdout: - run(stdin, stdout) - - -if __name__ == '__main__': - main() + parser = argparse.ArgumentParser( + description=__doc__, + formatter_class=argparse.RawDescriptionHelpFormatter, + ) + parser.add_argument( + "--input", + default="/dev/stdin", + help="File to read from. Defaults to stdin.", + ) + parser.add_argument( + "--output", + default="/dev/stdout", + help="File to write to. Defaults to stdout.", + ) + args = parser.parse_args() + + with open(args.input) as stdin: + with open(args.output, "w") as stdout: + run(stdin, stdout) + + +if __name__ == "__main__": + main() -- cgit v1.2.3 From c0041a9550814e402f661a560855ff99863cffb2 Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Tue, 6 Sep 2022 12:12:02 -0700 Subject: remove `from __future__ import ...` directives These are only useful when we're running code in a Python 2.7 interpreter. Since we no longer support python2, drop these. BUG=b:244644217 TEST=run_tests_for.py shows no new failures Change-Id: Ief9a12b87a560ab38ca71668636874bcb434a0b3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3877339 Reviewed-by: Ryan Beltran Commit-Queue: George Burgess Reviewed-by: Jordan Abrahams-Whitehead Tested-by: George Burgess --- afdo_redaction/remove_indirect_calls.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'afdo_redaction/remove_indirect_calls.py') diff --git a/afdo_redaction/remove_indirect_calls.py b/afdo_redaction/remove_indirect_calls.py index 6d77ba7a..769bd0ff 100755 --- a/afdo_redaction/remove_indirect_calls.py +++ b/afdo_redaction/remove_indirect_calls.py @@ -17,8 +17,6 @@ objects as Chrome, this can become problematic, and lead to NaCl doubling in size (or worse). See crbug.com/1005023 and crbug.com/916130. """ -from __future__ import division -from __future__ import print_function import argparse import re -- cgit v1.2.3 From fdcd39d5de4bd61cee94cf1e26416838d23092b8 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 13 Sep 2022 14:19:58 -0400 Subject: Update license boilerplate text in source code files Normally we don't do this, but enough changes have accumulated that we're doing a tree-wide one-off update of the name & style. BUG=chromium:1098010 TEST=`repo upload` works Change-Id: Icb42e5012a87920c2cd13b666fb3e55e7e4fb3b8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3891080 Auto-Submit: Mike Frysinger Tested-by: Mike Frysinger Commit-Queue: George Burgess Reviewed-by: George Burgess --- afdo_redaction/remove_indirect_calls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'afdo_redaction/remove_indirect_calls.py') diff --git a/afdo_redaction/remove_indirect_calls.py b/afdo_redaction/remove_indirect_calls.py index 769bd0ff..32dab3f4 100755 --- a/afdo_redaction/remove_indirect_calls.py +++ b/afdo_redaction/remove_indirect_calls.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# Copyright 2019 The ChromiumOS Authors. All rights reserved. +# Copyright 2019 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -- cgit v1.2.3