From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 7CBB73856DC2; Thu, 6 Oct 2022 19:12:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7CBB73856DC2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665083549; bh=hss6tT1qcnM6VFxjsuEzB1YI6Ol8FUolvl4itm1nA6w=; h=From:To:Subject:Date:From; b=xGzKQ/kZ1OHdQ0h2Bf7qPwk/+cvuLkbBxDqZi9eq2c/CcRi9AyKC0doH8UwCqo0gq 3whe4tpAOf7uYarDyjK26JkI5v/aBK73cTeVV8dekEUOSUtm597yALFglTKrLpyLmJ 5h41emoM8gogkB5rbPU42gl09LMiMwBrvytW34xc= 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] Fix indentation in riscv-tdep.c X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 60c90d8c6d4b8345b41ab6a0b4d5169d5f78edb3 X-Git-Newrev: 0bce60ac7f17996dd39ed8b6a530e8e6c6936ed8 Message-Id: <20221006191229.7CBB73856DC2@sourceware.org> Date: Thu, 6 Oct 2022 19:12:29 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D0bce60ac7f17= 996dd39ed8b6a530e8e6c6936ed8 commit 0bce60ac7f17996dd39ed8b6a530e8e6c6936ed8 Author: Tom Tromey Date: Thu Oct 6 11:26:38 2022 -0600 Fix indentation in riscv-tdep.c =20 This just fixes some indentation in riscv-tdep.c. Diff: --- gdb/riscv-tdep.c | 306 +++++++++++++++++++++++++++------------------------= ---- 1 file changed, 153 insertions(+), 153 deletions(-) diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 63ebed4ff19..feca17d9141 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -3241,173 +3241,173 @@ riscv_return_value (struct gdbarch *gdbarch, =20 if (readbuf !=3D nullptr || writebuf !=3D nullptr) { - unsigned int arg_len; - struct value *abi_val; - gdb_byte *old_readbuf =3D nullptr; - int regnum; - - /* We only do one thing at a time. */ - gdb_assert (readbuf =3D=3D nullptr || writebuf =3D=3D nullptr); - - /* In some cases the argument is not returned as the declared type, - and we need to cast to or from the ABI type in order to - correctly access the argument. When writing to the machine we - do the cast here, when reading from the machine the cast occurs - later, after extracting the value. As the ABI type can be - larger than the declared type, then the read or write buffers - passed in might be too small. Here we ensure that we are using - buffers of sufficient size. */ - if (writebuf !=3D nullptr) + unsigned int arg_len; + struct value *abi_val; + gdb_byte *old_readbuf =3D nullptr; + int regnum; + + /* We only do one thing at a time. */ + gdb_assert (readbuf =3D=3D nullptr || writebuf =3D=3D nullptr); + + /* In some cases the argument is not returned as the declared type, + and we need to cast to or from the ABI type in order to + correctly access the argument. When writing to the machine we + do the cast here, when reading from the machine the cast occurs + later, after extracting the value. As the ABI type can be + larger than the declared type, then the read or write buffers + passed in might be too small. Here we ensure that we are using + buffers of sufficient size. */ + if (writebuf !=3D nullptr) + { + struct value *arg_val; + + if (is_fixed_point_type (arg_type)) + { + /* Convert the argument to the type used to pass + the return value, but being careful to preserve + the fact that the value needs to be returned + unscaled. */ + gdb_mpz unscaled; + + unscaled.read (gdb::make_array_view (writebuf, + arg_type->length ()), + type_byte_order (arg_type), + arg_type->is_unsigned ()); + abi_val =3D allocate_value (info.type); + unscaled.write (value_contents_raw (abi_val), + type_byte_order (info.type), + info.type->is_unsigned ()); + } + else + { + arg_val =3D value_from_contents (arg_type, writebuf); + abi_val =3D value_cast (info.type, arg_val); + } + writebuf =3D value_contents_raw (abi_val).data (); + } + else + { + abi_val =3D allocate_value (info.type); + old_readbuf =3D readbuf; + readbuf =3D value_contents_raw (abi_val).data (); + } + arg_len =3D info.type->length (); + + switch (info.argloc[0].loc_type) + { + /* Return value in register(s). */ + case riscv_arg_info::location::in_reg: { - struct value *arg_val; + regnum =3D info.argloc[0].loc_data.regno; + gdb_assert (info.argloc[0].c_length <=3D arg_len); + gdb_assert (info.argloc[0].c_length + <=3D register_size (gdbarch, regnum)); =20 - if (is_fixed_point_type (arg_type)) + if (readbuf) { - /* Convert the argument to the type used to pass - the return value, but being careful to preserve - the fact that the value needs to be returned - unscaled. */ - gdb_mpz unscaled; - - unscaled.read (gdb::make_array_view (writebuf, - arg_type->length ()), - type_byte_order (arg_type), - arg_type->is_unsigned ()); - abi_val =3D allocate_value (info.type); - unscaled.write (value_contents_raw (abi_val), - type_byte_order (info.type), - info.type->is_unsigned ()); + gdb_byte *ptr =3D readbuf + info.argloc[0].c_offset; + regcache->cooked_read_part (regnum, 0, + info.argloc[0].c_length, + ptr); } - else + + if (writebuf) { - arg_val =3D value_from_contents (arg_type, writebuf); - abi_val =3D value_cast (info.type, arg_val); + const gdb_byte *ptr =3D writebuf + info.argloc[0].c_offset; + riscv_regcache_cooked_write (regnum, ptr, + info.argloc[0].c_length, + regcache, call_info.flen); + } + + /* A return value in register can have a second part in a + second register. */ + if (info.argloc[1].c_length > 0) + { + switch (info.argloc[1].loc_type) + { + case riscv_arg_info::location::in_reg: + regnum =3D info.argloc[1].loc_data.regno; + + gdb_assert ((info.argloc[0].c_length + + info.argloc[1].c_length) <=3D arg_len); + gdb_assert (info.argloc[1].c_length + <=3D register_size (gdbarch, regnum)); + + if (readbuf) + { + readbuf +=3D info.argloc[1].c_offset; + regcache->cooked_read_part (regnum, 0, + info.argloc[1].c_length, + readbuf); + } + + if (writebuf) + { + const gdb_byte *ptr + =3D writebuf + info.argloc[1].c_offset; + riscv_regcache_cooked_write + (regnum, ptr, info.argloc[1].c_length, + regcache, call_info.flen); + } + break; + + case riscv_arg_info::location::by_ref: + case riscv_arg_info::location::on_stack: + default: + error (_("invalid argument location")); + break; + } } - writebuf =3D value_contents_raw (abi_val).data (); - } - else - { - abi_val =3D allocate_value (info.type); - old_readbuf =3D readbuf; - readbuf =3D value_contents_raw (abi_val).data (); } - arg_len =3D info.type->length (); + break; =20 - switch (info.argloc[0].loc_type) + /* Return value by reference will have its address in A0. */ + case riscv_arg_info::location::by_ref: { - /* Return value in register(s). */ - case riscv_arg_info::location::in_reg: - { - regnum =3D info.argloc[0].loc_data.regno; - gdb_assert (info.argloc[0].c_length <=3D arg_len); - gdb_assert (info.argloc[0].c_length - <=3D register_size (gdbarch, regnum)); - - if (readbuf) - { - gdb_byte *ptr =3D readbuf + info.argloc[0].c_offset; - regcache->cooked_read_part (regnum, 0, - info.argloc[0].c_length, - ptr); - } + ULONGEST addr; + + regcache_cooked_read_unsigned (regcache, RISCV_A0_REGNUM, + &addr); + if (readbuf !=3D nullptr) + read_memory (addr, readbuf, info.length); + if (writebuf !=3D nullptr) + write_memory (addr, writebuf, info.length); + } + break; =20 - if (writebuf) - { - const gdb_byte *ptr =3D writebuf + info.argloc[0].c_offset; - riscv_regcache_cooked_write (regnum, ptr, - info.argloc[0].c_length, - regcache, call_info.flen); - } + case riscv_arg_info::location::on_stack: + default: + error (_("invalid argument location")); + break; + } =20 - /* A return value in register can have a second part in a - second register. */ - if (info.argloc[1].c_length > 0) - { - switch (info.argloc[1].loc_type) - { - case riscv_arg_info::location::in_reg: - regnum =3D info.argloc[1].loc_data.regno; - - gdb_assert ((info.argloc[0].c_length - + info.argloc[1].c_length) <=3D arg_len); - gdb_assert (info.argloc[1].c_length - <=3D register_size (gdbarch, regnum)); - - if (readbuf) - { - readbuf +=3D info.argloc[1].c_offset; - regcache->cooked_read_part (regnum, 0, - info.argloc[1].c_length, - readbuf); - } - - if (writebuf) - { - const gdb_byte *ptr - =3D writebuf + info.argloc[1].c_offset; - riscv_regcache_cooked_write - (regnum, ptr, info.argloc[1].c_length, - regcache, call_info.flen); - } - break; - - case riscv_arg_info::location::by_ref: - case riscv_arg_info::location::on_stack: - default: - error (_("invalid argument location")); - break; - } - } - } - break; + /* This completes the cast from abi type back to the declared type + in the case that we are reading from the machine. See the + comment at the head of this block for more details. */ + if (readbuf !=3D nullptr) + { + struct value *arg_val; =20 - /* Return value by reference will have its address in A0. */ - case riscv_arg_info::location::by_ref: + if (is_fixed_point_type (arg_type)) { - ULONGEST addr; - - regcache_cooked_read_unsigned (regcache, RISCV_A0_REGNUM, - &addr); - if (readbuf !=3D nullptr) - read_memory (addr, readbuf, info.length); - if (writebuf !=3D nullptr) - write_memory (addr, writebuf, info.length); + /* Convert abi_val to the actual return type, but + being careful to preserve the fact that abi_val + is unscaled. */ + gdb_mpz unscaled; + + unscaled.read (value_contents (abi_val), + type_byte_order (info.type), + info.type->is_unsigned ()); + arg_val =3D allocate_value (arg_type); + unscaled.write (value_contents_raw (arg_val), + type_byte_order (arg_type), + arg_type->is_unsigned ()); } - break; - - case riscv_arg_info::location::on_stack: - default: - error (_("invalid argument location")); - break; - } - - /* This completes the cast from abi type back to the declared type - in the case that we are reading from the machine. See the - comment at the head of this block for more details. */ - if (readbuf !=3D nullptr) - { - struct value *arg_val; - - if (is_fixed_point_type (arg_type)) - { - /* Convert abi_val to the actual return type, but - being careful to preserve the fact that abi_val - is unscaled. */ - gdb_mpz unscaled; - - unscaled.read (value_contents (abi_val), - type_byte_order (info.type), - info.type->is_unsigned ()); - arg_val =3D allocate_value (arg_type); - unscaled.write (value_contents_raw (arg_val), - type_byte_order (arg_type), - arg_type->is_unsigned ()); - } - else - arg_val =3D value_cast (arg_type, abi_val); - memcpy (old_readbuf, value_contents_raw (arg_val).data (), - arg_type->length ()); - } + else + arg_val =3D value_cast (arg_type, abi_val); + memcpy (old_readbuf, value_contents_raw (arg_val).data (), + arg_type->length ()); + } } =20 switch (info.argloc[0].loc_type)