aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbarch.py
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-10-18 09:48:09 -0600
committerTom Tromey <tromey@adacore.com>2022-10-31 09:04:10 -0600
commit6c8912c64bcbfd109af0500577409690074e9d27 (patch)
tree14654b29c15c6417565df7ed635fb7687cb3a5f4 /gdb/gdbarch.py
parent86430497337968e6163aef370c6312e7b5ed6504 (diff)
downloadgdb-6c8912c64bcbfd109af0500577409690074e9d27.zip
gdb-6c8912c64bcbfd109af0500577409690074e9d27.tar.gz
gdb-6c8912c64bcbfd109af0500577409690074e9d27.tar.bz2
Inline initialization of gdbarch members
This changes gdbarch to use the "predefault" to initialize its members inline. This required changing a couple of the Value instantiations to avoid a use of "gdbarch" during initialization, but on the whole I think this is better -- it removes a hidden ordering dependency.
Diffstat (limited to 'gdb/gdbarch.py')
-rwxr-xr-xgdb/gdbarch.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/gdb/gdbarch.py b/gdb/gdbarch.py
index ae8a3f7..a4c1818 100755
--- a/gdb/gdbarch.py
+++ b/gdb/gdbarch.py
@@ -286,11 +286,18 @@ with open("gdbarch.c", "w") as f:
print(" void **data = nullptr;", file=f)
print(file=f)
for c in filter(not_info, components):
- if isinstance(c, Value):
- print(f" {c.type} {c.name} = 0;", file=f)
+ if isinstance(c, Function):
+ print(f" gdbarch_{c.name}_ftype *", file=f, end="")
+ else:
+ print(f" {c.type} ", file=f, end="")
+ print(f"{c.name} = ", file=f, end="")
+ if c.predefault is not None:
+ print(f"{c.predefault};", file=f)
+ elif isinstance(c, Value):
+ print("0;", file=f)
else:
assert isinstance(c, Function)
- print(f" gdbarch_{c.name}_ftype *{c.name} = nullptr;", file=f)
+ print("nullptr;", file=f)
print("};", file=f)
print(file=f)
#
@@ -312,12 +319,6 @@ with open("gdbarch.c", "w") as f:
for c in filter(info, components):
print(f" gdbarch->{c.name} = info->{c.name};", file=f)
print(file=f)
- print(" /* Force the explicit initialization of these. */", file=f)
- for c in filter(not_info, components):
- if c.predefault and c.predefault != "0":
- print(f" gdbarch->{c.name} = {c.predefault};", file=f)
- print(" /* gdbarch_alloc() */", file=f)
- print(file=f)
print(" return gdbarch;", file=f)
print("}", file=f)
print(file=f)