From nobody Tue Apr 15 14:47:29 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1546879275027565.0024722951979; Mon, 7 Jan 2019 08:41:15 -0800 (PST) Received: from localhost ([127.0.0.1]:44623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggXxh-0003pG-UX for importer@patchew.org; Mon, 07 Jan 2019 11:41:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggXoT-0004wm-Qy for qemu-devel@nongnu.org; Mon, 07 Jan 2019 11:31:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggXoR-0001vZ-Dx for qemu-devel@nongnu.org; Mon, 07 Jan 2019 11:31:41 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:54913) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ggXoO-0001mk-AO for qemu-devel@nongnu.org; Mon, 07 Jan 2019 11:31:38 -0500 Received: by mail-wm1-x32b.google.com with SMTP id a62so1454877wmh.4 for ; Mon, 07 Jan 2019 08:31:34 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id j14sm46039759wrv.96.2019.01.07.08.31.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Jan 2019 08:31:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BttWZQoZnqRZyHxMFdEOuZXRafzydfBLYBSIF6UEwhQ=; b=gUxVjRAvqsshIV4scXZmbgLYNQ3xrxig566s+8HGyKLOcQ7sGGBKhWTfgVla176ANa nbfMqzDAw9MGOCR8dRRmA4b/b9x7odywgGUd5U9hd+rcbHH2GZRbOK40fu5CTt3Axvaf Qyi0dxjJ8vJt9x3fBN5PgSZFAMD0Y4aDT/Yd8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BttWZQoZnqRZyHxMFdEOuZXRafzydfBLYBSIF6UEwhQ=; b=I6A35eEYyg9u0NeDMWqwBIs7uOFcpaXN3K4pGx0GsSqkllK3QvfRTwbqXMir+sCWrS fNTrMPd+69ROyu+BX0g5xQdAqPbOzkaV4BsQ4h4ogvNRL+aJ40cUcS4ER+xtAl86bp0y RxGmVN599vTo/fHrdLv2/8qrmlZfqcVWQkCjxpFx5RZekY2LoTmGas6Wb6xd35b/IkVc tN5WVuqqoqoZG/fFd3q0CyBY1abC/vvcojLp1qkA3Cw8CNq3OyVpSvGmlAMO30gXhUwv TUslxHPNVNRe9UMWAffPf9JGuER5HiulGOEGXQyNL4XWQM9snMRREjS+owKp/fApEL2j Y3mg== X-Gm-Message-State: AJcUukepsQElBujV5fCAJqEcLB6aviWskS84WsV4GKTmuvwJU91MXIMz o6A2Zn50zASQcqrEk/FpJY9EPJALCxQwtg== X-Google-Smtp-Source: ALg8bN4JFJK7XWWaXa1MOsH5XmFZotIwenv492fruNeewry5H7uLM5f160zJtgT7sb0sh1U7ssQpDA== X-Received: by 2002:a1c:2314:: with SMTP id j20mr9039164wmj.142.1546878693530; Mon, 07 Jan 2019 08:31:33 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 7 Jan 2019 16:30:50 +0000 Message-Id: <20190107163117.16269-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190107163117.16269-1-peter.maydell@linaro.org> References: <20190107163117.16269-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32b Subject: [Qemu-devel] [PULL 10/37] gdbstub: add multiprocess support to Xfer:features:read: 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Luc Michel Change the Xfer:features:read: packet handling to support the multiprocess extension. This packet is used to request the XML description of the CPU. In multiprocess mode, different descriptions can be sent for different processes. This function now takes the process to send the description for as a parameter, and use a buffer in the process structure to store the generated description. It takes the first CPU of the process to generate the description. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Edgar E. Iglesias Reviewed-by: Alistair Francis Message-id: 20181207090135.7651-9-luc.michel@greensocs.com Signed-off-by: Peter Maydell --- gdbstub.c | 52 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index f70b5a326fe..1f2b155490d 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -300,6 +300,8 @@ typedef struct GDBRegisterState { typedef struct GDBProcess { uint32_t pid; bool attached; + + char target_xml[1024]; } GDBProcess; =20 enum RSState { @@ -812,13 +814,14 @@ static CPUState *gdb_first_attached_cpu(const GDBStat= e *s) return cpu; } =20 -static const char *get_feature_xml(const char *p, const char **newp, - CPUClass *cc) +static const char *get_feature_xml(const GDBState *s, const char *p, + const char **newp, GDBProcess *process) { size_t len; int i; const char *name; - static char target_xml[1024]; + CPUState *cpu =3D get_first_cpu_in_process(s, process); + CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 len =3D 0; while (p[len] && p[len] !=3D ':') @@ -827,36 +830,37 @@ static const char *get_feature_xml(const char *p, con= st char **newp, =20 name =3D NULL; if (strncmp(p, "target.xml", len) =3D=3D 0) { - /* Generate the XML description for this CPU. */ - if (!target_xml[0]) { - GDBRegisterState *r; - CPUState *cpu =3D first_cpu; + char *buf =3D process->target_xml; + const size_t buf_sz =3D sizeof(process->target_xml); =20 - pstrcat(target_xml, sizeof(target_xml), + /* Generate the XML description for this CPU. */ + if (!buf[0]) { + GDBRegisterState *r; + + pstrcat(buf, buf_sz, "" "" ""); if (cc->gdb_arch_name) { gchar *arch =3D cc->gdb_arch_name(cpu); - pstrcat(target_xml, sizeof(target_xml), ""); - pstrcat(target_xml, sizeof(target_xml), arch); - pstrcat(target_xml, sizeof(target_xml), ""); + pstrcat(buf, buf_sz, ""); + pstrcat(buf, buf_sz, arch); + pstrcat(buf, buf_sz, ""); g_free(arch); } - pstrcat(target_xml, sizeof(target_xml), "gdb_core_xml_file); - pstrcat(target_xml, sizeof(target_xml), "\"/>"); + pstrcat(buf, buf_sz, "gdb_core_xml_file); + pstrcat(buf, buf_sz, "\"/>"); for (r =3D cpu->gdb_regs; r; r =3D r->next) { - pstrcat(target_xml, sizeof(target_xml), "xml); - pstrcat(target_xml, sizeof(target_xml), "\"/>"); + pstrcat(buf, buf_sz, "xml); + pstrcat(buf, buf_sz, "\"/>"); } - pstrcat(target_xml, sizeof(target_xml), ""); + pstrcat(buf, buf_sz, ""); } - return target_xml; + return buf; } if (cc->gdb_get_dynamic_xml) { - CPUState *cpu =3D first_cpu; char *xmlname =3D g_strndup(p, len); const char *xml =3D cc->gdb_get_dynamic_xml(cpu, xmlname); =20 @@ -1266,6 +1270,7 @@ out: static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; + GDBProcess *process; CPUClass *cc; const char *p; uint32_t pid, tid; @@ -1650,14 +1655,15 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) const char *xml; target_ulong total_len; =20 - cc =3D CPU_GET_CLASS(first_cpu); + process =3D gdb_get_cpu_process(s, s->g_cpu); + cc =3D CPU_GET_CLASS(s->g_cpu); if (cc->gdb_core_xml_file =3D=3D NULL) { goto unknown_command; } =20 gdb_has_xml =3D true; p +=3D 19; - xml =3D get_feature_xml(p, &p, cc); + xml =3D get_feature_xml(s, p, &p, process); if (!xml) { snprintf(buf, sizeof(buf), "E00"); put_packet(s, buf); @@ -2070,6 +2076,7 @@ static void create_default_process(GDBState *s) =20 process->pid =3D max_pid + 1; process->attached =3D false; + process->target_xml[0] =3D '\0'; } =20 #ifdef CONFIG_USER_ONLY @@ -2345,6 +2352,7 @@ static int find_cpu_clusters(Object *child, void *opa= que) assert(cluster->cluster_id !=3D UINT32_MAX); process->pid =3D cluster->cluster_id + 1; process->attached =3D false; + process->target_xml[0] =3D '\0'; =20 return 0; } --=20 2.19.2