* [Qemu-devel] [PATCH] gdbstub: Catch and report more vmstop reasons
@ 2011-03-22 10:02 Jan Kiszka
2011-04-03 21:56 ` Aurelien Jarno
0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2011-03-22 10:02 UTC (permalink / raw)
To: qemu-devel
When the VM goes into stop state while there is a gdb frontend attached,
it makes sense to inform gdb about this fact and at least a bit about
the stop reason. Basically, all stops are interesting except for the
temporary VMSTOP_SAVE/LOADVM.
The patch maps the relevant VMSTOP reasons on unique and more or less
associatable signals that gdb understands.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
gdbstub.c | 49 +++++++++++++++++++++++++++++++++++++++----------
1 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/gdbstub.c b/gdbstub.c
index 1e9f931..0838948 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -45,7 +45,12 @@
enum {
GDB_SIGNAL_0 = 0,
GDB_SIGNAL_INT = 2,
+ GDB_SIGNAL_QUIT = 3,
GDB_SIGNAL_TRAP = 5,
+ GDB_SIGNAL_ABRT = 6,
+ GDB_SIGNAL_ALRM = 14,
+ GDB_SIGNAL_IO = 23,
+ GDB_SIGNAL_XCPU = 24,
GDB_SIGNAL_UNKNOWN = 143
};
@@ -2270,14 +2275,11 @@ static void gdb_vm_state_change(void *opaque, int running, int reason)
const char *type;
int ret;
- if (running || (reason != VMSTOP_DEBUG && reason != VMSTOP_USER) ||
- s->state == RS_INACTIVE || s->state == RS_SYSCALL) {
+ if (running || s->state == RS_INACTIVE || s->state == RS_SYSCALL) {
return;
}
- /* disable single step if it was enable */
- cpu_single_step(env, 0);
-
- if (reason == VMSTOP_DEBUG) {
+ switch (reason) {
+ case VMSTOP_DEBUG:
if (env->watchpoint_hit) {
switch (env->watchpoint_hit->flags & BP_MEM_ACCESS) {
case BP_MEM_READ:
@@ -2294,17 +2296,44 @@ static void gdb_vm_state_change(void *opaque, int running, int reason)
"T%02xthread:%02x;%swatch:" TARGET_FMT_lx ";",
GDB_SIGNAL_TRAP, gdb_id(env), type,
env->watchpoint_hit->vaddr);
- put_packet(s, buf);
env->watchpoint_hit = NULL;
- return;
+ goto send_packet;
}
- tb_flush(env);
+ tb_flush(env);
ret = GDB_SIGNAL_TRAP;
- } else {
+ break;
+ case VMSTOP_USER:
ret = GDB_SIGNAL_INT;
+ break;
+ case VMSTOP_SHUTDOWN:
+ ret = GDB_SIGNAL_QUIT;
+ break;
+ case VMSTOP_DISKFULL:
+ ret = GDB_SIGNAL_IO;
+ break;
+ case VMSTOP_WATCHDOG:
+ ret = GDB_SIGNAL_ALRM;
+ break;
+ case VMSTOP_PANIC:
+ ret = GDB_SIGNAL_ABRT;
+ break;
+ case VMSTOP_SAVEVM:
+ case VMSTOP_LOADVM:
+ return;
+ case VMSTOP_MIGRATE:
+ ret = GDB_SIGNAL_XCPU;
+ break;
+ default:
+ ret = GDB_SIGNAL_UNKNOWN;
+ break;
}
snprintf(buf, sizeof(buf), "T%02xthread:%02x;", ret, gdb_id(env));
+
+send_packet:
put_packet(s, buf);
+
+ /* disable single step if it was enabled */
+ cpu_single_step(env, 0);
}
#endif
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] gdbstub: Catch and report more vmstop reasons
2011-03-22 10:02 [Qemu-devel] [PATCH] gdbstub: Catch and report more vmstop reasons Jan Kiszka
@ 2011-04-03 21:56 ` Aurelien Jarno
0 siblings, 0 replies; 2+ messages in thread
From: Aurelien Jarno @ 2011-04-03 21:56 UTC (permalink / raw)
To: Jan Kiszka; +Cc: qemu-devel
On Tue, Mar 22, 2011 at 11:02:09AM +0100, Jan Kiszka wrote:
> When the VM goes into stop state while there is a gdb frontend attached,
> it makes sense to inform gdb about this fact and at least a bit about
> the stop reason. Basically, all stops are interesting except for the
> temporary VMSTOP_SAVE/LOADVM.
>
> The patch maps the relevant VMSTOP reasons on unique and more or less
> associatable signals that gdb understands.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> gdbstub.c | 49 +++++++++++++++++++++++++++++++++++++++----------
> 1 files changed, 39 insertions(+), 10 deletions(-)
Thanks, applied.
> diff --git a/gdbstub.c b/gdbstub.c
> index 1e9f931..0838948 100644
> --- a/gdbstub.c
> +++ b/gdbstub.c
> @@ -45,7 +45,12 @@
> enum {
> GDB_SIGNAL_0 = 0,
> GDB_SIGNAL_INT = 2,
> + GDB_SIGNAL_QUIT = 3,
> GDB_SIGNAL_TRAP = 5,
> + GDB_SIGNAL_ABRT = 6,
> + GDB_SIGNAL_ALRM = 14,
> + GDB_SIGNAL_IO = 23,
> + GDB_SIGNAL_XCPU = 24,
> GDB_SIGNAL_UNKNOWN = 143
> };
>
> @@ -2270,14 +2275,11 @@ static void gdb_vm_state_change(void *opaque, int running, int reason)
> const char *type;
> int ret;
>
> - if (running || (reason != VMSTOP_DEBUG && reason != VMSTOP_USER) ||
> - s->state == RS_INACTIVE || s->state == RS_SYSCALL) {
> + if (running || s->state == RS_INACTIVE || s->state == RS_SYSCALL) {
> return;
> }
> - /* disable single step if it was enable */
> - cpu_single_step(env, 0);
> -
> - if (reason == VMSTOP_DEBUG) {
> + switch (reason) {
> + case VMSTOP_DEBUG:
> if (env->watchpoint_hit) {
> switch (env->watchpoint_hit->flags & BP_MEM_ACCESS) {
> case BP_MEM_READ:
> @@ -2294,17 +2296,44 @@ static void gdb_vm_state_change(void *opaque, int running, int reason)
> "T%02xthread:%02x;%swatch:" TARGET_FMT_lx ";",
> GDB_SIGNAL_TRAP, gdb_id(env), type,
> env->watchpoint_hit->vaddr);
> - put_packet(s, buf);
> env->watchpoint_hit = NULL;
> - return;
> + goto send_packet;
> }
> - tb_flush(env);
> + tb_flush(env);
> ret = GDB_SIGNAL_TRAP;
> - } else {
> + break;
> + case VMSTOP_USER:
> ret = GDB_SIGNAL_INT;
> + break;
> + case VMSTOP_SHUTDOWN:
> + ret = GDB_SIGNAL_QUIT;
> + break;
> + case VMSTOP_DISKFULL:
> + ret = GDB_SIGNAL_IO;
> + break;
> + case VMSTOP_WATCHDOG:
> + ret = GDB_SIGNAL_ALRM;
> + break;
> + case VMSTOP_PANIC:
> + ret = GDB_SIGNAL_ABRT;
> + break;
> + case VMSTOP_SAVEVM:
> + case VMSTOP_LOADVM:
> + return;
> + case VMSTOP_MIGRATE:
> + ret = GDB_SIGNAL_XCPU;
> + break;
> + default:
> + ret = GDB_SIGNAL_UNKNOWN;
> + break;
> }
> snprintf(buf, sizeof(buf), "T%02xthread:%02x;", ret, gdb_id(env));
> +
> +send_packet:
> put_packet(s, buf);
> +
> + /* disable single step if it was enabled */
> + cpu_single_step(env, 0);
> }
> #endif
>
>
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-04-03 21:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-22 10:02 [Qemu-devel] [PATCH] gdbstub: Catch and report more vmstop reasons Jan Kiszka
2011-04-03 21:56 ` Aurelien Jarno
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).