From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 6808A3858C2D; Tue, 3 Jan 2023 16:44:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6808A3858C2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1672764272; bh=+/bBjPQTIEk9yuuyKc6SSqpn/AcDLWhYRE9kHczFGXk=; h=From:To:Subject:Date:From; b=kIflKkZhKqOGY1vy6ylc2iNVgH53RAYLwFJ80emUl3wLv7gZ1rUDkPS2S84hvJTy2 KkoMdf/8rupy0T0MWi7sV4W2YpYNYKpZImcpHXrRy7BfCNSVWPRSwyj8uy1zL8ii2z VTuCNyun0XkzsGGRk3EDputLae962m1u3xLOyQ1I= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Don't emit gdbarch_return_value X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 4e1d2f5814b29048d1dd1cea2cb50570e6c8f1f8 X-Git-Newrev: 43f2b4583f95775b2c0fefd71aab4c773c4f7a7e Message-Id: <20230103164432.6808A3858C2D@sourceware.org> Date: Tue, 3 Jan 2023 16:44:32 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D43f2b4583f95= 775b2c0fefd71aab4c773c4f7a7e commit 43f2b4583f95775b2c0fefd71aab4c773c4f7a7e Author: Tom Tromey Date: Wed Sep 7 08:58:18 2022 -0600 Don't emit gdbarch_return_value =20 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). =20 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. Diff: --- gdb/arch-utils.c | 36 ++++++++++++------------ gdb/gdbarch-components.py | 6 ++++ gdb/gdbarch-gen.h | 1 - gdb/gdbarch.c | 10 ------- gdb/gdbarch.py | 70 +++++++++++++++++++++++++------------------= ---- 5 files changed, 61 insertions(+), 62 deletions(-) diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 3ca193085cb..e8587607129 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -1098,24 +1098,6 @@ default_get_return_buf_addr (struct type *val_type, = frame_info_ptr cur_frame) return 0; } =20 -enum return_value_convention -default_gdbarch_return_value - (struct gdbarch *gdbarch, struct value *function, struct type *valtyp= e, - struct regcache *regcache, struct value **read_value, - const gdb_byte *writebuf) -{ - gdb_byte *readbuf =3D nullptr; - - if (read_value !=3D nullptr) - { - *read_value =3D allocate_value (valtype); - readbuf =3D value_contents_raw (*read_value).data (); - } - - return gdbarch_return_value (gdbarch, function, valtype, regcache, - readbuf, writebuf); -} - /* Non-zero if we want to trace architecture code. */ =20 #ifndef GDBARCH_DEBUG @@ -1186,6 +1168,24 @@ pstring_list (const char *const *list) =20 #include "gdbarch.c" =20 +enum return_value_convention +default_gdbarch_return_value + (struct gdbarch *gdbarch, struct value *function, struct type *valtyp= e, + struct regcache *regcache, struct value **read_value, + const gdb_byte *writebuf) +{ + gdb_byte *readbuf =3D nullptr; + + if (read_value !=3D nullptr) + { + *read_value =3D allocate_value (valtype); + readbuf =3D value_contents_raw (*read_value).data (); + } + + return gdbarch->return_value (gdbarch, function, valtype, regcache, + readbuf, writebuf); +} + obstack *gdbarch_obstack (gdbarch *arch) { return &arch->obstack; diff --git a/gdb/gdbarch-components.py b/gdb/gdbarch-components.py index 0e1ca40102d..76ad2832d8a 100644 --- a/gdb/gdbarch-components.py +++ b/gdb/gdbarch-components.py @@ -113,6 +113,9 @@ # 'result' can be used to reference the result of the function/method # implementation. The 'result_checks' can only be used if the 'type' # of this Function/Method is not 'void'. +# +# * "implement" - optional, a boolean. If True (the default), a +# wrapper function for this function will be emitted. =20 Info( type=3D"const struct bfd_arch_info *", @@ -868,6 +871,9 @@ method can properly handle variably-sized types. ("const gdb_byte *", "writebuf"), ], invalid=3DFalse, + # We don't want to accidentally introduce calls to this, as gdb + # should only ever call return_value_new (see below). + implement=3DFalse, ) =20 Method( diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h index 128efa10bef..32b2d96fbe0 100644 --- a/gdb/gdbarch-gen.h +++ b/gdb/gdbarch-gen.h @@ -439,7 +439,6 @@ extern void set_gdbarch_integer_to_address (struct gdba= rch *gdbarch, gdbarch_int method can properly handle variably-sized types. */ =20 typedef enum return_value_convention (gdbarch_return_value_ftype) (struct = gdbarch *gdbarch, struct value *function, struct type *valtype, struct regc= ache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf); -extern enum return_value_convention gdbarch_return_value (struct gdbarch *= gdbarch, struct value *function, struct type *valtype, struct regcache *reg= cache, gdb_byte *readbuf, const gdb_byte *writebuf); extern void set_gdbarch_return_value (struct gdbarch *gdbarch, gdbarch_ret= urn_value_ftype *return_value); =20 /* Return the return-value convention that will be used by FUNCTION diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 353040cf020..41b71ae1b4c 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -2571,16 +2571,6 @@ set_gdbarch_integer_to_address (struct gdbarch *gdba= rch, gdbarch->integer_to_address =3D integer_to_address; } =20 -enum return_value_convention -gdbarch_return_value (struct gdbarch *gdbarch, struct value *function, str= uct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_= byte *writebuf) -{ - gdb_assert (gdbarch !=3D NULL); - gdb_assert (gdbarch->return_value !=3D NULL); - if (gdbarch_debug >=3D 2) - gdb_printf (gdb_stdlog, "gdbarch_return_value called\n"); - return gdbarch->return_value (gdbarch, function, valtype, regcache, read= buf, writebuf); -} - void set_gdbarch_return_value (struct gdbarch *gdbarch, gdbarch_return_value_ftype return_value) diff --git a/gdb/gdbarch.py b/gdb/gdbarch.py index a1b665f0b5f..d2bf86039d1 100755 --- a/gdb/gdbarch.py +++ b/gdb/gdbarch.py @@ -124,6 +124,7 @@ class Function(_Component): printer=3DNone, param_checks=3DNone, result_checks=3DNone, + implement=3DTrue, ): super().__init__( comment=3Dcomment, @@ -137,6 +138,7 @@ class Function(_Component): params=3Dparams, param_checks=3Dparam_checks, result_checks=3Dresult_checks, + implement=3Dimplement, ) =20 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=3Df, ) - print( - f"extern {c.type} gdbarch_{c.name} ({c.set_list()});", - file=3Df, - ) + if c.implement: + print( + f"extern {c.type} gdbarch_{c.name} ({c.set_list()});", + file=3Df, + ) print( f"extern void set_gdbarch_{c.name} (struct gdbarch *gdbarc= h, {c.ftype()} *{c.name});", file=3Df, @@ -445,38 +448,39 @@ with open("gdbarch.c", "w") as f: print(f" return {c.get_predicate()};", file=3Df) print("}", file=3Df) if isinstance(c, Function): - print(file=3Df) - print(f"{c.type}", file=3Df) - print(f"gdbarch_{c.name} ({c.set_list()})", file=3Df) - print("{", file=3Df) - print(" gdb_assert (gdbarch !=3D NULL);", file=3Df) - print(f" gdb_assert (gdbarch->{c.name} !=3D NULL);", file=3Df) - if c.predicate and c.predefault: - # Allow a call to a function with a predicate. + if c.implement: + print(file=3Df) + print(f"{c.type}", file=3Df) + print(f"gdbarch_{c.name} ({c.set_list()})", file=3Df) + print("{", file=3Df) + print(" gdb_assert (gdbarch !=3D NULL);", file=3Df) + print(f" gdb_assert (gdbarch->{c.name} !=3D NULL);", file= =3Df) + 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=3Df, + ) + if c.param_checks: + for rule in c.param_checks: + print(f" gdb_assert ({rule});", file=3Df) + print(" if (gdbarch_debug >=3D 2)", file=3Df) print( - f" /* Do not check predicate: {c.get_predicate()}, al= low call. */", + f""" gdb_printf (gdb_stdlog, "gdbarch_{c.name} call= ed\\n");""", file=3Df, ) - if c.param_checks: - for rule in c.param_checks: - print(f" gdb_assert ({rule});", file=3Df) - print(" if (gdbarch_debug >=3D 2)", file=3Df) - print( - f""" gdb_printf (gdb_stdlog, "gdbarch_{c.name} called\\= n");""", - file=3Df, - ) - print(" ", file=3Df, end=3D"") - if c.type !=3D "void": - if c.result_checks: - print("auto result =3D ", file=3Df, end=3D"") - else: - print("return ", file=3Df, end=3D"") - print(f"gdbarch->{c.name} ({c.actuals()});", file=3Df) - if c.type !=3D "void" and c.result_checks: - for rule in c.result_checks: - print(f" gdb_assert ({rule});", file=3Df) - print(" return result;", file=3Df) - print("}", file=3Df) + print(" ", file=3Df, end=3D"") + if c.type !=3D "void": + if c.result_checks: + print("auto result =3D ", file=3Df, end=3D"") + else: + print("return ", file=3Df, end=3D"") + print(f"gdbarch->{c.name} ({c.actuals()});", file=3Df) + if c.type !=3D "void" and c.result_checks: + for rule in c.result_checks: + print(f" gdb_assert ({rule});", file=3Df) + print(" return result;", file=3Df) + print("}", file=3Df) print(file=3Df) print("void", file=3Df) setter_name =3D f"set_gdbarch_{c.name}"