From: Richard Henderson <richard.henderson@linaro.org>
To: "Ilya Leoshkevich" <iii@linux.ibm.com>,
"Laurent Vivier" <laurent@vivier.eu>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 3/5] target/i386/gdbstub: Factor out gdb_get_reg() and gdb_write_reg()
Date: Sun, 8 Sep 2024 13:57:10 -0700 [thread overview]
Message-ID: <a1ac975f-6d79-43bd-8c2e-68a2fbb9c3b2@linaro.org> (raw)
In-Reply-To: <20240802095942.34565-4-iii@linux.ibm.com>
On 8/2/24 02:59, Ilya Leoshkevich wrote:
> @@ -248,6 +253,22 @@ static int x86_cpu_gdb_load_seg(X86CPU *cpu, X86Seg sreg, uint8_t *mem_buf)
> return 4;
> }
>
> +static int gdb_write_reg(CPUX86State *env, uint8_t *mem_buf, target_ulong *val)
> +{
> + if (TARGET_LONG_BITS == 64) {
> + if (env->hflags & HF_CS64_MASK) {
> + *val = ldq_p(mem_buf);
> + } else {
> + *val = ldq_p(mem_buf) & 0xffffffffUL;
> + }
> + return 8;
> + } else {
> + *val &= ~0xffffffffUL;
> + *val |= (uint32_t)ldl_p(mem_buf);
> + return 4;
> + }
> +}
> +
> int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
> {
> X86CPU *cpu = X86_CPU(cs);
> @@ -288,18 +309,7 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
> } else {
> switch (n) {
> case IDX_IP_REG:
> - if (TARGET_LONG_BITS == 64) {
> - if (env->hflags & HF_CS64_MASK) {
> - env->eip = ldq_p(mem_buf);
> - } else {
> - env->eip = ldq_p(mem_buf) & 0xffffffffUL;
> - }
> - return 8;
> - } else {
> - env->eip &= ~0xffffffffUL;
> - env->eip |= (uint32_t)ldl_p(mem_buf);
> - return 4;
> - }
> + return gdb_write_reg(env, mem_buf, &env->eip);
Existing bug, but the insert in the !(TARGET_LONG_BITS == 64) case is silly.
Because TARGET_LONG_BITS == 32, target_ulong eip is 32-bits, so the "insert" doesn't
really insert anything.
Otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
next prev parent reply other threads:[~2024-09-08 20:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-02 9:59 [PATCH 0/4] linux-user/i386: Emulate orig_ax Ilya Leoshkevich
2024-08-02 9:59 ` [PATCH 1/5] include/exec: Introduce env_cpu_const() Ilya Leoshkevich
2024-09-08 19:46 ` Richard Henderson
2024-08-02 9:59 ` [PATCH 2/5] linux-user/i386: Emulate orig_ax Ilya Leoshkevich
2024-09-08 20:50 ` Richard Henderson
2024-08-02 9:59 ` [PATCH 3/5] target/i386/gdbstub: Factor out gdb_get_reg() and gdb_write_reg() Ilya Leoshkevich
2024-09-08 20:57 ` Richard Henderson [this message]
2024-08-02 9:59 ` [PATCH 4/5] target/i386/gdbstub: Expose orig_ax Ilya Leoshkevich
2024-09-08 21:00 ` Richard Henderson
2024-08-02 9:59 ` [PATCH 5/5] tests/tcg: Run test-proc-mappings.py on i386 Ilya Leoshkevich
2024-08-02 10:40 ` Alex Bennée
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=a1ac975f-6d79-43bd-8c2e-68a2fbb9c3b2@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=iii@linux.ibm.com \
--cc=laurent@vivier.eu \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.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 NNTP newsgroup(s).