From patchwork Wed Jul 12 10:52:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 107478 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp651202qge; Wed, 12 Jul 2017 03:58:22 -0700 (PDT) X-Received: by 10.237.61.47 with SMTP id g44mr5816932qtf.60.1499857102539; Wed, 12 Jul 2017 03:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499857102; cv=none; d=google.com; s=arc-20160816; b=DXtlS7g1l9wIJ+Zf4U01VxrJBGzhlIM7ELbEhqqdwB0CEm6SS2oOWwulxmAdJ9focr d3MqqS1+ZEBzl/32aFx4tUlfYQt8+TQAqeXwIct925ywFmxGNdFdavIFKvChrRZvcCih /qS51PzNKM4vN2tItfpheh5PJ5q2+hW3XACrDqh5P+wc6Q0azLbAjXHqO7RKR1OZQH0J 9Q/+2Xgg5vCjO53RxnpAcEsXFjjojb9cf1rkT+CZldAZBdqZ2C70PR4DS6FZ/CEISjHA Q2B05zj3KXLEH9/+vVVJD/pzDsGFIrSe51VSjhUrDHFuyHoblY+JakQoQA9m+SFDvafz ZlYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=xO/Ec+K17JlCPGB7JDiTf1+3NzuWADj/2pGqep1gdO0=; b=r+QW/+ICWk/zaIDxRgHb8Mw6ZzRYD5dkmyI8Rhmf50K1mgIGUgPuaMAVtU6tP821je oC9lVIXVG3iCpCW7svvkkFZwTAKU6JhEvuWgnAEm4gR4bxTlkUdyJuKXzd5XCL7EbNIw 5WvtEAVeLVqFUs1nJIeetpyBzTs6PB2d5M5t8aPM3TQ+UNKDD7J+GYFUDT3oizeh93VI H8TUQCE1wnvJIYoFPsRcKMJrxfW+EniQcRN60oCwr5YEvF9elSeZIIztTItzJuFsSvtb oUaE4bLK4LTG+z9FYM2mqUxQAmS6sGz7zYRD7mYPWDCdr/i/DP3iWS5DFnjWq77/IV2q IGJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=CA2eJEBr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [208.118.235.17]) by mx.google.com with ESMTPS id h68si2009546qkd.34.2017.07.12.03.58.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 12 Jul 2017 03:58:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.b=CA2eJEBr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51720 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVFLX-0000MK-VU for patch@linaro.org; Wed, 12 Jul 2017 06:58:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVFGq-0004kR-0b for qemu-devel@nongnu.org; Wed, 12 Jul 2017 06:53:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVFGm-000212-UO for qemu-devel@nongnu.org; Wed, 12 Jul 2017 06:53:28 -0400 Received: from mail-wr0-f169.google.com ([209.85.128.169]:35461) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dVFGm-00020X-No for qemu-devel@nongnu.org; Wed, 12 Jul 2017 06:53:24 -0400 Received: by mail-wr0-f169.google.com with SMTP id k67so28124806wrc.2 for ; Wed, 12 Jul 2017 03:53:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xO/Ec+K17JlCPGB7JDiTf1+3NzuWADj/2pGqep1gdO0=; b=CA2eJEBrDkT+U3teA2mTrFEXB3miCBLQM098JYElTkU7P2vMjrkftgWEZXfj1yQ9MJ tiHMzydsPw78zqNCDvVbkjJbQj/dpKwS2m01xolce8w2ljRuG4/J4xUNKecxmAum7uuy WOXQBY4HTm8lc6Q79+UeqchcTfCBojFIv4G9Q= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=xO/Ec+K17JlCPGB7JDiTf1+3NzuWADj/2pGqep1gdO0=; b=tgYeAhzAIHvmXKmIIkm2rbYC1W4MaEM9rpejfe4leHzoj+yJSOeu8c/D2dp4xgRCGG CbbCf07eW5Np9InAD4tc67jzzkoSNhcQpl9OOAUzAaj7+h72B6Ued+tzsNUYRcsj8NoU /cnw22Dn2olxcLgnh1plvFOPNYZHZdfB8B0/QBtcjWKWSwoV8UZEeEdY01UHA6erQDyU ORGmFsOMd7TBq+Pepqq8LlXcKAL9lp1RpUTL5zkymSaq1l7kDWET4LBWddoLGa1J22lH l7x6KsNR5wEn+BfmFxJpg1h5n5U9frDgliQy4WNcrltTU2ENyL6PxWfXaSIcJAcEUKHi 68nw== X-Gm-Message-State: AIVw111y8OitUZ/acCBZ7Cf86RQ/DmUsmmxhxGN5m/pyxeGg8OMuBBmN 0/0YOjjmLwKXWI7p X-Received: by 10.28.31.203 with SMTP id f194mr2111526wmf.44.1499856743403; Wed, 12 Jul 2017 03:52:23 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id j190sm2533310wmd.22.2017.07.12.03.52.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jul 2017 03:52:19 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 443B53E0B27; Wed, 12 Jul 2017 11:52:17 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: pbonzini@redhat.com Date: Wed, 12 Jul 2017 11:52:16 +0100 Message-Id: <20170712105216.747-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170712105216.747-1-alex.bennee@linaro.org> References: <20170712105216.747-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.128.169 Subject: [Qemu-devel] [PATCH v4 4/4] gdbstub: don't fail on vCont; C04:0; c packets 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: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The thread-id of 0 means any CPU but we then ignore the fact we find the first_cpu in this case who can have an index of 0. Instead of bailing out just test if we have managed to match up thread-id to a CPU. Otherwise you get: gdb_handle_packet: command='vCont;C04:0;c' put_packet: reply='E22' The actual reason for gdb sending vCont;C04:0;c was fixed in a previous commit where we ensure the first_cpu's tid is correctly reported to gdb however we should still behave correctly next time it does send 0. Signed-off-by: Alex Bennée Reviewed-by: Greg Kurz Reviewed-by: Claudio Imbrenda Reviewed-by: Philippe Mathieu-Daudé --- v4 - one more r-b v2 - used Greg's less convoluted suggestion - expand commit message --- gdbstub.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) -- 2.13.0 diff --git a/gdbstub.c b/gdbstub.c index 484e96dbd9..a576585638 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -938,23 +938,16 @@ static int gdb_handle_vcont(GDBState *s, const char *p) if (res) { goto out; } - idx = tmp; + /* 0 means any thread, so we pick the first valid CPU */ - if (!idx) { - idx = cpu_gdb_index(first_cpu); - } + cpu = tmp ? find_cpu(tmp) : first_cpu; - /* - * If we are in user mode, the thread specified is actually a - * thread id, and not an index. We need to find the actual - * CPU first, and only then we can use its index. - */ - cpu = find_cpu(idx); /* invalid CPU/thread specified */ - if (!idx || !cpu) { + if (!cpu) { res = -EINVAL; goto out; } + /* only use if no previous match occourred */ if (newstates[cpu->cpu_index] == 1) { newstates[cpu->cpu_index] = cur_action;