[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v11 21/29] target/arm: [tcg] Port to breakpoint_chec
From: |
Lluís Vilanova |
Subject: |
[Qemu-devel] [PATCH v11 21/29] target/arm: [tcg] Port to breakpoint_check |
Date: |
Wed, 28 Jun 2017 16:41:26 +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>
---
target/arm/translate.c | 68 ++++++++++++++++++++++++++++++++----------------
1 file changed, 46 insertions(+), 22 deletions(-)
diff --git a/target/arm/translate.c b/target/arm/translate.c
index c7e188b50e..790eaa2164 100644
--- a/target/arm/translate.c
+++ b/target/arm/translate.c
@@ -11918,6 +11918,32 @@ static void arm_trblock_insn_start(DisasContextBase
*dcbase, CPUState *cpu)
#endif
}
+static BreakpointCheckType arm_trblock_breakpoint_check(
+ DisasContextBase *dcbase, CPUState *cpu, const CPUBreakpoint *bp)
+{
+ DisasContext *dc = container_of(dcbase, DisasContext, base);
+
+ if (bp->flags & BP_CPU) {
+ gen_set_condexec(dc);
+ gen_set_pc_im(dc, dc->pc);
+ gen_helper_check_breakpoints(cpu_env);
+ /* End the TB early; it's likely not going to be executed */
+ dc->base.is_jmp = DISAS_UPDATE;
+ return BC_HIT_INSN;
+ } else {
+ gen_exception_internal_insn(dc, 0, EXCP_DEBUG);
+ /* 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. */
+ /* TODO: Advance PC by correct instruction length to
+ * avoid disassembler error messages */
+ dc->pc += 2;
+ return BC_HIT_TB;
+ }
+}
+
/* generate intermediate code for basic block 'tb'. */
void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb)
{
@@ -11965,36 +11991,34 @@ void gen_intermediate_code(CPUState *cpu,
TranslationBlock *tb)
dc->base.num_insns++;
arm_trblock_insn_start(&dc->base, cpu);
- if (unlikely(dc->base.is_jmp > DISAS_NEXT)) {
- break;
- }
-
if (unlikely(!QTAILQ_EMPTY(&cpu->breakpoints))) {
CPUBreakpoint *bp;
QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {
- if (bp->pc == dc->pc) {
- if (bp->flags & BP_CPU) {
- gen_set_condexec(dc);
- gen_set_pc_im(dc, dc->pc);
- gen_helper_check_breakpoints(cpu_env);
- /* End the TB early; it's likely not going to be
executed */
- dc->base.is_jmp = DISAS_UPDATE;
- } else {
- gen_exception_internal_insn(dc, 0, EXCP_DEBUG);
- /* 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. */
- /* TODO: Advance PC by correct instruction length to
- * avoid disassembler error messages */
- dc->pc += 2;
+ if (bp->pc == dc->base.pc_next) {
+ BreakpointCheckType bp_check =
+ arm_trblock_breakpoint_check(&dc->base, cpu, bp);
+ switch (bp_check) {
+ case BC_MISS:
+ /* Target ignored this breakpoint, go to next */
+ break;
+ case BC_HIT_INSN:
+ /* Hit, keep translating */
+ /*
+ * TODO: if we're never going to have more than one
+ * BP in a single address, we can simply use a
+ * bool here.
+ */
+ goto done_breakpoints;
+ case BC_HIT_TB:
+ /* Hit, end TB */
goto done_generating;
+ default:
+ g_assert_not_reached();
}
- break;
}
}
}
+ done_breakpoints:
if (dc->base.num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
- [Qemu-devel] [PATCH v11 11/29] target/i386: [tcg] Refactor tb_stop, (continued)
- [Qemu-devel] [PATCH v11 11/29] target/i386: [tcg] Refactor tb_stop, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 12/29] target/i386: [tcg] Refactor disas_log, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 13/29] target/i386: [tcg] Port to generic translation framework, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 14/29] target/arm: [tcg] Port to DisasContextBase, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 15/29] target/arm: [tcg] Port to init_disas_context, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 16/29] target/arm: [tcg, a64] Port to init_disas_context, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 17/29] target/arm: [tcg] Port to init_globals, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 18/29] target/arm: [tcg] Port to tb_start, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 19/29] target/arm: [tcg] Port to insn_start, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 20/29] target/arm: [tcg, a64] Port to insn_start, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 21/29] target/arm: [tcg] Port to breakpoint_check,
Lluís Vilanova <=
- [Qemu-devel] [PATCH v11 22/29] target/arm: [tcg, a64] Port to breakpoint_check, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 23/29] target/arm: [tcg] Port to translate_insn, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 24/29] target/arm: [tcg, a64] Port to translate_insn, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 25/29] target/arm: [tcg] Port to tb_stop, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 26/29] target/arm: [tcg, a64] Port to tb_stop, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 27/29] target/arm: [tcg] Port to disas_log, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 28/29] target/arm: [tcg, a64] Port to disas_log, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 29/29] target/arm: [tcg] Port to generic translation framework, Lluís Vilanova, 2017/06/28