From patchwork Fri Jun 2 13:05:18 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: 101249 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp185474obc; Fri, 2 Jun 2017 06:08:50 -0700 (PDT) X-Received: by 10.55.207.92 with SMTP id e89mr7634124qkj.200.1496408930284; Fri, 02 Jun 2017 06:08:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496408930; cv=none; d=google.com; s=arc-20160816; b=tA/cOD/kjbSe84vM2F7e5tSjil37Y1tL5LBpxqhdbbWj9bUJgXJkIbxGMyjPf4Ww+n qofQmSiDpjLp83cr9H2AWlrDWucsp08vn6zXZVHkQb9/u78F04IhsEYcVYnpB//vVWB5 Nnl8m/jYQoHrSXOH16GD2+Tko/rWjLMP4tmohOX+xTvm+AMLlNS3ZHYvFGlp6NugUOD8 L6Pk3odGYtLvGB0TdH4XAVRdNNfAeqcbnggreLLLXtmiyhYRbFVghBSw3b0msRudgi2h WpoPVBe+tQGTlqInEKjbd89ph3g+WdCz5q5XuShjnuqYJPh6dfonbPBQWgBukxL9wl08 C7/Q== 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=373B82/lO7Ee29Th9u3Ny6pJqw3QChtQzNQzvI0GHDw=; b=YO1gouaY61jf+xWzAcNKW9v5DVIEEM4MNYk27auoY6f0q0J9InfyxXC0lzaGthrk4I G/hMpNI4SqD2QoDweXpZSYVitjwyRd6Aa+KLJr/riQadmsMMK9nhk2c7JYyoBbRV1lpQ vn01x9+yP6+t9GnC3QcYfWFKK6BpLuy7hNjfQgL1P/bLkMeHHKwFfbVlOQ3RT8unJKse +XLLoo5YYZCNzpDyn+CdZeb+OsOa9u5tsg6TLq73vWgAJJhe22GsTb6eWGIU6LwGiCUW pAb2AXEpeca9RCTeNUxp4/4qEL+3GgSDlQNmBeU7hUNhQzoYzi8Xnc5BmkXkbQDnAGDv tZzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q16si21499000qkh.113.2017.06.02.06.08.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 02 Jun 2017 06:08:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:49712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGmJr-0000e3-JI for patch@linaro.org; Fri, 02 Jun 2017 09:08:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGmGJ-0006H1-HK for qemu-devel@nongnu.org; Fri, 02 Jun 2017 09:05:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGmGE-0002fI-PQ for qemu-devel@nongnu.org; Fri, 02 Jun 2017 09:05:07 -0400 Received: from mail-wr0-x22c.google.com ([2a00:1450:400c:c0c::22c]:34662) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dGmGE-0002es-Id for qemu-devel@nongnu.org; Fri, 02 Jun 2017 09:05:02 -0400 Received: by mail-wr0-x22c.google.com with SMTP id g76so6683697wrd.1 for ; Fri, 02 Jun 2017 06:05:02 -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=373B82/lO7Ee29Th9u3Ny6pJqw3QChtQzNQzvI0GHDw=; b=GoYoqJoP9c8T3+U28WbFHCm+xSs1RJE8rOodVtZSsCns69FSgVrXsKutXS/I9Un6xo 67PvQ9IXBbXToDDqAmfilz8uO2MxTBAYvnQciSG8jdqbMzXzVKFRe85S+JYQfJ40KnZb 2ZibYshNGFjZCBabCJmCVjUv65cC+prIsN3kA= 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=373B82/lO7Ee29Th9u3Ny6pJqw3QChtQzNQzvI0GHDw=; b=IF3Q88R9fb/usDZci54PPOTDwaM/f9Zi/s27/+40KZPnqB1i+bWMRj/p93qVnZliY6 tkKmVYU14KrnloQ9O4ygJPtmfnt28rTHEasHUcqyhQQwbOlvPJ4Iy/o1t0Gg7hLHIPUZ rflgnE9SZrAVhWF3nPNqOZsCTpT4Cy5UINlDrbAO4t2wmc1/drpP5eHjJXS+iHpl0syB qbk0SfWGeMgCSyiEUnBs/OxA6v7MZKANzHcZyMEG/eC/KHROzZBXi4F60dhn3HfGdaaC Ru4ujAN6f2Q4oQXfhbAJh6qJB8WCzdtjKysm/y8xftdbzx8Awwrr5O6w1BBAjK+/7kT8 C+Aw== X-Gm-Message-State: AODbwcCRTlXHk76SIWgHZ1n1ELzVVeoycQmL8cHbkcMwaz+fMp9IROSq SXZeXYXySeCt7DeQ X-Received: by 10.223.164.7 with SMTP id d7mr4685641wra.183.1496408701394; Fri, 02 Jun 2017 06:05:01 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id x37sm39747831wrb.42.2017.06.02.06.04.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 06:04:59 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 308D13E0334; Fri, 2 Jun 2017 14:05:19 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org, pbonzini@redhat.com, doug16k@gmail.com, imbrenda@linux.vnet.ibm.com Date: Fri, 2 Jun 2017 14:05:18 +0100 Message-Id: <20170602130518.22943-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170602130518.22943-1-alex.bennee@linaro.org> References: <20170602130518.22943-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22c Subject: [Qemu-devel] [PATCH v3 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 --- v2 - used Greg's less convoluted suggestion - expand commit message --- gdbstub.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) -- 2.13.0 Reviewed-by: Philippe Mathieu-Daudé diff --git a/gdbstub.c b/gdbstub.c index 45a3a0b16b..6b1e72e9f7 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -937,23 +937,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;