From patchwork Thu Jul 13 14:24:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 107696 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2303488qge; Thu, 13 Jul 2017 07:43:01 -0700 (PDT) X-Received: by 10.200.8.68 with SMTP id x4mr5781643qth.195.1499956981852; Thu, 13 Jul 2017 07:43:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499956981; cv=none; d=google.com; s=arc-20160816; b=CptDUAedeOfiW3ncAsI9Y+ojT650v7YTzhv/HqqKydFWsv8B2QzdQnm2FXi87W/bhR eeR/v9Xu546TjguqszshQEnzn1zFegzVNZntkhCoE947mDTXXgKif7YeYsCKWHU2EdQ2 zCcI0yYa02C3v9VtYRHVuCqORJIKL6wj4XsopEZhm4wFKSpNo1ldOJ4I/yRPniARVkHn 8cFRy9o8c6PiB0CZtnPv5LQphdHRvAp0h9i1YX77R3TN/hYxDmWBEMMj45g7I9thpzgY r5/pHioyAF4iGPVge0xyb+YqBGmFvkEayPVcQAP9dYghtzYymAPmuA4By01gThplW4nZ WKTg== 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=CMlD808lugJXGmG58AGJr1dxcm+wOz+OewK7oNnwtzA=; b=nd7bYPGD9hNUkKEMX2Lozb/x01EpXdPBhqktPlBTmqkAfyJx8YRzGvN6oM1eXZKg/u nUBMa+uMRz9amD0Tj6f42MhoL36zzS9I/6yTiBXfa38bEsm0Nf4nnhbvhSiWYsL5JizZ iDr3D+N52E3WrRbV25FrhwCF+JZS/d4538tnewBVF6RzSmcQqrTTjd5MQOjixqdOuCP1 vpqXngZqjm/nm9KeLudqvxIb7i0ygeWQUazwGeUZd7d5r9IwRXyaVDF75Nmv0P7vMWbr m9RXWtCvmu7K4B55JJcq1JA0asSxL38yB1GAJo5/zu794ps418oyflvhpw8qUiPEJPqf ikFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.b=N32PRGwG; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [208.118.235.17]) by mx.google.com with ESMTPS id o22si5199377qki.45.2017.07.13.07.43.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 13 Jul 2017 07:43:01 -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=@gmail.com header.b=N32PRGwG; 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=redhat.com Received: from localhost ([::1]:60442 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVfKV-0000jU-CM for patch@linaro.org; Thu, 13 Jul 2017 10:42:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVf3T-00012w-Ka for qemu-devel@nongnu.org; Thu, 13 Jul 2017 10:25:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVf3S-0002WC-JQ for qemu-devel@nongnu.org; Thu, 13 Jul 2017 10:25:23 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:34904) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dVf3S-0002Va-Ca for qemu-devel@nongnu.org; Thu, 13 Jul 2017 10:25:22 -0400 Received: by mail-wm0-x244.google.com with SMTP id u23so5457948wma.2 for ; Thu, 13 Jul 2017 07:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CMlD808lugJXGmG58AGJr1dxcm+wOz+OewK7oNnwtzA=; b=N32PRGwGYSBM2V3ezdy6x3rYu32xwpzbKYXxhaMwPm43vUEPXdc9JsygulGvjgDGtB BNGN2zabP0CKXV6BHw/myyoYdZedBUvybOtIchhEx74u8CK6ecAzvulVOzQjKRb9ApZC b8+HHXdAp60dLKKOah0pnqDSR+nnGWh4j84lz5928Tr4MYQiecg3OrOsHyOhOvUeLRlC QlPa7ltGxt6QDstVIcq8fWorck9mdPPx0yL3VL/pGXbE1XE3bpBTWfHaQHHum2Py5BR/ j+Fv+LwDZLJMGR67pFRAJ9CLbt5Vp/wnm3gisAmzfcBhufnPDzOlupiUTZ+P2ahgR5uF VPuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=CMlD808lugJXGmG58AGJr1dxcm+wOz+OewK7oNnwtzA=; b=SG20miiwdtTNLjKXT8bcPAV1VnU9fxFfQrcdsEooXoR2VyfFaKv0sY+7PVn9R/qbMr zgp1D6tcegdAH3qZSJhGbsD+EPMXEri3n0pAgUL7q2euT7JAvq6D8zlo2XIW+rjx7FiW wy8aP9GkhR+OFcndrlwAd64uKXPcL62Rm6sqN8c3RAkPMQIZ94jBWUbCXZuYj/4TJMck P8w0KYIWZ+n8mh/qdUy6t9BHosMNV+CiHkDAKDvDNH/604EEWXj0OLNXGbSVpNrcniOs Lpgx6pH75IBQykLP8FoqRXplCM+fXqZrlO+NJWP85/AB1KK19YIicsG4V6Lkm2BOC22F Gwwg== X-Gm-Message-State: AIVw111sv3RQvmKRTkCJZwOOV+UKp+Gp8fZD72aas/fJKm8pI3NyV3Lk MmRgJsiEZJsAygbmUxQ= X-Received: by 10.28.34.130 with SMTP id i124mr2294752wmi.116.1499955921125; Thu, 13 Jul 2017 07:25:21 -0700 (PDT) Received: from 640k.lan (94-39-191-51.adsl-ull.clienti.tiscali.it. [94.39.191.51]) by smtp.gmail.com with ESMTPSA id k75sm6042448wmh.10.2017.07.13.07.25.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 07:25:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 13 Jul 2017 16:24:20 +0200 Message-Id: <1499955874-10954-28-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1499955874-10954-1-git-send-email-pbonzini@redhat.com> References: <1499955874-10954-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 27/41] 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?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée 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é Message-Id: <20170712105216.747-5-alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini --- gdbstub.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) -- 1.8.3.1 diff --git a/gdbstub.c b/gdbstub.c index 378fdd8..f936ddd 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;