From: Jan Kiszka <jan.kiszka@web.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 1/3] Introduce SSTEP_INTERNAL
Date: Wed, 04 Jun 2008 20:53:26 +0200 [thread overview]
Message-ID: <4846E4A6.9070707@web.de> (raw)
In-Reply-To: <4846E354.805@web.de>
Introducing SSTEP_INTERNAL, this patch allows to reuse the
(host-injected) single-step infrastructure to let the emulator generate
and execute TBs that only include one instruction.
Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
---
cpu-all.h | 7 ++++---
cpu-exec.c | 4 +++-
exec.c | 2 ++
gdbstub.c | 4 ++--
target-arm/translate.c | 2 +-
target-cris/translate.c | 2 +-
target-i386/translate.c | 2 +-
target-m68k/translate.c | 4 ++--
target-mips/translate.c | 2 +-
target-ppc/translate.c | 2 +-
target-sh4/translate.c | 6 +++---
vl.c | 7 ++++---
12 files changed, 25 insertions(+), 19 deletions(-)
Index: b/cpu-all.h
===================================================================
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -804,9 +804,10 @@ int cpu_breakpoint_insert(CPUState *env,
int cpu_breakpoint_remove(CPUState *env, target_ulong pc);
void cpu_breakpoint_remove_all(CPUState *env);
-#define SSTEP_ENABLE 0x1 /* Enable simulated HW single stepping */
-#define SSTEP_NOIRQ 0x2 /* Do not use IRQ while single stepping */
-#define SSTEP_NOTIMER 0x4 /* Do not Timers while single stepping */
+#define SSTEP_DEBUG 0x1 /* Enable simulated HW single stepping */
+#define SSTEP_NOIRQ 0x2 /* Do not use IRQ while single stepping */
+#define SSTEP_NOTIMER 0x4 /* Do not Timers while single stepping */
+#define SSTEP_INTERNAL 0x8 /* QEMU internal, do not generate breakpoint */
void cpu_single_step(CPUState *env, int enabled);
void cpu_reset(CPUState *s);
Index: b/cpu-exec.c
===================================================================
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -369,7 +369,8 @@ int cpu_exec(CPUState *env1)
for(;;) {
interrupt_request = env->interrupt_request;
if (__builtin_expect(interrupt_request, 0) &&
- likely(!(env->singlestep_enabled & SSTEP_NOIRQ))) {
+ likely(!(env->singlestep_enabled &
+ (SSTEP_NOIRQ | SSTEP_INTERNAL)))) {
if (interrupt_request & CPU_INTERRUPT_DEBUG) {
env->interrupt_request &= ~CPU_INTERRUPT_DEBUG;
env->exception_index = EXCP_DEBUG;
@@ -609,6 +610,7 @@ int cpu_exec(CPUState *env1)
#endif
next_tb = tcg_qemu_tb_exec(tc_ptr);
env->current_tb = NULL;
+ env->singlestep_enabled &= ~SSTEP_INTERNAL;
/* reset soft MMU for next block (it can currently
only be set by a memory fault) */
#if defined(USE_KQEMU)
Index: b/exec.c
===================================================================
--- a/exec.c
+++ b/exec.c
@@ -1292,6 +1292,8 @@ int cpu_breakpoint_remove(CPUState *env,
void cpu_single_step(CPUState *env, int enabled)
{
#if defined(TARGET_HAS_ICE)
+ enabled &= SSTEP_DEBUG | SSTEP_NOIRQ | SSTEP_NOTIMER;
+ enabled |= env->singlestep_enabled & SSTEP_INTERNAL;
if (env->singlestep_enabled != enabled) {
env->singlestep_enabled = enabled;
/* must flush all the translated code to avoid inconsistancies */
Index: b/target-arm/translate.c
===================================================================
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -8666,7 +8666,7 @@ static inline int gen_intermediate_code_
/* At this stage dc->condjmp will only be set when the skipped
instruction was a conditional branch or trap, and the PC has
already been written. */
- if (__builtin_expect(env->singlestep_enabled, 0)) {
+ if (__builtin_expect(env->singlestep_enabled & SSTEP_DEBUG, 0)) {
/* Make sure the pc is updated, and raise a debug exception. */
if (dc->condjmp) {
gen_set_condexec(dc);
Index: b/target-cris/translate.c
===================================================================
--- a/target-cris/translate.c
+++ b/target-cris/translate.c
@@ -3067,7 +3067,7 @@ gen_intermediate_code_internal(CPUState
cris_evaluate_flags (dc);
done:
- if (__builtin_expect(env->singlestep_enabled, 0)) {
+ if (__builtin_expect(env->singlestep_enabled & SSTEP_DEBUG, 0)) {
t_gen_raise_exception(EXCP_DEBUG);
} else {
switch(dc->is_jmp) {
Index: b/target-i386/translate.c
===================================================================
--- a/target-i386/translate.c
+++ b/target-i386/translate.c
@@ -2618,7 +2618,7 @@ static void gen_eob(DisasContext *s)
if (s->tb->flags & HF_INHIBIT_IRQ_MASK) {
tcg_gen_helper_0_0(helper_reset_inhibit_irq);
}
- if (s->singlestep_enabled) {
+ if (s->singlestep_enabled & SSTEP_DEBUG) {
tcg_gen_helper_0_0(helper_debug);
} else if (s->tf) {
tcg_gen_helper_0_0(helper_single_step);
Index: b/target-m68k/translate.c
===================================================================
--- a/target-m68k/translate.c
+++ b/target-m68k/translate.c
@@ -871,7 +871,7 @@ static void gen_jmp_tb(DisasContext *s,
TranslationBlock *tb;
tb = s->tb;
- if (__builtin_expect (s->singlestep_enabled, 0)) {
+ if (__builtin_expect (s->singlestep_enabled & SSTEP_DEBUG, 0)) {
gen_exception(s, dest, EXCP_DEBUG);
} else if ((tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK) ||
(s->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK)) {
@@ -2974,7 +2974,7 @@ gen_intermediate_code_internal(CPUState
!env->singlestep_enabled &&
(pc_offset) < (TARGET_PAGE_SIZE - 32));
- if (__builtin_expect(env->singlestep_enabled, 0)) {
+ if (__builtin_expect(env->singlestep_enabled & SSTEP_DEBUG, 0)) {
/* Make sure the pc is updated, and raise a debug exception. */
if (!dc->is_jmp) {
gen_flush_cc_op(dc);
Index: b/target-mips/translate.c
===================================================================
--- a/target-mips/translate.c
+++ b/target-mips/translate.c
@@ -7259,7 +7259,7 @@ gen_intermediate_code_internal (CPUState
break;
#endif
}
- if (env->singlestep_enabled) {
+ if (env->singlestep_enabled & SSTEP_DEBUG) {
save_cpu_state(&ctx, ctx.bstate == BS_NONE);
gen_op_debug();
} else {
Index: b/target-ppc/translate.c
===================================================================
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -6319,7 +6319,7 @@ static always_inline int gen_intermediat
if (ctx.exception == POWERPC_EXCP_NONE) {
gen_goto_tb(&ctx, 0, ctx.nip);
} else if (ctx.exception != POWERPC_EXCP_BRANCH) {
- if (unlikely(env->singlestep_enabled)) {
+ if (unlikely(env->singlestep_enabled & SSTEP_DEBUG)) {
gen_update_nip(&ctx, ctx.nip);
gen_op_debug();
}
Index: b/target-sh4/translate.c
===================================================================
--- a/target-sh4/translate.c
+++ b/target-sh4/translate.c
@@ -161,7 +161,7 @@ static void gen_goto_tb(DisasContext * c
tcg_gen_exit_tb((long) tb + n);
} else {
gen_op_movl_imm_PC(dest);
- if (ctx->singlestep_enabled)
+ if (ctx->singlestep_enabled & SSTEP_DEBUG)
gen_op_debug();
tcg_gen_exit_tb(0);
}
@@ -173,7 +173,7 @@ static void gen_jump(DisasContext * ctx)
/* Target is not statically known, it comes necessarily from a
delayed jump as immediate jump are conditinal jumps */
gen_op_movl_delayed_pc_PC();
- if (ctx->singlestep_enabled)
+ if (ctx->singlestep_enabled & SSTEP_DEBUG)
gen_op_debug();
tcg_gen_exit_tb(0);
} else {
@@ -1251,7 +1251,7 @@ gen_intermediate_code_internal(CPUState
break;
#endif
}
- if (env->singlestep_enabled) {
+ if (env->singlestep_enabled & SSTEP_DEBUG) {
gen_op_debug();
} else {
switch (ctx.bstate) {
Index: b/vl.c
===================================================================
--- a/vl.c
+++ b/vl.c
@@ -7032,9 +7032,10 @@ void main_loop_wait(int timeout)
qemu_aio_poll();
if (vm_running) {
- if (likely(!(cur_cpu->singlestep_enabled & SSTEP_NOTIMER)))
- qemu_run_timers(&active_timers[QEMU_TIMER_VIRTUAL],
- qemu_get_clock(vm_clock));
+ if (likely(!(cur_cpu->singlestep_enabled &
+ (SSTEP_NOTIMER | SSTEP_INTERNAL))))
+ qemu_run_timers(&active_timers[QEMU_TIMER_VIRTUAL],
+ qemu_get_clock(vm_clock));
/* run dma transfers, if any */
DMA_run();
}
Index: b/gdbstub.c
===================================================================
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -77,7 +77,7 @@ typedef struct GDBState {
/* By default use no IRQs and no timers while single stepping so as to
* make single stepping like an ICE HW step.
*/
-static int sstep_flags = SSTEP_ENABLE|SSTEP_NOIRQ|SSTEP_NOTIMER;
+static int sstep_flags = SSTEP_DEBUG | SSTEP_NOIRQ | SSTEP_NOTIMER;
#ifdef CONFIG_USER_ONLY
/* XXX: This is not thread safe. Do we care? */
@@ -1144,7 +1144,7 @@ static int gdb_handle_packet(GDBState *s
if (!strcmp(p,"qemu.sstepbits")) {
/* Query Breakpoint bit definitions */
sprintf(buf,"ENABLE=%x,NOIRQ=%x,NOTIMER=%x",
- SSTEP_ENABLE,
+ SSTEP_DEBUG,
SSTEP_NOIRQ,
SSTEP_NOTIMER);
put_packet(s, buf);
next prev parent reply other threads:[~2008-06-04 18:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-04 18:47 [Qemu-devel] [PATCH 0/3] Alternative post-instruction early TB termination Jan Kiszka
2008-06-04 18:48 ` [Qemu-devel] [PATCH 3/3] remove unused TB cflags Jan Kiszka
2008-06-05 19:52 ` [Qemu-devel] [PATCH 3/3] remove unused TB cflags - v2 Jan Kiszka
2008-06-04 18:53 ` Jan Kiszka [this message]
2008-06-04 18:56 ` [Qemu-devel] [PATCH 2/3] Replace CF_SINGLE_INSN with SSTEP_INTERNAL Jan Kiszka
2008-06-04 21:43 ` [Qemu-devel] Re: [PATCH 2/3] Replace CF_SINGLE_INSN with SSTEP_INTERNAL - v2 Jan Kiszka
2008-06-05 8:36 ` [Qemu-devel] [PATCH 2/3] Replace CF_SINGLE_INSN with SSTEP_INTERNAL Fabrice Bellard
2008-06-05 19:52 ` [Qemu-devel] [PATCH 2/3] Replace CF_SINGLE_INSN with SSTEP_INTERNAL - v2 Jan Kiszka
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=4846E4A6.9070707@web.de \
--to=jan.kiszka@web.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.