From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7873) id AA0B639484B8; Mon, 9 May 2022 14:35:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA0B639484B8 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tiezhu Yang To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: LoongArch: Implement the return_value gdbarch method X-Act-Checkin: binutils-gdb X-Git-Author: Tiezhu Yang X-Git-Refname: refs/heads/master X-Git-Oldrev: 205d0542821c91e04e0ed174d8862f486a076950 X-Git-Newrev: 0b8c95579f78b352cd48cc14e48ea842c64a7a5a Message-Id: <20220509143525.AA0B639484B8@sourceware.org> Date: Mon, 9 May 2022 14:35:25 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 May 2022 14:35:25 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D0b8c95579f78= b352cd48cc14e48ea842c64a7a5a commit 0b8c95579f78b352cd48cc14e48ea842c64a7a5a Author: Tiezhu Yang Date: Mon May 9 16:26:47 2022 +0800 gdb: LoongArch: Implement the return_value gdbarch method =20 When execute the following command on LoongArch: =20 make check-gdb TESTS=3D"gdb.base/async.exp" =20 there exist the following failed testcases: =20 FAIL: gdb.base/async.exp: finish& (timeout) FAIL: gdb.base/async.exp: jump& (timeout) FAIL: gdb.base/async.exp: until& (timeout) FAIL: gdb.base/async.exp: set exec-done-display off (GDB internal err= or) =20 we can see the following messages in gdb/testsuite/gdb.log: =20 finish& Run till exit from #0 foo () at /home/loongson/gdb.git/gdb/testsuite= /gdb.base/async.c:9 (gdb) /home/loongson/gdb.git/gdb/gdbarch.c:2646: internal-error: gdba= rch_return_value: Assertion `gdbarch->return_value !=3D NULL' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. =20 In order to fix the above failed testcases, implement the return_value gdbarch method on LoongArch. =20 Signed-off-by: Tiezhu Yang Diff: --- gdb/loongarch-tdep.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/gdb/loongarch-tdep.c b/gdb/loongarch-tdep.c index e30ef8084da..28f04094f64 100644 --- a/gdb/loongarch-tdep.c +++ b/gdb/loongarch-tdep.c @@ -247,6 +247,36 @@ static const struct frame_unwind loongarch_frame_unwin= d =3D { /*.prev_arch =3D*/nullptr, }; =20 +/* Implement the return_value gdbarch method for LoongArch. */ + +static enum return_value_convention +loongarch_return_value (struct gdbarch *gdbarch, struct value *function, + struct type *type, struct regcache *regcache, + gdb_byte *readbuf, const gdb_byte *writebuf) +{ + loongarch_gdbarch_tdep *tdep =3D (loongarch_gdbarch_tdep *) gdbarch_tdep= (gdbarch); + auto regs =3D tdep->regs; + int len =3D TYPE_LENGTH (type); + int regnum =3D -1; + + /* See if our value is returned through a register. If it is, then + store the associated register number in REGNUM. */ + switch (type->code ()) + { + case TYPE_CODE_INT: + regnum =3D regs.r + 4; + break; + } + + /* Extract the return value from the register where it was stored. */ + if (readbuf) + regcache->raw_read_part (regnum, 0, len, readbuf); + if (writebuf) + regcache->raw_write_part (regnum, 0, len, writebuf); + + return RETURN_VALUE_REGISTER_CONVENTION; +} + /* Implement the "dwarf2_reg_to_regnum" gdbarch method. */ =20 static int @@ -418,6 +448,9 @@ loongarch_gdbarch_init (struct gdbarch_info info, struc= t gdbarch_list *arches) /* Finalise the target description registers. */ tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data)); =20 + /* Return value info */ + set_gdbarch_return_value (gdbarch, loongarch_return_value); + /* Advance PC across function entry code. */ set_gdbarch_skip_prologue (gdbarch, loongarch_skip_prologue);