From patchwork Mon Jul 31 08:43:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1814855 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20221208.gappssmtp.com header.i=@daynix-com.20221208.gappssmtp.com header.a=rsa-sha256 header.s=20221208 header.b=SP9Njlmk; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RDsMP49pQz1yfG for ; Mon, 31 Jul 2023 18:48:01 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOY0-0003i5-UF; Mon, 31 Jul 2023 04:46:36 -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 1qQOXW-0002fd-Py for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:46:07 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOXV-00050w-2x for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:46:06 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-686bc261111so2975861b3a.3 for ; Mon, 31 Jul 2023 01:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793164; x=1691397964; 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=2cCfolvh7idEXgF4TdLd2iHCvw9onhY6ET+lKLovyso=; b=SP9NjlmknQRt8bmqOt4+KZgBltXZrqoplF5HNUbp1ftNii9+BBx8WsYRJcjGeLNn/1 FbK6CKC2czHwrzuCR76MTeafDEXOtKGxNUoAsCoESgBIyXZrfyJrdx14Ch3OJWVNcnts E6q3oLO/PxBU8PmWiVc7y8YwUD7Kx3dSKy4TuSFTfCK1GRnOvh2cPhavYSXfyyv3YOUe 9XO/ckQ734cPkVbhf64rYBMQJmkIUKltmnEuLdXZNVCCv/BWhD9WA8HypmNm5k9xwBq4 EAjUDI/BjMnd6XDFf5MV04HP2l8vQMsq84YDD0vl3CbvSLyuFqck6QMElaa3AGOT19n/ 8ESQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793164; x=1691397964; 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=2cCfolvh7idEXgF4TdLd2iHCvw9onhY6ET+lKLovyso=; b=Vb2CnaqPbHpzmPyx/BSxHlH92K801A9Gr5u/BdmTNVbu30umBy/OIz480vxslHcJbD EZtswbWK0QoEDlvJgPEW0mTV6FRfDbdCbJvOrLrfsmjALId1zWmlWw2euaIPmfQti9Pg UjQApzXyennWyLcgO7ua1Jh/v/iMoaCntEFe3dtfJ8q9K2D7u/3g7k+WDKSSPlZCsl9K Qocf9KtdACO/M2uUnW4oeG/XWZPkq0mPyP7Zlt8PhAmGroFUvi5XaEr2D2Ia9z16lDCg f/ajPI71sMogOXfGS2ZiF+GRUNEYK+0DiEw/wcW1k6+AhoVNlxVKEZZ7mAWNFhofnYFs 68vg== X-Gm-Message-State: ABy/qLaeJtQ0uoG+xIrWeuIG/lblyUkKsDKfOuuAhqw+ODq5NRVKWceF 86hdAZqsPVJpIg57wdDcC35Xew== X-Google-Smtp-Source: APBJJlFMxBusi1wYx3a81pCvpSrp8aDs7saPi8oPhnUOMgwU6xu9h9csse0tazK95hVbdV7IY51PDg== X-Received: by 2002:a05:6a20:4299:b0:133:2fb2:917d with SMTP id o25-20020a056a20429900b001332fb2917dmr10174620pzj.5.1690793163948; Mon, 31 Jul 2023 01:46:03 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.45.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:46:03 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Richard Henderson , =?utf-8?q?Marc-Andr=C3=A9?= =?utf-8?q?_Lureau?= , =?utf-8?q?Daniel_P=2E_Be?= =?utf-8?q?rrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 12/24] gdbstub: Simplify XML lookup Date: Mon, 31 Jul 2023 17:43:39 +0900 Message-ID: <20230731084354.115015-13-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::436; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x436.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Now we know all instances of GDBFeature that is used in CPU so we can traverse them to find XML. This removes the need for a CPU-specific lookup function for dynamic XMLs. Signed-off-by: Akihiko Odaki --- gdbstub/gdbstub.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 182efe7e0f..e5bb2c89ba 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -354,8 +354,7 @@ static const char *get_feature_xml(const char *p, const char **newp, GDBProcess *process) { size_t len; - int i; - const char *name; + GDBRegisterState *r; CPUState *cpu = gdb_get_first_cpu_in_process(process); CPUClass *cc = CPU_GET_CLASS(cpu); @@ -364,15 +363,12 @@ static const char *get_feature_xml(const char *p, const char **newp, len++; *newp = p + len; - name = NULL; if (strncmp(p, "target.xml", len) == 0) { char *buf = process->target_xml; const size_t buf_sz = sizeof(process->target_xml); /* Generate the XML description for this CPU. */ if (!buf[0]) { - GDBRegisterState *r; - pstrcat(buf, buf_sz, "" "" @@ -389,28 +385,22 @@ static const char *get_feature_xml(const char *p, const char **newp, pstrcat(buf, buf_sz, "\"/>"); for (r = cpu->gdb_regs; r; r = r->next) { pstrcat(buf, buf_sz, "feature->xml); + pstrcat(buf, buf_sz, r->feature->xmlname); pstrcat(buf, buf_sz, "\"/>"); } pstrcat(buf, buf_sz, ""); } return buf; } - if (cc->gdb_get_dynamic_xml) { - char *xmlname = g_strndup(p, len); - const char *xml = cc->gdb_get_dynamic_xml(cpu, xmlname); - - g_free(xmlname); - if (xml) { - return xml; - } + if (strncmp(p, cc->gdb_core_feature->xmlname, len) == 0) { + return cc->gdb_core_feature->xml; } - for (i = 0; ; i++) { - name = gdb_features[i].xmlname; - if (!name || (strncmp(name, p, len) == 0 && strlen(name) == len)) - break; + for (r = cpu->gdb_regs; r; r = r->next) { + if (strncmp(p, r->feature->xmlname, len) == 0) { + return r->feature->xml; + } } - return name ? gdb_features[i].xml : NULL; + return NULL; } const GDBFeature *gdb_find_static_feature(const char *xmlname)