From patchwork Mon Jan 7 16:30:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 154918 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3675100ljp; Mon, 7 Jan 2019 08:39:37 -0800 (PST) X-Google-Smtp-Source: ALg8bN73fIbs7o47h7wv1+jIWzjH/xABF+N9E6EUH2z4MLw2StIVyTX+hYlNmWPCfsbhgNOQutJV X-Received: by 2002:a1c:3282:: with SMTP id y124mr2007739wmy.134.1546879177203; Mon, 07 Jan 2019 08:39:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546879177; cv=none; d=google.com; s=arc-20160816; b=T7OTPOmLZx8whnJgIbghqpcxyNGOI98qGQCBAJUhGaMV4H+7Vw649/NVkF79Q5u9zr 0GyqgF4kU7ADMbOIfFc9isH0+SuvYTJqb2I8Q/uSaV8HLLTt1yeznTvjyBowcTv5AB/m UJUEdI133s+dvBHkI3e8uMRS4r/tGOLRn84HRTWVPSjurbJAa2iE4dOLuj3zuLrbqPXl ZMqieeZxSEBaaprO+0lIuaL4TcXKFVnSpmnGxaAIyof9G/Y4D/wzHAUuLcCNnXcJE0Bs BZN+NCEepA3HlYyc4veYDzxMepO8RGs2tJJ66+Kj1OxXX9GOtimUHcw2diZLDrSW2DUz eUKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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; bh=BttWZQoZnqRZyHxMFdEOuZXRafzydfBLYBSIF6UEwhQ=; b=UvsDCUUCT/EuH+fnMkWrRppy7mCqX4qqtLoeMTW2/RY4RBv/xnLOW3QxsE+q+/DOIO Ai7IuJpKIN8/M6NX3OWkVgXpwQkTfoUVOqhiYIoEhaG/wkwyIXVWXtTAQnGPSWoLSsb4 l/nUpT2TVzIAHFWfz0cdEAU25lXFx6Ys4gy133oJ5kihJGQ7yjbJJxVuUNW8AJktjOGT IRGmR6TVovZw5K2G/9UQZ0OOADiW8ppwFsfjIYbXd+aWCGTqWWZVBPPOmz/u7qLW0KLw WK2EWY0Sgpv1vVx2OmsLXkCFoGD9KwM7LGykYUHSKiZAwyI0iO76H4IStdVBKrdz0+St HkEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gUxVjRAv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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. [209.51.188.17]) by mx.google.com with ESMTPS id w14si4512630wmi.20.2019.01.07.08.39.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 07 Jan 2019 08:39:37 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gUxVjRAv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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 ([127.0.0.1]:44255 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggXw8-0002Vg-1E for patch@linaro.org; Mon, 07 Jan 2019 11:39:36 -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) 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-Received: by 2002:a1c:2314:: with SMTP id j20mr9039164wmj.142.1546878693530; Mon, 07 Jan 2019 08:31:33 -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) 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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é 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(-) -- 2.19.2 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; enum RSState { @@ -812,13 +814,14 @@ static CPUState *gdb_first_attached_cpu(const GDBState *s) return cpu; } -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 = get_first_cpu_in_process(s, process); + CPUClass *cc = CPU_GET_CLASS(cpu); len = 0; while (p[len] && p[len] != ':') @@ -827,36 +830,37 @@ static const char *get_feature_xml(const char *p, const char **newp, name = NULL; if (strncmp(p, "target.xml", len) == 0) { - /* Generate the XML description for this CPU. */ - if (!target_xml[0]) { - GDBRegisterState *r; - CPUState *cpu = first_cpu; + char *buf = process->target_xml; + const size_t buf_sz = sizeof(process->target_xml); - 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 = 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 = cpu->gdb_regs; r; r = 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 = first_cpu; char *xmlname = g_strndup(p, len); const char *xml = cc->gdb_get_dynamic_xml(cpu, xmlname); @@ -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 char *line_buf) const char *xml; target_ulong total_len; - cc = CPU_GET_CLASS(first_cpu); + process = gdb_get_cpu_process(s, s->g_cpu); + cc = CPU_GET_CLASS(s->g_cpu); if (cc->gdb_core_xml_file == NULL) { goto unknown_command; } gdb_has_xml = true; p += 19; - xml = get_feature_xml(p, &p, cc); + xml = 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) process->pid = max_pid + 1; process->attached = false; + process->target_xml[0] = '\0'; } #ifdef CONFIG_USER_ONLY @@ -2345,6 +2352,7 @@ static int find_cpu_clusters(Object *child, void *opaque) assert(cluster->cluster_id != UINT32_MAX); process->pid = cluster->cluster_id + 1; process->attached = false; + process->target_xml[0] = '\0'; return 0; }