summaryrefslogtreecommitdiff
path: root/gdb/gdbarch.py
diff options
context:
space:
mode:
authorThiago Jung Bauermann <thiago.bauermann@linaro.org>2022-12-01 17:18:06 +0000
committerThiago Jung Bauermann <thiago.bauermann@linaro.org>2022-12-05 13:52:10 +0000
commitadc48a49264637719620b4d52224774cdc4607c8 (patch)
tree0fc47dea245f6852e4d550c4b70e2e0cf4f28594 /gdb/gdbarch.py
parent53e03d92a6d052dfb8d0cb2ff203f1d28462e656 (diff)
downloadbinutils-gdb-adc48a49264637719620b4d52224774cdc4607c8.tar.gz
gdbarch.py: Fix indentation in the generated set_gdbarch_* definitions
Use as many tabs as possible for indentation and pad with spaces to keep the argument aligned to the opening parenthesis in the line above. Co-developed-by: Simon Marchi <simon.marchi@efficios.com> Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb/gdbarch.py')
-rwxr-xr-xgdb/gdbarch.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/gdb/gdbarch.py b/gdb/gdbarch.py
index 6980421fe77..4ab0934f1ba 100755
--- a/gdb/gdbarch.py
+++ b/gdb/gdbarch.py
@@ -26,6 +26,11 @@ import gdbcopyright
components = []
+def indentation(n_columns):
+ """Return string with tabs and spaces to indent line to N_COLUMNS."""
+ return "\t" * (n_columns // 8) + " " * (n_columns % 8)
+
+
def join_type_and_name(t, n):
"Combine the type T and the name N into a C declaration."
if t.endswith("*") or t.endswith("&"):
@@ -474,11 +479,11 @@ with open("gdbarch.c", "w") as f:
print("}", file=f)
print(file=f)
print("void", file=f)
- print(f"set_gdbarch_{c.name} (struct gdbarch *gdbarch,", file=f)
- print(
- f" {' ' * len(c.name)} gdbarch_{c.name}_ftype {c.name})",
- file=f,
- )
+ setter_name = f"set_gdbarch_{c.name}"
+ ftype_name = f"gdbarch_{c.name}_ftype"
+ print(f"{setter_name} (struct gdbarch *gdbarch,", file=f)
+ indent_columns = len(f"{setter_name} (")
+ print(f"{indentation(indent_columns)}{ftype_name} {c.name})", file=f)
print("{", file=f)
print(f" gdbarch->{c.name} = {c.name};", file=f)
print("}", file=f)
@@ -505,8 +510,10 @@ with open("gdbarch.c", "w") as f:
print("}", file=f)
print(file=f)
print("void", file=f)
- print(f"set_gdbarch_{c.name} (struct gdbarch *gdbarch,", file=f)
- print(f" {' ' * len(c.name)} {c.type} {c.name})", file=f)
+ setter_name = f"set_gdbarch_{c.name}"
+ print(f"{setter_name} (struct gdbarch *gdbarch,", file=f)
+ indent_columns = len(f"{setter_name} (")
+ print(f"{indentation(indent_columns)}{c.type} {c.name})", file=f)
print("{", file=f)
print(f" gdbarch->{c.name} = {c.name};", file=f)
print("}", file=f)