From patchwork Tue Mar 22 10:02:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 87885 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 10E2AB6F7C for ; Tue, 22 Mar 2011 21:03:02 +1100 (EST) Received: from localhost ([127.0.0.1]:60077 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q1yQV-0002nm-3m for incoming@patchwork.ozlabs.org; Tue, 22 Mar 2011 06:02:59 -0400 Received: from [140.186.70.92] (port=33506 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q1yPo-0002n8-79 for qemu-devel@nongnu.org; Tue, 22 Mar 2011 06:02:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q1yPn-0002ff-2d for qemu-devel@nongnu.org; Tue, 22 Mar 2011 06:02:16 -0400 Received: from david.siemens.de ([192.35.17.14]:19703) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q1yPm-0002eq-PR for qemu-devel@nongnu.org; Tue, 22 Mar 2011 06:02:15 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by david.siemens.de (8.13.6/8.13.6) with ESMTP id p2MA2A70022259 for ; Tue, 22 Mar 2011 11:02:11 +0100 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id p2MA299e006218 for ; Tue, 22 Mar 2011 11:02:09 +0100 Message-ID: <4D8873A1.60001@siemens.com> Date: Tue, 22 Mar 2011 11:02:09 +0100 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: qemu-devel X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.35.17.14 Subject: [Qemu-devel] [PATCH] gdbstub: Catch and report more vmstop reasons X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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