From: "Edgar E. Iglesias" <edgar.iglesias@axis.com>
To: Jason Wessel <jason.wessel@windriver.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 4/5] gdbstub: support for gdb "detach/kill/quit"
Date: Thu, 15 May 2008 23:13:15 +0200 [thread overview]
Message-ID: <20080515211315.GA27300@edgar.se.axis.com> (raw)
In-Reply-To: <1210860693-22245-5-git-send-email-jason.wessel@windriver.com>
On Thu, May 15, 2008 at 09:11:32AM -0500, Jason Wessel wrote:
> Implement the 'k' gdbserial packet which kills the qemu instance via
> the debugger stub.
>
> Implement the 'D' detach packet for the gdb stub such that you can
> disconnect gdb with the "detach" command. This required implementing
> a cpu_breakpoint_remove_all() and a cpu_watchpoint_remove_all()
> function to cleanup all the breakpoints and watchpoints prior to
> leaving the gdb stub else simulation can stop with no debugger
> attached.
>
> On a '?' packet remove all the breakpoints and watchpoints. This is
> considered more of a safety net in case you force killed gdb or it
> crashed and you are reconnecting. The identical behavior exists for
> kgdb in the linux kernel.
>
> Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Thanks Jason, this one looks good to me.
> ---
> cpu-all.h | 2 ++
> exec.c | 21 +++++++++++++++++++++
> gdbstub.c | 17 +++++++++++++++++
> 3 files changed, 40 insertions(+), 0 deletions(-)
>
> diff --git a/cpu-all.h b/cpu-all.h
> index 7e77f76..d71166c 100644
> --- a/cpu-all.h
> +++ b/cpu-all.h
> @@ -760,8 +760,10 @@ void cpu_reset_interrupt(CPUState *env, int mask);
>
> int cpu_watchpoint_insert(CPUState *env, target_ulong addr);
> int cpu_watchpoint_remove(CPUState *env, target_ulong addr);
> +void cpu_watchpoint_remove_all(CPUState *env);
> int cpu_breakpoint_insert(CPUState *env, target_ulong pc);
> 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 */
> diff --git a/exec.c b/exec.c
> index 2fd0078..8f5c868 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1139,6 +1139,16 @@ int cpu_watchpoint_remove(CPUState *env, target_ulong addr)
> return -1;
> }
>
> +/* Remove all watchpoints. */
> +void cpu_watchpoint_remove_all(CPUState *env) {
> + int i;
> +
> + for (i = 0; i < env->nb_watchpoints; i++) {
> + tlb_flush_page(env, env->watchpoint[i].vaddr);
> + }
> + env->nb_watchpoints = 0;
> +}
> +
> /* add a breakpoint. EXCP_DEBUG is returned by the CPU loop if a
> breakpoint is reached */
> int cpu_breakpoint_insert(CPUState *env, target_ulong pc)
> @@ -1162,6 +1172,17 @@ int cpu_breakpoint_insert(CPUState *env, target_ulong pc)
> #endif
> }
>
> +/* remove all breakpoints */
> +void cpu_breakpoint_remove_all(CPUState *env) {
> +#if defined(TARGET_HAS_ICE)
> + int i;
> + for(i = 0; i < env->nb_breakpoints; i++) {
> + breakpoint_invalidate(env, env->breakpoints[i]);
> + }
> + env->nb_breakpoints = 0;
> +#endif
> +}
> +
> /* remove a breakpoint */
> int cpu_breakpoint_remove(CPUState *env, target_ulong pc)
> {
> diff --git a/gdbstub.c b/gdbstub.c
> index 833cdd9..fb2d948 100644
> --- a/gdbstub.c
> +++ b/gdbstub.c
> @@ -1035,6 +1035,12 @@ static int gdb_handle_packet(GDBState *s, CPUState *env, const char *line_buf)
> /* TODO: Make this return the correct value for user-mode. */
> snprintf(buf, sizeof(buf), "S%02x", SIGTRAP);
> put_packet(s, buf);
> + /* Remove all the breakpoints when this query is issued,
> + * because gdb is doing and initial connect and the state
> + * should be cleaned up.
> + */
> + cpu_breakpoint_remove_all(env);
> + cpu_watchpoint_remove_all(env);
> break;
> case 'c':
> if (*p != '\0') {
> @@ -1058,6 +1064,17 @@ static int gdb_handle_packet(GDBState *s, CPUState *env, const char *line_buf)
> }
> gdb_continue(s);
> return RS_IDLE;
> + case 'k':
> + /* Kill the target */
> + fprintf(stderr, "\nQEMU: Terminated via GDBstub\n");
> + exit(0);
> + case 'D':
> + /* Detach packet */
> + cpu_breakpoint_remove_all(env);
> + cpu_watchpoint_remove_all(env);
> + gdb_continue(s);
> + put_packet(s, "OK");
> + break;
> case 's':
> if (*p != '\0') {
> addr = strtoull(p, (char **)&p, 16);
> --
> 1.5.5.1
>
>
--
Edgar E. Iglesias
Axis Communications AB
next prev parent reply other threads:[~2008-05-15 21:13 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-15 14:11 [Qemu-devel] [PATCH 0/5] gdbstub and single step improvments Jason Wessel
2008-05-15 14:11 ` [Qemu-devel] [PATCH 1/5] gdbstub: replace singlestep q packets with qRcmd packets Jason Wessel
2008-05-15 14:11 ` [Qemu-devel] [PATCH 2/5] gdbstub: gdb pass-through qemu monitor support Jason Wessel
2008-05-15 14:11 ` [Qemu-devel] [PATCH 3/5] vl.c: always run the real time timers when single stepping Jason Wessel
2008-05-15 14:11 ` [Qemu-devel] [PATCH 4/5] gdbstub: support for gdb "detach/kill/quit" Jason Wessel
2008-05-15 14:11 ` [Qemu-devel] [PATCH 5/5] ppc: fix crash in ppc system single step support Jason Wessel
2008-05-15 21:13 ` Edgar E. Iglesias [this message]
2008-05-15 22:17 ` [Qemu-devel] [PATCH 2/5] gdbstub: gdb pass-through qemu monitor support Edgar E. Iglesias
2008-05-19 13:29 ` Jason Wessel
2008-05-19 16:30 ` Paul Brook
2008-05-21 12:58 ` Maxim Gorbachyov
2008-05-21 17:03 ` Jason Wessel
2008-05-22 13:24 ` [Qemu-devel] " Jan Kiszka
2008-05-22 13:45 ` Jason Wessel
2008-05-22 13:53 ` Jan Kiszka
2008-05-22 16:55 ` Jason Wessel
2008-05-23 15:33 ` Jan Kiszka
2008-05-15 21:33 ` [Qemu-devel] [PATCH 1/5] gdbstub: replace singlestep q packets with qRcmd packets Edgar E. Iglesias
2008-05-19 13:27 ` Jason Wessel
2008-05-19 15:14 ` Edgar E. Iglesias
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=20080515211315.GA27300@edgar.se.axis.com \
--to=edgar.iglesias@axis.com \
--cc=jason.wessel@windriver.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).