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: 770341 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wfPdc2K5Dz9s74 for ; Fri, 2 Jun 2017 23:07:48 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="GoYoqJoP"; dkim-atps=neutral Received: from localhost ([::1]:49707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGmIr-00082U-Ul for incoming@patchwork.ozlabs.org; Fri, 02 Jun 2017 09:07:46 -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=20Benn=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=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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é --- v2 - used Greg's less convoluted suggestion - expand commit message --- gdbstub.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) 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;