From patchwork Tue Jan 29 20:32:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10787215 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5685713BF for ; Tue, 29 Jan 2019 20:34:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 479FC2D2A1 for ; Tue, 29 Jan 2019 20:34:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BA112D6AC; Tue, 29 Jan 2019 20:34:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,FROM_LOCAL_NOVOWEL,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8F5902D2A1 for ; Tue, 29 Jan 2019 20:34:11 +0000 (UTC) Received: from localhost ([127.0.0.1]:55212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goa5C-00011B-DL for patchwork-qemu-devel@patchwork.kernel.org; Tue, 29 Jan 2019 15:34:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goa3r-0000DG-0K for qemu-devel@nongnu.org; Tue, 29 Jan 2019 15:32:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goa3q-00041R-5X for qemu-devel@nongnu.org; Tue, 29 Jan 2019 15:32:46 -0500 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]:34225) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1goa3p-0003zP-Qh for qemu-devel@nongnu.org; Tue, 29 Jan 2019 15:32:46 -0500 Received: by mail-lj1-x244.google.com with SMTP id u89-v6so18762251lje.1 for ; Tue, 29 Jan 2019 12:32:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=fzC1EKjWuiPU4/fDx1ENxnU/Wq+r0jgoQHEh+ABDd1o=; b=g5i6YVL+UJQ8diwCad/5g9RACAtOFkHHnyPyijQ5eFQj9wz79ixURDpGAH+QH2j01l Ck0SbZ9XYjMXur3Ja4uhcWVJkOdZa6EMPe24Mp9H5XVDuaVDxGz1PFljytx2tQ1X+UWw gNBxz3vugC8BJc7QsEZjZZaUcB9pgIdtpEl4nCHn79sU7ukQcpLEjsMLioDiJmQYUOFM t/U+JRrIHq0ovQi1TK0tUqXlVydYYZ+GNkEa1Vd+SL3IxERaRfn9Tog4SirkAG/tMjmJ 6I3P1GZnnC+cp43FN6992wwEqLDGurYLBCU1BaWtdQhupus7dSoi13JdEP1UrDdQs7VI ZTdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fzC1EKjWuiPU4/fDx1ENxnU/Wq+r0jgoQHEh+ABDd1o=; b=Gs/irhusfLthKzIO4d5jwoJcqRd6JNfIItSRAPme/Xt3yIRqjNGfCBEpT1VnD2iDEP GdyQ2I2Dhma/j8zdA4OrgmiaPUKMPHpqrtenmepe/TVhemWo1YayOMV/O1RAIs+aYzRF DxA2R2tFaeuuDI7ehcU8b45b6U8fQhkNdH2p+6XZNKAlXFaFerQYHmzBuNZAGhIX8Ubu wstFR9sE66R8Z1m4l1u3ZjgTQGb+RPOn3ix/PuuxtSWnvOPtKfPFoaKcc0EOe6xUoQJp dJ4D+INK+v/Nj45qbLGFUuXyjEh1FhBcYHw0fnzrYY/myjaIs3rJjgFIU4R91iogM1i7 Pr0g== X-Gm-Message-State: AJcUukeiyZRb+qYAIQiCaAmU8a4SyTJZyZC3ePZzxVOB5DSUxrwFTwT/ EXCHLY2ZWmmmFEZvi0/mOeFljfWW X-Google-Smtp-Source: ALg8bN5zYMABfZnGSY36X6JnzJlExwlEOMQw5ojcBZKPPPjyhCsVP0X2JyB4rOsDbyuP9d7o9k4GMg== X-Received: by 2002:a2e:7615:: with SMTP id r21-v6mr22349357ljc.131.1548793960193; Tue, 29 Jan 2019 12:32:40 -0800 (PST) Received: from octofox.cadence.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id c19sm3677662lfg.86.2019.01.29.12.32.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 12:32:39 -0800 (PST) From: Max Filippov To: qemu-devel@nongnu.org Date: Tue, 29 Jan 2019 12:32:19 -0800 Message-Id: <20190129203219.6473-1-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::244 Subject: [Qemu-devel] [PATCH] gdbstub: allow killing QEMU via vKill command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Luc Michel , Max Filippov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP With multiprocess extensions gdb uses 'vKill' packet instead of 'k' to kill the inferior. Handle 'vKill' the same way 'k' was handled in the presence of single process. Fixes: 7cf48f6752e5 ("gdbstub: add multiprocess support to (f|s)ThreadInfo and ThreadExtraInfo") Cc: Luc Michel Signed-off-by: Max Filippov --- gdbstub.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index bfc7afb50968..1ef31240c055 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1383,6 +1383,28 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, buf); break; + } else if (strncmp(p, "Kill;", 5) == 0) { + unsigned long pid; + + p += 5; + + if (qemu_strtoul(p, &p, 16, &pid)) { + put_packet(s, "E22"); + break; + } + process = gdb_get_process(s, pid); + + if (process == NULL) { + put_packet(s, "E22"); + break; + } + if (s->process_num <= 1) { + /* Kill the target */ + error_report("QEMU: Terminated via GDBstub"); + exit(0); + } + /* TODO: handle multiprocess case */ + goto unknown_command; } else { goto unknown_command; }