[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v13 07/26] target/i386: [tcg] Port to breakpoint_che
From: |
Lluís Vilanova |
Subject: |
[Qemu-devel] [PATCH v13 07/26] target/i386: [tcg] Port to breakpoint_check |
Date: |
Fri, 14 Jul 2017 11:41:48 +0300 |
User-agent: |
StGit/0.17.1-dirty |
Incrementally paves the way towards using the generic instruction translation
loop.
Signed-off-by: Lluís Vilanova <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Reviewed-by: Emilio G. Cota <address@hidden>
---
target/i386/translate.c | 45 +++++++++++++++++++++++++++++++++------------
1 file changed, 33 insertions(+), 12 deletions(-)
diff --git a/target/i386/translate.c b/target/i386/translate.c
index a4b9e5628f..d3df91041f 100644
--- a/target/i386/translate.c
+++ b/target/i386/translate.c
@@ -8455,6 +8455,25 @@ static void i386_tr_insn_start(DisasContextBase *dcbase,
CPUState *cpu)
tcg_gen_insn_start(dc->base.pc_next, dc->cc_op);
}
+static bool i386_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu,
+ const CPUBreakpoint *bp)
+{
+ DisasContext *dc = container_of(dcbase, DisasContext, base);
+ /* If RF is set, suppress an internally generated breakpoint. */
+ int flags = dc->base.tb->flags & HF_RF_MASK ? BP_GDB : BP_ANY;
+ if (bp->flags & flags) {
+ gen_debug(dc, dc->base.pc_next - dc->cs_base);
+ /* The address covered by the breakpoint must be included in
+ [tb->pc, tb->pc + tb->size) in order to for it to be
+ properly cleared -- thus we increment the PC here so that
+ the logic setting tb->size below does the right thing. */
+ dc->base.pc_next += 1;
+ return true;
+ } else {
+ return false;
+ }
+}
+
/* generate intermediate code for basic block 'tb'. */
void gen_intermediate_code(CPUState *cs, TranslationBlock *tb)
{
@@ -8485,18 +8504,21 @@ void gen_intermediate_code(CPUState *cs,
TranslationBlock *tb)
i386_tr_insn_start(&dc->base, cs);
num_insns++;
- /* If RF is set, suppress an internally generated breakpoint. */
- if (unlikely(cpu_breakpoint_test(cs, dc->base.pc_next,
- tb->flags & HF_RF_MASK
- ? BP_GDB : BP_ANY))) {
- gen_debug(dc, dc->base.pc_next - dc->cs_base);
- /* The address covered by the breakpoint must be included in
- [tb->pc, tb->pc + tb->size) in order to for it to be
- properly cleared -- thus we increment the PC here so that
- the logic setting tb->size below does the right thing. */
- dc->base.pc_next += 1;
- goto done_generating;
+ if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
+ CPUBreakpoint *bp;
+ QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
+ if (bp->pc == dc->base.pc_next) {
+ if (i386_tr_breakpoint_check(&dc->base, cs, bp)) {
+ break;
+ }
+ }
+ }
+
+ if (dc->base.is_jmp == DISAS_NORETURN) {
+ break;
+ }
}
+
if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}
@@ -8547,7 +8569,6 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock
*tb)
}
if (tb->cflags & CF_LAST_IO)
gen_io_end();
-done_generating:
gen_tb_end(tb, num_insns);
#ifdef DEBUG_DISAS
- [Qemu-devel] [PATCH v13 00/26] translate: [tcg] Generic translation framework, Lluís Vilanova, 2017/07/14
- [Qemu-devel] [PATCH v13 01/26] Pass generic CPUState to gen_intermediate_code(), Lluís Vilanova, 2017/07/14
- [Qemu-devel] [PATCH v13 02/26] target: [tcg] Use a generic enum for DISAS_ values, Lluís Vilanova, 2017/07/14
- [Qemu-devel] [PATCH v13 03/26] target: [tcg] Add generic translation framework, Lluís Vilanova, 2017/07/14
- [Qemu-devel] [PATCH v13 04/26] target/i386: [tcg] Port to DisasContextBase, Lluís Vilanova, 2017/07/14
- [Qemu-devel] [PATCH v13 05/26] target/i386: [tcg] Port to init_disas_context, Lluís Vilanova, 2017/07/14
- [Qemu-devel] [PATCH v13 06/26] target/i386: [tcg] Port to insn_start, Lluís Vilanova, 2017/07/14
- [Qemu-devel] [PATCH v13 07/26] target/i386: [tcg] Port to breakpoint_check,
Lluís Vilanova <=
- [Qemu-devel] [PATCH v13 08/26] target/i386: [tcg] Port to translate_insn, Lluís Vilanova, 2017/07/14
- [Qemu-devel] [PATCH v13 09/26] target/i386: [tcg] Port to tb_stop, Lluís Vilanova, 2017/07/14
- [Qemu-devel] [PATCH v13 10/26] target/i386: [tcg] Port to disas_log, Lluís Vilanova, 2017/07/14
- [Qemu-devel] [PATCH v13 11/26] target/i386: [tcg] Port to generic translation framework, Lluís Vilanova, 2017/07/14
- [Qemu-devel] [PATCH v13 12/26] target/arm: [tcg] Port to DisasContextBase, Lluís Vilanova, 2017/07/14
- [Qemu-devel] [PATCH v13 13/26] target/arm: [tcg] Port to init_disas_context, Lluís Vilanova, 2017/07/14
- [Qemu-devel] [PATCH v13 14/26] target/arm: [tcg, a64] Port to init_disas_context, Lluís Vilanova, 2017/07/14
- [Qemu-devel] [PATCH v13 15/26] target/arm: [tcg] Port to tb_start, Lluís Vilanova, 2017/07/14
- [Qemu-devel] [PATCH v13 16/26] target/arm: [tcg] Port to insn_start, Lluís Vilanova, 2017/07/14
- [Qemu-devel] [PATCH v13 17/26] target/arm: [tcg, a64] Port to insn_start, Lluís Vilanova, 2017/07/14