From: Andrew Burgess <andrew.burgess@embecosm.com>
To: John Baldwin <jhb@freebsd.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 4/8] regcache: Zero-extend small registers described by a register map.
Date: Tue, 19 Oct 2021 09:36:34 +0100 [thread overview]
Message-ID: <20211019083634.GD1693939@embecosm.com> (raw)
In-Reply-To: <20210714140741.6460-5-jhb@FreeBSD.org>
* John Baldwin <jhb@FreeBSD.org> [2021-07-14 07:07:37 -0700]:
> When registers are supplied via regcache_supply_register from a register
> block described by a register map, registers may be stored in slots smaller
> than GDB's native register size (e.g. x86 segment registers are 16 bits,
> but the GDB registers for those are 32-bits). regcache_collect_regset
> is careful to zero-extend slots larger than a register size, but
> regcache_supply_regset just used regcache::raw_supply_part and did not
> initialize the upper bytes of a register value.
>
> trad_frame_set_reg_regmap assumes these semantics (zero-extending
> short registers) as I had misread the implementation of
> regcache::transfer_regset and assumed it zero-extended short
> registers. In my specific use case (x86 segment registers stored as
> 16-bit values), I need the semantics of zero-extending a register
> value in a smaller slot.
I don't claim to know if anyone relies on the old behaviour of
transfer_regset_register, but the change you propose seems reasonable.
However, the second paragraph of your commit message really confuses
me.
It seems to say that a mistake was made in trad_frame_set_reg_regmap,
and so transfer_regset_register should change, then you just jump to
saying you need the zero extend. I don't really understand the
connection between all these ideas.
Also, when you say "In my specific use case .... I need the semantics
of zero-extending ...", but you don't say what your use case is, so if
I wanted to look at which piece of code is calling this for your
specific use case, I can't...
Thanks,
Andrew
> ---
> gdb/regcache.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/regcache.c b/gdb/regcache.c
> index 672da0556f..396923c8a5 100644
> --- a/gdb/regcache.c
> +++ b/gdb/regcache.c
> @@ -1169,7 +1169,12 @@ regcache::transfer_regset_register (struct regcache *out_regcache, int regnum,
> memset (out_buf + offs + reg_size, 0, slot_size - reg_size);
> }
> else if (in_buf != nullptr)
> - out_regcache->raw_supply_part (regnum, 0, reg_size, in_buf + offs);
> + {
> + /* Zero-extend the register value if the slot is smaller than the register. */
> + if (slot_size < register_size (gdbarch, regnum))
> + out_regcache->raw_supply_zeroed (regnum);
> + out_regcache->raw_supply_part (regnum, 0, reg_size, in_buf + offs);
> + }
> else
> {
> /* Invalidate the register. */
> --
> 2.31.1
>
next prev parent reply other threads:[~2021-10-19 8:36 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-14 14:07 [PATCH 0/8] Switch FreeBSD x86 to using register maps for GP registers John Baldwin
2021-07-14 14:07 ` [PATCH 1/8] Remove vestigal FreeBSD/i386 3.x support John Baldwin
2021-07-14 14:07 ` [PATCH 2/8] Remove support for pre-5.0 FreeBSD/i386 signal trampolines John Baldwin
2021-07-14 14:07 ` [PATCH 3/8] FreeBSD x86: Remove fallback for detecting signal trampolines by address John Baldwin
2021-07-14 14:07 ` [PATCH 4/8] regcache: Zero-extend small registers described by a register map John Baldwin
2021-10-19 8:36 ` Andrew Burgess [this message]
2021-10-19 16:31 ` John Baldwin
2021-10-26 21:17 ` John Baldwin
2021-12-22 21:20 ` John Baldwin
2022-01-26 18:43 ` John Baldwin
2022-01-28 15:43 ` Andrew Burgess
2021-07-14 14:07 ` [PATCH 5/8] Use register maps for gp regsets on FreeBSD/x86 core dumps John Baldwin
2021-07-14 14:07 ` [PATCH 6/8] FreeBSD x86: Use tramp-frame for signal frames John Baldwin
2021-07-14 14:07 ` [PATCH 7/8] fbsd-nat: Return a bool from fetch_register_set and store_register_set John Baldwin
2021-07-14 14:07 ` [PATCH 8/8] FreeBSD x86 nat: Use register maps for GP register sets John Baldwin
2021-08-10 15:56 ` [PATCH 0/8] Switch FreeBSD x86 to using register maps for GP registers John Baldwin
2021-09-14 15:43 ` [PING] " John Baldwin
2021-10-18 20:46 ` John Baldwin
2022-01-28 15:44 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211019083634.GD1693939@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
--cc=jhb@freebsd.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).