aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbarch.py
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-09-07 08:58:18 -0600
committerTom Tromey <tromey@adacore.com>2023-01-03 08:45:00 -0700
commit43f2b4583f95775b2c0fefd71aab4c773c4f7a7e (patch)
treed824b114c27606dd7023f198aa41e7fe21d3fba3 /gdb/gdbarch.py
parent4e1d2f5814b29048d1dd1cea2cb50570e6c8f1f8 (diff)
downloadgdb-43f2b4583f95775b2c0fefd71aab4c773c4f7a7e.zip
gdb-43f2b4583f95775b2c0fefd71aab4c773c4f7a7e.tar.gz
gdb-43f2b4583f95775b2c0fefd71aab4c773c4f7a7e.tar.bz2
Don't emit gdbarch_return_value
The previous patch introduced a new overload of gdbarch_return_value. The intent here is that this new overload always be called by the core of gdb -- the previous implementation is effectively deprecated, because a call to the old-style method will not work with any converted architectures (whereas calling the new-style method is will delegate when needed). This patch changes gdbarch.py so that the old gdbarch_return_value wrapper function can be omitted. This will prevent any errors from creeping in.
Diffstat (limited to 'gdb/gdbarch.py')
-rwxr-xr-xgdb/gdbarch.py70
1 files changed, 37 insertions, 33 deletions
diff --git a/gdb/gdbarch.py b/gdb/gdbarch.py
index a1b665f..d2bf860 100755
--- a/gdb/gdbarch.py
+++ b/gdb/gdbarch.py
@@ -124,6 +124,7 @@ class Function(_Component):
printer=None,
param_checks=None,
result_checks=None,
+ implement=True,
):
super().__init__(
comment=comment,
@@ -137,6 +138,7 @@ class Function(_Component):
params=params,
param_checks=param_checks,
result_checks=result_checks,
+ implement=implement,
)
def ftype(self):
@@ -251,10 +253,11 @@ with open("gdbarch-gen.h", "w") as f:
f"typedef {c.type} ({c.ftype()}) ({c.param_list()});",
file=f,
)
- print(
- f"extern {c.type} gdbarch_{c.name} ({c.set_list()});",
- file=f,
- )
+ if c.implement:
+ print(
+ f"extern {c.type} gdbarch_{c.name} ({c.set_list()});",
+ file=f,
+ )
print(
f"extern void set_gdbarch_{c.name} (struct gdbarch *gdbarch, {c.ftype()} *{c.name});",
file=f,
@@ -445,38 +448,39 @@ with open("gdbarch.c", "w") as f:
print(f" return {c.get_predicate()};", file=f)
print("}", file=f)
if isinstance(c, Function):
- print(file=f)
- print(f"{c.type}", file=f)
- print(f"gdbarch_{c.name} ({c.set_list()})", file=f)
- print("{", file=f)
- print(" gdb_assert (gdbarch != NULL);", file=f)
- print(f" gdb_assert (gdbarch->{c.name} != NULL);", file=f)
- if c.predicate and c.predefault:
- # Allow a call to a function with a predicate.
+ if c.implement:
+ print(file=f)
+ print(f"{c.type}", file=f)
+ print(f"gdbarch_{c.name} ({c.set_list()})", file=f)
+ print("{", file=f)
+ print(" gdb_assert (gdbarch != NULL);", file=f)
+ print(f" gdb_assert (gdbarch->{c.name} != NULL);", file=f)
+ if c.predicate and c.predefault:
+ # Allow a call to a function with a predicate.
+ print(
+ f" /* Do not check predicate: {c.get_predicate()}, allow call. */",
+ file=f,
+ )
+ if c.param_checks:
+ for rule in c.param_checks:
+ print(f" gdb_assert ({rule});", file=f)
+ print(" if (gdbarch_debug >= 2)", file=f)
print(
- f" /* Do not check predicate: {c.get_predicate()}, allow call. */",
+ f""" gdb_printf (gdb_stdlog, "gdbarch_{c.name} called\\n");""",
file=f,
)
- if c.param_checks:
- for rule in c.param_checks:
- print(f" gdb_assert ({rule});", file=f)
- print(" if (gdbarch_debug >= 2)", file=f)
- print(
- f""" gdb_printf (gdb_stdlog, "gdbarch_{c.name} called\\n");""",
- file=f,
- )
- print(" ", file=f, end="")
- if c.type != "void":
- if c.result_checks:
- print("auto result = ", file=f, end="")
- else:
- print("return ", file=f, end="")
- print(f"gdbarch->{c.name} ({c.actuals()});", file=f)
- if c.type != "void" and c.result_checks:
- for rule in c.result_checks:
- print(f" gdb_assert ({rule});", file=f)
- print(" return result;", file=f)
- print("}", file=f)
+ print(" ", file=f, end="")
+ if c.type != "void":
+ if c.result_checks:
+ print("auto result = ", file=f, end="")
+ else:
+ print("return ", file=f, end="")
+ print(f"gdbarch->{c.name} ({c.actuals()});", file=f)
+ if c.type != "void" and c.result_checks:
+ for rule in c.result_checks:
+ print(f" gdb_assert ({rule});", file=f)
+ print(" return result;", file=f)
+ print("}", file=f)
print(file=f)
print("void", file=f)
setter_name = f"set_gdbarch_{c.name}"