From patchwork Fri Nov 3 19:59:47 2023 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: 740732 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp12496wrr; Fri, 3 Nov 2023 13:11:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHArpu3igULeAeLGwJ4FgHdb6IRV4MIZ3xqwxR/emcPomMmdXjkPt34M4nXH8LqhbTj6duJ X-Received: by 2002:a5d:6d8a:0:b0:32f:76f4:b2b with SMTP id l10-20020a5d6d8a000000b0032f76f40b2bmr4675600wrs.11.1699042265421; Fri, 03 Nov 2023 13:11:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699042265; cv=none; d=google.com; s=arc-20160816; b=cds9TeItp4+i2BPhrDUFnk8xMBpNa0XHD+6hA2d3zq8/Kplb2NIf4mUbh/rHPxCWx+ bncStZbMLd8KYINmG2e7k3pvurHuwTTsiLNEPLhkG07TN7G0D3XmllkdiYLBsy0tZoWB 4tbWJePqLxSjBuvId9DhDZgc2K9o2K9z52X98Wfohb5hMRNPZL4WTtuUJy3d2vcddksZ unPLdX86vdqwZ+sGv7MslbOPqnP2Ff7ZaDjxB0ceBcYD0RyQZ45FKqpr9vfC6XPoF9w5 8lJ7cGZg1ECPgm8y87P24GbUMMJOqLCzSmCGzgMWj9nzDtS6r9WttfWoTaO0hjZLU6Vy HyfQ== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WvNpdCx7aCfQzdBz6Tk/5RuJuiLgzcCIAvSItOrN2Ac=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=m5CxfFwj6p7vPKxuqBCPeEJgRCCHILcs6Rrk/+gCQJnJUqsdVWxyvHEMuwG61ilDg3 1LlsLgxs7EwRuDVlfxZ7RuNhjhS7M0Wo6rc9TisgWjgKhI232lnXL63KUa53zBwtZC2u 2KwIKYShu94o4HNLAtXQXuSmGxPEPS5yWBeZyvT8VPyPmB7qEa333Pp3uOKxqUHiUIfn +dM7vIgYs91GRvabRVW0Z4HSxeUZXd/ebhVSM55IyXtDRE8Wu3ggUz11gW6GCbTppvMO vnM/qWeXp5oQcimuqfOrNqiriE2goifHyCSLZtoYW+DptwgylR58VDCjWV4lytGyxUmd 5QdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ZKC5Q/On"; 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=pass (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 f12-20020a0560001a8c00b0032cc2f12a3csi1906863wry.133.2023.11.03.13.11.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:11:05 -0700 (PDT) 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=pass header.i=@linaro.org header.s=google header.b="ZKC5Q/On"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qz0R9-0004c5-IO; Fri, 03 Nov 2023 16:06:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qz0R1-000431-7m for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:27 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Qm-0006ya-0m for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:26 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-32f78dcf036so2168357f8f.0 for ; Fri, 03 Nov 2023 13:06:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041970; x=1699646770; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WvNpdCx7aCfQzdBz6Tk/5RuJuiLgzcCIAvSItOrN2Ac=; b=ZKC5Q/On2c9NL162wKSjoC+GM6EDyD//JHWP5WNf2SI5ydiinby8FMHBDm6YRfIItK 5e1UzrU7hTDnloEpv0Dw2gYQhNyND877YAd/VHS9xIZcQgr6gXvsdQeABgot9qKWQen7 xhjX6s7r2S5R2akjNNEADJz4a97HWDu9PCYwwTxIxRP1zcVGIX8blQnJ5HnMPkMtCmPo Xz3qUBx3WXi4nxgV3Gm2rWNhNNgwCBciHFCXVuJ3wXIaxgQH9PnyTAsVFcH+Vz9ikZOe DNLaRSHNIzX0S72CFLDX6XHB+GHqx3adCNGhrUlIafTBinRmYrb7JN6vxNSip2cwF2t8 oNJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041970; x=1699646770; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WvNpdCx7aCfQzdBz6Tk/5RuJuiLgzcCIAvSItOrN2Ac=; b=YmVpUy4deb6bGlhp/UNpkqNp2kyaoTLOF79UFNotPUta6LGbgC0q2sRgjsALSbAra/ WkUP5uEyw76hxTzC6z80mnMCl/3swj+p3WbOcaZX4AYrkhC2iinFO0PutVzmbUDSlVEP 9Jfjc6FqBXTOJqc8PuGt7CZOh3AO5Zk1WobJNYzRhfvcimwFuUASfrAb70AJaRpfdsuz mI7iD+n0VTrTLs3CEx2ieQBJ4YieJCy5zmB7Yi51qyNj4tFvmyJYP0Lb76PpKkPA35ev Hc2EO3mnOYVMMiWMDLNmVWM735iBtYXFduySiW57nN7GcuD6fWypGG58kro6h7pWXLH3 55tw== X-Gm-Message-State: AOJu0YwkvnbNKN52IKqPkgpAJyzpzrwxqhoUZDAjGaZvojLxnn479kLY pofFbctlzjaR6UW/MRLwsqNrhw== X-Received: by 2002:a05:6000:1acf:b0:32f:81f6:9a1e with SMTP id i15-20020a0560001acf00b0032f81f69a1emr4137029wry.28.1699041970527; Fri, 03 Nov 2023 13:06:10 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id e11-20020adfe7cb000000b00317a04131c5sm2635033wrn.57.2023.11.03.13.06.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:06:08 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id E6EBA65750; Fri, 3 Nov 2023 19:59:58 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 20/29] gdbstub: Add members to identify registers to GDBFeature Date: Fri, 3 Nov 2023 19:59:47 +0000 Message-Id: <20231103195956.1998255-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki These members will be used to help plugins to identify registers. The added members in instances of GDBFeature dynamically generated by CPUs will be filled in later changes. Signed-off-by: Akihiko Odaki Message-Id: <20231025093128.33116-14-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- include/exec/gdbstub.h | 3 +++ gdbstub/gdbstub.c | 12 +++++++++--- target/riscv/gdbstub.c | 4 +--- scripts/feature_to_c.py | 14 +++++++++++++- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 82a8afa237..da9ddfe54c 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -13,12 +13,15 @@ typedef struct GDBFeature { const char *xmlname; const char *xml; + const char *name; + const char * const *regs; int num_regs; } GDBFeature; typedef struct GDBFeatureBuilder { GDBFeature *feature; GPtrArray *xml; + GPtrArray *regs; int base_reg; } GDBFeatureBuilder; diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index af63b5d159..7d7d887817 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -419,9 +419,10 @@ void gdb_feature_builder_init(GDBFeatureBuilder *builder, GDBFeature *feature, builder->feature = feature; builder->xml = g_ptr_array_new(); g_ptr_array_add(builder->xml, header); + builder->regs = g_ptr_array_new(); builder->base_reg = base_reg; feature->xmlname = xmlname; - feature->num_regs = 0; + feature->name = name; } void gdb_feature_builder_append_tag(const GDBFeatureBuilder *builder, @@ -440,10 +441,12 @@ void gdb_feature_builder_append_reg(const GDBFeatureBuilder *builder, const char *type, const char *group) { - if (builder->feature->num_regs < regnum) { - builder->feature->num_regs = regnum; + if (builder->regs->len <= regnum) { + g_ptr_array_set_size(builder->regs, regnum + 1); } + builder->regs->pdata[regnum] = (gpointer *)name; + if (group) { gdb_feature_builder_append_tag( builder, @@ -469,6 +472,9 @@ void gdb_feature_builder_end(const GDBFeatureBuilder *builder) } g_ptr_array_free(builder->xml, TRUE); + + builder->feature->num_regs = builder->regs->len; + builder->feature->regs = (void *)g_ptr_array_free(builder->regs, FALSE); } const GDBFeature *gdb_find_static_feature(const char *xmlname) diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index 9553ad62a3..fce87a16c2 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -263,11 +263,9 @@ static GDBFeature *riscv_gen_dynamic_csr_feature(CPUState *cs, int base_reg) } predicate = csr_ops[i].predicate; if (predicate && (predicate(env, i) == RISCV_EXCP_NONE)) { - g_autofree char *dynamic_name = NULL; name = csr_ops[i].name; if (!name) { - dynamic_name = g_strdup_printf("csr%03x", i); - name = dynamic_name; + name = g_strdup_printf("csr%03x", i); } gdb_feature_builder_append_reg(&builder, name, bitsize, i, diff --git a/scripts/feature_to_c.py b/scripts/feature_to_c.py index e04d6b2df7..807af0e685 100644 --- a/scripts/feature_to_c.py +++ b/scripts/feature_to_c.py @@ -50,7 +50,9 @@ def writeliteral(indent, bytes): sys.stderr.write(f'unexpected start tag: {element.tag}\n') exit(1) + feature_name = element.attrib['name'] regnum = 0 + regnames = [] regnums = [] tags = ['feature'] for event, element in events: @@ -67,6 +69,7 @@ def writeliteral(indent, bytes): if 'regnum' in element.attrib: regnum = int(element.attrib['regnum']) + regnames.append(element.attrib['name']) regnums.append(regnum) regnum += 1 @@ -85,6 +88,15 @@ def writeliteral(indent, bytes): writeliteral(8, bytes(os.path.basename(input), 'utf-8')) sys.stdout.write(',\n') writeliteral(8, read) - sys.stdout.write(f',\n {num_regs},\n }},\n') + sys.stdout.write(',\n') + writeliteral(8, bytes(feature_name, 'utf-8')) + sys.stdout.write(',\n (const char * const []) {\n') + + for index, regname in enumerate(regnames): + sys.stdout.write(f' [{regnums[index] - base_reg}] =\n') + writeliteral(16, bytes(regname, 'utf-8')) + sys.stdout.write(',\n') + + sys.stdout.write(f' }},\n {num_regs},\n }},\n') sys.stdout.write(' { NULL }\n};\n')