From: Peter Maydell <peter.maydell@linaro.org>
To: liguang <lig.fnst@cn.fujitsu.com>
Cc: qemu-devel@nongnu.org, imammedo@redhat.com, ehabkost@redhat.com,
afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH 3/3] target-i386:refactor check_hw_breakpoints function
Date: Thu, 29 Nov 2012 11:31:38 +0000 [thread overview]
Message-ID: <CAFEAcA8d4Dy0rrtFvbvWH86Q-ezPMos02x9O3wKA4N8VRJRJtA@mail.gmail.com> (raw)
In-Reply-To: <1354159971-6720-3-git-send-email-lig.fnst@cn.fujitsu.com>
On 29 November 2012 03:32, liguang <lig.fnst@cn.fujitsu.com> wrote:
> Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
> ---
> target-i386/helper.c | 28 ++++++++++++++++++++--------
> 1 files changed, 20 insertions(+), 8 deletions(-)
>
> diff --git a/target-i386/helper.c b/target-i386/helper.c
> index 9ca52a7..a506df0 100644
> --- a/target-i386/helper.c
> +++ b/target-i386/helper.c
> @@ -1012,22 +1012,34 @@ void hw_breakpoint_remove(CPUX86State *env, int index)
> int check_hw_breakpoints(CPUX86State *env, int force_dr6_update)
> {
> target_ulong dr6;
> - int reg, type;
> + int index;
> int hit_enabled = 0;
>
> dr6 = env->dr[6] & ~0xf;
> - for (reg = 0; reg < MAX_BP; reg++) {
> - type = hw_breakpoint_type(env->dr[7], reg);
> - if ((type == 0 && env->dr[reg] == env->eip) ||
> - ((type & 1) && env->cpu_watchpoint[reg] &&
> - (env->cpu_watchpoint[reg]->flags & BP_WATCHPOINT_HIT))) {
> - dr6 |= 1 << reg;
> - if (hw_breakpoint_enabled(env->dr[7], reg))
> + for (index = 0; index < MAX_BP; index++) {
> + switch (hw_breakpoint_type(env->dr[7], index)){
> + case BP_INST:
> + if (env->dr[index] != env->eip)
> + break;
> + goto enable_hit;
> + case BP_DATA_WR:
> + case BP_DATA_RW:
> + if (!env->cpu_watchpoint[index])
> + break;
> + if (!(env->cpu_watchpoint[index]->flags & BP_WATCHPOINT_HIT))
> + break;
> + enable_hit:
> + dr6 |= 1 << index;
> + if (hw_breakpoint_enabled(env->dr[7], index))
> hit_enabled = 1;
> + break;
> + case BP_IO_RW:
> + break;
> }
If you have to resort to gotos and fallthroughs in
a switch statement, I don't think this is actually
clearer than the existing code...
(Also it has coding style issues, use scripts/checkpatch.pl.)
-- PMM
next prev parent reply other threads:[~2012-11-29 11:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-29 3:32 [Qemu-devel] [PATCH 1/3] define name for some fields of dr7 liguang
2012-11-29 3:32 ` [Qemu-devel] [PATCH 2/3] use dr7's bit name for breakpoint liguang
2012-11-29 11:28 ` Peter Maydell
2012-12-03 1:30 ` li guang
2012-11-29 3:32 ` [Qemu-devel] [PATCH 3/3] target-i386:refactor check_hw_breakpoints function liguang
2012-11-29 11:31 ` Peter Maydell [this message]
2012-11-29 4:08 ` [Qemu-devel] [PATCH 1/3] define name for some fields of dr7 li guang
2012-11-29 11:24 ` Peter Maydell
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=CAFEAcA8d4Dy0rrtFvbvWH86Q-ezPMos02x9O3wKA4N8VRJRJtA@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=afaerber@suse.de \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=lig.fnst@cn.fujitsu.com \
--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).