From nobody Tue Feb 10 17:02:40 2026 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=1693717481; cv=none; d=zohomail.com; s=zohoarc; b=koJfw5Eqlwflg+q9EZXchkLyRd61BOvTGDwdvCAJ0dFDiK9Uu3yRYXZTiwRnpAw1TtRUjrLuN8ht0e3y7wfjDiNcx8ux2Wl/KIiSICIaGCI95aJU6JPWc2fpRTJMdvkgUdypfOKKa3XA6NkNPWFSFl1DnbPrqKrwasrWpyFUQQE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693717481; 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=i4xTQLVH/t4lJzmRwDn0811v9zJ3oM+fHQTaO7tk+O4=; b=hNat9IPgHeopOPYL7oK8ZjOkYinIJxe8E85W1DeL/u3lYxhubMm0zFl32q6BYsxCRdmtWX8rZk60xCWggzM89SOggPygLE71QZXc5X2wEIlWJPor9Kr48VwiRHyy+c1ESm0va8235aTFIOlrPndEReOmgzK8Pd5Ep2/6Q9+pcVU= 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 1693717481803134.11456335535718; Sat, 2 Sep 2023 22:04:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcfHB-0002ea-ER; Sun, 03 Sep 2023 01:03: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 1qcfH3-0002eD-79 for qemu-devel@nongnu.org; Sun, 03 Sep 2023 01:03:49 -0400 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcfH0-0001fA-UU for qemu-devel@nongnu.org; Sun, 03 Sep 2023 01:03:48 -0400 Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-6bc9811558cso446076a34.0 for ; Sat, 02 Sep 2023 22:03:46 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id l11-20020a170902f68b00b001b8af7f632asm5324835plg.176.2023.09.02.22.03.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 22:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1693717425; x=1694322225; 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=i4xTQLVH/t4lJzmRwDn0811v9zJ3oM+fHQTaO7tk+O4=; b=V6A3HYYAlHtkRmJfEaji/sFYbVShTcY5RMTlWoteo2AXhXS/AIS3FT1Ad0sqyUvIFG UYm6rzrSRhPA0Jiz8C5vDuU1hg7ppci8ENOXgjwCnNe7KEuK5+H+Jj83Fv1uzNbYQpWL Lh1/yzzdGmqyYD8lxKW6FqcI+QDTT0JJZzzp14mSjWEirtZlLgX63PWBANaU9eWrbpc1 wjXWZyKmetnF1kcjoJ3HynNdVSBqTZnw20L97UuxivV/csVqU/LVB1Lp0kPIn4BjLIWu JBX+uuQR/VxUXRaTcDpj+Bxxkfb3dRLYIcIgrl470vU3T3O3k1qOlTA55wzyGkwcp+Hp Bukg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693717425; x=1694322225; 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=i4xTQLVH/t4lJzmRwDn0811v9zJ3oM+fHQTaO7tk+O4=; b=kmENIyksnBQEzEsBtQ3CdZKp/VKTAl6ART/ak9gqhl/Z3VHBZSwIbm45qG+cz3Znbk Z9f5PSVQVO3PN0hUOBp0yGyRapCnFDWKnDGaJSeaZwrK0NJWnWE8H6xLgFOkaMff2iuU bFVc71WUD0Xxfe/w+LN7dDXlC3OBUobRvBseMIUNj+PcO2zGNW+poVA3pgUCI2AuDU6G vMwzT+V6eWKwTSeQmhKWeVBWsoXEQJhcqN19n9GssrulrXo5CWsChn03JPTV4p5MBp1S 6+omA+FmN2NOFaooL1E/UsNhMo4unvsbVEf+iB26kVpMNuOrvqUCqSWHY68/o5hCPuR6 hVHg== X-Gm-Message-State: AOJu0Yyfa1hKXu30FLjo/DEmFmwDNh9fUq3l1FMMMt4DLC241CjIFjWW P03hseu6xKlT5ehOVi84S+cuuA== X-Google-Smtp-Source: AGHT+IG0/w5J/TKSNz4r5HxF1fS7r9itlpoTgbf5l2l+y6B8AZzBAq/U2aT6JJQva8eGJpURWcso+w== X-Received: by 2002:a05:6830:1b65:b0:6bd:152f:9913 with SMTP id d5-20020a0568301b6500b006bd152f9913mr7357239ote.29.1693717425626; Sat, 02 Sep 2023 22:03:45 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Snow , Cleber Rosa Subject: [PATCH v6 01/18] gdbstub: Add num_regs member to GDBFeature Date: Sun, 3 Sep 2023 14:03:09 +0900 Message-ID: <20230903050338.35256-2-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230903050338.35256-1-akihiko.odaki@daynix.com> References: <20230903050338.35256-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::32a; envelope-from=akihiko.odaki@daynix.com; helo=mail-ot1-x32a.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: 1693717482989100003 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 ecbc60a934..7dc097fcf6 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