From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851566; cv=none; d=zohomail.com; s=zohoarc; b=fIDJfIvbIDKcN5O9Wavq+OOp1YmxooKToVI26JICGvlrsTq3pFkZB4RyYrQ8KkI+iTcPEqYrohL9uAwBDHHroXtLIk7gvYAvCnU0Sla6XL6A/UMd6fIr7ii+CCA8k8DFZwyYYKJwQ44RkAlSU4bCjcI5PotJ4F2C7adDOlrz18Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851566; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=21Z173hVFszR8s4nfjM3OYWaOyCmfZYL9fagBQvy26Q=; b=HMl9sGmZaLodfvTGjv8yv5d/hha3nJL+7sPj6fbRq2GPmCN8yX+Po2J57xhxt6pvZ+d+rn0BbjrT9fYXG+vRkUGC3iV4eJpEA8cptUs+7Tb0eiUVLyIWrLaf5Gp++dOSo0vtJVjSDJKyu0Wyf7CBLm3ajuLZuPcmTHk7/6Jrxbs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694851566577888.3468291922378; Sat, 16 Sep 2023 01:06:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQG2-0003Cw-QO; Sat, 16 Sep 2023 04:02:26 -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 1qhQFv-0003Bv-QV for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:19 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhQFu-0005xt-Ai for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:19 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-68fac346f6aso2686121b3a.3 for ; Sat, 16 Sep 2023 01:02:18 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.02.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:02:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851337; x=1695456137; 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=21Z173hVFszR8s4nfjM3OYWaOyCmfZYL9fagBQvy26Q=; b=rEWKv5VVG4XNLwt7EJ/0xCI89XCLk1ND0ghIxOIjV1cijTL7T53gQAt0+H7UZgndzg hxgRDEDBsDWcydp5UijdY15WE9n1XtjLOohM21I9x7IpyxUqVF9kg5D1LwSceXoImdok AeI5HHzorX4HiDzIXoKJSc1PopFc0MKAMtgF/38osVb2okizPWHU7YPn+NgjmUNS8uv9 bE8CNDlp7ehlkdvLJky/oxme3lnEYvd5LJA2k+ItytomSUtblaMaf1U/u2CWGav8vaKa sIRTZq/7oEIGEMB7LGBjhMXmHt1TnKIviM2dAHyG+yT/P6vXPep2CElsi+BLWbPnTAw0 fkHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851337; x=1695456137; 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=21Z173hVFszR8s4nfjM3OYWaOyCmfZYL9fagBQvy26Q=; b=iVaTAqSLBO20ATuf8UiYBhPeieN1Hh/DI5K1k2lYObfAvadN8tR5ByVBdYp262IiAi +WZly/B/jNTA+Mx3+l9PfiKCSZOmBaj4cVtsEoUa1RIEgFb3NMp90kpRGZsKWph4cx5D 9ryOX5PgX7I7CjDM8gRmYzH876urAazJhEykU5jwJ+tcEY0T1jsGpQeaxaK/wCUdf9UV RVvMvALc/vU02MKE7FH1x3k4rMX0+KA8Dr2mBZF1z+GFf8ynZLyx5CQ3qMospXAhhYED Ne4oRtOxDaK6b8LELyjMzvxnUyZcoqdB6FjQI6koS0e1tQb/vhu5O5fffG7fiqPxQHSj ZSig== X-Gm-Message-State: AOJu0YwOfnamvVM745TP24J+HMCtYMtzhchDABIsR6LCJKQk92PK1iB3 Tf2/xVJqln+2Fc6YpbDcKpBnfQ== X-Google-Smtp-Source: AGHT+IGgpl7byC9G6zNPznONiowPDkwA/x2kgtGgsz4q0jnazDB8LUm6k3j6Y12nZoeirGDLf3ML1w== X-Received: by 2002:a05:6a20:1442:b0:159:fe1d:2f09 with SMTP id a2-20020a056a20144200b00159fe1d2f09mr5451383pzi.6.1694851337104; Sat, 16 Sep 2023 01:02:17 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , John Snow , Cleber Rosa Subject: [PATCH v8 01/19] gdbstub: Add num_regs member to GDBFeature Date: Sat, 16 Sep 2023 17:01:18 +0900 Message-ID: <20230916080149.129989-2-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=2607:f8b0:4864:20::42f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42f.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851567071100001 Currently the number of registers exposed to GDB is written as magic numbers in code. Derive the number of registers GDB actually see from XML files to replace the magic numbers in code later. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e --- include/exec/gdbstub.h | 1 + scripts/feature_to_c.py | 46 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 1a01c35f8e..a43aa34dad 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -13,6 +13,7 @@ typedef struct GDBFeature { const char *xmlname; const char *xml; + int num_regs; } GDBFeature; =20 =20 diff --git a/scripts/feature_to_c.py b/scripts/feature_to_c.py index bcbcb83beb..e04d6b2df7 100755 --- a/scripts/feature_to_c.py +++ b/scripts/feature_to_c.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: GPL-2.0-or-later =20 -import os, sys +import os, sys, xml.etree.ElementTree =20 def writeliteral(indent, bytes): sys.stdout.write(' ' * indent) @@ -39,10 +39,52 @@ def writeliteral(indent, bytes): with open(input, 'rb') as file: read =3D file.read() =20 + parser =3D xml.etree.ElementTree.XMLPullParser(['start', 'end']) + parser.feed(read) + events =3D parser.read_events() + event, element =3D next(events) + if event !=3D 'start': + sys.stderr.write(f'unexpected event: {event}\n') + exit(1) + if element.tag !=3D 'feature': + sys.stderr.write(f'unexpected start tag: {element.tag}\n') + exit(1) + + regnum =3D 0 + regnums =3D [] + tags =3D ['feature'] + for event, element in events: + if event =3D=3D 'end': + if element.tag !=3D tags[len(tags) - 1]: + sys.stderr.write(f'unexpected end tag: {element.tag}\n') + exit(1) + + tags.pop() + if element.tag =3D=3D 'feature': + break + elif event =3D=3D 'start': + if len(tags) < 2 and element.tag =3D=3D 'reg': + if 'regnum' in element.attrib: + regnum =3D int(element.attrib['regnum']) + + regnums.append(regnum) + regnum +=3D 1 + + tags.append(element.tag) + else: + raise Exception(f'unexpected event: {event}\n') + + if len(tags): + sys.stderr.write('unterminated feature tag\n') + exit(1) + + base_reg =3D min(regnums) + num_regs =3D max(regnums) - base_reg + 1 if len(regnums) else 0 + sys.stdout.write(' {\n') writeliteral(8, bytes(os.path.basename(input), 'utf-8')) sys.stdout.write(',\n') writeliteral(8, read) - sys.stdout.write('\n },\n') + sys.stdout.write(f',\n {num_regs},\n }},\n') =20 sys.stdout.write(' { NULL }\n};\n') --=20 2.42.0 From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851563; cv=none; d=zohomail.com; s=zohoarc; b=NIfSFHpb1rDWWniaolmfSVJF26cDenfgOPYfVUKhXRLwW7kvwsEfcRczYFasZHMPCGaKpzbI9d5iGrwkMZ1ZOWYSfV7cpruP9K8RkGwsS4vRy1G+FpoIdTQlssKlVwdOpdSy878wjo+mmJ8aN4Q3hSizFN//1iIm1hyUFMx0i2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851563; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=Tnf03Q7+288TJsyd7lSqF33vPvOy+ywzsBcRMgBbA/w=; b=hQZ89Z26GF0/C18yXqBEf2CyI28we+FLI1+s4uKy8FCdNSOVnvEZwbTx5F71NW0uzbzE04eT33uNBU72DQcguQ2nvWlNMOSEKLo/lpXRiyeO82596onw4wJTYObJruQLQanOP4Ux/wWZ7MKz7uoWpsYqHISJZXfJTjm3uQZbU+M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694851563136580.3120750536311; Sat, 16 Sep 2023 01:06:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQG3-0003DG-H5; Sat, 16 Sep 2023 04:02:27 -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 1qhQFy-0003CD-Fe for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:25 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhQFw-0005yC-Gq for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:21 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-68fbb10dec7so2651542b3a.3 for ; Sat, 16 Sep 2023 01:02:20 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.02.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851339; x=1695456139; 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=Tnf03Q7+288TJsyd7lSqF33vPvOy+ywzsBcRMgBbA/w=; b=vm4AFZzb5KvicQXETQ4tsqDN8UtvnmLkT4jY0DKLzfuLjeI90iLvV7rO82GYe4Wgyo k7WhR1YH1Dk3eSSiQfLs29cQzFKLDLPs/1PaPbAmxL++KqklH9rMpZSEz7jIfhF+I7jI c4itAyzOv5v4//wNPCdu+q1w2ygbDQ2VJXb8vpYXo9GykFXCZ/mI+ROZ2u4nUtRJfmlk ArYuvJ9mTVAbV8Egf1+H3FIKkCENPN33ps7Ve//hjQ2rvACJoMfbU9cR4LbiPq6+PS4M gQADStUDVN/LD86Doce6v67aMmJqRp50IYK+OgSa3b/nAe6B9MFlW0mOTOBp5+ZlWH1B OfSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851339; x=1695456139; 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=Tnf03Q7+288TJsyd7lSqF33vPvOy+ywzsBcRMgBbA/w=; b=KD/57abey0YMDVoyxBAFFA6QbO3GyZTht26v964bAel9GtAmPCntJlhP3uVxRkKSOK PZiFPB++bOJFO1ggLqxv3K5g3lrjrTzZoea24PP4pE6tB5EpKbW/3I/X3nUFA/e1HTj5 LSYqaRvKEYnzHyk3Co4bY8AsTWt+Mz0mRR0AP4Vw96ohx3+/cF+Pcg4eXlUzh0uVN1cU brsDLj/wUaoYW6P2vQmAAAmgiKQkk1U+cbdcDhWomWIJ4cRB/cJMWGrZqQ8amROCEtLC 1Y/aQtE445KR8YB+hAgYsD0mJFauWztA9hS+GgtMsOOY4AHdpITGRTHw690UpF/yP6lG ZOSg== X-Gm-Message-State: AOJu0YyUv9jwA5+ZeOOVPkWRv08rPGfM0I3o7Rdg4LBHCp2s+VAK58AV 4lbiwspVW9iwIrazvdnFUVRhJnjFcFh6eWAPgjY= X-Google-Smtp-Source: AGHT+IG5ylxptxqrsqMDXDxOX5FX2lPnsuYBAo9rVpjiC8hcbcg1obJnCwHBwkcdrMC6mKnoAJx9Rg== X-Received: by 2002:a05:6a20:3d1d:b0:131:f504:a631 with SMTP id y29-20020a056a203d1d00b00131f504a631mr4703700pzi.51.1694851339293; Sat, 16 Sep 2023 01:02:19 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Richard Henderson Subject: [PATCH v8 02/19] gdbstub: Introduce gdb_find_static_feature() Date: Sat, 16 Sep 2023 17:01:19 +0900 Message-ID: <20230916080149.129989-3-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=2607:f8b0:4864:20::42c; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42c.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851564474100001 This function is useful to determine the number of registers exposed to GDB from the XML name. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- include/exec/gdbstub.h | 2 ++ gdbstub/gdbstub.c | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index a43aa34dad..071021415a 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -44,6 +44,8 @@ void gdb_register_coprocessor(CPUState *cpu, */ int gdbserver_start(const char *port_or_device); =20 +const GDBFeature *gdb_find_static_feature(const char *xmlname); + void gdb_set_stop_cpu(CPUState *cpu); =20 /* in gdbstub-xml.c, generated by scripts/feature_to_c.py */ diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 9810d15278..fd73d6d257 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -420,6 +420,19 @@ static const char *get_feature_xml(const char *p, cons= t char **newp, return NULL; } =20 +const GDBFeature *gdb_find_static_feature(const char *xmlname) +{ + const GDBFeature *feature; + + for (feature =3D gdb_static_features; feature->xmlname; feature++) { + if (!strcmp(feature->xmlname, xmlname)) { + return feature; + } + } + + g_assert_not_reached(); +} + static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) { CPUClass *cc =3D CPU_GET_CLASS(cpu); --=20 2.42.0 From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851383; cv=none; d=zohomail.com; s=zohoarc; b=fEFbaMKGB66xcNPQUMtTnil9kEayOTQtxWygMG0oF2kfyFsekz2kJICQErt7hAfHdHPZ0vSvIZRNesEckTusH62NNjq8ZwP4tyTQ0PnLhHmqTICKr1KUkdT5mWnm12P76vdYWCe6uedPveoqAFLBIy9m34/RfKWPwWZMCE6lKDc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851383; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=qR50/oVHEkhYuE4uesWq3gxNrw/NRvm4C1y1sZ4STiU=; b=OSJwWNN30a4VoBauJFxzAyDxUPQCXWFaHK4DCUYtmJ5+TxbpoMUj7VMwpyEqp21V4YSXD22JvCZqUFx++8NeR33DZawPr+he8E4O78FE7JyStNInaWDOrnFqQz2pzjcVAHRsynFUWV+2OyBuyN6o9DBpdtiH8ym+v90ZtDiN51w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694851383675796.5539944221537; Sat, 16 Sep 2023 01:03:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQG4-0003DP-4Z; Sat, 16 Sep 2023 04:02:28 -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 1qhQG0-0003CK-Qa for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:25 -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 1qhQFy-0005yV-J1 for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:24 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-68fb98745c1so2375497b3a.1 for ; Sat, 16 Sep 2023 01:02:22 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.02.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851341; x=1695456141; 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=qR50/oVHEkhYuE4uesWq3gxNrw/NRvm4C1y1sZ4STiU=; b=m3NYwkGq5coJN9DE6wo/RXQ2J+tGpZEXlWNlayuf2Wnwl6jsc3pehofHvh7mZ4bwoZ naq/wcNalpOTLA+gU3qXlYfbqsdV8BTP0SKs5xeXriWig6XdzRBh+HyeKRhwanfYiP+E puIDq0l3LzGHu2g8+DeVMuVFFGLrF5oJXZPx9MCUiYmB0+rbQc06yZBFZ5yEwCJ+e2YR dkQQbFXIFmrWQNjgnZJ0avLzkucrhrWjoKqBd+ErZpTxYh1Tp+lYDA6Cb3ErDN2voYDa v32u/24dWQyG+5ahpVIZUkAyXPdu4x6wAEgpfkXVdYDzyCnvGu+p59s0ebDcTfBjNdgk uFLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851341; x=1695456141; 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=qR50/oVHEkhYuE4uesWq3gxNrw/NRvm4C1y1sZ4STiU=; b=Havv7KsO8GjMkuFz7Zy30NUPkLi/7a/pHp0zXvWbuwgu8168FJFzI/onBqZTsTAjHH Ti3VkfLZWKROq+EHdpkd2E0i/u2OZ1G6VFRESfsssp1q+RGKQAREjYuzei51pZIX2Dkg vnqttCFPBL44ULS4bp+gd3g1Wj7JFT0QtjFKg6dizgeCYCdFwwr47xjlvnDPXB4auGsO U17W5hQcmLS7rnGaizNrwERWogUbi2N1WVUZoMLLjczqCOCxHXhXKe3l94ExEFqiQVOU OKG1hCm6Qqzmhh+IO0Ta2YlLdbYAN+J6WLX/tkI3MkhPAMICi3AIJuIyE+fEKiUtVwmK yrpA== X-Gm-Message-State: AOJu0YxNZlLVp2coRsqbXdhEkFfv/o8oQ+JXgUBNTs7mSTYUwVcDhyi5 8xNX+Ib5u2or288637izyLpBpQ== X-Google-Smtp-Source: AGHT+IG5p+Mh98SGrfob5xUGKOhLKP/hC7+2BosiOfxp+BhNNZOn7Wt/Wmmq1iSs5gGS1wzLMPdodg== X-Received: by 2002:a05:6a00:2d04:b0:68f:dfe2:9f03 with SMTP id fa4-20020a056a002d0400b0068fdfe29f03mr3266293pfb.11.1694851341384; Sat, 16 Sep 2023 01:02:21 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Richard Henderson Subject: [PATCH v8 03/19] gdbstub: Introduce GDBFeatureBuilder Date: Sat, 16 Sep 2023 17:01:20 +0900 Message-ID: <20230916080149.129989-4-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; 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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851385451100001 Content-Type: text/plain; charset="utf-8" GDBFeatureBuilder unifies the logic to generate dynamic GDBFeature. Signed-off-by: Akihiko Odaki Reviewed-by: Richard Henderson --- include/exec/gdbstub.h | 20 ++++++++++++++ gdbstub/gdbstub.c | 59 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 071021415a..d9ef2ccbff 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -16,6 +16,11 @@ typedef struct GDBFeature { int num_regs; } GDBFeature; =20 +typedef struct GDBFeatureBuilder { + GDBFeature *feature; + GPtrArray *xml; +} GDBFeatureBuilder; + =20 /* Get or set a register. Returns the size of the register. */ typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArray *buf, int reg); @@ -44,6 +49,21 @@ void gdb_register_coprocessor(CPUState *cpu, */ int gdbserver_start(const char *port_or_device); =20 +void gdb_feature_builder_init(GDBFeatureBuilder *builder, GDBFeature *feat= ure, + const char *name, const char *xmlname); + +void gdb_feature_builder_append_tag(const GDBFeatureBuilder *builder, + const char *format, ...) + G_GNUC_PRINTF(2, 3); + +int gdb_feature_builder_append_reg(const GDBFeatureBuilder *builder, + const char *name, + int bitsize, + const char *type, + const char *group); + +void gdb_feature_builder_end(const GDBFeatureBuilder *builder); + const GDBFeature *gdb_find_static_feature(const char *xmlname); =20 void gdb_set_stop_cpu(CPUState *cpu); diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index fd73d6d257..d63f6c0d9d 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -420,6 +420,65 @@ static const char *get_feature_xml(const char *p, cons= t char **newp, return NULL; } =20 +void gdb_feature_builder_init(GDBFeatureBuilder *builder, GDBFeature *feat= ure, + const char *name, const char *xmlname) +{ + char *header =3D g_markup_printf_escaped( + "" + "" + "", + name); + + builder->feature =3D feature; + builder->xml =3D g_ptr_array_new(); + g_ptr_array_add(builder->xml, header); + feature->xmlname =3D xmlname; + feature->num_regs =3D 0; +} + +void gdb_feature_builder_append_tag(const GDBFeatureBuilder *builder, + const char *format, ...) +{ + va_list ap; + va_start(ap, format); + g_ptr_array_add(builder->xml, g_markup_vprintf_escaped(format, ap)); + va_end(ap); +} + +int gdb_feature_builder_append_reg(const GDBFeatureBuilder *builder, + const char *name, + int bitsize, + const char *type, + const char *group) +{ + if (group) { + gdb_feature_builder_append_tag( + builder, + "", + name, bitsize, type, group); + } else { + gdb_feature_builder_append_tag( + builder, "", + name, bitsize, type); + } + + return builder->feature->num_regs++; +} + +void gdb_feature_builder_end(const GDBFeatureBuilder *builder) +{ + g_ptr_array_add(builder->xml, (void *)""); + g_ptr_array_add(builder->xml, NULL); + + builder->feature->xml =3D g_strjoinv(NULL, (void *)builder->xml->pdata= ); + + for (guint i =3D 0; i < builder->xml->len - 2; i++) { + g_free(g_ptr_array_index(builder->xml, i)); + } + + g_ptr_array_free(builder->xml, TRUE); +} + const GDBFeature *gdb_find_static_feature(const char *xmlname) { const GDBFeature *feature; --=20 2.42.0 From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851387; cv=none; d=zohomail.com; s=zohoarc; b=IvsSMaWSMz009KlceYpWRmiGsLu8nMP4yRQTGfy4hnW9l8du/yPRl+vsSLUyCLiawRcQ98e6Qs3RJsl29iEbM1QFM8wy7q6v6gySEuVuvknQYacjL4ZrQy/lPVIFv7fow9nYArrFuEMAY4iZdaQzQEcZUnh9NTX2pWqA763Ism0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851387; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=l7WuGmjq2+wyLrnwwiS53pSIsK7THIe0sUG4uz6fGKA=; b=DWyAF/mpjzjZP4vxxRdigi8eQ4OkbjYf6lFellzso8zcdPVL+Sj96RuidllWsHy29GZUoFcd8Uvaf8Qx2YHrCDMC0b4EWVVUm93UtCMHS/IOkGI+unNsvYfY45g4E4ry5ItVWNfWxCZlym81r6DWEghZNtzuQQDqZvXXhPWvYes= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694851387470962.1062179530703; Sat, 16 Sep 2023 01:03:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQG6-0003Eo-84; Sat, 16 Sep 2023 04:02:30 -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 1qhQG4-0003DO-2Z for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:28 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhQG1-0005ym-G1 for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:27 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-68fac346f6aso2686156b3a.3 for ; Sat, 16 Sep 2023 01:02:24 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.02.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:02:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851344; x=1695456144; 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=l7WuGmjq2+wyLrnwwiS53pSIsK7THIe0sUG4uz6fGKA=; b=1IEj/15HBv6CuCrprb+/3scKnxZ5ZXhyk1ROWi0bi4We9B5RYHPjvMVfksdHDHyUR3 yH94sp+U7xq53F0i6Yo9UlJY9ao1ygcY+jcp3ZkEs1sTX001mIpWf4c7vJTtGq0crejQ Jd9jKVj7PFXC5YU3C01rpOcBpT5n+vFBRQw5cRrkunBFhyGEngHXRjVzoPIGSVIv8yO5 sG7iaUUC13n+3UlW8D7Mg1P2/cjjQba/7AkY3/20j9wvqUa37yD6+0BWr6T1wmIW1y2q WnFTY0XvSNDZDvvbI/Aqif/QFUS1vVWS0sqxHcsJ47Kl275rK8SkEjBEQHOB4O5dEpg1 RRpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851344; x=1695456144; 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=l7WuGmjq2+wyLrnwwiS53pSIsK7THIe0sUG4uz6fGKA=; b=QTsg0sAexvAFXHuzww4aoHBu8F4x8aHhjKVHzWeF+pZA/zXmzbizbtc6v26EI6qcB7 5n2opJYYhA4OtIRddKmardQVHs5J6y5QdBb+qf4qlvVK/jGFHA5GxeolNJoIy4d4GgQF 5jDh+yKw7eS3VL4r3RjA1sZFPBSodzCL0kKRjxYU5Ik6ZdzSUX+x6/q5smk0Xlij7ay5 HJT/D1ACaO/ZK4t0UXSBAX/dntZ4wtJwjNVRxxPnV6nNaEhFVFAorCHQ6qNLhToC1K8I 7CkcAREPOe4ej3mRawOresHZla49IQYhYKuCmCD8dcc9DsqHI9z0Uhi+utDoIwD8eCv9 cbyw== X-Gm-Message-State: AOJu0Yy2DIvzhLPK/oExarNMqMRuuVRiTMUjIfpnCxvl821yhuh6kPTD bI+crF6Y+k45tHXX4xbAgXftNw== X-Google-Smtp-Source: AGHT+IHt2r/FSgwMpkX96aQbMAH3JSJuvYToZkK+iHKUYcddofvvpRvNL9cH1lAtAbS/zUjpO2lv1g== X-Received: by 2002:a05:6a00:134e:b0:682:537f:2cb8 with SMTP id k14-20020a056a00134e00b00682537f2cb8mr4576488pfu.26.1694851343819; Sat, 16 Sep 2023 01:02:23 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Richard Henderson , Peter Maydell , qemu-arm@nongnu.org (open list:ARM TCG CPUs) Subject: [PATCH v8 04/19] target/arm: Use GDBFeature for dynamic XML Date: Sat, 16 Sep 2023 17:01:21 +0900 Message-ID: <20230916080149.129989-5-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=2607:f8b0:4864:20::430; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x430.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851388673100009 Content-Type: text/plain; charset="utf-8" In preparation for a change to use GDBFeature as a parameter of gdb_register_coprocessor(), convert the internal representation of dynamic feature from plain XML to GDBFeature. Signed-off-by: Akihiko Odaki Acked-by: Richard Henderson --- target/arm/cpu.h | 21 +++---- target/arm/internals.h | 2 +- target/arm/gdbstub.c | 134 ++++++++++++++++++----------------------- target/arm/gdbstub64.c | 90 ++++++++++++--------------- 4 files changed, 109 insertions(+), 138 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 278cc135c2..24c6adff36 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -25,6 +25,7 @@ #include "hw/registerfields.h" #include "cpu-qom.h" #include "exec/cpu-defs.h" +#include "exec/gdbstub.h" #include "qapi/qapi-types-common.h" =20 /* ARM processors have a weak memory model */ @@ -136,23 +137,21 @@ enum { */ =20 /** - * DynamicGDBXMLInfo: - * @desc: Contains the XML descriptions. - * @num: Number of the registers in this XML seen by GDB. + * DynamicGDBFeatureInfo: + * @desc: Contains the feature descriptions. * @data: A union with data specific to the set of registers * @cpregs_keys: Array that contains the corresponding Key of * a given cpreg with the same order of the cpreg * in the XML description. */ -typedef struct DynamicGDBXMLInfo { - char *desc; - int num; +typedef struct DynamicGDBFeatureInfo { + GDBFeature desc; union { struct { uint32_t *keys; } cpregs; } data; -} DynamicGDBXMLInfo; +} DynamicGDBFeatureInfo; =20 /* CPU state for each instance of a generic timer (in cp15 c14) */ typedef struct ARMGenericTimer { @@ -881,10 +880,10 @@ struct ArchCPU { uint64_t *cpreg_vmstate_values; int32_t cpreg_vmstate_array_len; =20 - DynamicGDBXMLInfo dyn_sysreg_xml; - DynamicGDBXMLInfo dyn_svereg_xml; - DynamicGDBXMLInfo dyn_m_systemreg_xml; - DynamicGDBXMLInfo dyn_m_secextreg_xml; + DynamicGDBFeatureInfo dyn_sysreg_feature; + DynamicGDBFeatureInfo dyn_svereg_feature; + DynamicGDBFeatureInfo dyn_m_systemreg_feature; + DynamicGDBFeatureInfo dyn_m_secextreg_feature; =20 /* Timers used by the generic (architected) timer */ QEMUTimer *gt_timer[NUM_GTIMERS]; diff --git a/target/arm/internals.h b/target/arm/internals.h index 5f5393b25c..58f1a66f8d 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1385,7 +1385,7 @@ static inline uint64_t pmu_counter_mask(CPUARMState *= env) } =20 #ifdef TARGET_AARCH64 -int arm_gen_dynamic_svereg_xml(CPUState *cpu, int base_reg); +GDBFeature *arm_gen_dynamic_svereg_feature(CPUState *cpu); int aarch64_gdb_get_sve_reg(CPUARMState *env, GByteArray *buf, int reg); int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg); int aarch64_gdb_get_fpu_reg(CPUARMState *env, GByteArray *buf, int reg); diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index b7ace24bfc..fc0aa6f235 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -25,11 +25,10 @@ #include "internals.h" #include "cpregs.h" =20 -typedef struct RegisterSysregXmlParam { +typedef struct RegisterSysregFeatureParam { CPUState *cs; - GString *s; - int n; -} RegisterSysregXmlParam; + GDBFeatureBuilder builder; +} RegisterSysregFeatureParam; =20 /* Old gdb always expect FPA registers. Newer (xml-aware) gdb only expect whatever the target description contains. Due to a historical mishap @@ -215,7 +214,7 @@ static int arm_gdb_get_sysreg(CPUARMState *env, GByteAr= ray *buf, int reg) const ARMCPRegInfo *ri; uint32_t key; =20 - key =3D cpu->dyn_sysreg_xml.data.cpregs.keys[reg]; + key =3D cpu->dyn_sysreg_feature.data.cpregs.keys[reg]; ri =3D get_arm_cp_reginfo(cpu->cp_regs, key); if (ri) { if (cpreg_field_is_64bit(ri)) { @@ -232,34 +231,32 @@ static int arm_gdb_set_sysreg(CPUARMState *env, uint8= _t *buf, int reg) return 0; } =20 -static void arm_gen_one_xml_sysreg_tag(GString *s, DynamicGDBXMLInfo *dyn_= xml, +static void arm_gen_one_feature_sysreg(GDBFeatureBuilder *builder, + DynamicGDBFeatureInfo *dyn_feature, ARMCPRegInfo *ri, uint32_t ri_key, - int bitsize, int regnum) + int bitsize) { - g_string_append_printf(s, "name); - g_string_append_printf(s, " bitsize=3D\"%d\"", bitsize); - g_string_append_printf(s, " regnum=3D\"%d\"", regnum); - g_string_append_printf(s, " group=3D\"cp_regs\"/>"); - dyn_xml->data.cpregs.keys[dyn_xml->num] =3D ri_key; - dyn_xml->num++; + int num =3D gdb_feature_builder_append_reg(builder, ri->name, bitsize, + "int", "cp_regs"); + + dyn_feature->data.cpregs.keys[num] =3D ri_key; } =20 -static void arm_register_sysreg_for_xml(gpointer key, gpointer value, - gpointer p) +static void arm_register_sysreg_for_feature(gpointer key, gpointer value, + gpointer p) { uint32_t ri_key =3D (uintptr_t)key; ARMCPRegInfo *ri =3D value; - RegisterSysregXmlParam *param =3D (RegisterSysregXmlParam *)p; - GString *s =3D param->s; + RegisterSysregFeatureParam *param =3D p; ARMCPU *cpu =3D ARM_CPU(param->cs); CPUARMState *env =3D &cpu->env; - DynamicGDBXMLInfo *dyn_xml =3D &cpu->dyn_sysreg_xml; + DynamicGDBFeatureInfo *dyn_feature =3D &cpu->dyn_sysreg_feature; =20 if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_NO_GDB))) { if (arm_feature(env, ARM_FEATURE_AARCH64)) { if (ri->state =3D=3D ARM_CP_STATE_AA64) { - arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64, - param->n++); + arm_gen_one_feature_sysreg(¶m->builder, dyn_feature, + ri, ri_key, 64); } } else { if (ri->state =3D=3D ARM_CP_STATE_AA32) { @@ -268,32 +265,31 @@ static void arm_register_sysreg_for_xml(gpointer key,= gpointer value, return; } if (ri->type & ARM_CP_64BIT) { - arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64, - param->n++); + arm_gen_one_feature_sysreg(¶m->builder, dyn_featur= e, + ri, ri_key, 64); } else { - arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 32, - param->n++); + arm_gen_one_feature_sysreg(¶m->builder, dyn_featur= e, + ri, ri_key, 32); } } } } } =20 -static int arm_gen_dynamic_sysreg_xml(CPUState *cs, int base_reg) +static GDBFeature *arm_gen_dynamic_sysreg_feature(CPUState *cs) { ARMCPU *cpu =3D ARM_CPU(cs); - GString *s =3D g_string_new(NULL); - RegisterSysregXmlParam param =3D {cs, s, base_reg}; - - cpu->dyn_sysreg_xml.num =3D 0; - cpu->dyn_sysreg_xml.data.cpregs.keys =3D g_new(uint32_t, g_hash_table_= size(cpu->cp_regs)); - g_string_printf(s, ""); - g_string_append_printf(s, "= "); - g_string_append_printf(s, ""); - g_hash_table_foreach(cpu->cp_regs, arm_register_sysreg_for_xml, ¶m= ); - g_string_append_printf(s, ""); - cpu->dyn_sysreg_xml.desc =3D g_string_free(s, false); - return cpu->dyn_sysreg_xml.num; + RegisterSysregFeatureParam param =3D {cs}; + gsize num_regs =3D g_hash_table_size(cpu->cp_regs); + + gdb_feature_builder_init(¶m.builder, + &cpu->dyn_sysreg_feature.desc, + "org.qemu.gdb.arm.sys.regs", + "system-registers.xml"); + cpu->dyn_sysreg_feature.data.cpregs.keys =3D g_new(uint32_t, num_regs); + g_hash_table_foreach(cpu->cp_regs, arm_register_sysreg_for_feature, &p= aram); + gdb_feature_builder_end(¶m.builder); + return &cpu->dyn_sysreg_feature.desc; } =20 #ifdef CONFIG_TCG @@ -385,31 +381,26 @@ static int arm_gdb_set_m_systemreg(CPUARMState *env, = uint8_t *buf, int reg) return 0; /* TODO */ } =20 -static int arm_gen_dynamic_m_systemreg_xml(CPUState *cs, int orig_base_reg) +static GDBFeature *arm_gen_dynamic_m_systemreg_feature(CPUState *cs) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; - GString *s =3D g_string_new(NULL); - int base_reg =3D orig_base_reg; + GDBFeatureBuilder builder; int i; =20 - g_string_printf(s, ""); - g_string_append_printf(s, "= "); - g_string_append_printf(s, "\n"); + gdb_feature_builder_init(&builder, &cpu->dyn_m_systemreg_feature.desc, + "org.gnu.gdb.arm.m-system", "arm-m-system.xml= "); =20 for (i =3D 0; i < ARRAY_SIZE(m_sysreg_def); i++) { if (arm_feature(env, m_sysreg_def[i].feature)) { - g_string_append_printf(s, - "\n", - m_sysreg_def[i].name, base_reg++); + gdb_feature_builder_append_reg(&builder, m_sysreg_def[i].name,= 32, + "int", NULL); } } =20 - g_string_append_printf(s, ""); - cpu->dyn_m_systemreg_xml.desc =3D g_string_free(s, false); - cpu->dyn_m_systemreg_xml.num =3D base_reg - orig_base_reg; + gdb_feature_builder_end(&builder); =20 - return cpu->dyn_m_systemreg_xml.num; + return &cpu->dyn_m_systemreg_feature.desc; } =20 #ifndef CONFIG_USER_ONLY @@ -427,31 +418,26 @@ static int arm_gdb_set_m_secextreg(CPUARMState *env, = uint8_t *buf, int reg) return 0; /* TODO */ } =20 -static int arm_gen_dynamic_m_secextreg_xml(CPUState *cs, int orig_base_reg) +static GDBFeature *arm_gen_dynamic_m_secextreg_feature(CPUState *cs) { ARMCPU *cpu =3D ARM_CPU(cs); - GString *s =3D g_string_new(NULL); - int base_reg =3D orig_base_reg; + GDBFeatureBuilder builder; + char *name; int i; =20 - g_string_printf(s, ""); - g_string_append_printf(s, "= "); - g_string_append_printf(s, "= \n"); + gdb_feature_builder_init(&builder, &cpu->dyn_m_secextreg_feature.desc, + "org.gnu.gdb.arm.secext", "arm-m-secext.xml"); =20 for (i =3D 0; i < ARRAY_SIZE(m_sysreg_def); i++) { - g_string_append_printf(s, - "\n", - m_sysreg_def[i].name, base_reg++); - g_string_append_printf(s, - "\n", - m_sysreg_def[i].name, base_reg++); + name =3D g_strconcat(m_sysreg_def[i].name, "_ns", NULL); + gdb_feature_builder_append_reg(&builder, name, 32, "int", NULL); + name =3D g_strconcat(m_sysreg_def[i].name, "_s", NULL); + gdb_feature_builder_append_reg(&builder, name, 32, "int", NULL); } =20 - g_string_append_printf(s, ""); - cpu->dyn_m_secextreg_xml.desc =3D g_string_free(s, false); - cpu->dyn_m_secextreg_xml.num =3D base_reg - orig_base_reg; + gdb_feature_builder_end(&builder); =20 - return cpu->dyn_m_secextreg_xml.num; + return &cpu->dyn_m_secextreg_feature.desc; } #endif #endif /* CONFIG_TCG */ @@ -461,14 +447,14 @@ const char *arm_gdb_get_dynamic_xml(CPUState *cs, con= st char *xmlname) ARMCPU *cpu =3D ARM_CPU(cs); =20 if (strcmp(xmlname, "system-registers.xml") =3D=3D 0) { - return cpu->dyn_sysreg_xml.desc; + return cpu->dyn_sysreg_feature.desc.xml; } else if (strcmp(xmlname, "sve-registers.xml") =3D=3D 0) { - return cpu->dyn_svereg_xml.desc; + return cpu->dyn_svereg_feature.desc.xml; } else if (strcmp(xmlname, "arm-m-system.xml") =3D=3D 0) { - return cpu->dyn_m_systemreg_xml.desc; + return cpu->dyn_m_systemreg_feature.desc.xml; #ifndef CONFIG_USER_ONLY } else if (strcmp(xmlname, "arm-m-secext.xml") =3D=3D 0) { - return cpu->dyn_m_secextreg_xml.desc; + return cpu->dyn_m_secextreg_feature.desc.xml; #endif } return NULL; @@ -486,7 +472,7 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) */ #ifdef TARGET_AARCH64 if (isar_feature_aa64_sve(&cpu->isar)) { - int nreg =3D arm_gen_dynamic_svereg_xml(cs, cs->gdb_num_regs); + int nreg =3D arm_gen_dynamic_svereg_feature(cs)->num_regs; gdb_register_coprocessor(cs, aarch64_gdb_get_sve_reg, aarch64_gdb_set_sve_reg, nreg, "sve-registers.xml", 0); @@ -532,20 +518,20 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *c= pu) 1, "arm-m-profile-mve.xml", 0); } gdb_register_coprocessor(cs, arm_gdb_get_sysreg, arm_gdb_set_sysreg, - arm_gen_dynamic_sysreg_xml(cs, cs->gdb_num_re= gs), + arm_gen_dynamic_sysreg_feature(cs)->num_regs, "system-registers.xml", 0); =20 #ifdef CONFIG_TCG if (arm_feature(env, ARM_FEATURE_M) && tcg_enabled()) { gdb_register_coprocessor(cs, arm_gdb_get_m_systemreg, arm_gdb_set_m_systemreg, - arm_gen_dynamic_m_systemreg_xml(cs, cs->gdb_num_regs), + arm_gen_dynamic_m_systemreg_feature(cs)->num_regs, "arm-m-system.xml", 0); #ifndef CONFIG_USER_ONLY if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { gdb_register_coprocessor(cs, arm_gdb_get_m_secextreg, arm_gdb_set_m_secextreg, - arm_gen_dynamic_m_secextreg_xml(cs, cs->gdb_num_regs), + arm_gen_dynamic_m_secextreg_feature(cs)->num_regs, "arm-m-secext.xml", 0); } #endif diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index d7b79a6589..632ac2a520 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -247,7 +247,7 @@ int aarch64_gdb_set_pauth_reg(CPUARMState *env, uint8_t= *buf, int reg) return 0; } =20 -static void output_vector_union_type(GString *s, int reg_width, +static void output_vector_union_type(GDBFeatureBuilder *builder, int reg_w= idth, const char *name) { struct TypeSize { @@ -282,10 +282,10 @@ static void output_vector_union_type(GString *s, int = reg_width, =20 /* First define types and totals in a whole VL */ for (i =3D 0; i < ARRAY_SIZE(vec_lanes); i++) { - g_string_append_printf(s, - "", - name, vec_lanes[i].sz, vec_lanes[i].suffix, - vec_lanes[i].gdb_type, reg_width / vec_lane= s[i].size); + gdb_feature_builder_append_tag( + builder, "", + name, vec_lanes[i].sz, vec_lanes[i].suffix, + vec_lanes[i].gdb_type, reg_width / vec_lanes[i].size); } =20 /* @@ -296,86 +296,72 @@ static void output_vector_union_type(GString *s, int = reg_width, for (i =3D 0; i < ARRAY_SIZE(suf); i++) { int bits =3D 8 << i; =20 - g_string_append_printf(s, "", name, suf[i]); + gdb_feature_builder_append_tag(builder, "", + name, suf[i]); for (j =3D 0; j < ARRAY_SIZE(vec_lanes); j++) { if (vec_lanes[j].size =3D=3D bits) { - g_string_append_printf(s, "", - vec_lanes[j].suffix, name, - vec_lanes[j].sz, vec_lanes[j].suffi= x); + gdb_feature_builder_append_tag( + builder, "", + vec_lanes[j].suffix, name, + vec_lanes[j].sz, vec_lanes[j].suffix); } } - g_string_append(s, ""); + gdb_feature_builder_append_tag(builder, ""); } =20 /* And now the final union of unions */ - g_string_append_printf(s, "", name); + gdb_feature_builder_append_tag(builder, "", name); for (i =3D ARRAY_SIZE(suf) - 1; i >=3D 0; i--) { - g_string_append_printf(s, "= ", - suf[i], name, suf[i]); + gdb_feature_builder_append_tag(builder, + "", + suf[i], name, suf[i]); } - g_string_append(s, ""); + gdb_feature_builder_append_tag(builder, ""); } =20 -int arm_gen_dynamic_svereg_xml(CPUState *cs, int orig_base_reg) +GDBFeature *arm_gen_dynamic_svereg_feature(CPUState *cs) { ARMCPU *cpu =3D ARM_CPU(cs); - GString *s =3D g_string_new(NULL); - DynamicGDBXMLInfo *info =3D &cpu->dyn_svereg_xml; int reg_width =3D cpu->sve_max_vq * 128; int pred_width =3D cpu->sve_max_vq * 16; - int base_reg =3D orig_base_reg; + GDBFeatureBuilder builder; + char *name; int i; =20 - g_string_printf(s, ""); - g_string_append_printf(s, "= "); - g_string_append_printf(s, ""); + gdb_feature_builder_init(&builder, &cpu->dyn_svereg_feature.desc, + "org.gnu.gdb.aarch64.sve", "sve-registers.xml= "); =20 /* Create the vector union type. */ - output_vector_union_type(s, reg_width, "svev"); + output_vector_union_type(&builder, reg_width, "svev"); =20 /* Create the predicate vector type. */ - g_string_append_printf(s, - "", - pred_width / 8); + gdb_feature_builder_append_tag( + &builder, "= ", + pred_width / 8); =20 /* Define the vector registers. */ for (i =3D 0; i < 32; i++) { - g_string_append_printf(s, - "", - i, reg_width, base_reg++); + name =3D g_strdup_printf("z%d", i); + gdb_feature_builder_append_reg(&builder, name, reg_width, "svev", = NULL); } =20 /* fpscr & status registers */ - g_string_append_printf(s, "", base_reg++); - g_string_append_printf(s, "", base_reg++); + gdb_feature_builder_append_reg(&builder, "fpsr", 32, "int", "float"); + gdb_feature_builder_append_reg(&builder, "fpcr", 32, "int", "float"); =20 /* Define the predicate registers. */ for (i =3D 0; i < 16; i++) { - g_string_append_printf(s, - "", - i, pred_width, base_reg++); + name =3D g_strdup_printf("p%d", i); + gdb_feature_builder_append_reg(&builder, name, pred_width, + "svep", NULL); } - g_string_append_printf(s, - "", - pred_width, base_reg++); + gdb_feature_builder_append_reg(&builder, "ffr", pred_width, + "svep", "vector"); =20 /* Define the vector length pseudo-register. */ - g_string_append_printf(s, - "", - base_reg++); + gdb_feature_builder_append_reg(&builder, "vg", 64, "int", NULL); =20 - g_string_append_printf(s, ""); + gdb_feature_builder_end(&builder); =20 - info->desc =3D g_string_free(s, false); - info->num =3D base_reg - orig_base_reg; - return info->num; + return &cpu->dyn_svereg_feature.desc; } --=20 2.42.0 From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851586; cv=none; d=zohomail.com; s=zohoarc; b=jpO4xzV/6XgPxLAN9+holqT1GmMc+CXq5Gi+4Bbp2CUWEUUYwd2M2WS9flekqSjfjXJHPj1hlI/+XlJYZmmYqDWJFGlOiAQTdUKaBFkI5jMU6HtAncsmLD8GuOqXNnzA4f/CXvGvMIoXmvuQNk0It3o5k4BuHQ79hjYII4y+ZB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851586; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=avRhnhhmRoSFjHlCtGBPRqQZKIH1603z0E6RjEsC82w=; b=BnGVy1uyCDUj1XzQINmLe516ao1MH4cllktkx1Gu7Ws6vb+lhfOeteJI6nyik1TBBY4Qvc1fTF1PocajUUp7Per+R7zLjkzom8y7nr4ja7b8QQa7cZZhKXnnbfBoj8ICwSrAzwpnIK3/BX3oxaCBSjCoXdZqLeaQml40KIISDPA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694851586043511.20544359475707; Sat, 16 Sep 2023 01:06:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQG7-0003Ev-1T; Sat, 16 Sep 2023 04:02:31 -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 1qhQG6-0003Ee-2e for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:30 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0: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 1qhQG4-0005zL-BM for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:29 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-68fdd5c1bbbso2107808b3a.1 for ; Sat, 16 Sep 2023 01:02:27 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.02.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:02:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851347; x=1695456147; 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=avRhnhhmRoSFjHlCtGBPRqQZKIH1603z0E6RjEsC82w=; b=Ga3zaV4p9OUHe8XEJp8474RygEzYMFftnrEHC05v7qLF8cIMBQxojRTOvAZvMi8zEg GJ4BFwmHs4bN9H4/hNAW+nCq6ZKG8yVFnl4GSSQibrLoi9qV2p2UKpRr6HQZRNaFI1ub P2Qx3mcVEzr/702NlSS9W7UQpxr6I8pL1N4wpT6uIQtLeo4aHtTL3Go91IU6rBQld+yX pruX7O7TDK/Q/SNo1zVYqDUdTb7+IWB8sda4anuA0PgT+5wwv6nN+SqF62cuJwcDEHtw WL3Vs8GIHQbb2c5gWNgfWkQK0QqGJxIfCyKG9m8fB1risTousEvc58ZeabVqnDTGGvq8 vD5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851347; x=1695456147; 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=avRhnhhmRoSFjHlCtGBPRqQZKIH1603z0E6RjEsC82w=; b=a5HY/A7/eyAxvEhRuG+rskJGJjT38nXDjYGCiwrOZf5ClHQBD5yhJOP/9MxXlJYeyG 2yndaRYzqlZz81Y5bQoOnzMKRdRfWxe2siMapUpqkjyeRo9T/E3P55IV6CsqlaftaewM 1p0tJtntTomHDZwnXJuzmvDUnZEZhD9hGEkTDwAOy5fDZf/3QRd8zdtqY/rybt07WkF8 gwvnZwW76F4CETNW/90ijoNfeqL812hCoONMCfhXJDNu68MBtPFj4asVbBA7Y8FfRHCF Y6FduZSpPE3b9SbvgTH55kEB7GyNU7q7NHYADAdWM8H/pZ7b6B3wCc/GGeByn+/5UjKr Y1fw== X-Gm-Message-State: AOJu0YztrK6TfibFW0masQ/xAiRvz6qeSY/us/PqaTT1Bp09dHSfB35B QzzfFzIF4kU3yczOFWVkaOKSrA== X-Google-Smtp-Source: AGHT+IHXxNWJZAi/r/+pVEiQCT8/e7x4u34XxSaCk3Ru881B+PfTzo9AL3JHhdH6lc1gPNPVcWU37g== X-Received: by 2002:a05:6a00:1704:b0:68f:d44c:22f8 with SMTP id h4-20020a056a00170400b0068fd44c22f8mr5207349pfc.1.1694851346963; Sat, 16 Sep 2023 01:02:26 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Richard Henderson , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , qemu-ppc@nongnu.org (open list:PowerPC TCG CPUs) Subject: [PATCH v8 05/19] target/ppc: Use GDBFeature for dynamic XML Date: Sat, 16 Sep 2023 17:01:22 +0900 Message-ID: <20230916080149.129989-6-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=2607:f8b0:4864:20::42b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42b.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851587586100001 Content-Type: text/plain; charset="utf-8" In preparation for a change to use GDBFeature as a parameter of gdb_register_coprocessor(), convert the internal representation of dynamic feature from plain XML to GDBFeature. Signed-off-by: Akihiko Odaki Reviewed-by: Richard Henderson --- target/ppc/cpu-qom.h | 4 ++-- target/ppc/cpu.h | 2 +- target/ppc/cpu_init.c | 2 +- target/ppc/gdbstub.c | 45 ++++++++++++++----------------------------- 4 files changed, 18 insertions(+), 35 deletions(-) diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index be33786bd8..8d5ebba5d3 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -20,6 +20,7 @@ #ifndef QEMU_PPC_CPU_QOM_H #define QEMU_PPC_CPU_QOM_H =20 +#include "exec/gdbstub.h" #include "hw/core/cpu.h" #include "qom/object.h" =20 @@ -186,8 +187,7 @@ struct PowerPCCPUClass { int bfd_mach; uint32_t l1_dcache_size, l1_icache_size; #ifndef CONFIG_USER_ONLY - unsigned int gdb_num_sprs; - const char *gdb_spr_xml; + GDBFeature gdb_spr; #endif const PPCHash64Options *hash64_opts; struct ppc_radix_page_info *radix_page_info; diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 25fac9577a..5f251bdffe 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1381,7 +1381,7 @@ int ppc_cpu_gdb_write_register(CPUState *cpu, uint8_t= *buf, int reg); int ppc_cpu_gdb_write_register_apple(CPUState *cpu, uint8_t *buf, int reg); #ifndef CONFIG_USER_ONLY hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu); +void ppc_gdb_gen_spr_feature(PowerPCCPU *cpu); const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name); #endif int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 02b7aad9b0..e69405efed 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -6673,7 +6673,7 @@ static void init_ppc_proc(PowerPCCPU *cpu) (*pcc->init_proc)(env); =20 #if !defined(CONFIG_USER_ONLY) - ppc_gdb_gen_spr_xml(cpu); + ppc_gdb_gen_spr_feature(cpu); #endif =20 /* MSR bits & flags consistency checks */ diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index ec5731e5d6..43de40ac36 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -300,15 +300,21 @@ int ppc_cpu_gdb_write_register_apple(CPUState *cs, ui= nt8_t *mem_buf, int n) } =20 #ifndef CONFIG_USER_ONLY -void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu) +void ppc_gdb_gen_spr_feature(PowerPCCPU *cpu) { PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); CPUPPCState *env =3D &cpu->env; - GString *xml; - char *spr_name; + GDBFeatureBuilder builder; unsigned int num_regs =3D 0; int i; =20 + if (pcc->gdb_spr.xml) { + return; + } + + gdb_feature_builder_init(&builder, &pcc->gdb_spr, + "org.qemu.power.spr", "power-spr.xml"); + for (i =3D 0; i < ARRAY_SIZE(env->spr_cb); i++) { ppc_spr_t *spr =3D &env->spr_cb[i]; =20 @@ -326,35 +332,12 @@ void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu) */ spr->gdb_id =3D num_regs; num_regs++; - } - - if (pcc->gdb_spr_xml) { - return; - } - - xml =3D g_string_new(""); - g_string_append(xml, ""); - g_string_append(xml, ""); =20 - for (i =3D 0; i < ARRAY_SIZE(env->spr_cb); i++) { - ppc_spr_t *spr =3D &env->spr_cb[i]; - - if (!spr->name) { - continue; - } - - spr_name =3D g_ascii_strdown(spr->name, -1); - g_string_append_printf(xml, ""); + gdb_feature_builder_append_reg(&builder, g_ascii_strdown(spr->name= , -1), + TARGET_LONG_BITS, "int", "spr"); } =20 - g_string_append(xml, ""); - - pcc->gdb_num_sprs =3D num_regs; - pcc->gdb_spr_xml =3D g_string_free(xml, false); + gdb_feature_builder_end(&builder); } =20 const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name) @@ -362,7 +345,7 @@ const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const= char *xml_name) PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cs); =20 if (strcmp(xml_name, "power-spr.xml") =3D=3D 0) { - return pcc->gdb_spr_xml; + return pcc->gdb_spr.xml; } return NULL; } @@ -600,6 +583,6 @@ void ppc_gdb_init(CPUState *cs, PowerPCCPUClass *pcc) } #ifndef CONFIG_USER_ONLY gdb_register_coprocessor(cs, gdb_get_spr_reg, gdb_set_spr_reg, - pcc->gdb_num_sprs, "power-spr.xml", 0); + pcc->gdb_spr.num_regs, "power-spr.xml", 0); #endif } --=20 2.42.0 From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851412; cv=none; d=zohomail.com; s=zohoarc; b=HHS9bc1l0aNijY5W+nRTtClH7hi/Gp7E8T2MoFjccCVIjg4N/9jstm6cYV6mtm8j0j1C4ZDfRJfk4e6ryduofoa1aaohkgFZ/r3qg2TbF2zI42JIyipduVuhaDke/n5WKBDwsnW8a2u2/qeSQSX0nAI9ZoR7FiVy1w24GFmpifo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851412; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=ymSh20+A8Q0yOyEFfwLE/tP7KBbwmi6aU0/6AI6Gm9E=; b=c5DlaC1sX5BhjFGPgsJcBWRtS7YsL+WB7MinoIY1kOgd4eqH5XbK2MWBruoWqWbDPxvz8Jx505GgexezvwrJ3Wdq5dTq/8vmyPKtIxi0X0BPbHNFBoF3ZPsnItQhgsKVBUd28Wx/kVVm5UA/GBT3wfOhzBykGz03sEMTUOl9ykw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694851412511470.0089471137544; Sat, 16 Sep 2023 01:03:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQGB-0003Gg-Et; Sat, 16 Sep 2023 04:02: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 1qhQG9-0003Fy-P5 for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:33 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhQG7-0005zy-OI for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:33 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-69002ef0104so2395940b3a.1 for ; Sat, 16 Sep 2023 01:02:31 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.02.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851350; x=1695456150; 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=ymSh20+A8Q0yOyEFfwLE/tP7KBbwmi6aU0/6AI6Gm9E=; b=MQ2YqVur+U4sg7JwJ2djlzvz5UIJX9mnZkzb/Dgyt0h0QZ7e1QkSv7NTQ/0BEFH+da UzKrXh22m7soXJ5S376fJ5zO58DI5Nge8i9XHMBJLUxtC1SQUzQhaC7LjvhF3uSZ7yer BDuF80fZr5cskCVZnf0ijaZ/+pb0Nl9pxF2Bt6wizjnSpYI+XqiIkwJ3Q/f2zMBEhwIO BXD7jMDmrBTvdrNp/ByYtBQIHzkGcKQKwY5hdLmTki5tEvq54f7h7IRhiEMFw2gyFyMa qb79LV2DtlmkDCBT8ubQjEB/kwJ2QtERWm01M0087gKVH6nNzKmTVB6UFoawldbmgij4 pwoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851350; x=1695456150; 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=ymSh20+A8Q0yOyEFfwLE/tP7KBbwmi6aU0/6AI6Gm9E=; b=Izyuu+E/MB+fub72lz7ZrqJvBHFzKxtppngE0HkZOnd4Xqz7R7r8uwFmSAmscyhrow had+aA66aNZSdWLtuZN7JvU6nl2IfW27gU2aD47Mpb9ZZORZkfqtCJm30SaU0cHoiptb 9BCnSBhQAXzypevQnIYYFLQWjjzQdObebbmgqrSjRjna7A/3/t/t8mGOx38Mo/ZflnBa 82B8vcb023ePStfaA1Frme4xbpv/eAKAvA5hV5ApbCLrQQolElwTlAHPl28BTK97FQV4 QVnwSSCHaSfO+Pzs4sVIMLkCAZWQJZQqMEA3Nqh3B6sTqUE0xRAp0d2vDF9MZLsCnjuF D8RQ== X-Gm-Message-State: AOJu0YyKkvKlpaCRdOkBgAsBrxNrRpKQUb7eL9KDzK8Hif1laYGIWgLF 8pstREw00I1KZN2IPkIlUbjvhg== X-Google-Smtp-Source: AGHT+IHQFVLFmI7JjkUZJALX0USBltBUZ8l2ph+CmkSXL6WMrOmsPq1WtOeJno+ON5eYHheJmtxcXg== X-Received: by 2002:a05:6a20:1442:b0:13d:5b8e:db83 with SMTP id a2-20020a056a20144200b0013d5b8edb83mr4780225pzi.9.1694851350030; Sat, 16 Sep 2023 01:02:30 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs) Subject: [PATCH v8 06/19] target/riscv: Use GDBFeature for dynamic XML Date: Sat, 16 Sep 2023 17:01:23 +0900 Message-ID: <20230916080149.129989-7-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=2607:f8b0:4864:20::429; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x429.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851414671100003 Content-Type: text/plain; charset="utf-8" In preparation for a change to use GDBFeature as a parameter of gdb_register_coprocessor(), convert the internal representation of dynamic feature from plain XML to GDBFeature. Signed-off-by: Akihiko Odaki --- target/riscv/cpu.h | 5 +-- target/riscv/cpu.c | 4 +-- target/riscv/gdbstub.c | 77 ++++++++++++++++++------------------------ 3 files changed, 38 insertions(+), 48 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 6ea22e0eea..9063aa1fca 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -23,6 +23,7 @@ #include "hw/core/cpu.h" #include "hw/registerfields.h" #include "exec/cpu-defs.h" +#include "exec/gdbstub.h" #include "qemu/cpu-float.h" #include "qom/object.h" #include "qemu/int128.h" @@ -391,8 +392,8 @@ struct ArchCPU { CPUNegativeOffsetState neg; CPURISCVState env; =20 - char *dyn_csr_xml; - char *dyn_vreg_xml; + GDBFeature dyn_csr_feature; + GDBFeature dyn_vreg_feature; =20 /* Configuration Settings */ RISCVCPUConfig cfg; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index ef8faaaff5..a03c9069ca 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1960,9 +1960,9 @@ static const char *riscv_gdb_get_dynamic_xml(CPUState= *cs, const char *xmlname) RISCVCPU *cpu =3D RISCV_CPU(cs); =20 if (strcmp(xmlname, "riscv-csr.xml") =3D=3D 0) { - return cpu->dyn_csr_xml; + return cpu->dyn_csr_feature.xml; } else if (strcmp(xmlname, "riscv-vector.xml") =3D=3D 0) { - return cpu->dyn_vreg_xml; + return cpu->dyn_vreg_feature.xml; } =20 return NULL; diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index 524bede865..cdae406751 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -212,12 +212,13 @@ static int riscv_gdb_set_virtual(CPURISCVState *cs, u= int8_t *mem_buf, int n) return 0; } =20 -static int riscv_gen_dynamic_csr_xml(CPUState *cs, int base_reg) +static GDBFeature *riscv_gen_dynamic_csr_feature(CPUState *cs) { RISCVCPU *cpu =3D RISCV_CPU(cs); CPURISCVState *env =3D &cpu->env; - GString *s =3D g_string_new(NULL); + GDBFeatureBuilder builder; riscv_csr_predicate_fn predicate; + const char *name; int bitsize =3D 16 << env->misa_mxl_max; int i; =20 @@ -230,9 +231,8 @@ static int riscv_gen_dynamic_csr_xml(CPUState *cs, int = base_reg) bitsize =3D 64; } =20 - g_string_printf(s, ""); - g_string_append_printf(s, ""); - g_string_append_printf(s, ""= ); + gdb_feature_builder_init(&builder, &cpu->dyn_csr_feature, + "org.gnu.gdb.riscv.csr", "riscv-csr.xml"); =20 for (i =3D 0; i < CSR_TABLE_SIZE; i++) { if (env->priv_ver < csr_ops[i].min_priv_ver) { @@ -240,72 +240,63 @@ static int riscv_gen_dynamic_csr_xml(CPUState *cs, in= t base_reg) } predicate =3D csr_ops[i].predicate; if (predicate && (predicate(env, i) =3D=3D RISCV_EXCP_NONE)) { - if (csr_ops[i].name) { - g_string_append_printf(s, "", base_reg + i); + + gdb_feature_builder_append_reg(&builder, name, bitsize, + "int", NULL); } } =20 - g_string_append_printf(s, ""); - - cpu->dyn_csr_xml =3D g_string_free(s, false); + gdb_feature_builder_end(&builder); =20 #if !defined(CONFIG_USER_ONLY) env->debugger =3D false; #endif =20 - return CSR_TABLE_SIZE; + return &cpu->dyn_csr_feature; } =20 -static int ricsv_gen_dynamic_vector_xml(CPUState *cs, int base_reg) +static GDBFeature *ricsv_gen_dynamic_vector_feature(CPUState *cs) { RISCVCPU *cpu =3D RISCV_CPU(cs); - GString *s =3D g_string_new(NULL); - g_autoptr(GString) ts =3D g_string_new(""); + GDBFeatureBuilder builder; int reg_width =3D cpu->cfg.vlen; - int num_regs =3D 0; int i; =20 - g_string_printf(s, ""); - g_string_append_printf(s, "= "); - g_string_append_printf(s, ""); + gdb_feature_builder_init(&builder, &cpu->dyn_vreg_feature, + "org.gnu.gdb.riscv.vector", "riscv-vector.xml= "); =20 /* First define types and totals in a whole VL */ for (i =3D 0; i < ARRAY_SIZE(vec_lanes); i++) { int count =3D reg_width / vec_lanes[i].size; - g_string_printf(ts, "%s", vec_lanes[i].id); - g_string_append_printf(s, - "", - ts->str, vec_lanes[i].gdb_type, count); + gdb_feature_builder_append_tag( + &builder, "", + vec_lanes[i].id, vec_lanes[i].gdb_type, count); } =20 /* Define unions */ - g_string_append_printf(s, ""); + gdb_feature_builder_append_tag(&builder, ""); for (i =3D 0; i < ARRAY_SIZE(vec_lanes); i++) { - g_string_append_printf(s, "", - vec_lanes[i].suffix, - vec_lanes[i].id); + gdb_feature_builder_append_tag(&builder, + "", + vec_lanes[i].suffix, vec_lanes[i].i= d); } - g_string_append(s, ""); + gdb_feature_builder_append_tag(&builder, ""); =20 /* Define vector registers */ for (i =3D 0; i < 32; i++) { - g_string_append_printf(s, - "", - i, reg_width, base_reg++); - num_regs++; + gdb_feature_builder_append_reg(&builder, g_strdup_printf("v%d", i), + reg_width, "riscv_vector", "vector"= ); } =20 - g_string_append_printf(s, ""); + gdb_feature_builder_end(&builder); =20 - cpu->dyn_vreg_xml =3D g_string_free(s, false); - return num_regs; + return &cpu->dyn_vreg_feature; } =20 void riscv_cpu_register_gdb_regs_for_features(CPUState *cs) @@ -320,10 +311,9 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState= *cs) 32, "riscv-32bit-fpu.xml", 0); } if (env->misa_ext & RVV) { - int base_reg =3D cs->gdb_num_regs; gdb_register_coprocessor(cs, riscv_gdb_get_vector, riscv_gdb_set_vector, - ricsv_gen_dynamic_vector_xml(cs, base_reg= ), + ricsv_gen_dynamic_vector_feature(cs)->num= _regs, "riscv-vector.xml", 0); } switch (env->misa_mxl_max) { @@ -343,9 +333,8 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState = *cs) } =20 if (cpu->cfg.ext_icsr) { - int base_reg =3D cs->gdb_num_regs; gdb_register_coprocessor(cs, riscv_gdb_get_csr, riscv_gdb_set_csr, - riscv_gen_dynamic_csr_xml(cs, base_reg), + riscv_gen_dynamic_csr_feature(cs)->num_re= gs, "riscv-csr.xml", 0); } } --=20 2.42.0 From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851445; cv=none; d=zohomail.com; s=zohoarc; b=b4SKF4JDwcHnCpkkPJxfmvfG7BSQaN17nZoebAUMwTc8nE0Htw3XbuW/AZqaCYil4+a/jtk5w9cO5QbVnoPAiICfyAeNUod+ta2MUsT0clWaV+a1k6eEPJaXQOuS11M/2/j0GnIouJ5wQFHUa5AnPnHQLHfgyDHpa0tombIR1OM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851445; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=nCn2t5fGa7wEFIpcGdX2m0SZJxIL5BnyLqWM2W7Bw1A=; b=KP3CJhvlw5xWg6DQNAr3Zvd0CC2YiJtd6tgxOl9x+5i5O37/eRDZ6yBAaggYs5n55qfRSYCZjZ1RXfa0inwrFTOQ2vQ8DPCg1tH/Jdr2mVsaM52VjP0nE585XUniMOJk79A4POZczl6ANEDZL6sd1hrvP5Z90vWfuNtDr4yiK38= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694851445693737.0119055448557; Sat, 16 Sep 2023 01:04:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQGH-0003HR-8Z; Sat, 16 Sep 2023 04:02:41 -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 1qhQGF-0003Gw-Ir for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:39 -0400 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhQGD-00060g-5Z for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:39 -0400 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6b9a2416b1cso1768723a34.2 for ; Sat, 16 Sep 2023 01:02:36 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851356; x=1695456156; 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=nCn2t5fGa7wEFIpcGdX2m0SZJxIL5BnyLqWM2W7Bw1A=; b=Uar74rqSOf7klKSDqaXdIddEyojSVgBpFkuejM9yOort6FlWzpeYv9dkn6Vh2ch3Ts J5xH38UKD0CK2x4eifawXNFdMXbVA2dYlw5GPzwUvD+N3UiiIQXuX4X1eYoXliPb04Sp nbFi7eE2QgGgIkPEYmZuD2iQaL5UxSTp6WJfNl1UGEeACpTnMndRDYcIdXn2HNeltW9X lR84IVyuxBIto1TIEMhxHveIPmJWT9zylJCvffLN/3Zg6aI7xItXlIzdr8ajPBsBcOAD F3FYzeSJ4L5Zjr03QZFQrkmnPifExTh1OBTzT1aMXHdi74i4TbvYe5om0T8Xc0/jiQbZ k0+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851356; x=1695456156; 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=nCn2t5fGa7wEFIpcGdX2m0SZJxIL5BnyLqWM2W7Bw1A=; b=SCO582oriTM2mDeeIyG+wCtAUbjAgBku8yh/44zDzoF51yXWXjRK/ZfW9+ub8u/irG D0DSeB9cTqi7CIFAXDC4uFd91THKSCrY+7Qp++AnHZSUc3Bpt6f3hIa3uuurkAfrj5Yt J5NfdEVR9hGdjyfWCrZICrLEvZ2bfwRM6cDdfM/KIaJyny8Ot5BMSLJ+rmUKoo5EUS65 UNYYCnpkMmDv/VNmMwUrH3hebB4w8IrVBOyh5CMDTmvTmqUh0grHbi04CtxALc5C3j8W eURC+6k8+8IrMq4PlvSrnRhTKtYOAnRwsJaXbNdjqIeproX6u9YvYrcI4RbTdHU6f3Ly ThrA== X-Gm-Message-State: AOJu0YwGAhjpYkG5unxSNqh+1+j5/xO6jEaysOrJht/lcopxQqdPEn24 bVZ2R8oB6hnoL9TGdrBlOx9jMA== X-Google-Smtp-Source: AGHT+IFeD0syP+XB0Vt2bpcLWPMt7/cbGeQ4zA7vntIzECRtwLl+XUoX979RPS0KBc5zTC2o/rLlVw== X-Received: by 2002:a05:6358:6f86:b0:140:ea43:37e3 with SMTP id s6-20020a0563586f8600b00140ea4337e3mr3703107rwn.27.1694851355979; Sat, 16 Sep 2023 01:02:35 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Peter Maydell , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , "Edgar E. Iglesias" , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , qemu-arm@nongnu.org (open list:ARM TCG CPUs), qemu-ppc@nongnu.org (open list:PowerPC TCG CPUs), qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs), qemu-s390x@nongnu.org (open list:S390 TCG CPUs) Subject: [PATCH v8 07/19] gdbstub: Use GDBFeature for gdb_register_coprocessor Date: Sat, 16 Sep 2023 17:01:24 +0900 Message-ID: <20230916080149.129989-8-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=2607:f8b0:4864:20::329; envelope-from=akihiko.odaki@daynix.com; helo=mail-ot1-x329.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851448109100003 This is a tree-wide change to introduce GDBFeature parameter to gdb_register_coprocessor(). The new parameter just replaces num_regs and xml parameters for now. GDBFeature will be utilized to simplify XML lookup in a following change. Signed-off-by: Akihiko Odaki Acked-by: Alex Benn=C3=A9e --- include/exec/gdbstub.h | 2 +- gdbstub/gdbstub.c | 13 +++++++------ target/arm/gdbstub.c | 34 ++++++++++++++++++---------------- target/hexagon/cpu.c | 3 +-- target/loongarch/gdbstub.c | 2 +- target/m68k/helper.c | 6 +++--- target/microblaze/cpu.c | 5 +++-- target/ppc/gdbstub.c | 11 ++++++----- target/riscv/gdbstub.c | 18 ++++++++++-------- target/s390x/gdbstub.c | 28 +++++++--------------------- 10 files changed, 57 insertions(+), 65 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index d9ef2ccbff..5525eea090 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -37,7 +37,7 @@ typedef int (*gdb_set_reg_cb)(CPUArchState *env, uint8_t = *buf, int reg); */ void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_r= eg, - int num_regs, const char *xml, int g_pos); + const GDBFeature *feature, int g_pos); =20 /** * gdbserver_start: start the gdb server diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index d63f6c0d9d..61783ffa48 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -532,7 +532,7 @@ static int gdb_write_register(CPUState *cpu, uint8_t *m= em_buf, int reg) =20 void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_r= eg, - int num_regs, const char *xml, int g_pos) + const GDBFeature *feature, int g_pos) { GDBRegisterState *s; guint i; @@ -541,7 +541,7 @@ void gdb_register_coprocessor(CPUState *cpu, for (i =3D 0; i < cpu->gdb_regs->len; i++) { /* Check for duplicates. */ s =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (strcmp(s->xml, xml) =3D=3D 0) + if (strcmp(s->xml, feature->xmlname) =3D=3D 0) return; } } else { @@ -552,17 +552,18 @@ void gdb_register_coprocessor(CPUState *cpu, g_array_set_size(cpu->gdb_regs, i + 1); s =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); s->base_reg =3D cpu->gdb_num_regs; - s->num_regs =3D num_regs; + s->num_regs =3D feature->num_regs; s->get_reg =3D get_reg; s->set_reg =3D set_reg; - s->xml =3D xml; + s->xml =3D feature->xml; =20 /* Add to end of list. */ - cpu->gdb_num_regs +=3D num_regs; + cpu->gdb_num_regs +=3D feature->num_regs; if (g_pos) { if (g_pos !=3D s->base_reg) { error_report("Error: Bad gdb register numbering for '%s', " - "expected %d got %d", xml, g_pos, s->base_reg); + "expected %d got %d", feature->xml, + g_pos, s->base_reg); } else { cpu->gdb_num_g_regs =3D cpu->gdb_num_regs; } diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index fc0aa6f235..99040e0c4c 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -472,14 +472,14 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *c= pu) */ #ifdef TARGET_AARCH64 if (isar_feature_aa64_sve(&cpu->isar)) { - int nreg =3D arm_gen_dynamic_svereg_feature(cs)->num_regs; + GDBFeature *feature =3D arm_gen_dynamic_svereg_feature(cs); gdb_register_coprocessor(cs, aarch64_gdb_get_sve_reg, - aarch64_gdb_set_sve_reg, nreg, - "sve-registers.xml", 0); + aarch64_gdb_set_sve_reg, feature, 0); } else { gdb_register_coprocessor(cs, aarch64_gdb_get_fpu_reg, aarch64_gdb_set_fpu_reg, - 34, "aarch64-fpu.xml", 0); + gdb_find_static_feature("aarch64-fpu.= xml"), + 0); } /* * Note that we report pauth information via the feature name @@ -490,19 +490,22 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *c= pu) if (isar_feature_aa64_pauth(&cpu->isar)) { gdb_register_coprocessor(cs, aarch64_gdb_get_pauth_reg, aarch64_gdb_set_pauth_reg, - 4, "aarch64-pauth.xml", 0); + gdb_find_static_feature("aarch64-paut= h.xml"), + 0); } #endif } else { if (arm_feature(env, ARM_FEATURE_NEON)) { gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg, - 49, "arm-neon.xml", 0); + gdb_find_static_feature("arm-neon.xml= "), + 0); } else if (cpu_isar_feature(aa32_simd_r32, cpu)) { gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg, - 33, "arm-vfp3.xml", 0); + gdb_find_static_feature("arm-vfp3.xml= "), + 0); } else if (cpu_isar_feature(aa32_vfp_simd, cpu)) { gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg, - 17, "arm-vfp.xml", 0); + gdb_find_static_feature("arm-vfp.xml"= ), 0); } if (!arm_feature(env, ARM_FEATURE_M)) { /* @@ -510,29 +513,28 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *c= pu) * expose to gdb. */ gdb_register_coprocessor(cs, vfp_gdb_get_sysreg, vfp_gdb_set_s= ysreg, - 2, "arm-vfp-sysregs.xml", 0); + gdb_find_static_feature("arm-vfp-sysr= egs.xml"), + 0); } } if (cpu_isar_feature(aa32_mve, cpu) && tcg_enabled()) { gdb_register_coprocessor(cs, mve_gdb_get_reg, mve_gdb_set_reg, - 1, "arm-m-profile-mve.xml", 0); + gdb_find_static_feature("arm-m-profile-mv= e.xml"), + 0); } gdb_register_coprocessor(cs, arm_gdb_get_sysreg, arm_gdb_set_sysreg, - arm_gen_dynamic_sysreg_feature(cs)->num_regs, - "system-registers.xml", 0); + arm_gen_dynamic_sysreg_feature(cs), 0); =20 #ifdef CONFIG_TCG if (arm_feature(env, ARM_FEATURE_M) && tcg_enabled()) { gdb_register_coprocessor(cs, arm_gdb_get_m_systemreg, arm_gdb_set_m_systemreg, - arm_gen_dynamic_m_systemreg_feature(cs)->num_regs, - "arm-m-system.xml", 0); + arm_gen_dynamic_m_systemreg_feature(cs), 0); #ifndef CONFIG_USER_ONLY if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { gdb_register_coprocessor(cs, arm_gdb_get_m_secextreg, arm_gdb_set_m_secextreg, - arm_gen_dynamic_m_secextreg_feature(cs)->num_regs, - "arm-m-secext.xml", 0); + arm_gen_dynamic_m_secextreg_feature(cs), 0); } #endif } diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index f155936289..1dc8e0da24 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -342,8 +342,7 @@ static void hexagon_cpu_realize(DeviceState *dev, Error= **errp) =20 gdb_register_coprocessor(cs, hexagon_hvx_gdb_read_register, hexagon_hvx_gdb_write_register, - NUM_VREGS + NUM_QREGS, - "hexagon-hvx.xml", 0); + gdb_find_static_feature("hexagon-hvx.xml"), 0= ); =20 qemu_init_vcpu(cs); cpu_reset(cs); diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c index b09804b62f..e04742c202 100644 --- a/target/loongarch/gdbstub.c +++ b/target/loongarch/gdbstub.c @@ -117,5 +117,5 @@ static int loongarch_gdb_set_fpu(CPULoongArchState *env, void loongarch_cpu_register_gdb_regs_for_features(CPUState *cs) { gdb_register_coprocessor(cs, loongarch_gdb_get_fpu, loongarch_gdb_set_= fpu, - 41, "loongarch-fpu.xml", 0); + gdb_find_static_feature("loongarch-fpu.xml"),= 0); } diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 0a1544cd68..675f2dcd5a 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -152,10 +152,10 @@ void m68k_cpu_init_gdb(M68kCPU *cpu) =20 if (m68k_feature(env, M68K_FEATURE_CF_FPU)) { gdb_register_coprocessor(cs, cf_fpu_gdb_get_reg, cf_fpu_gdb_set_re= g, - 11, "cf-fp.xml", 18); + gdb_find_static_feature("cf-fp.xml"), 18); } else if (m68k_feature(env, M68K_FEATURE_FPU)) { - gdb_register_coprocessor(cs, m68k_fpu_gdb_get_reg, - m68k_fpu_gdb_set_reg, 11, "m68k-fp.xml", = 18); + gdb_register_coprocessor(cs, m68k_fpu_gdb_get_reg, m68k_fpu_gdb_se= t_reg, + gdb_find_static_feature("m68k-fp.xml"), 1= 8); } /* TODO: Add [E]MAC registers. */ } diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 03c2c4db1f..e1eff0b837 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -298,8 +298,9 @@ static void mb_cpu_initfn(Object *obj) =20 cpu_set_cpustate_pointers(cpu); gdb_register_coprocessor(CPU(cpu), mb_cpu_gdb_read_stack_protect, - mb_cpu_gdb_write_stack_protect, 2, - "microblaze-stack-protect.xml", 0); + mb_cpu_gdb_write_stack_protect, + gdb_find_static_feature("microblaze-stack-pro= tect.xml"), + 0); =20 set_float_rounding_mode(float_round_nearest_even, &env->fp_status); =20 diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index 43de40ac36..9f2aad7aa9 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -567,22 +567,23 @@ void ppc_gdb_init(CPUState *cs, PowerPCCPUClass *pcc) { if (pcc->insns_flags & PPC_FLOAT) { gdb_register_coprocessor(cs, gdb_get_float_reg, gdb_set_float_reg, - 33, "power-fpu.xml", 0); + gdb_find_static_feature("power-fpu.xml"),= 0); } if (pcc->insns_flags & PPC_ALTIVEC) { gdb_register_coprocessor(cs, gdb_get_avr_reg, gdb_set_avr_reg, - 34, "power-altivec.xml", 0); + gdb_find_static_feature("power-altivec.xm= l"), + 0); } if (pcc->insns_flags & PPC_SPE) { gdb_register_coprocessor(cs, gdb_get_spe_reg, gdb_set_spe_reg, - 34, "power-spe.xml", 0); + gdb_find_static_feature("power-spe.xml"),= 0); } if (pcc->insns_flags2 & PPC2_VSX) { gdb_register_coprocessor(cs, gdb_get_vsx_reg, gdb_set_vsx_reg, - 32, "power-vsx.xml", 0); + gdb_find_static_feature("power-vsx.xml"),= 0); } #ifndef CONFIG_USER_ONLY gdb_register_coprocessor(cs, gdb_get_spr_reg, gdb_set_spr_reg, - pcc->gdb_spr.num_regs, "power-spr.xml", 0); + &pcc->gdb_spr, 0); #endif } diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index cdae406751..d4f9eb1516 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -305,28 +305,31 @@ void riscv_cpu_register_gdb_regs_for_features(CPUStat= e *cs) CPURISCVState *env =3D &cpu->env; if (env->misa_ext & RVD) { gdb_register_coprocessor(cs, riscv_gdb_get_fpu, riscv_gdb_set_fpu, - 32, "riscv-64bit-fpu.xml", 0); + gdb_find_static_feature("riscv-64bit-fpu.= xml"), + 0); } else if (env->misa_ext & RVF) { gdb_register_coprocessor(cs, riscv_gdb_get_fpu, riscv_gdb_set_fpu, - 32, "riscv-32bit-fpu.xml", 0); + gdb_find_static_feature("riscv-32bit-fpu.= xml"), + 0); } if (env->misa_ext & RVV) { gdb_register_coprocessor(cs, riscv_gdb_get_vector, riscv_gdb_set_vector, - ricsv_gen_dynamic_vector_feature(cs)->num= _regs, - "riscv-vector.xml", 0); + ricsv_gen_dynamic_vector_feature(cs), 0); } switch (env->misa_mxl_max) { case MXL_RV32: gdb_register_coprocessor(cs, riscv_gdb_get_virtual, riscv_gdb_set_virtual, - 1, "riscv-32bit-virtual.xml", 0); + gdb_find_static_feature("riscv-32bit-virt= ual.xml"), + 0); break; case MXL_RV64: case MXL_RV128: gdb_register_coprocessor(cs, riscv_gdb_get_virtual, riscv_gdb_set_virtual, - 1, "riscv-64bit-virtual.xml", 0); + gdb_find_static_feature("riscv-64bit-virt= ual.xml"), + 0); break; default: g_assert_not_reached(); @@ -334,7 +337,6 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState = *cs) =20 if (cpu->cfg.ext_icsr) { gdb_register_coprocessor(cs, riscv_gdb_get_csr, riscv_gdb_set_csr, - riscv_gen_dynamic_csr_feature(cs)->num_re= gs, - "riscv-csr.xml", 0); + riscv_gen_dynamic_csr_feature(cs), 0); } } diff --git a/target/s390x/gdbstub.c b/target/s390x/gdbstub.c index 6fbfd41bc8..02c388dc32 100644 --- a/target/s390x/gdbstub.c +++ b/target/s390x/gdbstub.c @@ -69,8 +69,6 @@ int s390_cpu_gdb_write_register(CPUState *cs, uint8_t *me= m_buf, int n) /* the values represent the positions in s390-acr.xml */ #define S390_A0_REGNUM 0 #define S390_A15_REGNUM 15 -/* total number of registers in s390-acr.xml */ -#define S390_NUM_AC_REGS 16 =20 static int cpu_read_ac_reg(CPUS390XState *env, GByteArray *buf, int n) { @@ -98,8 +96,6 @@ static int cpu_write_ac_reg(CPUS390XState *env, uint8_t *= mem_buf, int n) #define S390_FPC_REGNUM 0 #define S390_F0_REGNUM 1 #define S390_F15_REGNUM 16 -/* total number of registers in s390-fpr.xml */ -#define S390_NUM_FP_REGS 17 =20 static int cpu_read_fp_reg(CPUS390XState *env, GByteArray *buf, int n) { @@ -132,8 +128,6 @@ static int cpu_write_fp_reg(CPUS390XState *env, uint8_t= *mem_buf, int n) #define S390_V15L_REGNUM 15 #define S390_V16_REGNUM 16 #define S390_V31_REGNUM 31 -/* total number of registers in s390-vx.xml */ -#define S390_NUM_VREGS 32 =20 static int cpu_read_vreg(CPUS390XState *env, GByteArray *buf, int n) { @@ -172,8 +166,6 @@ static int cpu_write_vreg(CPUS390XState *env, uint8_t *= mem_buf, int n) /* the values represent the positions in s390-cr.xml */ #define S390_C0_REGNUM 0 #define S390_C15_REGNUM 15 -/* total number of registers in s390-cr.xml */ -#define S390_NUM_C_REGS 16 =20 #ifndef CONFIG_USER_ONLY static int cpu_read_c_reg(CPUS390XState *env, GByteArray *buf, int n) @@ -206,8 +198,6 @@ static int cpu_write_c_reg(CPUS390XState *env, uint8_t = *mem_buf, int n) #define S390_VIRT_CPUTM_REGNUM 1 #define S390_VIRT_BEA_REGNUM 2 #define S390_VIRT_PREFIX_REGNUM 3 -/* total number of registers in s390-virt.xml */ -#define S390_NUM_VIRT_REGS 4 =20 static int cpu_read_virt_reg(CPUS390XState *env, GByteArray *mem_buf, int = n) { @@ -254,8 +244,6 @@ static int cpu_write_virt_reg(CPUS390XState *env, uint8= _t *mem_buf, int n) #define S390_VIRT_KVM_PFT_REGNUM 1 #define S390_VIRT_KVM_PFS_REGNUM 2 #define S390_VIRT_KVM_PFC_REGNUM 3 -/* total number of registers in s390-virt-kvm.xml */ -#define S390_NUM_VIRT_KVM_REGS 4 =20 static int cpu_read_virt_kvm_reg(CPUS390XState *env, GByteArray *mem_buf, = int n) { @@ -303,8 +291,6 @@ static int cpu_write_virt_kvm_reg(CPUS390XState *env, u= int8_t *mem_buf, int n) #define S390_GS_GSD_REGNUM 1 #define S390_GS_GSSM_REGNUM 2 #define S390_GS_GSEPLA_REGNUM 3 -/* total number of registers in s390-gs.xml */ -#define S390_NUM_GS_REGS 4 =20 static int cpu_read_gs_reg(CPUS390XState *env, GByteArray *buf, int n) { @@ -322,33 +308,33 @@ void s390_cpu_gdb_init(CPUState *cs) { gdb_register_coprocessor(cs, cpu_read_ac_reg, cpu_write_ac_reg, - S390_NUM_AC_REGS, "s390-acr.xml", 0); + gdb_find_static_feature("s390-acr.xml"), 0); =20 gdb_register_coprocessor(cs, cpu_read_fp_reg, cpu_write_fp_reg, - S390_NUM_FP_REGS, "s390-fpr.xml", 0); + gdb_find_static_feature("s390-fpr.xml"), 0); =20 gdb_register_coprocessor(cs, cpu_read_vreg, cpu_write_vreg, - S390_NUM_VREGS, "s390-vx.xml", 0); + gdb_find_static_feature("s390-vx.xml"), 0); =20 gdb_register_coprocessor(cs, cpu_read_gs_reg, cpu_write_gs_reg, - S390_NUM_GS_REGS, "s390-gs.xml", 0); + gdb_find_static_feature("s390-gs.xml"), 0); =20 #ifndef CONFIG_USER_ONLY gdb_register_coprocessor(cs, cpu_read_c_reg, cpu_write_c_reg, - S390_NUM_C_REGS, "s390-cr.xml", 0); + gdb_find_static_feature("s390-cr.xml"), 0); =20 gdb_register_coprocessor(cs, cpu_read_virt_reg, cpu_write_virt_reg, - S390_NUM_VIRT_REGS, "s390-virt.xml", 0); + gdb_find_static_feature("s390-virt.xml"), 0); =20 if (kvm_enabled()) { gdb_register_coprocessor(cs, cpu_read_virt_kvm_reg, cpu_write_virt_kvm_reg, - S390_NUM_VIRT_KVM_REGS, "s390-virt-kvm.xm= l", + gdb_find_static_feature("s390-virt-kvm.xm= l"), 0); } #endif --=20 2.42.0 From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851493; cv=none; d=zohomail.com; s=zohoarc; b=Q7zhMSrpFF4QaznLXgH2gZonMnhvkImmbTUHpKY3dJZ6gC8GWs4Yd3DzqyyqZXNlt9PyK94OycY2BjFQvJr0cXhi0o7wmpB0ml/PrDgzrHKqEdjTs/zBHuuGckF09WCotI0tqs7OnLlmTw51PA4WUU62uGYCzF0vCG4/eKnJvhc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851493; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=6Is0bjJtCP1Idi9BRAvC0U7JHxowGP/S7yosEU5rXTI=; b=T8asaBuWuU22BDUJtnceupjETNd2YeSmtj4SC3KclddKpZAfIuSZK0syt/j9TW9oNTyGUEx4Ek+8MXmHTpnvL6sZAXb56trG5syXnuUC7SfiMBM4Cv3YyTtRjkKkw5OplcHchfMX5Soug8VayIiAIN3ERsdPnJiRW5yvHjNxNpU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694851493947345.0495277482065; Sat, 16 Sep 2023 01:04:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQGK-0003IS-Sh; Sat, 16 Sep 2023 04:02:44 -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 1qhQGJ-0003I9-FO for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:43 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhQGH-000613-Fr for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:43 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-68fbd31d9ddso2422927b3a.0 for ; Sat, 16 Sep 2023 01:02:39 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851358; x=1695456158; 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=6Is0bjJtCP1Idi9BRAvC0U7JHxowGP/S7yosEU5rXTI=; b=2oeufpc16qpzrwJV50y7Ie2O0NXlfFfWJRspqZAWAy7iklbEsvIAHJDD85obu5xJgP K6yMv/Om8D5ltjcYZd3W5qKNcxPAjlZM9c3EdbG+XbTW0cFuBGLhQzYZGaWodT+blSGI tvbjgGS5J1FlDiuLnIsVIpDVmxX+E3iAPkpUby8gIfJ1fRmg4wWSoErdtGSILMc/PHzH OvddjbgqBGPEzo6hk3T6yINXdJfXAZEIAx3yYjaGaA24sLRVufU2U+daWBLN4NV9uYHc fbj4/5U+76iOum3qE0SjwRewHiAHrgp0MEyb+rg7pbzjbD3oScfbOz++wqAb8+/0slpy 1uTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851358; x=1695456158; 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=6Is0bjJtCP1Idi9BRAvC0U7JHxowGP/S7yosEU5rXTI=; b=bTanDnRRUNCxynEQHmMaiQIM+V/sZHkGG173o1gxXKekA8LyD34zAeFdByHJOtwb10 hIJYyFcGt4aCJ/vkb3PhM26SwgaoqavWkufhur5fwlv92vRe62ersB/SQpLF0nHYV95w rAarfZTGsTNgMxAMu28mjV6nbLedzKk6UHlSg4wczmPiVPqOpGmc9Q+Ljk2FGnicS+n1 FChp25Hm3gAb/BqxtgCtc1LSQIMxHv6HN/VJc5vOJlOO6OndJpONH9MJ37R0X+u8EAph etZ3POT3SB/verNj/lfYJDprh6B6yCeir/Vxjyi+GO6K35zmVKhmWkBrosyB/k1XoEFu 5ZMg== X-Gm-Message-State: AOJu0YxQcmr5n61QIdhT8TI8bOe7Zu/k1gMOpyP7jPzFpiV3+KZtP9w3 5EFO/4iUI3xjHY+XK33U8n8hIA== X-Google-Smtp-Source: AGHT+IGZCZPNUBKwAaNwWj80WXb/lVnGh8iioHv/3Z5uBZsGfpWRqXtfoG8FPMKaUSLqzBIaojGC8A== X-Received: by 2002:aa7:88d6:0:b0:68e:4653:2a2b with SMTP id k22-20020aa788d6000000b0068e46532a2bmr4349083pff.24.1694851357943; Sat, 16 Sep 2023 01:02:37 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki Subject: [PATCH v8 08/19] gdbstub: Use GDBFeature for GDBRegisterState Date: Sat, 16 Sep 2023 17:01:25 +0900 Message-ID: <20230916080149.129989-9-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=2607:f8b0:4864:20::42d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42d.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851495819100003 Content-Type: text/plain; charset="utf-8" Simplify GDBRegisterState by replacing num_regs and xml members with one member that points to GDBFeature. Signed-off-by: Akihiko Odaki --- gdbstub/gdbstub.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 61783ffa48..b3f6f0dd2d 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -47,10 +47,9 @@ =20 typedef struct GDBRegisterState { int base_reg; - int num_regs; gdb_get_reg_cb get_reg; gdb_set_reg_cb set_reg; - const char *xml; + const GDBFeature *feature; } GDBRegisterState; =20 GDBState gdbserver_state; @@ -390,7 +389,7 @@ static const char *get_feature_xml(const char *p, const= char **newp, g_ptr_array_add( xml, g_markup_printf_escaped("", - r->xml)); + r->feature->xmlname)); } g_ptr_array_add(xml, g_strdup("")); g_ptr_array_add(xml, NULL); @@ -504,7 +503,7 @@ static int gdb_read_register(CPUState *cpu, GByteArray = *buf, int reg) =20 for (guint i =3D 0; i < cpu->gdb_regs->len; i++) { r =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (r->base_reg <=3D reg && reg < r->base_reg + r->num_regs) { + if (r->base_reg <=3D reg && reg < r->base_reg + r->feature->num_re= gs) { return r->get_reg(env, buf, reg - r->base_reg); } } @@ -523,7 +522,7 @@ static int gdb_write_register(CPUState *cpu, uint8_t *m= em_buf, int reg) =20 for (guint i =3D 0; i < cpu->gdb_regs->len; i++) { r =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (r->base_reg <=3D reg && reg < r->base_reg + r->num_regs) { + if (r->base_reg <=3D reg && reg < r->base_reg + r->feature->num_re= gs) { return r->set_reg(env, mem_buf, reg - r->base_reg); } } @@ -541,7 +540,7 @@ void gdb_register_coprocessor(CPUState *cpu, for (i =3D 0; i < cpu->gdb_regs->len; i++) { /* Check for duplicates. */ s =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (strcmp(s->xml, feature->xmlname) =3D=3D 0) + if (s->feature =3D=3D feature) return; } } else { @@ -552,10 +551,9 @@ void gdb_register_coprocessor(CPUState *cpu, g_array_set_size(cpu->gdb_regs, i + 1); s =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); s->base_reg =3D cpu->gdb_num_regs; - s->num_regs =3D feature->num_regs; s->get_reg =3D get_reg; s->set_reg =3D set_reg; - s->xml =3D feature->xml; + s->feature =3D feature; =20 /* Add to end of list. */ cpu->gdb_num_regs +=3D feature->num_regs; --=20 2.42.0 From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851593; cv=none; d=zohomail.com; s=zohoarc; b=j19kTfXZjdwr2nWfh2sFJdKeUU1h8qR2GUjCohdI2tIihAbmi+0ibj0lJ5SSuBcgoSza0EuVjn0BrFuwiCagEjR4Jh3BtHKY2FUa0yEOiqfE94muG+hr/ILF5djyRM0nbvLZZRBm6tGo//0qHLb+iC9JCHRckUrv0lPVgpPetBo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851593; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=PfSjmEDVhfP8S9yyf7Msr/ihLbUKp60KnhAZgS2zH+U=; b=kdiTZOVQzc1S/7AppufdoCqfkKcDZjK1tj18EZk7omx1mDTguSvp5/OKSFdvh5+SpcMr1UWTGnLEAL5k+BY5/7X58cRNB3fsfA2AVimB72wBu7XMg9yUCbHqa4U5EwpjX4TtFjfwR1ihfyj/6n0xhrMfOrI6RKzHente1Z7xgy4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694851593166117.15647959899309; Sat, 16 Sep 2023 01:06:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQGZ-0003ZD-MD; Sat, 16 Sep 2023 04:02:59 -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 1qhQGS-0003Lk-M8 for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:55 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhQGM-000623-FO for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:51 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-68fb2e9ebcdso2372952b3a.2 for ; Sat, 16 Sep 2023 01:02:46 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:02:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851364; x=1695456164; 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=PfSjmEDVhfP8S9yyf7Msr/ihLbUKp60KnhAZgS2zH+U=; b=cmTB8mwaF6390ejHQ4Nkk89MSNzoV5LpPvsK3Sl9qBXygZRU+A+c65hx83qi2VrbU+ gzHF0LfTRYl2YiDo7wAPPXs6azNfphy8YMYqiaN1MkWpb97RMBhC8zAk8dCKEkXzL8t5 dtOm0ARhrBiwEOazAXRRSYIx276v6yNpM1ljp6f8Wucpcyca7JFp/PLCPru1TJk1VszY AsTcCFhQTJHYvCi73cQltFMCDENIWiFl0+5MpDUe7Xy5jLeHQYKWvDzft893Z2W3cdLm t3YFKAvBERlIixo80sX3S+nWvke5l8jRkCufGKT4wXxaalZOVeQmHrJT8KEsEf0yucDL qOFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851364; x=1695456164; 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=PfSjmEDVhfP8S9yyf7Msr/ihLbUKp60KnhAZgS2zH+U=; b=Dy4/MAkCWdf09+yLdRpWOxAlCFgqVhqTYgz1BwjisiONn8ICD9ZQ02cfeGaWzcZl+6 +TOozsJr+Pc5Flcljlk7nBE99Uhkl2i0czlIxK4eOjVC0hpBe+RiMoTK6+2gmZUGoCxW 7u8+iH+FN9Yez2HYTo2v56//3LsVrZzmaoGK3mu8NXQ/i0AOl44+P8HAIro5uS5UJwvW FyL8GZDgwcMlTN8foOlEnWHrN7/yICrciy+SH+Cq0Chg+EBSlDK+RDqozT2XlscDEXyg smzewcU9Rm80VQAB5/53ZIZ2BjqxOIcQ8eWoCFRQHyYFvEw9Lww36BjIpvZmrwv+RV3D Jl3Q== X-Gm-Message-State: AOJu0YyUqnu4OlMJV7jZCt+uJbEEBPAHAOZ42l7QTgqBQkYh6BcC3xby fyBWkspqTIkZVa/qMvHz4LX71A== X-Google-Smtp-Source: AGHT+IFryEMqPgKcDPXm0gMbdOQOeERbaGjC6ywP5CSeZbf2+Q13SMVC+zgAzA9ltk2S9r0LGUQKuw== X-Received: by 2002:a05:6a00:b92:b0:68e:2cc4:c720 with SMTP id g18-20020a056a000b9200b0068e2cc4c720mr4316430pfj.12.1694851363955; Sat, 16 Sep 2023 01:02:43 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Peter Maydell , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , "Edgar E. Iglesias" , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , qemu-arm@nongnu.org (open list:ARM TCG CPUs), qemu-ppc@nongnu.org (open list:PowerPC TCG CPUs), qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs), qemu-s390x@nongnu.org (open list:S390 TCG CPUs) Subject: [PATCH v8 09/19] gdbstub: Change gdb_get_reg_cb and gdb_set_reg_cb Date: Sat, 16 Sep 2023 17:01:26 +0900 Message-ID: <20230916080149.129989-10-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=2607:f8b0:4864:20::435; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x435.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851595479100003 Content-Type: text/plain; charset="utf-8" Align the parameters of gdb_get_reg_cb and gdb_set_reg_cb with the gdb_read_register and gdb_write_register members of CPUClass to allow to unify the logic to access registers of the core and coprocessors in the future. Signed-off-by: Akihiko Odaki --- include/exec/gdbstub.h | 4 +- target/arm/internals.h | 12 +++--- target/hexagon/internal.h | 4 +- target/microblaze/cpu.h | 4 +- gdbstub/gdbstub.c | 6 +-- target/arm/gdbstub.c | 51 ++++++++++++++++-------- target/arm/gdbstub64.c | 27 +++++++++---- target/hexagon/gdbstub.c | 10 ++++- target/loongarch/gdbstub.c | 11 ++++-- target/m68k/helper.c | 20 ++++++++-- target/microblaze/gdbstub.c | 9 ++++- target/ppc/gdbstub.c | 46 +++++++++++++++++----- target/riscv/gdbstub.c | 46 ++++++++++++++++------ target/s390x/gdbstub.c | 77 ++++++++++++++++++++++++++++--------- 14 files changed, 236 insertions(+), 91 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 5525eea090..38b8db29f7 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -23,8 +23,8 @@ typedef struct GDBFeatureBuilder { =20 =20 /* Get or set a register. Returns the size of the register. */ -typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArray *buf, int reg); -typedef int (*gdb_set_reg_cb)(CPUArchState *env, uint8_t *buf, int reg); +typedef int (*gdb_get_reg_cb)(CPUState *cpu, GByteArray *buf, int reg); +typedef int (*gdb_set_reg_cb)(CPUState *cpu, uint8_t *buf, int reg); =20 /** * gdb_register_coprocessor() - register a supplemental set of registers diff --git a/target/arm/internals.h b/target/arm/internals.h index 58f1a66f8d..5240d86619 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1386,12 +1386,12 @@ static inline uint64_t pmu_counter_mask(CPUARMState= *env) =20 #ifdef TARGET_AARCH64 GDBFeature *arm_gen_dynamic_svereg_feature(CPUState *cpu); -int aarch64_gdb_get_sve_reg(CPUARMState *env, GByteArray *buf, int reg); -int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg); -int aarch64_gdb_get_fpu_reg(CPUARMState *env, GByteArray *buf, int reg); -int aarch64_gdb_set_fpu_reg(CPUARMState *env, uint8_t *buf, int reg); -int aarch64_gdb_get_pauth_reg(CPUARMState *env, GByteArray *buf, int reg); -int aarch64_gdb_set_pauth_reg(CPUARMState *env, uint8_t *buf, int reg); +int aarch64_gdb_get_sve_reg(CPUState *cs, GByteArray *buf, int reg); +int aarch64_gdb_set_sve_reg(CPUState *cs, uint8_t *buf, int reg); +int aarch64_gdb_get_fpu_reg(CPUState *cs, GByteArray *buf, int reg); +int aarch64_gdb_set_fpu_reg(CPUState *cs, uint8_t *buf, int reg); +int aarch64_gdb_get_pauth_reg(CPUState *cs, GByteArray *buf, int reg); +int aarch64_gdb_set_pauth_reg(CPUState *cs, uint8_t *buf, int reg); void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp); void arm_cpu_sme_finalize(ARMCPU *cpu, Error **errp); void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp); diff --git a/target/hexagon/internal.h b/target/hexagon/internal.h index d732b6bb3c..beb08cb7e3 100644 --- a/target/hexagon/internal.h +++ b/target/hexagon/internal.h @@ -33,8 +33,8 @@ =20 int hexagon_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int hexagon_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); -int hexagon_hvx_gdb_read_register(CPUHexagonState *env, GByteArray *mem_bu= f, int n); -int hexagon_hvx_gdb_write_register(CPUHexagonState *env, uint8_t *mem_buf,= int n); +int hexagon_hvx_gdb_read_register(CPUState *env, GByteArray *mem_buf, int = n); +int hexagon_hvx_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n); =20 void hexagon_debug_vreg(CPUHexagonState *env, int regnum); void hexagon_debug_qreg(CPUHexagonState *env, int regnum); diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h index f6cab6ce19..820d3c261e 100644 --- a/target/microblaze/cpu.h +++ b/target/microblaze/cpu.h @@ -370,8 +370,8 @@ G_NORETURN void mb_cpu_do_unaligned_access(CPUState *cs= , vaddr vaddr, void mb_cpu_dump_state(CPUState *cpu, FILE *f, int flags); int mb_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); -int mb_cpu_gdb_read_stack_protect(CPUArchState *cpu, GByteArray *buf, int = reg); -int mb_cpu_gdb_write_stack_protect(CPUArchState *cpu, uint8_t *buf, int re= g); +int mb_cpu_gdb_read_stack_protect(CPUState *cs, GByteArray *buf, int reg); +int mb_cpu_gdb_write_stack_protect(CPUState *cs, uint8_t *buf, int reg); =20 static inline uint32_t mb_cpu_read_msr(const CPUMBState *env) { diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index b3f6f0dd2d..fb9f56bd4a 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -494,7 +494,6 @@ const GDBFeature *gdb_find_static_feature(const char *x= mlname) static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) { CPUClass *cc =3D CPU_GET_CLASS(cpu); - CPUArchState *env =3D cpu->env_ptr; GDBRegisterState *r; =20 if (reg < cc->gdb_num_core_regs) { @@ -504,7 +503,7 @@ static int gdb_read_register(CPUState *cpu, GByteArray = *buf, int reg) for (guint i =3D 0; i < cpu->gdb_regs->len; i++) { r =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); if (r->base_reg <=3D reg && reg < r->base_reg + r->feature->num_re= gs) { - return r->get_reg(env, buf, reg - r->base_reg); + return r->get_reg(cpu, buf, reg - r->base_reg); } } return 0; @@ -513,7 +512,6 @@ static int gdb_read_register(CPUState *cpu, GByteArray = *buf, int reg) static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg) { CPUClass *cc =3D CPU_GET_CLASS(cpu); - CPUArchState *env =3D cpu->env_ptr; GDBRegisterState *r; =20 if (reg < cc->gdb_num_core_regs) { @@ -523,7 +521,7 @@ static int gdb_write_register(CPUState *cpu, uint8_t *m= em_buf, int reg) for (guint i =3D 0; i < cpu->gdb_regs->len; i++) { r =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); if (r->base_reg <=3D reg && reg < r->base_reg + r->feature->num_re= gs) { - return r->set_reg(env, mem_buf, reg - r->base_reg); + return r->set_reg(cpu, mem_buf, reg - r->base_reg); } } return 0; diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 99040e0c4c..aa2c6c1bde 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -104,9 +104,10 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *= mem_buf, int n) return 0; } =20 -static int vfp_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg) +static int vfp_gdb_get_reg(CPUState *cs, GByteArray *buf, int reg) { - ARMCPU *cpu =3D env_archcpu(env); + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; int nregs =3D cpu_isar_feature(aa32_simd_r32, cpu) ? 32 : 16; =20 /* VFP data registers are always little-endian. */ @@ -128,9 +129,10 @@ static int vfp_gdb_get_reg(CPUARMState *env, GByteArra= y *buf, int reg) return 0; } =20 -static int vfp_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg) +static int vfp_gdb_set_reg(CPUState *cs, uint8_t *buf, int reg) { - ARMCPU *cpu =3D env_archcpu(env); + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; int nregs =3D cpu_isar_feature(aa32_simd_r32, cpu) ? 32 : 16; =20 if (reg < nregs) { @@ -154,8 +156,11 @@ static int vfp_gdb_set_reg(CPUARMState *env, uint8_t *= buf, int reg) return 0; } =20 -static int vfp_gdb_get_sysreg(CPUARMState *env, GByteArray *buf, int reg) +static int vfp_gdb_get_sysreg(CPUState *cs, GByteArray *buf, int reg) { + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + switch (reg) { case 0: return gdb_get_reg32(buf, env->vfp.xregs[ARM_VFP_FPSID]); @@ -165,8 +170,11 @@ static int vfp_gdb_get_sysreg(CPUARMState *env, GByteA= rray *buf, int reg) return 0; } =20 -static int vfp_gdb_set_sysreg(CPUARMState *env, uint8_t *buf, int reg) +static int vfp_gdb_set_sysreg(CPUState *cs, uint8_t *buf, int reg) { + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + switch (reg) { case 0: env->vfp.xregs[ARM_VFP_FPSID] =3D ldl_p(buf); @@ -178,8 +186,11 @@ static int vfp_gdb_set_sysreg(CPUARMState *env, uint8_= t *buf, int reg) return 0; } =20 -static int mve_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg) +static int mve_gdb_get_reg(CPUState *cs, GByteArray *buf, int reg) { + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + switch (reg) { case 0: return gdb_get_reg32(buf, env->v7m.vpr); @@ -188,8 +199,11 @@ static int mve_gdb_get_reg(CPUARMState *env, GByteArra= y *buf, int reg) } } =20 -static int mve_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg) +static int mve_gdb_set_reg(CPUState *cs, uint8_t *buf, int reg) { + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + switch (reg) { case 0: env->v7m.vpr =3D ldl_p(buf); @@ -208,9 +222,10 @@ static int mve_gdb_set_reg(CPUARMState *env, uint8_t *= buf, int reg) * We return the number of bytes copied */ =20 -static int arm_gdb_get_sysreg(CPUARMState *env, GByteArray *buf, int reg) +static int arm_gdb_get_sysreg(CPUState *cs, GByteArray *buf, int reg) { - ARMCPU *cpu =3D env_archcpu(env); + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; const ARMCPRegInfo *ri; uint32_t key; =20 @@ -226,7 +241,7 @@ static int arm_gdb_get_sysreg(CPUARMState *env, GByteAr= ray *buf, int reg) return 0; } =20 -static int arm_gdb_set_sysreg(CPUARMState *env, uint8_t *buf, int reg) +static int arm_gdb_set_sysreg(CPUState *cs, uint8_t *buf, int reg) { return 0; } @@ -364,8 +379,11 @@ static int m_sysreg_get(CPUARMState *env, GByteArray *= buf, return gdb_get_reg32(buf, *ptr); } =20 -static int arm_gdb_get_m_systemreg(CPUARMState *env, GByteArray *buf, int = reg) +static int arm_gdb_get_m_systemreg(CPUState *cs, GByteArray *buf, int reg) { + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + /* * Here, we emulate MRS instruction, where CONTROL has a mix of * banked and non-banked bits. @@ -376,7 +394,7 @@ static int arm_gdb_get_m_systemreg(CPUARMState *env, GB= yteArray *buf, int reg) return m_sysreg_get(env, buf, reg, env->v7m.secure); } =20 -static int arm_gdb_set_m_systemreg(CPUARMState *env, uint8_t *buf, int reg) +static int arm_gdb_set_m_systemreg(CPUState *cs, uint8_t *buf, int reg) { return 0; /* TODO */ } @@ -408,12 +426,15 @@ static GDBFeature *arm_gen_dynamic_m_systemreg_featur= e(CPUState *cs) * For user-only, we see the non-secure registers via m_systemreg above. * For secext, encode the non-secure view as even and secure view as odd. */ -static int arm_gdb_get_m_secextreg(CPUARMState *env, GByteArray *buf, int = reg) +static int arm_gdb_get_m_secextreg(CPUState *cs, GByteArray *buf, int reg) { + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + return m_sysreg_get(env, buf, reg >> 1, reg & 1); } =20 -static int arm_gdb_set_m_secextreg(CPUARMState *env, uint8_t *buf, int reg) +static int arm_gdb_set_m_secextreg(CPUState *cs, uint8_t *buf, int reg) { return 0; /* TODO */ } diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 632ac2a520..b7978bdf02 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -72,8 +72,11 @@ int aarch64_cpu_gdb_write_register(CPUState *cs, uint8_t= *mem_buf, int n) return 0; } =20 -int aarch64_gdb_get_fpu_reg(CPUARMState *env, GByteArray *buf, int reg) +int aarch64_gdb_get_fpu_reg(CPUState *cs, GByteArray *buf, int reg) { + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + switch (reg) { case 0 ... 31: { @@ -92,8 +95,11 @@ int aarch64_gdb_get_fpu_reg(CPUARMState *env, GByteArray= *buf, int reg) } } =20 -int aarch64_gdb_set_fpu_reg(CPUARMState *env, uint8_t *buf, int reg) +int aarch64_gdb_set_fpu_reg(CPUState *cs, uint8_t *buf, int reg) { + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + switch (reg) { case 0 ... 31: /* 128 bit FP register */ @@ -116,9 +122,10 @@ int aarch64_gdb_set_fpu_reg(CPUARMState *env, uint8_t = *buf, int reg) } } =20 -int aarch64_gdb_get_sve_reg(CPUARMState *env, GByteArray *buf, int reg) +int aarch64_gdb_get_sve_reg(CPUState *cs, GByteArray *buf, int reg) { - ARMCPU *cpu =3D env_archcpu(env); + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; =20 switch (reg) { /* The first 32 registers are the zregs */ @@ -164,9 +171,10 @@ int aarch64_gdb_get_sve_reg(CPUARMState *env, GByteArr= ay *buf, int reg) return 0; } =20 -int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg) +int aarch64_gdb_set_sve_reg(CPUState *cs, uint8_t *buf, int reg) { - ARMCPU *cpu =3D env_archcpu(env); + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; =20 /* The first 32 registers are the zregs */ switch (reg) { @@ -210,8 +218,11 @@ int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t = *buf, int reg) return 0; } =20 -int aarch64_gdb_get_pauth_reg(CPUARMState *env, GByteArray *buf, int reg) +int aarch64_gdb_get_pauth_reg(CPUState *cs, GByteArray *buf, int reg) { + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + switch (reg) { case 0: /* pauth_dmask */ case 1: /* pauth_cmask */ @@ -241,7 +252,7 @@ int aarch64_gdb_get_pauth_reg(CPUARMState *env, GByteAr= ray *buf, int reg) } } =20 -int aarch64_gdb_set_pauth_reg(CPUARMState *env, uint8_t *buf, int reg) +int aarch64_gdb_set_pauth_reg(CPUState *cs, uint8_t *buf, int reg) { /* All pseudo registers are read-only. */ return 0; diff --git a/target/hexagon/gdbstub.c b/target/hexagon/gdbstub.c index 54d37e006e..6007e6462b 100644 --- a/target/hexagon/gdbstub.c +++ b/target/hexagon/gdbstub.c @@ -81,8 +81,11 @@ static int gdb_get_qreg(CPUHexagonState *env, GByteArray= *mem_buf, int n) return total; } =20 -int hexagon_hvx_gdb_read_register(CPUHexagonState *env, GByteArray *mem_bu= f, int n) +int hexagon_hvx_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { + HexagonCPU *cpu =3D HEXAGON_CPU(cs); + CPUHexagonState *env =3D &cpu->env; + if (n < NUM_VREGS) { return gdb_get_vreg(env, mem_buf, n); } @@ -115,8 +118,11 @@ static int gdb_put_qreg(CPUHexagonState *env, uint8_t = *mem_buf, int n) return MAX_VEC_SIZE_BYTES / 8; } =20 -int hexagon_hvx_gdb_write_register(CPUHexagonState *env, uint8_t *mem_buf,= int n) +int hexagon_hvx_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { + HexagonCPU *cpu =3D HEXAGON_CPU(cs); + CPUHexagonState *env =3D &cpu->env; + if (n < NUM_VREGS) { return gdb_put_vreg(env, mem_buf, n); } diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c index e04742c202..2da5d2aef7 100644 --- a/target/loongarch/gdbstub.c +++ b/target/loongarch/gdbstub.c @@ -83,9 +83,11 @@ int loongarch_cpu_gdb_write_register(CPUState *cs, uint8= _t *mem_buf, int n) return length; } =20 -static int loongarch_gdb_get_fpu(CPULoongArchState *env, - GByteArray *mem_buf, int n) +static int loongarch_gdb_get_fpu(CPUState *cs, GByteArray *mem_buf, int n) { + LoongArchCPU *cpu =3D LOONGARCH_CPU(cs); + CPULoongArchState *env =3D &cpu->env; + if (0 <=3D n && n < 32) { return gdb_get_reg64(mem_buf, env->fpr[n].vreg.D(0)); } else if (32 <=3D n && n < 40) { @@ -96,9 +98,10 @@ static int loongarch_gdb_get_fpu(CPULoongArchState *env, return 0; } =20 -static int loongarch_gdb_set_fpu(CPULoongArchState *env, - uint8_t *mem_buf, int n) +static int loongarch_gdb_set_fpu(CPUState *cs, uint8_t *mem_buf, int n) { + LoongArchCPU *cpu =3D LOONGARCH_CPU(cs); + CPULoongArchState *env =3D &cpu->env; int length =3D 0; =20 if (0 <=3D n && n < 32) { diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 675f2dcd5a..a5ee4d87e3 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -69,8 +69,11 @@ void m68k_cpu_list(void) g_slist_free(list); } =20 -static int cf_fpu_gdb_get_reg(CPUM68KState *env, GByteArray *mem_buf, int = n) +static int cf_fpu_gdb_get_reg(CPUState *cs, GByteArray *mem_buf, int n) { + M68kCPU *cpu =3D M68K_CPU(cs); + CPUM68KState *env =3D &cpu->env; + if (n < 8) { float_status s; return gdb_get_reg64(mem_buf, floatx80_to_float64(env->fregs[n].d,= &s)); @@ -86,8 +89,11 @@ static int cf_fpu_gdb_get_reg(CPUM68KState *env, GByteAr= ray *mem_buf, int n) return 0; } =20 -static int cf_fpu_gdb_set_reg(CPUM68KState *env, uint8_t *mem_buf, int n) +static int cf_fpu_gdb_set_reg(CPUState *cs, uint8_t *mem_buf, int n) { + M68kCPU *cpu =3D M68K_CPU(cs); + CPUM68KState *env =3D &cpu->env; + if (n < 8) { float_status s; env->fregs[n].d =3D float64_to_floatx80(ldq_p(mem_buf), &s); @@ -106,8 +112,11 @@ static int cf_fpu_gdb_set_reg(CPUM68KState *env, uint8= _t *mem_buf, int n) return 0; } =20 -static int m68k_fpu_gdb_get_reg(CPUM68KState *env, GByteArray *mem_buf, in= t n) +static int m68k_fpu_gdb_get_reg(CPUState *cs, GByteArray *mem_buf, int n) { + M68kCPU *cpu =3D M68K_CPU(cs); + CPUM68KState *env =3D &cpu->env; + if (n < 8) { int len =3D gdb_get_reg16(mem_buf, env->fregs[n].l.upper); len +=3D gdb_get_reg16(mem_buf, 0); @@ -125,8 +134,11 @@ static int m68k_fpu_gdb_get_reg(CPUM68KState *env, GBy= teArray *mem_buf, int n) return 0; } =20 -static int m68k_fpu_gdb_set_reg(CPUM68KState *env, uint8_t *mem_buf, int n) +static int m68k_fpu_gdb_set_reg(CPUState *cs, uint8_t *mem_buf, int n) { + M68kCPU *cpu =3D M68K_CPU(cs); + CPUM68KState *env =3D &cpu->env; + if (n < 8) { env->fregs[n].l.upper =3D lduw_be_p(mem_buf); env->fregs[n].l.lower =3D ldq_be_p(mem_buf + 4); diff --git a/target/microblaze/gdbstub.c b/target/microblaze/gdbstub.c index 29ac6e9c0f..6ffc5ad075 100644 --- a/target/microblaze/gdbstub.c +++ b/target/microblaze/gdbstub.c @@ -94,8 +94,10 @@ int mb_cpu_gdb_read_register(CPUState *cs, GByteArray *m= em_buf, int n) return gdb_get_reg32(mem_buf, val); } =20 -int mb_cpu_gdb_read_stack_protect(CPUMBState *env, GByteArray *mem_buf, in= t n) +int mb_cpu_gdb_read_stack_protect(CPUState *cs, GByteArray *mem_buf, int n) { + MicroBlazeCPU *cpu =3D MICROBLAZE_CPU(cs); + CPUMBState *env =3D &cpu->env; uint32_t val; =20 switch (n) { @@ -153,8 +155,11 @@ int mb_cpu_gdb_write_register(CPUState *cs, uint8_t *m= em_buf, int n) return 4; } =20 -int mb_cpu_gdb_write_stack_protect(CPUMBState *env, uint8_t *mem_buf, int = n) +int mb_cpu_gdb_write_stack_protect(CPUState *cs, uint8_t *mem_buf, int n) { + MicroBlazeCPU *cpu =3D MICROBLAZE_CPU(cs); + CPUMBState *env =3D &cpu->env; + switch (n) { case GDB_SP_SHL: env->slr =3D ldl_p(mem_buf); diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index 9f2aad7aa9..2392625441 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -366,8 +366,10 @@ static int gdb_find_spr_idx(CPUPPCState *env, int n) return -1; } =20 -static int gdb_get_spr_reg(CPUPPCState *env, GByteArray *buf, int n) +static int gdb_get_spr_reg(CPUState *cs, GByteArray *buf, int n) { + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + CPUPPCState *env =3D &cpu->env; int reg; int len; =20 @@ -382,8 +384,10 @@ static int gdb_get_spr_reg(CPUPPCState *env, GByteArra= y *buf, int n) return len; } =20 -static int gdb_set_spr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_set_spr_reg(CPUState *cs, uint8_t *mem_buf, int n) { + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + CPUPPCState *env =3D &cpu->env; int reg; int len; =20 @@ -400,8 +404,10 @@ static int gdb_set_spr_reg(CPUPPCState *env, uint8_t *= mem_buf, int n) } #endif =20 -static int gdb_get_float_reg(CPUPPCState *env, GByteArray *buf, int n) +static int gdb_get_float_reg(CPUState *cs, GByteArray *buf, int n) { + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + CPUPPCState *env =3D &cpu->env; uint8_t *mem_buf; if (n < 32) { gdb_get_reg64(buf, *cpu_fpr_ptr(env, n)); @@ -418,8 +424,11 @@ static int gdb_get_float_reg(CPUPPCState *env, GByteAr= ray *buf, int n) return 0; } =20 -static int gdb_set_float_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_set_float_reg(CPUState *cs, uint8_t *mem_buf, int n) { + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + CPUPPCState *env =3D &cpu->env; + if (n < 32) { ppc_maybe_bswap_register(env, mem_buf, 8); *cpu_fpr_ptr(env, n) =3D ldq_p(mem_buf); @@ -433,8 +442,10 @@ static int gdb_set_float_reg(CPUPPCState *env, uint8_t= *mem_buf, int n) return 0; } =20 -static int gdb_get_avr_reg(CPUPPCState *env, GByteArray *buf, int n) +static int gdb_get_avr_reg(CPUState *cs, GByteArray *buf, int n) { + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + CPUPPCState *env =3D &cpu->env; uint8_t *mem_buf; =20 if (n < 32) { @@ -459,8 +470,11 @@ static int gdb_get_avr_reg(CPUPPCState *env, GByteArra= y *buf, int n) return 0; } =20 -static int gdb_set_avr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_set_avr_reg(CPUState *cs, uint8_t *mem_buf, int n) { + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + CPUPPCState *env =3D &cpu->env; + if (n < 32) { ppc_avr_t *avr =3D cpu_avr_ptr(env, n); ppc_maybe_bswap_register(env, mem_buf, 16); @@ -481,8 +495,11 @@ static int gdb_set_avr_reg(CPUPPCState *env, uint8_t *= mem_buf, int n) return 0; } =20 -static int gdb_get_spe_reg(CPUPPCState *env, GByteArray *buf, int n) +static int gdb_get_spe_reg(CPUState *cs, GByteArray *buf, int n) { + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + CPUPPCState *env =3D &cpu->env; + if (n < 32) { #if defined(TARGET_PPC64) gdb_get_reg32(buf, env->gpr[n] >> 32); @@ -505,8 +522,11 @@ static int gdb_get_spe_reg(CPUPPCState *env, GByteArra= y *buf, int n) return 0; } =20 -static int gdb_set_spe_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_set_spe_reg(CPUState *cs, uint8_t *mem_buf, int n) { + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + CPUPPCState *env =3D &cpu->env; + if (n < 32) { #if defined(TARGET_PPC64) target_ulong lo =3D (uint32_t)env->gpr[n]; @@ -534,8 +554,11 @@ static int gdb_set_spe_reg(CPUPPCState *env, uint8_t *= mem_buf, int n) return 0; } =20 -static int gdb_get_vsx_reg(CPUPPCState *env, GByteArray *buf, int n) +static int gdb_get_vsx_reg(CPUState *cs, GByteArray *buf, int n) { + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + CPUPPCState *env =3D &cpu->env; + if (n < 32) { gdb_get_reg64(buf, *cpu_vsrl_ptr(env, n)); ppc_maybe_bswap_register(env, gdb_get_reg_ptr(buf, 8), 8); @@ -544,8 +567,11 @@ static int gdb_get_vsx_reg(CPUPPCState *env, GByteArra= y *buf, int n) return 0; } =20 -static int gdb_set_vsx_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_set_vsx_reg(CPUState *cs, uint8_t *mem_buf, int n) { + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + CPUPPCState *env =3D &cpu->env; + if (n < 32) { ppc_maybe_bswap_register(env, mem_buf, 8); *cpu_vsrl_ptr(env, n) =3D ldq_p(mem_buf); diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index d4f9eb1516..c8525794ef 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -106,8 +106,11 @@ int riscv_cpu_gdb_write_register(CPUState *cs, uint8_t= *mem_buf, int n) return length; } =20 -static int riscv_gdb_get_fpu(CPURISCVState *env, GByteArray *buf, int n) +static int riscv_gdb_get_fpu(CPUState *cs, GByteArray *buf, int n) { + RISCVCPU *cpu =3D RISCV_CPU(cs); + CPURISCVState *env =3D &cpu->env; + if (n < 32) { if (env->misa_ext & RVD) { return gdb_get_reg64(buf, env->fpr[n]); @@ -119,8 +122,11 @@ static int riscv_gdb_get_fpu(CPURISCVState *env, GByte= Array *buf, int n) return 0; } =20 -static int riscv_gdb_set_fpu(CPURISCVState *env, uint8_t *mem_buf, int n) +static int riscv_gdb_set_fpu(CPUState *cs, uint8_t *mem_buf, int n) { + RISCVCPU *cpu =3D RISCV_CPU(cs); + CPURISCVState *env =3D &cpu->env; + if (n < 32) { env->fpr[n] =3D ldq_p(mem_buf); /* always 64-bit */ return sizeof(uint64_t); @@ -128,8 +134,10 @@ static int riscv_gdb_set_fpu(CPURISCVState *env, uint8= _t *mem_buf, int n) return 0; } =20 -static int riscv_gdb_get_vector(CPURISCVState *env, GByteArray *buf, int n) +static int riscv_gdb_get_vector(CPUState *cs, GByteArray *buf, int n) { + RISCVCPU *cpu =3D RISCV_CPU(cs); + CPURISCVState *env =3D &cpu->env; uint16_t vlenb =3D riscv_cpu_cfg(env)->vlen >> 3; if (n < 32) { int i; @@ -144,8 +152,10 @@ static int riscv_gdb_get_vector(CPURISCVState *env, GB= yteArray *buf, int n) return 0; } =20 -static int riscv_gdb_set_vector(CPURISCVState *env, uint8_t *mem_buf, int = n) +static int riscv_gdb_set_vector(CPUState *cs, uint8_t *mem_buf, int n) { + RISCVCPU *cpu =3D RISCV_CPU(cs); + CPURISCVState *env =3D &cpu->env; uint16_t vlenb =3D riscv_cpu_cfg(env)->vlen >> 3; if (n < 32) { int i; @@ -158,8 +168,11 @@ static int riscv_gdb_set_vector(CPURISCVState *env, ui= nt8_t *mem_buf, int n) return 0; } =20 -static int riscv_gdb_get_csr(CPURISCVState *env, GByteArray *buf, int n) +static int riscv_gdb_get_csr(CPUState *cs, GByteArray *buf, int n) { + RISCVCPU *cpu =3D RISCV_CPU(cs); + CPURISCVState *env =3D &cpu->env; + if (n < CSR_TABLE_SIZE) { target_ulong val =3D 0; int result; @@ -172,8 +185,11 @@ static int riscv_gdb_get_csr(CPURISCVState *env, GByte= Array *buf, int n) return 0; } =20 -static int riscv_gdb_set_csr(CPURISCVState *env, uint8_t *mem_buf, int n) +static int riscv_gdb_set_csr(CPUState *cs, uint8_t *mem_buf, int n) { + RISCVCPU *cpu =3D RISCV_CPU(cs); + CPURISCVState *env =3D &cpu->env; + if (n < CSR_TABLE_SIZE) { target_ulong val =3D ldtul_p(mem_buf); int result; @@ -186,25 +202,31 @@ static int riscv_gdb_set_csr(CPURISCVState *env, uint= 8_t *mem_buf, int n) return 0; } =20 -static int riscv_gdb_get_virtual(CPURISCVState *cs, GByteArray *buf, int n) +static int riscv_gdb_get_virtual(CPUState *cs, GByteArray *buf, int n) { if (n =3D=3D 0) { #ifdef CONFIG_USER_ONLY return gdb_get_regl(buf, 0); #else - return gdb_get_regl(buf, cs->priv); + RISCVCPU *cpu =3D RISCV_CPU(cs); + CPURISCVState *env =3D &cpu->env; + + return gdb_get_regl(buf, env->priv); #endif } return 0; } =20 -static int riscv_gdb_set_virtual(CPURISCVState *cs, uint8_t *mem_buf, int = n) +static int riscv_gdb_set_virtual(CPUState *cs, uint8_t *mem_buf, int n) { if (n =3D=3D 0) { #ifndef CONFIG_USER_ONLY - cs->priv =3D ldtul_p(mem_buf) & 0x3; - if (cs->priv =3D=3D PRV_RESERVED) { - cs->priv =3D PRV_S; + RISCVCPU *cpu =3D RISCV_CPU(cs); + CPURISCVState *env =3D &cpu->env; + + env->priv =3D ldtul_p(mem_buf) & 0x3; + if (env->priv =3D=3D PRV_RESERVED) { + env->priv =3D PRV_S; } #endif return sizeof(target_ulong); diff --git a/target/s390x/gdbstub.c b/target/s390x/gdbstub.c index 02c388dc32..c1e7c59b82 100644 --- a/target/s390x/gdbstub.c +++ b/target/s390x/gdbstub.c @@ -70,8 +70,11 @@ int s390_cpu_gdb_write_register(CPUState *cs, uint8_t *m= em_buf, int n) #define S390_A0_REGNUM 0 #define S390_A15_REGNUM 15 =20 -static int cpu_read_ac_reg(CPUS390XState *env, GByteArray *buf, int n) +static int cpu_read_ac_reg(CPUState *cs, GByteArray *buf, int n) { + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + switch (n) { case S390_A0_REGNUM ... S390_A15_REGNUM: return gdb_get_reg32(buf, env->aregs[n]); @@ -80,8 +83,11 @@ static int cpu_read_ac_reg(CPUS390XState *env, GByteArra= y *buf, int n) } } =20 -static int cpu_write_ac_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_write_ac_reg(CPUState *cs, uint8_t *mem_buf, int n) { + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + switch (n) { case S390_A0_REGNUM ... S390_A15_REGNUM: env->aregs[n] =3D ldl_p(mem_buf); @@ -97,8 +103,11 @@ static int cpu_write_ac_reg(CPUS390XState *env, uint8_t= *mem_buf, int n) #define S390_F0_REGNUM 1 #define S390_F15_REGNUM 16 =20 -static int cpu_read_fp_reg(CPUS390XState *env, GByteArray *buf, int n) +static int cpu_read_fp_reg(CPUState *cs, GByteArray *buf, int n) { + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + switch (n) { case S390_FPC_REGNUM: return gdb_get_reg32(buf, env->fpc); @@ -109,8 +118,11 @@ static int cpu_read_fp_reg(CPUS390XState *env, GByteAr= ray *buf, int n) } } =20 -static int cpu_write_fp_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_write_fp_reg(CPUState *cs, uint8_t *mem_buf, int n) { + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + switch (n) { case S390_FPC_REGNUM: env->fpc =3D ldl_p(mem_buf); @@ -129,8 +141,10 @@ static int cpu_write_fp_reg(CPUS390XState *env, uint8_= t *mem_buf, int n) #define S390_V16_REGNUM 16 #define S390_V31_REGNUM 31 =20 -static int cpu_read_vreg(CPUS390XState *env, GByteArray *buf, int n) +static int cpu_read_vreg(CPUState *cs, GByteArray *buf, int n) { + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; int ret; =20 switch (n) { @@ -148,8 +162,11 @@ static int cpu_read_vreg(CPUS390XState *env, GByteArra= y *buf, int n) return ret; } =20 -static int cpu_write_vreg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_write_vreg(CPUState *cs, uint8_t *mem_buf, int n) { + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + switch (n) { case S390_V0L_REGNUM ... S390_V15L_REGNUM: env->vregs[n][1] =3D ldtul_p(mem_buf + 8); @@ -168,8 +185,11 @@ static int cpu_write_vreg(CPUS390XState *env, uint8_t = *mem_buf, int n) #define S390_C15_REGNUM 15 =20 #ifndef CONFIG_USER_ONLY -static int cpu_read_c_reg(CPUS390XState *env, GByteArray *buf, int n) +static int cpu_read_c_reg(CPUState *cs, GByteArray *buf, int n) { + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + switch (n) { case S390_C0_REGNUM ... S390_C15_REGNUM: return gdb_get_regl(buf, env->cregs[n]); @@ -178,8 +198,11 @@ static int cpu_read_c_reg(CPUS390XState *env, GByteArr= ay *buf, int n) } } =20 -static int cpu_write_c_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_write_c_reg(CPUState *cs, uint8_t *mem_buf, int n) { + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + switch (n) { case S390_C0_REGNUM ... S390_C15_REGNUM: env->cregs[n] =3D ldtul_p(mem_buf); @@ -199,8 +222,11 @@ static int cpu_write_c_reg(CPUS390XState *env, uint8_t= *mem_buf, int n) #define S390_VIRT_BEA_REGNUM 2 #define S390_VIRT_PREFIX_REGNUM 3 =20 -static int cpu_read_virt_reg(CPUS390XState *env, GByteArray *mem_buf, int = n) +static int cpu_read_virt_reg(CPUState *cs, GByteArray *mem_buf, int n) { + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + switch (n) { case S390_VIRT_CKC_REGNUM: return gdb_get_regl(mem_buf, env->ckc); @@ -215,24 +241,27 @@ static int cpu_read_virt_reg(CPUS390XState *env, GByt= eArray *mem_buf, int n) } } =20 -static int cpu_write_virt_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_write_virt_reg(CPUState *cs, uint8_t *mem_buf, int n) { + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + switch (n) { case S390_VIRT_CKC_REGNUM: env->ckc =3D ldtul_p(mem_buf); - cpu_synchronize_post_init(env_cpu(env)); + cpu_synchronize_post_init(cs); return 8; case S390_VIRT_CPUTM_REGNUM: env->cputm =3D ldtul_p(mem_buf); - cpu_synchronize_post_init(env_cpu(env)); + cpu_synchronize_post_init(cs); return 8; case S390_VIRT_BEA_REGNUM: env->gbea =3D ldtul_p(mem_buf); - cpu_synchronize_post_init(env_cpu(env)); + cpu_synchronize_post_init(cs); return 8; case S390_VIRT_PREFIX_REGNUM: env->psa =3D ldtul_p(mem_buf); - cpu_synchronize_post_init(env_cpu(env)); + cpu_synchronize_post_init(cs); return 8; default: return 0; @@ -245,8 +274,11 @@ static int cpu_write_virt_reg(CPUS390XState *env, uint= 8_t *mem_buf, int n) #define S390_VIRT_KVM_PFS_REGNUM 2 #define S390_VIRT_KVM_PFC_REGNUM 3 =20 -static int cpu_read_virt_kvm_reg(CPUS390XState *env, GByteArray *mem_buf, = int n) +static int cpu_read_virt_kvm_reg(CPUState *cs, GByteArray *mem_buf, int n) { + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + switch (n) { case S390_VIRT_KVM_PP_REGNUM: return gdb_get_regl(mem_buf, env->pp); @@ -261,8 +293,11 @@ static int cpu_read_virt_kvm_reg(CPUS390XState *env, G= ByteArray *mem_buf, int n) } } =20 -static int cpu_write_virt_kvm_reg(CPUS390XState *env, uint8_t *mem_buf, in= t n) +static int cpu_write_virt_kvm_reg(CPUState *cs, uint8_t *mem_buf, int n) { + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + switch (n) { case S390_VIRT_KVM_PP_REGNUM: env->pp =3D ldtul_p(mem_buf); @@ -292,13 +327,19 @@ static int cpu_write_virt_kvm_reg(CPUS390XState *env,= uint8_t *mem_buf, int n) #define S390_GS_GSSM_REGNUM 2 #define S390_GS_GSEPLA_REGNUM 3 =20 -static int cpu_read_gs_reg(CPUS390XState *env, GByteArray *buf, int n) +static int cpu_read_gs_reg(CPUState *cs, GByteArray *buf, int n) { + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + return gdb_get_regl(buf, env->gscb[n]); } =20 -static int cpu_write_gs_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_write_gs_reg(CPUState *cs, uint8_t *mem_buf, int n) { + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + env->gscb[n] =3D ldtul_p(mem_buf); cpu_synchronize_post_init(env_cpu(env)); return 8; --=20 2.42.0 From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851583; cv=none; d=zohomail.com; s=zohoarc; b=n2p1zYvwgmnlhO4DSi5UhdcKhPF+LOXNuQzw9mwukcQ7N+zU50Pirw64q/Yiwnq0na8YjRMQ4UfcnN76rb1x+Vj1L3fTW8GLPzrEVmF/Mr452BT8g3cdJXnq7pX6leVHZGsy/XL/aMkkc0jPGrDjXoFmTgrjCJ29A7EH1JmlZNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851583; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=Umo2QdFmj6fXPFRoTffyd5nTftLEatYAZUP0DZd0IXk=; b=f5vmbzB/kBF7XT1OSyMPGm9qsJyUOhJ0WE8RVK9F9XE06Aoa55mgc8QhgAyX8Da7QdDopveUrk42jvXCTT3kg7MwcazuiPRRVSPeEhHbLLOgCbr2GucnjbgRNy0x3N4zuGwN3QGbVaJdTvBwGmrRih2hYn1bkrhquvZmG7v1HAQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169485158362851.84172171224657; Sat, 16 Sep 2023 01:06:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQGX-0003RN-CC; Sat, 16 Sep 2023 04:02:57 -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 1qhQGQ-0003Ki-F8 for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:50 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhQGN-00062W-5R for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:50 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-68fac16ee5fso2662006b3a.1 for ; Sat, 16 Sep 2023 01:02:46 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851366; x=1695456166; 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=Umo2QdFmj6fXPFRoTffyd5nTftLEatYAZUP0DZd0IXk=; b=0sGQIMw+ST65Pj6IzGxdrIMVZ1ZnntXsANHNvit1+7yOr8Q3oHFb5/SOb/fGh0jDL3 3tsqiOrXvz0BZYY6HNelZZFzXg6CysyrLSn+Pb9ZmlgWFxMiVubFRdaN9hWnIfBIcbJa Y0tURQnOZxwPAqZYVYlC/h8hw4uKRaU/CLMHhnMAQcNRX7wg5MOyd9F5O+8deG5iiDxc PmRPBm+EwnHCuvRSElJJdO0+a1FNfy//LF0nOMucS2Cyoa8JecJdp8s7PLLOjuQBZGfG birYB3hKFRDCyZVBpnkxWrw8YK6uQUmoUPE17Mr2QbY2ir6M8Ih4L/kdFTLVNoueLa5V L/Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851366; x=1695456166; 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=Umo2QdFmj6fXPFRoTffyd5nTftLEatYAZUP0DZd0IXk=; b=jCrmvC5GBb0Sm1cm0S+fW1ymRgE/9gLG4oTvO90QJYg9bhpJqugn+EAYfNhip6/JTo oIEorqY/GFn0OBGDFpESunTic8BvcIXcuwGWYGmtQHa/C8Yjju6RXpIFhb/578fThurM 5iGEuaE2BGAzx11OtiVvZPuZf6vDzE5gRXGQzziWM+hLGYTyN+gjeuUP0qgecAcayH/W Q+utFJokRSLVed0X+D9GwLWR1q0vMA+rBHp0iORZHikaMg6xuiWuXkADn1COEWguyvvt c9hQQh7JQXGNXwmgBLP4oOSy1yFQOPnhKKRscxflIVeIMAMjmqSD4vB0TTA9k/fCR2em DRRw== X-Gm-Message-State: AOJu0YwNSZH+EWWPY6rKcHGfVXwJbv6cBAz3rKRES9K5AVTQ5IqXrDP3 IAL1xfiRUxr80wnUPi0XbZnQOMcbhGrI63YY/Vk= X-Google-Smtp-Source: AGHT+IGRPojV2g8gKZjK340BKV/u64XhdIAbxKAGwh1Y0UMGK9nzVlRZAyJSbkPbRKTG7uxYDyGetA== X-Received: by 2002:a05:6a21:3e09:b0:153:5dd1:219f with SMTP id bk9-20020a056a213e0900b001535dd1219fmr3681374pzc.31.1694851365954; Sat, 16 Sep 2023 01:02:45 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki Subject: [PATCH v8 10/19] gdbstub: Simplify XML lookup Date: Sat, 16 Sep 2023 17:01:27 +0900 Message-ID: <20230916080149.129989-11-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=2607:f8b0:4864:20::42d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42d.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851585356100002 Content-Type: text/plain; charset="utf-8" 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 --- include/exec/gdbstub.h | 2 + gdbstub/gdbstub.c | 85 +++++++++++++++++++++++------------------- hw/core/cpu-common.c | 5 ++- 3 files changed, 52 insertions(+), 40 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 38b8db29f7..67f363132e 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -26,6 +26,8 @@ typedef struct GDBFeatureBuilder { typedef int (*gdb_get_reg_cb)(CPUState *cpu, GByteArray *buf, int reg); typedef int (*gdb_set_reg_cb)(CPUState *cpu, uint8_t *buf, int reg); =20 +void gdb_init_cpu(CPUState *cpu); + /** * gdb_register_coprocessor() - register a supplemental set of registers * @cpu - the CPU associated with registers diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index fb9f56bd4a..c2afdf20c2 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -352,6 +352,7 @@ static const char *get_feature_xml(const char *p, const= char **newp, { CPUState *cpu =3D gdb_get_first_cpu_in_process(process); CPUClass *cc =3D CPU_GET_CLASS(cpu); + GDBRegisterState *r; size_t len; =20 /* @@ -365,7 +366,6 @@ static const char *get_feature_xml(const char *p, const= char **newp, /* Is it the main target xml? */ if (strncmp(p, "target.xml", len) =3D=3D 0) { if (!process->target_xml) { - GDBRegisterState *r; g_autoptr(GPtrArray) xml =3D g_ptr_array_new_with_free_func(g_= free); =20 g_ptr_array_add( @@ -380,10 +380,6 @@ static const char *get_feature_xml(const char *p, cons= t char **newp, g_markup_printf_escaped("%s", cc->gdb_arch_name(cpu))); } - g_ptr_array_add( - xml, - g_markup_printf_escaped("", - cc->gdb_core_xml_file)); for (guint i =3D 0; i < cpu->gdb_regs->len; i++) { r =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); g_ptr_array_add( @@ -398,20 +394,11 @@ static const char *get_feature_xml(const char *p, con= st char **newp, } return process->target_xml; } - /* Is it dynamically generated by the target? */ - if (cc->gdb_get_dynamic_xml) { - g_autofree char *xmlname =3D g_strndup(p, len); - const char *xml =3D cc->gdb_get_dynamic_xml(cpu, xmlname); - if (xml) { - return xml; - } - } - /* Is it one of the encoded gdb-xml/ files? */ - for (int i =3D 0; gdb_static_features[i].xmlname; i++) { - const char *name =3D gdb_static_features[i].xmlname; - if ((strncmp(name, p, len) =3D=3D 0) && - strlen(name) =3D=3D len) { - return gdb_static_features[i].xml; + /* Is it one of the features? */ + for (guint i =3D 0; i < cpu->gdb_regs->len; i++) { + r =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); + if (strncmp(p, r->feature->xmlname, len) =3D=3D 0) { + return r->feature->xml; } } =20 @@ -527,39 +514,61 @@ static int gdb_write_register(CPUState *cpu, uint8_t = *mem_buf, int reg) return 0; } =20 +static void gdb_register_feature(CPUState *cpu, int base_reg, + gdb_get_reg_cb get_reg, gdb_set_reg_cb se= t_reg, + const GDBFeature *feature) +{ + guint i =3D cpu->gdb_regs->len; + GDBRegisterState *s; + + g_array_set_size(cpu->gdb_regs, i + 1); + s =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); + s->base_reg =3D base_reg; + s->get_reg =3D get_reg; + s->set_reg =3D set_reg; + s->feature =3D feature; +} + +void gdb_init_cpu(CPUState *cpu) +{ + CPUClass *cc =3D CPU_GET_CLASS(cpu); + const GDBFeature *feature; + + cpu->gdb_regs =3D g_array_new(false, false, sizeof(GDBRegisterState)); + + if (cc->gdb_core_xml_file) { + feature =3D gdb_find_static_feature(cc->gdb_core_xml_file); + gdb_register_feature(cpu, 0, + cc->gdb_read_register, cc->gdb_write_register, + feature); + } + + cpu->gdb_num_regs =3D cpu->gdb_num_g_regs =3D cc->gdb_num_core_regs; +} + void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_r= eg, const GDBFeature *feature, int g_pos) { GDBRegisterState *s; guint i; + int base_reg =3D cpu->gdb_num_regs; =20 - if (cpu->gdb_regs) { - for (i =3D 0; i < cpu->gdb_regs->len; i++) { - /* Check for duplicates. */ - s =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (s->feature =3D=3D feature) - return; - } - } else { - cpu->gdb_regs =3D g_array_new(false, false, sizeof(GDBRegisterStat= e)); - i =3D 0; + for (i =3D 0; i < cpu->gdb_regs->len; i++) { + /* Check for duplicates. */ + s =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); + if (s->feature =3D=3D feature) + return; } =20 - g_array_set_size(cpu->gdb_regs, i + 1); - s =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - s->base_reg =3D cpu->gdb_num_regs; - s->get_reg =3D get_reg; - s->set_reg =3D set_reg; - s->feature =3D feature; + gdb_register_feature(cpu, base_reg, get_reg, set_reg, feature); =20 /* Add to end of list. */ cpu->gdb_num_regs +=3D feature->num_regs; if (g_pos) { - if (g_pos !=3D s->base_reg) { + if (g_pos !=3D base_reg) { error_report("Error: Bad gdb register numbering for '%s', " - "expected %d got %d", feature->xml, - g_pos, s->base_reg); + "expected %d got %d", feature->xml, g_pos, base_r= eg); } else { cpu->gdb_num_g_regs =3D cpu->gdb_num_regs; } diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index ced66c2b34..88a1d186a6 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -27,6 +27,7 @@ #include "qemu/main-loop.h" #include "exec/log.h" #include "exec/cpu-common.h" +#include "exec/gdbstub.h" #include "qemu/error-report.h" #include "qemu/qemu-print.h" #include "sysemu/tcg.h" @@ -223,11 +224,10 @@ static void cpu_common_unrealizefn(DeviceState *dev) static void cpu_common_initfn(Object *obj) { CPUState *cpu =3D CPU(obj); - CPUClass *cc =3D CPU_GET_CLASS(obj); =20 + gdb_init_cpu(cpu); cpu->cpu_index =3D UNASSIGNED_CPU_INDEX; cpu->cluster_index =3D UNASSIGNED_CLUSTER_INDEX; - cpu->gdb_num_regs =3D cpu->gdb_num_g_regs =3D cc->gdb_num_core_regs; /* *-user doesn't have configurable SMP topology */ /* the default value is changed by qemu_init_vcpu() for softmmu */ cpu->nr_cores =3D 1; @@ -247,6 +247,7 @@ static void cpu_common_finalize(Object *obj) { CPUState *cpu =3D CPU(obj); =20 + g_array_free(cpu->gdb_regs, TRUE); qemu_lockcnt_destroy(&cpu->in_ioctl_lock); qemu_mutex_destroy(&cpu->work_mutex); } --=20 2.42.0 From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851467; cv=none; d=zohomail.com; s=zohoarc; b=I39TB1dVaX7y2OYHY/LXQiviYSmXLFq51tEMgei7t91+Pe0axBXEli0dKg10O/Rjpforp1Au+dzNIGsW5D/7T4GW4lzicKRZ6EJ0Ey/0RqElu4Uifhst+HGWol9ZVCK/g6m8IF7Gd1P4IwRJUXmIiRsFLVXKI5UL+oRDcrA60/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851467; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=lEoFSfA0E+eFy/GOPRnOuEzTUNwGcfOXWig+xDARntI=; b=NOdxDHtEgYElGr0TcXwgmDjMhxHOaNydp1ZGF4JNnAqZGgw0bKbKu3vyfYgiTwtrBUWFyTliHgGHRx+U8DW2bmQpTgcyJgvu054Vp8kViRI5KHI/cK1hSLL/aywCuTtOQgK/fuOmr+oZP+j3KENWn7OKfvRtkphcYZJ30Wtpj3k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694851467388949.1806120004185; Sat, 16 Sep 2023 01:04:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQGY-0003Vb-F5; Sat, 16 Sep 2023 04:02:58 -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 1qhQGX-0003RM-BN for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:57 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhQGU-00066M-28 for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:57 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-68fdd6011f2so2373034b3a.3 for ; Sat, 16 Sep 2023 01:02:52 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:02:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851372; x=1695456172; 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=lEoFSfA0E+eFy/GOPRnOuEzTUNwGcfOXWig+xDARntI=; b=Ydbc+mhPs7QM/yNHSDZDufJxmxzqH58rrZ98yJd2UhVBIBT313m7NrAJsjvYaf7SU7 +3EUsl4nJ5T8hbUPxXD6CiwWB09Lu2cqmacK2WVV4iW8eE3ntmsaqiN3h8SxiNBTtyz2 b+CwbasFn+x2UUuXj4g9ikVxTGHAuTNtepxL3JX/a2v3OyuLrkyx4CyzCxIkSZT9T4Xn oZUEWuRYEotqMX41yJLMcQdDAPwVrSQy0iEyc3QsSbSueIcsKU6vJLzUGS6jW4xNfiEt dQxqfTXhHWk2w0YLP9Js/SL/g929KlJdInJJw5EPSBxIDLWeH1ttEdo/HMScyVyBFOO1 0myQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851372; x=1695456172; 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=lEoFSfA0E+eFy/GOPRnOuEzTUNwGcfOXWig+xDARntI=; b=Zt3lAITvWB6RXeE9myg/qf3JLJC7go7PwaJ+dyJmwO/pte72zxZcVY65XI/pJv/oH+ IAD5Zp+BFkADEaIKlTBJ5dZiFtbLEeKyYa7EwoH9HK8R6Qw4BJCLzWUnSBhzecmipNMM T5h8XhkRfMCdll+pTGYhdrfINJj22GO8amG8tHwBfzoC4N9HjMbZVhXcbrDfXbl6xyaw lp/Ar+y+wl7jyeKK5a2PNUne+ksNTAcyTw2yyayn4S/aCOyLdI+pE6VnWNDEoGUpUqtg CC5c4KW264VLcGlm4uqrrs8v4pqcZ5PodZWUeMoRbPbHlKDG3IbUefs+ZnxGZTfCpoKA ruHw== X-Gm-Message-State: AOJu0Yzm0q/zcHVC64o0jW1Wp9tLK1MajFf7ISZkKEFWRcNkSK6+eSKg dqJ2wgtakVfwGWoaQOXRfzuJQo1zAo2IAsWH3kc= X-Google-Smtp-Source: AGHT+IG0fbXSrDRSiTh0I11E4ed5xILhVTVEanVL6RXYzdvY1D6ggO1LXXgtrvhd8lOu9iNsT5z6zQ== X-Received: by 2002:aa7:88cd:0:b0:68f:c9df:2ccb with SMTP id k13-20020aa788cd000000b0068fc9df2ccbmr4061742pff.1.1694851371818; Sat, 16 Sep 2023 01:02:51 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Eduardo Habkost , Marcel Apfelbaum , Yanan Wang , Peter Maydell , Michael Rolnik , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , "Edgar E. Iglesias" , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Yoshinori Sato , Thomas Huth , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , qemu-arm@nongnu.org (open list:ARM TCG CPUs), qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs), qemu-s390x@nongnu.org (open list:S390 general arch...) Subject: [PATCH v8 11/19] gdbstub: Infer number of core registers from XML Date: Sat, 16 Sep 2023 17:01:28 +0900 Message-ID: <20230916080149.129989-12-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=2607:f8b0:4864:20::434; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x434.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851468512100003 Content-Type: text/plain; charset="utf-8" GDBFeature has the num_regs member so use it where applicable to remove magic numbers. Signed-off-by: Akihiko Odaki --- include/hw/core/cpu.h | 3 ++- target/s390x/cpu.h | 2 -- gdbstub/gdbstub.c | 5 ++++- target/arm/cpu.c | 1 - target/arm/cpu64.c | 1 - target/avr/cpu.c | 1 - target/hexagon/cpu.c | 1 - target/i386/cpu.c | 2 -- target/loongarch/cpu.c | 2 -- target/m68k/cpu.c | 1 - target/microblaze/cpu.c | 1 - target/riscv/cpu.c | 1 - target/rx/cpu.c | 1 - target/s390x/cpu.c | 1 - 14 files changed, 6 insertions(+), 17 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index c84c631242..5426822ee0 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -126,7 +126,8 @@ struct SysemuCPUOps; * @gdb_adjust_breakpoint: Callback for adjusting the address of a * breakpoint. Used by AVR to handle a gdb mis-feature with * its Harvard architecture split code and data. - * @gdb_num_core_regs: Number of core registers accessible to GDB. + * @gdb_num_core_regs: Number of core registers accessible to GDB or 0 to = infer + * from @gdb_core_xml_file. * @gdb_core_xml_file: File name for core registers GDB XML description. * @gdb_stop_before_watchpoint: Indicates whether GDB expects the CPU to s= top * before the insn which triggers a watchpoint rather than after= it. diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index eb5b65b7d3..c5bac3230c 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -451,8 +451,6 @@ static inline void cpu_get_tb_cpu_state(CPUS390XState *= env, vaddr *pc, #define S390_R13_REGNUM 15 #define S390_R14_REGNUM 16 #define S390_R15_REGNUM 17 -/* Total Core Registers. */ -#define S390_NUM_CORE_REGS 18 =20 static inline void setcc(S390CPU *cpu, uint64_t cc) { diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index c2afdf20c2..8d45daf6d7 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -541,9 +541,12 @@ void gdb_init_cpu(CPUState *cpu) gdb_register_feature(cpu, 0, cc->gdb_read_register, cc->gdb_write_register, feature); + cpu->gdb_num_regs =3D cpu->gdb_num_g_regs =3D feature->num_regs; } =20 - cpu->gdb_num_regs =3D cpu->gdb_num_g_regs =3D cc->gdb_num_core_regs; + if (cc->gdb_num_core_regs) { + cpu->gdb_num_regs =3D cpu->gdb_num_g_regs =3D cc->gdb_num_core_reg= s; + } } =20 void gdb_register_coprocessor(CPUState *cpu, diff --git a/target/arm/cpu.c b/target/arm/cpu.c index a13c609249..dc38ebec18 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2388,7 +2388,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) #ifndef CONFIG_USER_ONLY cc->sysemu_ops =3D &arm_sysemu_ops; #endif - cc->gdb_num_core_regs =3D 26; cc->gdb_arch_name =3D arm_gdb_arch_name; cc->gdb_get_dynamic_xml =3D arm_gdb_get_dynamic_xml; cc->gdb_stop_before_watchpoint =3D true; diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 6b91aab6b7..72a1089163 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -754,7 +754,6 @@ static void aarch64_cpu_class_init(ObjectClass *oc, voi= d *data) =20 cc->gdb_read_register =3D aarch64_cpu_gdb_read_register; cc->gdb_write_register =3D aarch64_cpu_gdb_write_register; - cc->gdb_num_core_regs =3D 34; cc->gdb_core_xml_file =3D "aarch64-core.xml"; cc->gdb_arch_name =3D aarch64_gdb_arch_name; =20 diff --git a/target/avr/cpu.c b/target/avr/cpu.c index 8f741f258c..a77ec65b04 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -246,7 +246,6 @@ static void avr_cpu_class_init(ObjectClass *oc, void *d= ata) cc->gdb_read_register =3D avr_cpu_gdb_read_register; cc->gdb_write_register =3D avr_cpu_gdb_write_register; cc->gdb_adjust_breakpoint =3D avr_cpu_gdb_adjust_breakpoint; - cc->gdb_num_core_regs =3D 35; cc->gdb_core_xml_file =3D "avr-cpu.xml"; cc->tcg_ops =3D &avr_tcg_ops; } diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index 1dc8e0da24..b7d688e583 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -388,7 +388,6 @@ static void hexagon_cpu_class_init(ObjectClass *c, void= *data) cc->get_pc =3D hexagon_cpu_get_pc; cc->gdb_read_register =3D hexagon_gdb_read_register; cc->gdb_write_register =3D hexagon_gdb_write_register; - cc->gdb_num_core_regs =3D TOTAL_PER_THREAD_REGS; cc->gdb_stop_before_watchpoint =3D true; cc->gdb_core_xml_file =3D "hexagon-core.xml"; cc->disas_set_info =3D hexagon_cpu_disas_set_info; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 5678b52472..f948530d3c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7968,10 +7968,8 @@ static void x86_cpu_common_class_init(ObjectClass *o= c, void *data) cc->gdb_arch_name =3D x86_gdb_arch_name; #ifdef TARGET_X86_64 cc->gdb_core_xml_file =3D "i386-64bit.xml"; - cc->gdb_num_core_regs =3D 66; #else cc->gdb_core_xml_file =3D "i386-32bit.xml"; - cc->gdb_num_core_regs =3D 50; #endif cc->disas_set_info =3D x86_disas_set_info; =20 diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index f88cfa93ce..03cc1b7384 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -772,7 +772,6 @@ static void loongarch32_cpu_class_init(ObjectClass *c, = void *data) { CPUClass *cc =3D CPU_CLASS(c); =20 - cc->gdb_num_core_regs =3D 35; cc->gdb_core_xml_file =3D "loongarch-base32.xml"; cc->gdb_arch_name =3D loongarch32_gdb_arch_name; } @@ -786,7 +785,6 @@ static void loongarch64_cpu_class_init(ObjectClass *c, = void *data) { CPUClass *cc =3D CPU_CLASS(c); =20 - cc->gdb_num_core_regs =3D 35; cc->gdb_core_xml_file =3D "loongarch-base64.xml"; cc->gdb_arch_name =3D loongarch64_gdb_arch_name; } diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 70d58471dc..cf69a3ecc9 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -572,7 +572,6 @@ static void m68k_cpu_class_init(ObjectClass *c, void *d= ata) #endif cc->disas_set_info =3D m68k_cpu_disas_set_info; =20 - cc->gdb_num_core_regs =3D 18; cc->tcg_ops =3D &m68k_tcg_ops; } =20 diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index e1eff0b837..0826855b80 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -429,7 +429,6 @@ static void mb_cpu_class_init(ObjectClass *oc, void *da= ta) cc->sysemu_ops =3D &mb_sysemu_ops; #endif device_class_set_props(dc, mb_properties); - cc->gdb_num_core_regs =3D 32 + 25; cc->gdb_core_xml_file =3D "microblaze-core.xml"; =20 cc->disas_set_info =3D mb_disas_set_info; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index a03c9069ca..f8234da054 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -2138,7 +2138,6 @@ static void riscv_cpu_class_init(ObjectClass *c, void= *data) cc->get_pc =3D riscv_cpu_get_pc; cc->gdb_read_register =3D riscv_cpu_gdb_read_register; cc->gdb_write_register =3D riscv_cpu_gdb_write_register; - cc->gdb_num_core_regs =3D 33; cc->gdb_stop_before_watchpoint =3D true; cc->disas_set_info =3D riscv_cpu_disas_set_info; #ifndef CONFIG_USER_ONLY diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 157e57da0f..4a45f6dc8c 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -239,7 +239,6 @@ static void rx_cpu_class_init(ObjectClass *klass, void = *data) cc->gdb_write_register =3D rx_cpu_gdb_write_register; cc->disas_set_info =3D rx_cpu_disas_set_info; =20 - cc->gdb_num_core_regs =3D 26; cc->gdb_core_xml_file =3D "rx-core.xml"; cc->tcg_ops =3D &rx_tcg_ops; } diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index cf4b5e43f2..a97b69bda3 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -348,7 +348,6 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) s390_cpu_class_init_sysemu(cc); #endif cc->disas_set_info =3D s390_cpu_disas_set_info; - cc->gdb_num_core_regs =3D S390_NUM_CORE_REGS; cc->gdb_core_xml_file =3D "s390x-core64.xml"; cc->gdb_arch_name =3D s390_gdb_arch_name; =20 --=20 2.42.0 From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851495; cv=none; d=zohomail.com; s=zohoarc; b=AlCmx4gg9Ehee6nDRmcNRfJIlErsUcPLSb4hQavA+6Zz6xWlDqqqaKHZkYUVOcQaSV2Tj/hfuZJxpdwPcAUbGL5OCvWErFOWG1/9Mgltz2TiuBpil8kwROKgzkAujg6VY2Bryur3C4S+ahb7wjIEI4Au3FjCLaCzq0kB8BppxSs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851495; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=zuwkTGFn4CUWLfbEaHznI+TK7KvMW/M6pf3tb7SDPP8=; b=cCO2nX4iTkDoOxqbVD6GGmcZgt7y3RWIMuCMaEvxgzTJuVAIumwHr+1SypN7g6tgItlsqIl5kzv8dB02F9caWSAYz7LosavnY6INP5iQVYxtmCNcQNwQf3WtGuWA0Ua98ljwQ+Uf9sD3uz6KyRNSvgRVz3sdXIHVNoNAtdasvxo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694851495190284.00783506785945; Sat, 16 Sep 2023 01:04:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQGc-0003hb-3x; Sat, 16 Sep 2023 04:03:02 -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 1qhQGZ-0003aG-Tv for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:59 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhQGX-0006AR-TH for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:02:59 -0400 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-573d52030fbso2327652a12.0 for ; Sat, 16 Sep 2023 01:02:57 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851376; x=1695456176; 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=zuwkTGFn4CUWLfbEaHznI+TK7KvMW/M6pf3tb7SDPP8=; b=LAs0Qx1p+rxBYelmNU6fQOK8SNs1oYA5C0Y8nTfBz8XGm5hsTWRs8cMheD11Vrf+++ VHoqQJIwjffM+0Z7F+YXdEWgRaJ/PbF9MR/9HD04AeGsXIxecRsNdRhIt9tFyTiSoWEC 4Iyvq8BsKalsE4wEmgLDjNQ1IJAy9F0LU8wf/Y5bqWQimTUlBuhFAzVXXidFDTcZeiKZ LgXGGRFXxSWrVlh8TGIPjgX1TtBql5EpgKpLQ3OjmKe6RuzZQasBX/nXeHkGfQZB8QCr pqelVVy7O2Vtga1GioWOzHbuLDjXvwE6Gav6dw9WrX27bYNEdTecLtQkmJGrnz7xAGLb ALNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851376; x=1695456176; 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=zuwkTGFn4CUWLfbEaHznI+TK7KvMW/M6pf3tb7SDPP8=; b=cvv3aBPRWfcHKB2AFBtpJw0WqlgFpWFj3C2kbjsKFkMjri412pXMgr+vrv4mqd78kU Hy2/NamZSaqk1JHU+WUZPLgDnSeGuDWNqZEdsNv00CBNqrsH9NUpXA7/qNEBJl5IQtFf MimcT56dkgZqvjvxB4vJNahxYxQrCNfOc9QR2adsqnF2GvjnpJVq74UB8lQNNpp0VSOL 74w10d3C5qsnQFONjX8oVMJ9AQV53O+qBWWZG16OQUsV/zhfSj5l11kzHA9wDR/XlWSP RadPxFCbLVjkZT9jaE27zcHAzGwCuIVTNZmalaYScnDar4UMDUmOLlVJJjvWuPYGvG0q MHAw== X-Gm-Message-State: AOJu0YzL9gXZO55AGy03xOrXY0md2Az40rIKdH/gpGtJHEBK9/LPqn+z y+1/zcfW2QOttbhE8tHPELPDaw== X-Google-Smtp-Source: AGHT+IHO8tPgPeM/ygovARNeCsJOeF3Tb4p5m5dRqeGLhzt0PiK/HciRV18oNkzPLy79Tmw1gXNrlQ== X-Received: by 2002:a05:6a20:549f:b0:135:4df7:f165 with SMTP id i31-20020a056a20549f00b001354df7f165mr4362794pzk.21.1694851376528; Sat, 16 Sep 2023 01:02:56 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Eduardo Habkost , Marcel Apfelbaum , Yanan Wang , Peter Maydell , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , qemu-arm@nongnu.org (open list:ARM TCG CPUs), qemu-ppc@nongnu.org (open list:PowerPC TCG CPUs), qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs) Subject: [PATCH v8 12/19] hw/core/cpu: Remove gdb_get_dynamic_xml member Date: Sat, 16 Sep 2023 17:01:29 +0900 Message-ID: <20230916080149.129989-13-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=2607:f8b0:4864:20::52f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x52f.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851496172100005 Content-Type: text/plain; charset="utf-8" This function is no longer used. Signed-off-by: Akihiko Odaki --- include/hw/core/cpu.h | 4 ---- target/arm/cpu.h | 6 ------ target/ppc/cpu.h | 1 - target/arm/cpu.c | 1 - target/arm/gdbstub.c | 18 ------------------ target/ppc/cpu_init.c | 3 --- target/ppc/gdbstub.c | 10 ---------- target/riscv/cpu.c | 14 -------------- 8 files changed, 57 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 5426822ee0..06f7cdcfad 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -133,9 +133,6 @@ struct SysemuCPUOps; * before the insn which triggers a watchpoint rather than after= it. * @gdb_arch_name: Optional callback that returns the architecture name kn= own * to GDB. The caller must free the returned string with g_free. - * @gdb_get_dynamic_xml: Callback to return dynamically generated XML for = the - * gdb stub. Returns a pointer to the XML contents for the specified XML= file - * or NULL if the CPU doesn't have a dynamically generated content for i= t. * @disas_set_info: Setup architecture specific components of disassembly = info * @adjust_watchpoint_address: Perform a target-specific adjustment to an * address before attempting to match it against watchpoints. @@ -166,7 +163,6 @@ struct CPUClass { =20 const char *gdb_core_xml_file; const gchar * (*gdb_arch_name)(CPUState *cpu); - const char * (*gdb_get_dynamic_xml)(CPUState *cpu, const char *xmlname= ); =20 void (*disas_set_info)(CPUState *cpu, disassemble_info *info); =20 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 24c6adff36..3fe93b8864 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1136,12 +1136,6 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *c= pu, vaddr addr, int arm_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); =20 -/* Returns the dynamically generated XML for the gdb stub. - * Returns a pointer to the XML contents for the specified XML file or NULL - * if the XML name doesn't match the predefined one. - */ -const char *arm_gdb_get_dynamic_xml(CPUState *cpu, const char *xmlname); - int arm_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, DumpState *s); int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 5f251bdffe..3dc6e545e3 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1382,7 +1382,6 @@ int ppc_cpu_gdb_write_register_apple(CPUState *cpu, u= int8_t *buf, int reg); #ifndef CONFIG_USER_ONLY hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); void ppc_gdb_gen_spr_feature(PowerPCCPU *cpu); -const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name); #endif int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, DumpState *s); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index dc38ebec18..a2c5bd9841 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2389,7 +2389,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) cc->sysemu_ops =3D &arm_sysemu_ops; #endif cc->gdb_arch_name =3D arm_gdb_arch_name; - cc->gdb_get_dynamic_xml =3D arm_gdb_get_dynamic_xml; cc->gdb_stop_before_watchpoint =3D true; cc->disas_set_info =3D arm_disas_set_info; =20 diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index aa2c6c1bde..f9774b5547 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -463,24 +463,6 @@ static GDBFeature *arm_gen_dynamic_m_secextreg_feature= (CPUState *cs) #endif #endif /* CONFIG_TCG */ =20 -const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) -{ - ARMCPU *cpu =3D ARM_CPU(cs); - - if (strcmp(xmlname, "system-registers.xml") =3D=3D 0) { - return cpu->dyn_sysreg_feature.desc.xml; - } else if (strcmp(xmlname, "sve-registers.xml") =3D=3D 0) { - return cpu->dyn_svereg_feature.desc.xml; - } else if (strcmp(xmlname, "arm-m-system.xml") =3D=3D 0) { - return cpu->dyn_m_systemreg_feature.desc.xml; -#ifndef CONFIG_USER_ONLY - } else if (strcmp(xmlname, "arm-m-secext.xml") =3D=3D 0) { - return cpu->dyn_m_secextreg_feature.desc.xml; -#endif - } - return NULL; -} - void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) { CPUState *cs =3D CPU(cpu); diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index e69405efed..e16c4acd4e 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -7370,9 +7370,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, void = *data) #endif =20 cc->gdb_num_core_regs =3D 71; -#ifndef CONFIG_USER_ONLY - cc->gdb_get_dynamic_xml =3D ppc_gdb_get_dynamic_xml; -#endif #ifdef USE_APPLE_GDB cc->gdb_read_register =3D ppc_cpu_gdb_read_register_apple; cc->gdb_write_register =3D ppc_cpu_gdb_write_register_apple; diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index 2392625441..a20d5922dd 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -339,16 +339,6 @@ void ppc_gdb_gen_spr_feature(PowerPCCPU *cpu) =20 gdb_feature_builder_end(&builder); } - -const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name) -{ - PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cs); - - if (strcmp(xml_name, "power-spr.xml") =3D=3D 0) { - return pcc->gdb_spr.xml; - } - return NULL; -} #endif =20 #if !defined(CONFIG_USER_ONLY) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index f8234da054..3182607113 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1955,19 +1955,6 @@ static const gchar *riscv_gdb_arch_name(CPUState *cs) } } =20 -static const char *riscv_gdb_get_dynamic_xml(CPUState *cs, const char *xml= name) -{ - RISCVCPU *cpu =3D RISCV_CPU(cs); - - if (strcmp(xmlname, "riscv-csr.xml") =3D=3D 0) { - return cpu->dyn_csr_feature.xml; - } else if (strcmp(xmlname, "riscv-vector.xml") =3D=3D 0) { - return cpu->dyn_vreg_feature.xml; - } - - return NULL; -} - #ifndef CONFIG_USER_ONLY static int64_t riscv_get_arch_id(CPUState *cs) { @@ -2145,7 +2132,6 @@ static void riscv_cpu_class_init(ObjectClass *c, void= *data) cc->get_arch_id =3D riscv_get_arch_id; #endif cc->gdb_arch_name =3D riscv_gdb_arch_name; - cc->gdb_get_dynamic_xml =3D riscv_gdb_get_dynamic_xml; cc->tcg_ops =3D &riscv_tcg_ops; =20 object_class_property_add(c, "mvendorid", "uint32", cpu_get_mvendorid, --=20 2.42.0 From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851570; cv=none; d=zohomail.com; s=zohoarc; b=WmRzl5YdwIrev+ec770nfEXPv8Kd4aN0BGWNavfGZbncZY5mxF34TgwOcOx4hNtV3bNXpbTmfX05i5jzENw7ttD8Pl2nuGfP+Pmg/n0Veu+2EH9omAh2nb1MQRDVyQRXzyPfiZJMcMWqOxmTi4Q0Xifoij/zYNa2rnNaTqrKnoc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851570; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=whWo5tKtnh96wOd8/J5aT9p6Pdm6/pTl0OTz7gsGvtU=; b=NXVI4LcyHvg6ctgjUP+EfjSuARuTIQYDI6Jd+YqfPGeM1EWtAzi/TCD2WY97F1weY0C7ks4+sBTij+2jFI+yObhTl5wrwAmDNGrbrTRnN5WGM0doWRaDwTUaN2iGSGBOOtiz/WNszO0lhdNWXrlz12U2y5bxOCR/SwbHkhvxTmk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694851570311716.3949531619559; Sat, 16 Sep 2023 01:06:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQGg-0003xw-3v; Sat, 16 Sep 2023 04:03:06 -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 1qhQGe-0003rW-G2 for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:03:04 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhQGc-0006Bs-NG for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:03:04 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-69042d398b1so1522678b3a.0 for ; Sat, 16 Sep 2023 01:03:01 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.02.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:02:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851380; x=1695456180; 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=whWo5tKtnh96wOd8/J5aT9p6Pdm6/pTl0OTz7gsGvtU=; b=mf7GeXWXpLy/2dkTeWKwmdjk9MCl7PH95CqxzfbKmTQDXC5o6wkth+VNPJMLVItT7f OA39xmcnlP6wb1McCbJmn7AgjIn/siDgixpI08J+SgZ64ylKID032C5XH6QeL95b4aez 8eMJgWaeFy3Nbw4/BVBlKU+R97yb3RnKQNWM7uSK8O1159M7Qv/CGKduXOfsjhFbfk0d Z57Gu+rSMYC90WoyiXwh1bgqa00gjvZlAjNMCUr3RVe0DHEYRXB98VsX2siO9OvTs/xW Mkf37cHV1ZYciN7nNsv1iq7a3js177iVPMs46kGRurHq09Klt/i2Q1fxJAvQnDRmgmlj GFkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851380; x=1695456180; 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=whWo5tKtnh96wOd8/J5aT9p6Pdm6/pTl0OTz7gsGvtU=; b=NFUODGrWr9sAQlF7UwFxE7HvEN2kOQSyAICzbN36nJkLRSd6fcI1lN6uTsEEsY6VK7 EhqSs/tgq2s8P3f8HrseqdPVVeg1TXxYxBvXF3B0z3IHoT3HwyFChmlC4dmHEHjEnYwJ 46ulX4Z2KShu6oXevPD9+DaMRiViRQBrSqOI86JG1zp1UdCkaAgmaZcrJ8upatEQ8s1W 8HjF3M5CV5+fimUXS3TU13XzrgCSPvEWpPN2JnloZuasX5ME4jqarjLz7Y5tDlet9N1M BvMcaYuH2RHo94uB203Od94B0TTyl7C0uIBAOyy+ctBL+Vu7jGYefwRzbershBBhfdeN tBcQ== X-Gm-Message-State: AOJu0YyKnF739Nh9osX3VdxTgNMFYm0sHunuy6dItmfwKJM9Chx7eZGS yPPm5TmPFsxxIucs9zMXR2ioSg== X-Google-Smtp-Source: AGHT+IHs4eqj7R0TWZiKbCJb7qVkQ6K5xUqwtEHOdo4jnz9QcoCHETz3pB6lSFj9YGSR/glVRTKGDQ== X-Received: by 2002:a05:6a20:8e27:b0:13a:43e8:3fb5 with SMTP id y39-20020a056a208e2700b0013a43e83fb5mr5238776pzj.51.1694851380323; Sat, 16 Sep 2023 01:03:00 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , John Snow , Cleber Rosa , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs) Subject: [PATCH v8 13/19] gdbstub: Add members to identify registers to GDBFeature Date: Sat, 16 Sep 2023 17:01:30 +0900 Message-ID: <20230916080149.129989-14-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=2607:f8b0:4864:20::42f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42f.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851571167100001 Content-Type: text/plain; charset="utf-8" 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 --- include/exec/gdbstub.h | 3 +++ gdbstub/gdbstub.c | 10 ++++++++-- target/riscv/gdbstub.c | 4 +--- scripts/feature_to_c.py | 14 +++++++++++++- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 67f363132e..b2b2675f6f 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; =20 typedef struct GDBFeatureBuilder { GDBFeature *feature; GPtrArray *xml; + GPtrArray *regs; } GDBFeatureBuilder; =20 =20 diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 8d45daf6d7..c6dd5fcd51 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -417,9 +417,10 @@ void gdb_feature_builder_init(GDBFeatureBuilder *build= er, GDBFeature *feature, =20 builder->feature =3D feature; builder->xml =3D g_ptr_array_new(); + builder->regs =3D g_ptr_array_new(); g_ptr_array_add(builder->xml, header); feature->xmlname =3D xmlname; - feature->num_regs =3D 0; + feature->name =3D name; } =20 void gdb_feature_builder_append_tag(const GDBFeatureBuilder *builder, @@ -448,7 +449,9 @@ int gdb_feature_builder_append_reg(const GDBFeatureBuil= der *builder, name, bitsize, type); } =20 - return builder->feature->num_regs++; + g_ptr_array_add(builder->regs, (void *)name); + + return builder->regs->len - 1; } =20 void gdb_feature_builder_end(const GDBFeatureBuilder *builder) @@ -463,6 +466,9 @@ void gdb_feature_builder_end(const GDBFeatureBuilder *b= uilder) } =20 g_ptr_array_free(builder->xml, TRUE); + + builder->feature->num_regs =3D builder->regs->len; + builder->feature->regs =3D (void *)g_ptr_array_free(builder->regs, FAL= SE); } =20 const GDBFeature *gdb_find_static_feature(const char *xmlname) diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index c8525794ef..f125109787 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -262,11 +262,9 @@ static GDBFeature *riscv_gen_dynamic_csr_feature(CPUSt= ate *cs) } predicate =3D csr_ops[i].predicate; if (predicate && (predicate(env, i) =3D=3D RISCV_EXCP_NONE)) { - g_autofree char *dynamic_name =3D NULL; name =3D csr_ops[i].name; if (!name) { - dynamic_name =3D g_strdup_printf("csr%03x", i); - name =3D dynamic_name; + name =3D g_strdup_printf("csr%03x", i); } =20 gdb_feature_builder_append_reg(&builder, name, bitsize, diff --git a/scripts/feature_to_c.py b/scripts/feature_to_c.py index e04d6b2df7..807af0e685 100755 --- 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) =20 + feature_name =3D element.attrib['name'] regnum =3D 0 + regnames =3D [] regnums =3D [] tags =3D ['feature'] for event, element in events: @@ -67,6 +69,7 @@ def writeliteral(indent, bytes): if 'regnum' in element.attrib: regnum =3D int(element.attrib['regnum']) =20 + regnames.append(element.attrib['name']) regnums.append(regnum) regnum +=3D 1 =20 @@ -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}] =3D\n= ') + writeliteral(16, bytes(regname, 'utf-8')) + sys.stdout.write(',\n') + + sys.stdout.write(f' }},\n {num_regs},\n }},\n') =20 sys.stdout.write(' { NULL }\n};\n') --=20 2.42.0 From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851484; cv=none; d=zohomail.com; s=zohoarc; b=nKCUag1ajEbY/MXKRW38c7xXhqz/M/oXB+y2JkRueO5Oh+ivHgi8xCQmNqC3Hx1eNn/LQDlUWsnkuYiRzJAj68yLVfxXoQsUZ732U/tVtbQfqBGiYOirJzBJsktP2CohdyPYSIYl9utjbvjpI/8Suv5Kw0xclZb7EPNdPJyi6Hg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851484; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=EJB9NYY0WJP2DG5WyP6qLUa7eNIynRr75aERnm1lLVY=; b=n37H93RpukqhXqFjhcdWAxJOJAs/3DaTEL7n6yIE9l0U2S6qdXyveYv6oVPMv6UHm2oMlRwkh8Pq+K9cTyZq753v7wn5Yc9Gtc+onDaXYjo6JfRN00BQSPX3AHx1yOgeVdiqXj/30zP3uGzy66YRb/5iTpFwGNbyzHmhvKXvlcE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694851484974212.1949506446557; Sat, 16 Sep 2023 01:04:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQGh-00043F-9y; Sat, 16 Sep 2023 04:03:07 -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 1qhQGf-0003vs-GB for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:03:05 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhQGd-0006CK-SH for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:03:05 -0400 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-577f6205f42so2151346a12.1 for ; Sat, 16 Sep 2023 01:03:03 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.03.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851382; x=1695456182; 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=EJB9NYY0WJP2DG5WyP6qLUa7eNIynRr75aERnm1lLVY=; b=tpPh0kZ0DaKdpuZkirxZ5cYHgzExt/y8AY7Sg85iGUNk1ups71COwkSulRR7DVZJKb ZE61O1uRDwCV2KtR2K0G5tC0Le1SI1rN0cp+QL6yXWnjKVc0g7UU3uIEEQS40llZF2WR v7au6WuayMOLKIWAeIPtcjvtGN3b+6Tv5DUtLlSun8PePuM0P+t8RnL4c1t5RcciONdi kt9Gh9Am8bpiQ12X8jkRytp4M+rODclSFRfgyR3VBlbprZT1AieHX4GjzMAuYyVPlZha KqELgrY1Fs9l+ZgWhozkAX9iNfq4Q0XHQBBcvz5Mi3GzFJ3Bxh4MkMAe6LfYU0hV3Npg WY8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851382; x=1695456182; 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=EJB9NYY0WJP2DG5WyP6qLUa7eNIynRr75aERnm1lLVY=; b=k9xW7VCazneqX07YLCVeb0jKBPHCnluE2nMeNjUz4DsXQPcBOeYsSh/vcCV6Eh+RjO m/a3f6ZobraURManZ3/WDgmIyc7mtr8oYvEix8zuaBwoYb+mTPO7vueN8rRwen6RUZtD +9lkTicPImdaovPEscadCdUuBK0d1pJb8ww6YiXJM1IsCR2X/RpY3hh7J0dAq1TEF5Hi qcD5rq7iN0FqKrQR4r8nM8DlgfIZZsmpIwHpqXWmAzs1o9IBoUow9QD8hfY8PvrPGevp 3sEdnMfIrD6O+Q1rCB4O+EbQNHoGVLw+nAzaglUkPLoA8K6mk8qN9W/XrIQVRqPGTufE Fqjg== X-Gm-Message-State: AOJu0YzKpZCF5TkLbGl7vjhjoZs9EKHrEVbQpyrO7ZMJAJbxnu1c1qo4 E2recmBac92AxBbGhu/IaWPLUKeJRaQVr9huOW0= X-Google-Smtp-Source: AGHT+IF3RPreAgSiJDaAIfs2imYhzJJa9X6frj0p7+YWsp+7qFQQRJR5zD0IcW+UxanRyQxRDO+P7A== X-Received: by 2002:a05:6a20:ce89:b0:104:ad71:f080 with SMTP id if9-20020a056a20ce8900b00104ad71f080mr3733107pzb.34.1694851382485; Sat, 16 Sep 2023 01:03:02 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki Subject: [PATCH v8 14/19] gdbstub: Expose functions to read registers Date: Sat, 16 Sep 2023 17:01:31 +0900 Message-ID: <20230916080149.129989-15-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=2607:f8b0:4864:20::530; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x530.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851486108100003 Content-Type: text/plain; charset="utf-8" gdb_find_feature() and gdb_find_feature_register() find registers. gdb_read_register() actually reads registers. Signed-off-by: Akihiko Odaki --- include/exec/gdbstub.h | 5 +++++ gdbstub/gdbstub.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index b2b2675f6f..d73abfbd44 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -71,6 +71,11 @@ void gdb_feature_builder_end(const GDBFeatureBuilder *bu= ilder); =20 const GDBFeature *gdb_find_static_feature(const char *xmlname); =20 +int gdb_find_feature(CPUState *cpu, const char *name); +int gdb_find_feature_register(CPUState *cpu, int feature, const char *name= ); + +int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); + void gdb_set_stop_cpu(CPUState *cpu); =20 /* in gdbstub-xml.c, generated by scripts/feature_to_c.py */ diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index c6dd5fcd51..8667f44fc6 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -484,7 +484,36 @@ const GDBFeature *gdb_find_static_feature(const char *= xmlname) g_assert_not_reached(); } =20 -static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) +int gdb_find_feature(CPUState *cpu, const char *name) +{ + GDBRegisterState *r; + + for (guint i =3D 0; i < cpu->gdb_regs->len; i++) { + r =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); + if (!strcmp(name, r->feature->name)) { + return i; + } + } + + return -1; +} + +int gdb_find_feature_register(CPUState *cpu, int feature, const char *name) +{ + GDBRegisterState *r; + + r =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, feature); + + for (int i =3D 0; i < r->feature->num_regs; i++) { + if (r->feature->regs[i] && !strcmp(name, r->feature->regs[i])) { + return r->base_reg + i; + } + } + + return -1; +} + +int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) { CPUClass *cc =3D CPU_GET_CLASS(cpu); GDBRegisterState *r; --=20 2.42.0 From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851460; cv=none; d=zohomail.com; s=zohoarc; b=gvHSMr5Tbgz07OnkTkBvlAUA6C+pi9cvpBUKfnEySoMYZIiyIpyejl7H0LgsAGFw9jGjGp+PAvpAFJ7qAZUUAf4LQhO2vgqHcVyxvafEWmIG4JPRwOtQ70YjMgtIQLSv0vowppUrTButJ05uAWPwHrgjtgEuOucPW0a9KcLsDdk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851460; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=du4pvBFajNyLkLy2seo77TR3Uw7N6iMFpyL/5U/v0Hk=; b=IgDws5Wwr+J0js/vAiZNDVJyIr38whuLPxYthC+mC7vGOvVRwzhDXH7Ax+3piKyMv5HyhfFSvgTwlehvIk/773mVzbBd68psUfoUf1yyiSF3jDD1z1le5IgOvcqf5Wi3w7xCURvAzbpvKv2iVgBcpiXtMM0TjAS1vXgxUPjXgCs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694851460815737.4773452397363; Sat, 16 Sep 2023 01:04:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQGk-00046T-2K; Sat, 16 Sep 2023 04:03:10 -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 1qhQGh-00044o-Sg for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:03:07 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhQGg-0006Cs-6x for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:03:07 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-68fe2470d81so2686610b3a.1 for ; Sat, 16 Sep 2023 01:03:05 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.03.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851385; x=1695456185; 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=du4pvBFajNyLkLy2seo77TR3Uw7N6iMFpyL/5U/v0Hk=; b=S/9YbuPHTiJYKMwLxuvsi14XMg7diUh9LszRrLNsFO0Ka+zoOE6EU/DZdfM1j9+ho7 vHqe0T9bT4Y7h49PfrFnyNBj+qzJVLLLKbUmxBTNmR2lgE8PmKwu55qhstUt4ftiPf8Q asiAWofKOfSOlHNg8XmjHB3qLqlVEgpzGwHTSYXlvvD/VI0YrczCZP2q2Mu0UHGhuOd5 /FP+TK2HKG2zF+88J++6lN6muqINrAC/MkKJPx8hEXlnFOI9KnZnqbqmwESbrUY6hhn3 Hu5drotMLW9Mbs6pU3o5czyR+FLBu0a7AnhxYOkBpaKJXoPqxta6gJyDMd3x1C1GFa34 4/UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851385; x=1695456185; 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=du4pvBFajNyLkLy2seo77TR3Uw7N6iMFpyL/5U/v0Hk=; b=wP0oeHmDGwGccL/jpcJTesSXivU2wwCdWgH7wPHU4wA/kf19iOMgarQvK2ila2XCaa FGvL6zb4lmduQQ4BSutKP8B/RYT0XBN50H2QOF0cp9MhmBrcWRCgG9zvVL+pQg0lXURj Vwm6HgP2olBSJ47EnE7/W/wX07cgvn0ORDiSQvkBKULowWC/zavHLmlbss6cK3YbDlZZ uZn/Wj1BO76R2FubqxcKQczUVH1ME5jwidhiMUrFLcP+OQbuPf8/5LVfpiRGBXjjwqlX czczhQFYzpo0QPy1YdqjwOT3rWpyIISOy+bbnQTSGxPq9s7bXuhxB6GThbW74jFyn1lw wFGw== X-Gm-Message-State: AOJu0Yy0cT66QCr/l4PSKjRc/Bh/IUqm2Vy5kMqF2xz5TKYIxhTYescA LeVX0BwDX7gVcuqZhVvNZz64yA== X-Google-Smtp-Source: AGHT+IGZVJ0+iTdscgFe5KI7kBCxb7bNro4R6gZ2hWIeSNs60n6w+iaQ+0asWopU4Ch1mOoDtFi0pQ== X-Received: by 2002:a05:6a00:248a:b0:68e:496a:7852 with SMTP id c10-20020a056a00248a00b0068e496a7852mr4281560pfv.27.1694851385048; Sat, 16 Sep 2023 01:03:05 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Eduardo Habkost , Marcel Apfelbaum , Yanan Wang Subject: [PATCH v8 15/19] cpu: Call plugin hooks only when ready Date: Sat, 16 Sep 2023 17:01:32 +0900 Message-ID: <20230916080149.129989-16-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=2607:f8b0:4864:20::42d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42d.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851462478100003 Content-Type: text/plain; charset="utf-8" The initialization and exit hooks will not affect the state of vCPU outside TCG context, but they may depend on the state of vCPU. Therefore, it's better to call plugin hooks after the vCPU state is fully initialized and before it gets uninitialized. Signed-off-by: Akihiko Odaki --- cpu.c | 11 ----------- hw/core/cpu-common.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cpu.c b/cpu.c index 1c948d1161..2552c85249 100644 --- a/cpu.c +++ b/cpu.c @@ -42,7 +42,6 @@ #include "hw/core/accel-cpu.h" #include "trace/trace-root.h" #include "qemu/accel.h" -#include "qemu/plugin.h" =20 uintptr_t qemu_host_page_size; intptr_t qemu_host_page_mask; @@ -148,11 +147,6 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) /* Wait until cpu initialization complete before exposing cpu. */ cpu_list_add(cpu); =20 - /* Plugin initialization must wait until cpu_index assigned. */ - if (tcg_enabled()) { - qemu_plugin_vcpu_init_hook(cpu); - } - #ifdef CONFIG_USER_ONLY assert(qdev_get_vmsd(DEVICE(cpu)) =3D=3D NULL || qdev_get_vmsd(DEVICE(cpu))->unmigratable); @@ -179,11 +173,6 @@ void cpu_exec_unrealizefn(CPUState *cpu) } #endif =20 - /* Call the plugin hook before clearing cpu->cpu_index in cpu_list_rem= ove */ - if (tcg_enabled()) { - qemu_plugin_vcpu_exit_hook(cpu); - } - cpu_list_remove(cpu); /* * Now that the vCPU has been removed from the RCU list, we can call diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 88a1d186a6..d5e1eac8b3 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -210,6 +210,11 @@ static void cpu_common_realizefn(DeviceState *dev, Err= or **errp) cpu_resume(cpu); } =20 + /* Plugin initialization must wait until the cpu is fully realized. */ + if (tcg_enabled()) { + qemu_plugin_vcpu_init_hook(cpu); + } + /* NOTE: latest generic point where the cpu is fully realized */ } =20 @@ -217,6 +222,11 @@ static void cpu_common_unrealizefn(DeviceState *dev) { CPUState *cpu =3D CPU(dev); =20 + /* Call the plugin hook before clearing the cpu is fully unrealized */ + if (tcg_enabled()) { + qemu_plugin_vcpu_exit_hook(cpu); + } + /* NOTE: latest generic point before the cpu is fully unrealized */ cpu_exec_unrealizefn(cpu); } --=20 2.42.0 From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851580; cv=none; d=zohomail.com; s=zohoarc; b=ZiVbu6lY/lQJ6ZV8j7ZUrs+6vwBJaKBDzup7XFC9CSpJtDlvT8PgdQZUoIFsvxDj04mJROrmiB4ORjo0Vo9Cid9OeV9bl7ZaqQxgche7iIO3rYMuOI8/HT3u2Dn2JrS+6R3142jnmTIRNCCxMb+pwqLd9THL25IDaqGGHCpbj64= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851580; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=ilI8SXEV4hZ7IsqJh+1hYxWm1mnGnjzep4yVtP0lQYY=; b=GL/9Emz8w4JQTWa6wKbs4slFqwha4i9OEia55gQBu1TfVuss7f+xIzgXiyd3fEe78TguPm8Q0T9svAO/JD91pb8zifDA2BS+YOKVkOuOJnChStAD7dijR3pBlJjLfA4jDssUX4fqeGOWaN9wusA4V0rVsup0f101T7MujruM2f8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694851580824159.12758314527434; Sat, 16 Sep 2023 01:06:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQGu-0004If-Df; Sat, 16 Sep 2023 04:03:20 -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 1qhQGs-0004E6-Rg for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:03:18 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhQGk-0006DH-2d for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:03:18 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-68a3ced3ec6so2699243b3a.1 for ; Sat, 16 Sep 2023 01:03:09 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:03:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851387; x=1695456187; 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=ilI8SXEV4hZ7IsqJh+1hYxWm1mnGnjzep4yVtP0lQYY=; b=Nnf8eKYgRLkt6tQNHJn43Vl+Q3QH1HneuLciFYfYoctsRu0+/UF8QWe0XERncil+2R TefrRH9Ba9zU8JvwejWc9a6kAJlwCYarfxJkKeZaAyE2B8yTc0HEJ2+lS0PT3EPc5aPT LgQXR2WFCMlbd0rP3MLEPYqkNVSxGvrZe74fyH5fFIerwzL+7LhIVgVPuxR004C3CDmG DQHcdHbQYznjobCNI8d2Ys/c8rJNDz/oJlaMfrHUJqu4GySMrJ/dZSVJ/pgiuXnAvLxq 3SBlMI7VuVz2prxgAxQPOHknOnP9xiTT37/9CY1097DeEGtr7vOHVppqyFLtxAKhRErq QpoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851387; x=1695456187; 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=ilI8SXEV4hZ7IsqJh+1hYxWm1mnGnjzep4yVtP0lQYY=; b=ZEvcs2fb/hEP6IC5Aayhx+Op91/uwz7jR2QshiQmULWlTX6tNIsv4vfjfFiB7+NUx/ 29ufOrZkqv8Wo7zkkthMubkJ+/w3NY/+V/krmw8kzgeADt0n51nf+oSJupdeklmm8VdV QMwCfhv4axFw+CW0KMA54QdDJpfIgaocfRXWroGtzW+vVfvrIUP5y6JU3g7dEeMNvkVI GIGxoiqq+ZvejgyOuTcp5dUpKg/ulJ1WjZmz7a5r9pRNrEu1mVoTKEv/sHQLnm6KgQaJ aVxWDaDf1KwqLeqYDpELavdEBJep0TrHQU3N9TzFvXdUfhOwgGEjJJvRysgjx6ojRqHL kYrw== X-Gm-Message-State: AOJu0YzHwQN4MOf/KPf6D3hNZCxcfK+zdU4tQgY7BHK4PzZh/l+RR/b3 CJpERvTP/ymXtBcjkdhOFfQvFw== X-Google-Smtp-Source: AGHT+IEId4pJwb3qGdRiWr56YM/8TdYIgz2GATItyEYapU0PzDHYa/8LNd0wGnovHTgGrzRT6zy/4w== X-Received: by 2002:a05:6a00:2d26:b0:68a:49bc:e0af with SMTP id fa38-20020a056a002d2600b0068a49bce0afmr3966053pfb.1.1694851387724; Sat, 16 Sep 2023 01:03:07 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Alexandre Iooss , Mahmoud Mandour Subject: [PATCH v8 16/19] plugins: Allow to read registers Date: Sat, 16 Sep 2023 17:01:33 +0900 Message-ID: <20230916080149.129989-17-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=2607:f8b0:4864:20::433; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x433.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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851582138100001 Content-Type: text/plain; charset="utf-8" It is based on GDB protocol to ensure interface stability. The timing of the vcpu init hook is also changed so that the hook will get called after GDB features are initialized. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1706 Signed-off-by: Akihiko Odaki --- include/qemu/qemu-plugin.h | 52 +++++++++++++++++++++++++++++++++--- plugins/api.c | 20 ++++++++++++++ plugins/qemu-plugins.symbols | 3 +++ 3 files changed, 72 insertions(+), 3 deletions(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 50a9957279..40aae8db68 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -11,6 +11,7 @@ #ifndef QEMU_QEMU_PLUGIN_H #define QEMU_QEMU_PLUGIN_H =20 +#include #include #include #include @@ -51,7 +52,7 @@ typedef uint64_t qemu_plugin_id_t; =20 extern QEMU_PLUGIN_EXPORT int qemu_plugin_version; =20 -#define QEMU_PLUGIN_VERSION 1 +#define QEMU_PLUGIN_VERSION 2 =20 /** * struct qemu_info_t - system information for plugins @@ -218,8 +219,8 @@ struct qemu_plugin_insn; * @QEMU_PLUGIN_CB_R_REGS: callback reads the CPU's regs * @QEMU_PLUGIN_CB_RW_REGS: callback reads and writes the CPU's regs * - * Note: currently unused, plugins cannot read or change system - * register state. + * Note: currently QEMU_PLUGIN_CB_RW_REGS is unused, plugins cannot change + * system register state. */ enum qemu_plugin_cb_flags { QEMU_PLUGIN_CB_NO_REGS, @@ -664,4 +665,49 @@ uint64_t qemu_plugin_end_code(void); */ uint64_t qemu_plugin_entry_code(void); =20 +/** + * qemu_plugin_find_register_file() - find register file + * + * @vcpu_index: the index of the vcpu context + * @name: the name of the register file. + * + * Returns the identifier of the register file if it was found, and a nega= tive + * value otherwise. + * + * The names of register files are identical with names of GDB's standard + * target features with some extensions. For details, see: + * https://sourceware.org/gdb/onlinedocs/gdb/Standard-Target-Features.html + */ +int qemu_plugin_find_register_file(unsigned int vcpu_index, const char *na= me); + +/** + * qemu_plugin_find_register() - find register + * + * @vcpu_index: the index of the vcpu context + * @file: the register file identifier determined with + * qemu_plugin_find_register_file(). + * @name: the name of the register. + * + * The names of register are identical with names used in GDB's standard + * target features with some extensions. For details, see: + * https://sourceware.org/gdb/onlinedocs/gdb/Standard-Target-Features.html + */ +int qemu_plugin_find_register(unsigned int vcpu_index, int file, + const char *name); + +/** + * qemu_plugin_read_register() - read register + * + * @buf: the byte array to append the read register content to. + * @reg: the register identifier determined with + * qemu_plugin_find_register(). + * + * This function is only available in a context that register read access = is + * explicitly requested. + * + * Returns the size of the read register. The content of @buf is in target= byte + * order. + */ +int qemu_plugin_read_register(GByteArray *buf, int reg); + #endif /* QEMU_QEMU_PLUGIN_H */ diff --git a/plugins/api.c b/plugins/api.c index 2078b16edb..7c2843da1a 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -35,10 +35,12 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/main-loop.h" #include "qemu/plugin.h" #include "qemu/log.h" #include "tcg/tcg.h" #include "exec/exec-all.h" +#include "exec/gdbstub.h" #include "exec/ram_addr.h" #include "disas/disas.h" #include "plugin.h" @@ -442,3 +444,21 @@ uint64_t qemu_plugin_entry_code(void) #endif return entry; } + +int qemu_plugin_find_register_file(unsigned int vcpu_index, const char *na= me) +{ + QEMU_IOTHREAD_LOCK_GUARD(); + return gdb_find_feature(qemu_get_cpu(vcpu_index), name); +} + +int qemu_plugin_find_register(unsigned int vcpu_index, int file, + const char *name) +{ + QEMU_IOTHREAD_LOCK_GUARD(); + return gdb_find_feature_register(qemu_get_cpu(vcpu_index), file, name); +} + +int qemu_plugin_read_register(GByteArray *buf, int reg) +{ + return gdb_read_register(current_cpu, buf, reg); +} diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 71f6c90549..977f1fcfcb 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -42,4 +42,7 @@ qemu_plugin_tb_vaddr; qemu_plugin_uninstall; qemu_plugin_vcpu_for_each; + qemu_plugin_find_register_file; + qemu_plugin_find_register; + qemu_plugin_read_register; }; --=20 2.42.0 From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851595; cv=none; d=zohomail.com; s=zohoarc; b=L5HrxcyALveq3VTJ0u60y0LepPaGglLd+EcH4kMXMFbWABFgZbcm+S2KYpapHOV/EqBoFwb1c1de1AG2R6NSowWs4s4rPeFGaDX/aiJtirEpmFkxzHDBujEAGg9yk3hCUVx4HoV1r/C7tvGgiG6oGxr+AYB+k/d0DEwoamz7wfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851595; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=JCJCzqQ6Ba4FCVkTkN3rupr67lFRisvbzNM+HnYlWm0=; b=Q9p+icJrCC7RYKZ+/uqWIFguSvU2+daJmi+CxjD0fyDMnNoyI4fj0AFu8SyyvItkVNxfQ4M5yj3q95nty0YgdBl3FUB82Mu6A4yEkGXmAyA2tjkJW6nkn8Y/aJrNstXerXFLjHAhvwCiRQ6gKei2YnLcsNWJS4tZWVwgMOanvBk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694851595907113.43764030438092; Sat, 16 Sep 2023 01:06:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQGp-00047f-FF; Sat, 16 Sep 2023 04:03:15 -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 1qhQGo-000477-7d for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:03:14 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhQGl-0006DW-Lt for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:03:13 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-68fbb10dea4so2386779b3a.3 for ; Sat, 16 Sep 2023 01:03:11 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.03.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:03:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851390; x=1695456190; 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=JCJCzqQ6Ba4FCVkTkN3rupr67lFRisvbzNM+HnYlWm0=; b=pXR7+m+qUD8B6lB96KeL5FbV/INSd3Q96KzDm/OKxIqBHM6T4a3XCzGgB4PR0kjDH5 66KazdxPb1ExmCAlWnl4sCniKbEQjiWYDC8QvsKXxYTThsk/y9675okj2w9qv0Th7I+N DCGxxtljwr4etOafKy26dLiubr5MoTrWvtizQ0p1AOugM9YG/ydZqwS52O/mCwBGwv30 QpsJQKH3FNje3b28kGY9z5hZ2Qac/KH+WWBXAzq3dEbsEEfR1JBzNrMYai3qKyAagnIZ kU0nDBJuPgvzquHxkXkJjk2XseKk3+oWSQqMEu3x2rU7cwvA80siFyxQLNRXiJHVsHrs fLJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851390; x=1695456190; 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=JCJCzqQ6Ba4FCVkTkN3rupr67lFRisvbzNM+HnYlWm0=; b=cByEHYTWnGOEf6eg4X6v61QTv/aNL3mR/rluGpetc2E3MlqnFbcsEF72dX5SX4L49Z fQaLckQVSSRpj0bm6WqkBcjWHfn2yoWPUKH4vgCxPw+Y3rYXtRyTDun5EbmAZh73/PnY jiv4uOStXRhDsXhsDwQqDqkrr6xyS5BmiKWLo99bCsifVbVpUMzf+kiSSmyfAKBQdLP3 528paTt0NzfStuQS3/63eluvFFKfUnPf6CXSE006x3jTL+okhBPxHp122S9m7Es7yKOn xlJx8Er8WNLGWZj8Z5TXYIM8mtdJmhV2RfXatRNw0R+sEEZ7ayew4uD+pNoKMLA+0VRS H4bA== X-Gm-Message-State: AOJu0YwX51ulpb7kS9+1IyRfvOy9sxe3HTBwZtvmpny4n14cb8rq5Mj8 WSLWrFjmQfP6dcFX+Q6sDcMSwA== X-Google-Smtp-Source: AGHT+IFjZ65UwnvvzsilWOmKeKMxVprdu+v9tN7ZW/u+G+6L3KxX8NzUsvlT4mkVrOLc1+RMOgFgTQ== X-Received: by 2002:a05:6a00:178e:b0:68a:69ba:6791 with SMTP id s14-20020a056a00178e00b0068a69ba6791mr4367668pfg.8.1694851390329; Sat, 16 Sep 2023 01:03:10 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Alexandre Iooss , Mahmoud Mandour , Richard Henderson , Paolo Bonzini Subject: [PATCH v8 17/19] contrib/plugins: Allow to log registers Date: Sat, 16 Sep 2023 17:01:34 +0900 Message-ID: <20230916080149.129989-18-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=2607:f8b0:4864:20::42e; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42e.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851596200100005 Content-Type: text/plain; charset="utf-8" This demonstrates how a register can be read from a plugin. Signed-off-by: Akihiko Odaki --- docs/devel/tcg-plugins.rst | 10 +++- contrib/plugins/execlog.c | 120 +++++++++++++++++++++++++++---------- 2 files changed, 97 insertions(+), 33 deletions(-) diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst index 81dcd43a61..c9f8b27590 100644 --- a/docs/devel/tcg-plugins.rst +++ b/docs/devel/tcg-plugins.rst @@ -497,6 +497,15 @@ arguments if required:: $ qemu-system-arm $(QEMU_ARGS) \ -plugin ./contrib/plugins/libexeclog.so,ifilter=3Dst1w,afilter=3D0x400= 01808 -d plugin =20 +This plugin can also dump a specified register. The specification of regis= ter +follows `GDB standard target features `__. + +Specify the name of the feature that contains the register and the name of= the +register with ``rfile`` and ``reg`` options, respectively:: + + $ qemu-system-arm $(QEMU_ARGS) \ + -plugin ./contrib/plugins/libexeclog.so,rfile=3Dorg.gnu.gdb.arm.core,r= eg=3Dsp -d plugin + - contrib/plugins/cache.c =20 Cache modelling plugin that measures the performance of a given L1 cache @@ -583,4 +592,3 @@ The following API is generated from the inline document= ation in include the full kernel-doc annotations. =20 .. kernel-doc:: include/qemu/qemu-plugin.h - diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c index 82dc2f584e..f3e714c888 100644 --- a/contrib/plugins/execlog.c +++ b/contrib/plugins/execlog.c @@ -15,27 +15,43 @@ =20 #include =20 +typedef struct CPU { + /* Store last executed instruction on each vCPU as a GString */ + GString *last_exec; + GByteArray *reg_history[2]; + + int reg; +} CPU; + QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; =20 -/* Store last executed instruction on each vCPU as a GString */ -static GPtrArray *last_exec; +static CPU *cpus; +static int num_cpus; static GRWLock expand_array_lock; =20 static GPtrArray *imatches; static GArray *amatches; =20 +static char *rfile_name; +static char *reg_name; + /* - * Expand last_exec array. + * Expand cpu array. * * As we could have multiple threads trying to do this we need to * serialise the expansion under a lock. */ -static void expand_last_exec(int cpu_index) +static void expand_cpu(int cpu_index) { g_rw_lock_writer_lock(&expand_array_lock); - while (cpu_index >=3D last_exec->len) { - GString *s =3D g_string_new(NULL); - g_ptr_array_add(last_exec, s); + if (cpu_index >=3D num_cpus) { + cpus =3D g_realloc_n(cpus, cpu_index + 1, sizeof(*cpus)); + while (cpu_index >=3D num_cpus) { + cpus[num_cpus].last_exec =3D g_string_new(NULL); + cpus[num_cpus].reg_history[0] =3D g_byte_array_new(); + cpus[num_cpus].reg_history[1] =3D g_byte_array_new(); + num_cpus++; + } } g_rw_lock_writer_unlock(&expand_array_lock); } @@ -50,8 +66,8 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugin_= meminfo_t info, =20 /* Find vCPU in array */ g_rw_lock_reader_lock(&expand_array_lock); - g_assert(cpu_index < last_exec->len); - s =3D g_ptr_array_index(last_exec, cpu_index); + g_assert(cpu_index < num_cpus); + s =3D cpus[cpu_index].last_exec; g_rw_lock_reader_unlock(&expand_array_lock); =20 /* Indicate type of memory access */ @@ -77,28 +93,42 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugi= n_meminfo_t info, */ static void vcpu_insn_exec(unsigned int cpu_index, void *udata) { - GString *s; + int n; + int i; =20 - /* Find or create vCPU in array */ g_rw_lock_reader_lock(&expand_array_lock); - if (cpu_index >=3D last_exec->len) { - g_rw_lock_reader_unlock(&expand_array_lock); - expand_last_exec(cpu_index); - g_rw_lock_reader_lock(&expand_array_lock); - } - s =3D g_ptr_array_index(last_exec, cpu_index); - g_rw_lock_reader_unlock(&expand_array_lock); =20 /* Print previous instruction in cache */ - if (s->len) { - qemu_plugin_outs(s->str); + if (cpus[cpu_index].last_exec->len) { + if (cpus[cpu_index].reg >=3D 0) { + GByteArray *current =3D cpus[cpu_index].reg_history[0]; + GByteArray *last =3D cpus[cpu_index].reg_history[1]; + + g_byte_array_set_size(current, 0); + n =3D qemu_plugin_read_register(current, cpus[cpu_index].reg); + + if (n !=3D last->len || memcmp(current->data, last->data, n)) { + g_string_append(cpus[cpu_index].last_exec, ", reg,"); + for (i =3D 0; i < n; i++) { + g_string_append_printf(cpus[cpu_index].last_exec, " %0= 2x", + current->data[i]); + } + } + + cpus[cpu_index].reg_history[0] =3D last; + cpus[cpu_index].reg_history[1] =3D current; + } + + qemu_plugin_outs(cpus[cpu_index].last_exec->str); qemu_plugin_outs("\n"); } =20 /* Store new instruction in cache */ /* vcpu_mem will add memory access information to last_exec */ - g_string_printf(s, "%u, ", cpu_index); - g_string_append(s, (char *)udata); + g_string_printf(cpus[cpu_index].last_exec, "%u, ", cpu_index); + g_string_append(cpus[cpu_index].last_exec, (char *)udata); + + g_rw_lock_reader_unlock(&expand_array_lock); } =20 /** @@ -167,8 +197,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct = qemu_plugin_tb *tb) QEMU_PLUGIN_MEM_RW, NULL); =20 /* Register callback on instruction */ - qemu_plugin_register_vcpu_insn_exec_cb(insn, vcpu_insn_exec, - QEMU_PLUGIN_CB_NO_REGS,= output); + qemu_plugin_register_vcpu_insn_exec_cb( + insn, vcpu_insn_exec, + rfile_name ? QEMU_PLUGIN_CB_R_REGS : QEMU_PLUGIN_CB_NO_REG= S, + output); =20 /* reset skip */ skip =3D (imatches || amatches); @@ -177,17 +209,33 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct= qemu_plugin_tb *tb) } } =20 +static void vcpu_init(qemu_plugin_id_t id, unsigned int vcpu_index) +{ + int reg =3D -1; + + expand_cpu(vcpu_index); + + if (rfile_name) { + int rfile =3D qemu_plugin_find_register_file(vcpu_index, rfile_nam= e); + if (rfile >=3D 0) { + reg =3D qemu_plugin_find_register(vcpu_index, rfile, reg_name); + } + } + + g_rw_lock_writer_lock(&expand_array_lock); + cpus[vcpu_index].reg =3D reg; + g_rw_lock_writer_unlock(&expand_array_lock); +} + /** * On plugin exit, print last instruction in cache */ static void plugin_exit(qemu_plugin_id_t id, void *p) { guint i; - GString *s; - for (i =3D 0; i < last_exec->len; i++) { - s =3D g_ptr_array_index(last_exec, i); - if (s->str) { - qemu_plugin_outs(s->str); + for (i =3D 0; i < num_cpus; i++) { + if (cpus[i].last_exec->str) { + qemu_plugin_outs(cpus[i].last_exec->str); qemu_plugin_outs("\n"); } } @@ -224,9 +272,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_= id_t id, * we don't know the size before emulation. */ if (info->system_emulation) { - last_exec =3D g_ptr_array_sized_new(info->system.max_vcpus); - } else { - last_exec =3D g_ptr_array_new(); + cpus =3D g_new(CPU, info->system.max_vcpus); } =20 for (int i =3D 0; i < argc; i++) { @@ -236,13 +282,23 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugi= n_id_t id, parse_insn_match(tokens[1]); } else if (g_strcmp0(tokens[0], "afilter") =3D=3D 0) { parse_vaddr_match(tokens[1]); + } else if (g_strcmp0(tokens[0], "rfile") =3D=3D 0) { + rfile_name =3D g_strdup(tokens[1]); + } else if (g_strcmp0(tokens[0], "reg") =3D=3D 0) { + reg_name =3D g_strdup(tokens[1]); } else { fprintf(stderr, "option parsing failed: %s\n", opt); return -1; } } =20 + if ((!rfile_name) !=3D (!reg_name)) { + fputs("file and reg need to be set at the same time\n", stderr); + return -1; + } + /* Register translation block and exit callbacks */ + qemu_plugin_register_vcpu_init_cb(id, vcpu_init); qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); =20 --=20 2.42.0 From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851505; cv=none; d=zohomail.com; s=zohoarc; b=ml74hvx+Z+oWTXcgQVO+yEeERqnImIlrxSLL8QlVLioSSFufSjgBbLebDq1U+Cygo1qqHkA2Cd2z2pQ1WYPCVlZ84HP2Y6+w1Drsr7VIuG7pB3VfvrCpI0qSBg6kb7Eap+YLNxQMF/dA+667b9YOMR+adckK2ocy6Um1jU912QA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851505; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=SHEeIOFIQeEybg1OP9uxYR6frP9B0kGaVRtOZCYAkPQ=; b=Qz/ByPdcupzlM/xy0Yuf8CEibXs8h4FHvSmdXNNAld606d/esVpE5WhJ02DifQpaMRkR6DLJqsHDBawH0Q1k3FOFclxMGmatQqBL6qWooLn/ku7fchqq1ZCvFGsffCBCCS0L40Mznwuw1X8POawtY3fOGw+rnzgbnmTOW9w/jT0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694851505530888.3289387895469; Sat, 16 Sep 2023 01:05:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQGr-000498-Ng; Sat, 16 Sep 2023 04:03:17 -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 1qhQGp-00047a-8x for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:03:15 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhQGn-0006Dk-PU for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:03:15 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-68fc081cd46so2752548b3a.0 for ; Sat, 16 Sep 2023 01:03:13 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:03:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851392; x=1695456192; 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=SHEeIOFIQeEybg1OP9uxYR6frP9B0kGaVRtOZCYAkPQ=; b=YGABrqQQUR9QRh0346kTIJ2VuE99KAECVv2U54cYthWFhVoyxa7oFAS6g0yeuoIStW ryJ5jg0nSu6kDQ1MWNVGzWXPyjcG0hl/6Bzv6Yboq+t+SGSHiByA8uIlfnPmsHRaUSSs EIIYpAMVdCyavU4iygMOAZIfK4jqCvZghiP/l15YdwRJ2nr1ynfY3sExYkrbZAnRPo4j EkmfENw2r9WLzJ32PYoQdQot7SuK4ML2NwF+sblTs6fMyrrhLk77ZGBWNtqATH5IZkcC 9j+UQXWfcj+5ztetTrfwVQ7qIqRIPWzLi0L/Uez5F9+Ts2SzxBhhwDbphj+nmuB4MbS9 HLwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851392; x=1695456192; 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=SHEeIOFIQeEybg1OP9uxYR6frP9B0kGaVRtOZCYAkPQ=; b=XQxTjDEEoKowIBt4bo2qG+kYYLlnokRQM+0zP4e+sP2A7hnyqKXMYW6WxcdUhouFii aelvX505hLpUPCboXKEKHA8RfsaZE2nKesIn/yKfEWT7UkDKcn9MRUF7TNLHKWJc2bcv cZ2IKj8ZC6uorm1mx6Kr/zGhU6L8VMiEmHppge1/lEKV5eHASbn3bClIwoc6tbELpSq5 n+0U1BZLI8fybFNkUDHCQIPvTQopzoPNzsp/GBEpDShQ4Fk+Z27QHE7PXpL3kZREMuSX MqdG1wyvTNUHLeml0V2LBcshYSQFcO8qJccEp3p4HpgkedStoEvjzR9T3DNyALLhK2eu GF6Q== X-Gm-Message-State: AOJu0Yw93f7Son4cQhkPPwTJbiy36CuWhx5lrqBT9PdZvZ+Kfy3ZSdrH 09wMu0ksB1Gtp+sVIKo8v7em7g== X-Google-Smtp-Source: AGHT+IFycmLgwZhCZbjHimc0h6fGsSyYEyrFjQNkWPB6gzc9gf7+kfoiqibHqouHAUo+p11/4sy00g== X-Received: by 2002:a05:6a20:394b:b0:14d:6309:fc90 with SMTP id r11-20020a056a20394b00b0014d6309fc90mr3113589pzg.8.1694851392330; Sat, 16 Sep 2023 01:03:12 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki Subject: [PATCH v8 18/19] plugins: Support C++ Date: Sat, 16 Sep 2023 17:01:35 +0900 Message-ID: <20230916080149.129989-19-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=2607:f8b0:4864:20::431; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x431.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851505837100001 Content-Type: text/plain; charset="utf-8" Make qemu-plugin.h consumable for C++ platform. Signed-off-by: Akihiko Odaki --- include/qemu/qemu-plugin.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 40aae8db68..55f514ca6c 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -16,6 +16,8 @@ #include #include =20 +G_BEGIN_DECLS + /* * For best performance, build the plugin with -fvisibility=3Dhidden so th= at * QEMU_PLUGIN_LOCAL is implicit. Then, just mark qemu_plugin_install with @@ -710,4 +712,6 @@ int qemu_plugin_find_register(unsigned int vcpu_index, = int file, */ int qemu_plugin_read_register(GByteArray *buf, int reg); =20 +G_END_DECLS + #endif /* QEMU_QEMU_PLUGIN_H */ --=20 2.42.0 From nobody Fri May 17 09:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694851599; cv=none; d=zohomail.com; s=zohoarc; b=i/R0tYf29kiVLS2Ee2M8WWZvCk1QCM6wGrlNBWWh6sIp6uJ2SOuAK/470lDaZO3Wd2l/J1EKD9IEIjTl70RookA1uwHJwbz5ndkSfkjmy+Q4SQ5kIyakX2iFAzp5qZqGhkOS9EXa0kHSeu3RTGBG/xzEOuoDMG+nVDPcLhi+y3I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694851599; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=UJRUv8O4TokTXkVqeubhuAV8gl+wRJjs7dLP5rlsco4=; b=NL9TomK5UEp6WWjb3XGJbSBhZca1NC3cwkB4bpYU7r/1vkoKccnoDaC/DEimsEJxmJ7PZD3Dzez7jTkEoKo81GtlrjmFiAXsg3pjb7FMARmOrpNAFnZzlgEGHHnRcxBiAu/uWuo3jWLUg4SWQj4aAAqcbXS6+7t0biMsw9HiWkU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694851599941715.226662020404; Sat, 16 Sep 2023 01:06:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhQGt-0004Eo-5L; Sat, 16 Sep 2023 04:03:19 -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 1qhQGr-00049l-Uj for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:03:17 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhQGq-0006EK-7B for qemu-devel@nongnu.org; Sat, 16 Sep 2023 04:03:17 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-68fb5bd8f02so2800779b3a.0 for ; Sat, 16 Sep 2023 01:03:15 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b0068a46cd4120sm4029484pfa.199.2023.09.16.01.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694851395; x=1695456195; 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=UJRUv8O4TokTXkVqeubhuAV8gl+wRJjs7dLP5rlsco4=; b=1ePcVEachnV/im4Z3QpUT6xNWyqxFzdzlmVgxQLc/DYSccLwk+atZCNw5Cci9CXvJy O6gBpBcJTle9ALi9xEfuWqTQqoNLs3hRgtEQoQsO+nDghVXvWbzkhErTIWvnUVnlsoei PxmBbSjjAs5xnpy/Xk/oCcv4rhldX4VznVG72dTsRmW4oSwdHJIHqlEzJDoM8URglMkz xV9s3ts4aboO+dPE3oO8Ks3fyhcTwM+GUS+MRlC8hRo0csQV8BZw/diQPQ6+VYnSCRYQ t2gpWM5fBTdZo9Mbu+QdJF9Vq6XCQJfjrVzb91gG2JBh2t2wJ2CFHqnfAOSsiEyVBvdV S9nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694851395; x=1695456195; 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=UJRUv8O4TokTXkVqeubhuAV8gl+wRJjs7dLP5rlsco4=; b=Q4+Xce/ombjN+SNdRkA7aFaUy8NYqsjSCtYddHeHcoqOAiZVDooH9d2iiP49CI6xa/ y2oGpJIJQj7RiAQ7hMBjekgeKwvC+D/yONE2xNWSQIojCC9DPrxOwgEiDXUKrHahO/N2 eBTem4yjk/F1zCTRNtJ+N4NanIjWOjqVXcjM16T7yIUNRtqbokpzUGu4yVYyPIUIw17v 6cIq75nXsS4G/zdYeWEmGNQRfNJaRHJxkZ5o/pI8PLdeLqbmLZ9ztbriiuhyfb/szS+m xNnRB7W/itF/Z+2g32QKxl+RtJhUtbRbEfQl1Rc4gaw45KcBmF10s+ho29m3dGw4LScr QZrQ== X-Gm-Message-State: AOJu0YzAAz+ToA/7JmkDi9g0kx1eDKoxBMEzbiIDKYdC+4N1CL9mj1Er bUoHj22CAUseKVIKz//kPfeTpg== X-Google-Smtp-Source: AGHT+IGu8IH3OL+4xqL2Tait9XsgdaTyBSNrf44x0x7X6O6lCinN27PCSX3QLplgMRQzJDh1JxzxyA== X-Received: by 2002:a05:6a20:748e:b0:156:e1ce:d4a4 with SMTP id p14-20020a056a20748e00b00156e1ced4a4mr3851713pzd.54.1694851395121; Sat, 16 Sep 2023 01:03:15 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Paolo Bonzini , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Richard Henderson Subject: [PATCH v8 19/19] contrib/plugins: Add cc plugin Date: Sat, 16 Sep 2023 17:01:36 +0900 Message-ID: <20230916080149.129989-20-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916080149.129989-1-akihiko.odaki@daynix.com> References: <20230916080149.129989-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=2607:f8b0:4864:20::42a; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42a.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694851601554100001 Content-Type: text/plain; charset="utf-8" This demonstrates how to write a plugin in C++. Signed-off-by: Akihiko Odaki --- docs/devel/tcg-plugins.rst | 8 ++++++++ configure | 15 ++++++++++++--- contrib/plugins/Makefile | 5 +++++ contrib/plugins/cc.cc | 17 +++++++++++++++++ tests/tcg/Makefile.target | 3 +++ 5 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 contrib/plugins/cc.cc diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst index c9f8b27590..0a11f8036c 100644 --- a/docs/devel/tcg-plugins.rst +++ b/docs/devel/tcg-plugins.rst @@ -584,6 +584,14 @@ The plugin has a number of arguments, all of them are = optional: configuration arguments implies ``l2=3Don``. (default: N =3D 2097152 (2MB), B =3D 64, A =3D 16) =20 +- contrib/plugins/cc.cc + +cc plugin demonstrates how to write a plugin in C++. It simply outputs +"hello, world" to the plugin log:: + + $ qemu-system-arm $(QEMU_ARGS) \ + -plugin ./contrib/plugins/libcc.so -d plugin + API --- =20 diff --git a/configure b/configure index b9bd008592..c3cd5a15e7 100755 --- a/configure +++ b/configure @@ -293,10 +293,18 @@ else cc=3D"${CC-${cross_prefix}gcc}" fi =20 -if test -z "${CXX}${cross_prefix}"; then - cxx=3D"c++" +if test -n "${CXX+x}"; then + cxx=3D"$CXX" else - cxx=3D"${CXX-${cross_prefix}g++}" + if test -n "${cross_prefix}"; then + cxx=3D"${cross_prefix}g++" + else + cxx=3D"c++" + fi + + if ! has "$cxx"; then + cxx=3D + fi fi =20 # Preferred ObjC compiler: @@ -1765,6 +1773,7 @@ echo "MESON=3D$meson" >> $config_host_mak echo "NINJA=3D$ninja" >> $config_host_mak echo "PKG_CONFIG=3D${pkg_config}" >> $config_host_mak echo "CC=3D$cc" >> $config_host_mak +echo "CXX=3D$cxx" >> $config_host_mak echo "EXESUF=3D$EXESUF" >> $config_host_mak =20 # use included Linux headers for KVM architectures diff --git a/contrib/plugins/Makefile b/contrib/plugins/Makefile index b2b9db9f51..93d86b3d07 100644 --- a/contrib/plugins/Makefile +++ b/contrib/plugins/Makefile @@ -21,6 +21,9 @@ NAMES +=3D lockstep NAMES +=3D hwprofile NAMES +=3D cache NAMES +=3D drcov +ifneq ($(CXX),) +NAMES +=3D cc +endif =20 SONAMES :=3D $(addsuffix .so,$(addprefix lib,$(NAMES))) =20 @@ -31,6 +34,8 @@ CFLAGS +=3D -fPIC -Wall CFLAGS +=3D $(if $(CONFIG_DEBUG_TCG), -ggdb -O0) CFLAGS +=3D -I$(SRC_PATH)/include/qemu =20 +CXXFLAGS :=3D $(CFLAGS) + all: $(SONAMES) =20 %.o: %.c diff --git a/contrib/plugins/cc.cc b/contrib/plugins/cc.cc new file mode 100644 index 0000000000..83a5528db0 --- /dev/null +++ b/contrib/plugins/cc.cc @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include + +extern "C" { + +QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, int ar= gc, + char **argv) +{ + qemu_plugin_outs("hello, world\n"); + return 0; +} + +}; diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index 462289f47c..3d7837d3b8 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -149,6 +149,9 @@ PLUGIN_SRC=3D$(SRC_PATH)/tests/plugin PLUGIN_LIB=3D../../plugin VPATH+=3D$(PLUGIN_LIB) PLUGINS=3D$(patsubst %.c, lib%.so, $(notdir $(wildcard $(PLUGIN_SRC)/*.c))) +ifneq ($(CXX),) +PLUGINS+=3D$(patsubst %.cc, lib%.so, $(notdir $(wildcard $(PLUGIN_SRC)/*.c= c))) +endif =20 # We need to ensure expand the run-plugin-TEST-with-PLUGIN # pre-requistes manually here as we can't use stems to handle it. We --=20 2.42.0