From patchwork Thu Jun 1 14:49:13 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: 100937 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp843280qge; Thu, 1 Jun 2017 07:53:03 -0700 (PDT) X-Received: by 10.55.25.41 with SMTP id k41mr2142994qkh.163.1496328783546; Thu, 01 Jun 2017 07:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496328783; cv=none; d=google.com; s=arc-20160816; b=lNuCxpJp41TONZvOAviSpaq0cix9Fr4pV4lhhbgvVS/u7UDqn7H4DKESD8QNxqZFdH Kf3HUIRnXi6Vg7Jrg0GTerkBRi3KnRqtHe5+JKm5OoltVoFwatWawF2KsapufAIitIoG 2P88l3o0XN+2SXaiw8VRzosdCmDFwyr89gfPwBh0Opl06zvTkwlVhoo+x+mxkxVvwx12 HKeLrZz/nKlROCrTKxA/XJwBwT4S7m9U1xedK3PHC7iEaSspAWRHJHfrboZQvy5ShAD0 akg7K1E+cNmzs1mbLjoyA7AUiKWFlrtDlhap3U/POdbYwU+b9Sjkjfl4+29XVgVB+Rj5 JC7A== 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=nFQz955pVf6XYmLR/H9E6SlZOO9vXhykp50f21v7cj8=; b=nncPPK2dt8d0rse5lE9DwduCqCg9tUf/WGOOgt9HfWUSrDn4w7uPlmyPGRmq5BjoD3 Qlu6SicMPKf4CkV2ekqv6BavCvFhgdhdhPkBBR5LRnJKAZumTfIxOhJ/K7S1hP4rwgow mLwtRPnaukEHDSn86zSCNV+CndfwmdNSUsvFOB8qIFbLgTB6sEwVazaHGy6PBkUceVTo HN5samaiUzlk3g1UqtEcpIoQktvdvRTTMwOz2VOJUwq/SfUb92g0JxGEosH/tKqs/D/1 9/c1gGE/nOmQg4fvq+N4L6Mwhoz/corH/2lHDtfuAlr4B3f/eXIO2WiKjrpwcSrBXLCT iQtw== 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 u128si19366173qkf.227.2017.06.01.07.53.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Jun 2017 07:53:03 -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]:45064 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGRTB-00076R-1P for patch@linaro.org; Thu, 01 Jun 2017 10:53:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGRPP-0004ZP-GE for qemu-devel@nongnu.org; Thu, 01 Jun 2017 10:49:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGRPJ-0002Uz-GC for qemu-devel@nongnu.org; Thu, 01 Jun 2017 10:49:07 -0400 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:38393) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dGRPJ-0002UK-96 for qemu-devel@nongnu.org; Thu, 01 Jun 2017 10:49:01 -0400 Received: by mail-wm0-x229.google.com with SMTP id n195so35525007wmg.1 for ; Thu, 01 Jun 2017 07:49:01 -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=nFQz955pVf6XYmLR/H9E6SlZOO9vXhykp50f21v7cj8=; b=LOIbfVuNRJYlctX+i1nU9VDFP+8fYZkBNjbVpolncPyO3ug0M8beflPrucg9c0xttB 1TBJzc8C2aJjBZiCSN3s44v3FJagMt4u0juEfASPNYNjAzqYstWS0M9eRRZLmbPXkV6x eH6U3OsUBG6a23cDKUCkCy0ag0iRLYm8//qC8= 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=nFQz955pVf6XYmLR/H9E6SlZOO9vXhykp50f21v7cj8=; b=YHTbXHFn+Z6Yh9rbuD/S+LcvpKzfrE8d6J7rLhERKPaDc5XrrV6YLynF+WA4qitnbe 4IgpwbrnBuHXeXiAOeE8/a8H+50N3jnEONxnMKurMo9rsz00tvJ9hL++kMkCoi8V566G vLa8njSSfe0yZjeKnH8XDxjZEOmnKSkQZRCzYKEf2lObXPVJRzEZM8XWbM6CKVhF7X+E PWQAQoTG7wxgE3zQu8KjMsb9wr3ioLwAi1nwh4HDLjJUezjE2hLi0XFr712mIuMZgWpp CA3XrHX63pzTGEijbiyA7vRwEienQxCTvBSnXtwFRckH9QKe7LXLllyQC7xZ3wjcZKiI bb/w== X-Gm-Message-State: AODbwcC5zfEz+s5zSpVoK+cVG3SALvoMPKXHCQ2P5QFQP5JCMRIiCQxF 8a4p+Ptf1bU5NluB X-Received: by 10.28.30.139 with SMTP id e133mr2141101wme.71.1496328540091; Thu, 01 Jun 2017 07:49:00 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o49sm17880823wrb.47.2017.06.01.07.48.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 07:48:57 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 70F9B3E0488; Thu, 1 Jun 2017 15:49:15 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: pbonzini@redhat.com, doug16k@gmail.com, imbrenda@linux.vnet.ibm.com Date: Thu, 1 Jun 2017 15:49:13 +0100 Message-Id: <20170601144915.20778-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170601144915.20778-1-alex.bennee@linaro.org> References: <20170601144915.20778-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:c09::229 Subject: [Qemu-devel] [PATCH v2 2/4] gdbstub: rename cpu_index -> cpu_gdb_index 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" This is to make it clear the index is purely a gdbstub function and should not be confused with the value of cpu->cpu_index. Signed-off-by: Alex Bennée --- gdbstub.c | 12 ++++++------ include/exec/gdbstub.h | 7 ++++++- 2 files changed, 12 insertions(+), 7 deletions(-) -- 2.13.0 Reviewed-by: Greg Kurz Reviewed-by: Claudio Imbrenda Reviewed-by: Philippe Mathieu-Daudé diff --git a/gdbstub.c b/gdbstub.c index a249846954..026d1fe6bb 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -837,7 +837,7 @@ static CPUState *find_cpu(uint32_t thread_id) CPUState *cpu; CPU_FOREACH(cpu) { - if (cpu_index(cpu) == thread_id) { + if (cpu_gdb_index(cpu) == thread_id) { return cpu; } } @@ -925,7 +925,7 @@ static int gdb_handle_vcont(GDBState *s, const char *p) idx = tmp; /* 0 means any thread, so we pick the first valid CPU */ if (!idx) { - idx = cpu_index(first_cpu); + idx = cpu_gdb_index(first_cpu); } /* @@ -975,7 +975,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) case '?': /* TODO: Make this return the correct value for user-mode. */ snprintf(buf, sizeof(buf), "T%02xthread:%02x;", GDB_SIGNAL_TRAP, - cpu_index(s->c_cpu)); + cpu_gdb_index(s->c_cpu)); put_packet(s, buf); /* Remove all the breakpoints when this query is issued, * because gdb is doing and initial connect and the state @@ -1243,7 +1243,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } else if (strcmp(p,"sThreadInfo") == 0) { report_cpuinfo: if (s->query_cpu) { - snprintf(buf, sizeof(buf), "m%x", cpu_index(s->query_cpu)); + snprintf(buf, sizeof(buf), "m%x", cpu_gdb_index(s->query_cpu)); put_packet(s, buf); s->query_cpu = CPU_NEXT(s->query_cpu); } else @@ -1400,7 +1400,7 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) } snprintf(buf, sizeof(buf), "T%02xthread:%02x;%swatch:" TARGET_FMT_lx ";", - GDB_SIGNAL_TRAP, cpu_index(cpu), type, + GDB_SIGNAL_TRAP, cpu_gdb_index(cpu), type, (target_ulong)cpu->watchpoint_hit->vaddr); cpu->watchpoint_hit = NULL; goto send_packet; @@ -1434,7 +1434,7 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) break; } gdb_set_stop_cpu(cpu); - snprintf(buf, sizeof(buf), "T%02xthread:%02x;", ret, cpu_index(cpu)); + snprintf(buf, sizeof(buf), "T%02xthread:%02x;", ret, cpu_gdb_index(cpu)); send_packet: put_packet(s, buf); diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index f9708bbcd6..c4fe567600 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -58,7 +58,12 @@ void gdb_register_coprocessor(CPUState *cpu, gdb_reg_cb get_reg, gdb_reg_cb set_reg, int num_regs, const char *xml, int g_pos); -static inline int cpu_index(CPUState *cpu) +/* Return the GDB index for a given vCPU state. + * + * For user mode this is simply the thread id. In system mode GDB + * numbers CPUs from 1 as 0 is reserved as an "any cpu" index. + */ +static inline int cpu_gdb_index(CPUState *cpu) { #if defined(CONFIG_USER_ONLY) return cpu->host_tid;