From nobody Wed Nov 27 11:47:10 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1699296758; cv=none; d=zohomail.com; s=zohoarc; b=U9xlER6Td7EtgO+VogB71TX85P/HGsB6HyIz6kqfEoGv0N+3ELUWRBO0TvA8n/qAGGmq53NoDVtl8knwc4UKfGwghFRt0h9Uk5hfFwNUTqsBWncRO3yhJZuxe/mLaWVHnRmWihGHo9b6fX6IbdPlN8nqtf99j7PmPA2DCKKaHnw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699296758; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CXyrhp6VqJgeL6/elgmM8fEowiioTyfg620gHXDRwcg=; b=OZtjzplYE1BxOwwCDrOliYpxBh2prx3EoQO5XYPxG760eN26lZGtwuz92XSIwYVG2D34Ul8AQ4lN+PNOqZbR5MVUIphxoOvcy29vVi9WUKpxvgXg4vRzn+Bd58glW3MIh0FocBn3QkpAvnBrbCUf6u1QLxrMvE2s6jslGEJUS/c= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699296758452719.0732500767435; Mon, 6 Nov 2023 10:52:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r04h1-0005vv-Kz; Mon, 06 Nov 2023 13:51:23 -0500 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 1r04h0-0005t0-2B for qemu-devel@nongnu.org; Mon, 06 Nov 2023 13:51:22 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r04gy-0000yB-7E for qemu-devel@nongnu.org; Mon, 06 Nov 2023 13:51:21 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4084de32db5so42127275e9.0 for ; Mon, 06 Nov 2023 10:51:18 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a16-20020a5d5710000000b0031aef72a021sm284215wrv.86.2023.11.06.10.51.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 10:51:15 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 311DE6575B; Mon, 6 Nov 2023 18:51:13 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699296678; x=1699901478; 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=CXyrhp6VqJgeL6/elgmM8fEowiioTyfg620gHXDRwcg=; b=fuKBlV2wwUDhebO2fr9RpN/z4Y4cgFwAYv6Kbc5AQpxUuIHUYENsu7/EY7LVr5oYqZ Pw71AtxCXt+vmwEJBOByHZlMmnoqP4ONS+j2dVYgQs3yzM8gvjoF9DzGGwQelobVFH1T 8XdnU8F+p8MYNnpqvSuUPEz4ORAEZgsYMV2GUigFxJXSlyoy9PNAj1Wi+O4CcUDjs1sY whGXMcQrrSg3AvP7THVM34Sg10NHr44HLtAgkocIV7XZc9tC909IWwVci19tQ8XHAK9D MA2AxbXCdQGS4PnnGMb2u4IttVB26dp287vHd28njsm4DVm/Qt/CPCnbQNe3YVamSHnx UYIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699296678; x=1699901478; 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=CXyrhp6VqJgeL6/elgmM8fEowiioTyfg620gHXDRwcg=; b=qCd030wnizFZxnIJSVr/BU/cWs0LTVn0qGO+jZtlxKqJirBJ8Jcj/60wwabnnEAVmu Q7WtiuEbFzmSNmXnSCtrM44kVK2bSyMK0xm+xVgO+7KQdYsO9OTiy1lDVl6PBDf8WqMs RyzareFxNqNzXJmmbdgFD/cDWgUeaXbCuqcj3O8zJ93HYwggt60SyUkh8zsMQAd44g80 ySK3VUiJpReu5iUhSE6SVxHYVjwFWi1DRHrKs8NpJWcUKVLnBGzBAen9GnNrALknv1gb DCor4OC0Eg5Zglwz7Ap5Oip4furEM5Bw7lZNDfOnW+jZwDlZ7+dmKgjHPThlih8RAiTU pnyA== X-Gm-Message-State: AOJu0YxtvebsUIQFA7hmIRJLcpS8ldN7WJp2ySkgL38xzfYp45hKYEDS PkCWROFkxZb9mAx4Mr/aXPZYOA== X-Google-Smtp-Source: AGHT+IGB+cv75UYfhNe2Ufhutn/6j9BMTkalqdpmHHumAt/m9EnCc+8s8cqWo0k7UohX2rNmiic3Eg== X-Received: by 2002:a05:600c:3596:b0:408:3804:2a20 with SMTP id p22-20020a05600c359600b0040838042a20mr463754wmq.22.1699296677905; Mon, 06 Nov 2023 10:51:17 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Laurent Vivier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mahmoud Mandour , Cleber Rosa , Wainer dos Santos Moschetta , Paolo Bonzini , Thomas Huth , Beraldo Leal , Alexandre Iooss , John Snow , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Chris Wulff , Marek Vasut , Richard Henderson , Akihiko Odaki Subject: [PATCH 08/22] gdbstub: Add num_regs member to GDBFeature Date: Mon, 6 Nov 2023 18:50:58 +0000 Message-Id: <20231106185112.2755262-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231106185112.2755262-1-alex.bennee@linaro.org> References: <20231106185112.2755262-1-alex.bennee@linaro.org> 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: pass client-ip=2a00:1450:4864:20::334; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1699296760528100003 From: Akihiko Odaki 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 Message-Id: <20231025093128.33116-2-akihiko.odaki@daynix.com> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20231103195956.1998255-9-alex.bennee@linaro.org> --- 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 100644 --- 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.39.2