diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-05-07 10:56:20 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-05-07 10:56:20 -0400 |
commit | 13123da89a2c7e06a5312ca6b4b24c68ba1c6c2d (patch) | |
tree | ec33a85ccb58f44445608d0cab68020fa588cb74 /gdb/syscalls | |
parent | a9b49cbcd5935a713da5715799ea3b24e0a52851 (diff) | |
download | gdb-13123da89a2c7e06a5312ca6b4b24c68ba1c6c2d.zip gdb-13123da89a2c7e06a5312ca6b4b24c68ba1c6c2d.tar.gz gdb-13123da89a2c7e06a5312ca6b4b24c68ba1c6c2d.tar.bz2 |
gdb: re-format Python files using black 21.4b0
Re-format all Python files using black [1] version 21.4b0. The goal is
that from now on, we keep all Python files formatted using black. And
that we never have to discuss formatting during review (for these files
at least) ever again.
One change is needed in gdb.python/py-prettyprint.exp, because it
matches the string representation of an exception, which shows source
code. So the change in formatting must be replicated in the expected
regexp.
To document our usage of black I plan on adding this to the "GDB Python
Coding Standards" wiki page [2]:
--8<--
All Python source files under the `gdb/` directory must be formatted
using black version 21.4b0.
This specific version can be installed using:
$ pip3 install 'black == 21.4b0'
All you need to do to re-format files is run `black <file/directory>`,
and black will re-format any Python file it finds in there. It runs
quite fast, so the simplest is to do:
$ black gdb/
from the top-level.
If you notice that black produces changes unrelated to your patch, it's
probably because someone forgot to run it before you. In this case,
don't include unrelated hunks in your patch. Push an obvious patch
fixing the formatting and rebase your work on top of that.
-->8--
Once this is merged, I plan on setting a up an `ignoreRevsFile`
config so that git-blame ignores this commit, as described here:
https://github.com/psf/black#migrating-your-code-style-without-ruining-git-blame
I also plan on working on a git commit hook (checked in the repo) to
automatically check the formatting of the Python files on commit.
[1] https://pypi.org/project/black/
[2] https://sourceware.org/gdb/wiki/Internals%20GDB-Python-Coding-Standards
gdb/ChangeLog:
* Re-format all Python files using black.
gdb/testsuite/ChangeLog:
* Re-format all Python files using black.
* gdb.python/py-prettyprint.exp (run_lang_tests): Adjust.
Change-Id: I28588a22c2406afd6bc2703774ddfff47cd61919
Diffstat (limited to 'gdb/syscalls')
-rw-r--r-- | gdb/syscalls/arm-linux.py | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/gdb/syscalls/arm-linux.py b/gdb/syscalls/arm-linux.py index e3985f8..e9cd00b 100644 --- a/gdb/syscalls/arm-linux.py +++ b/gdb/syscalls/arm-linux.py @@ -12,7 +12,8 @@ import time infname = sys.argv[1] inf = file(infname) -print("""\ +print( + """\ <?xml version="1.0"?> <!-- Copyright (C) 2009-%s Free Software Foundation, Inc. @@ -30,31 +31,33 @@ print("""\ The file mentioned above belongs to the Linux Kernel. Some small hand-edits were made. --> -<syscalls_info>""" % (time.strftime("%Y"), infname)) +<syscalls_info>""" + % (time.strftime("%Y"), infname) +) + def record(name, number, comment=None): - #nm = 'name="%s"' % name - #s = ' <syscall %-30s number="%d"/>' % (nm, number) + # nm = 'name="%s"' % name + # s = ' <syscall %-30s number="%d"/>' % (nm, number) s = ' <syscall name="%s" number="%d"/>' % (name, number) if comment: - s += ' <!-- %s -->' % comment + s += " <!-- %s -->" % comment print(s) + for line in inf: - m = re.match(r'^#define __NR_(\w+)\s+\(__NR_SYSCALL_BASE\+\s*(\d+)\)', - line) + m = re.match(r"^#define __NR_(\w+)\s+\(__NR_SYSCALL_BASE\+\s*(\d+)\)", line) if m: record(m.group(1), int(m.group(2))) continue - m = re.match(r'^\s+/\* (\d+) was sys_(\w+) \*/$', line) + m = re.match(r"^\s+/\* (\d+) was sys_(\w+) \*/$", line) if m: - record(m.group(2), int(m.group(1)), 'removed') + record(m.group(2), int(m.group(1)), "removed") - m = re.match(r'^#define __ARM_NR_(\w+)\s+\(__ARM_NR_BASE\+\s*(\d+)\)', - line) + m = re.match(r"^#define __ARM_NR_(\w+)\s+\(__ARM_NR_BASE\+\s*(\d+)\)", line) if m: - record('ARM_'+m.group(1), 0x0f0000+int(m.group(2))) + record("ARM_" + m.group(1), 0x0F0000 + int(m.group(2))) continue -print('</syscalls_info>') +print("</syscalls_info>") |