From nobody Wed Nov 27 12:28:56 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=1699367096; cv=none; d=zohomail.com; s=zohoarc; b=O4CFBlqjJB4cm2BlfdFbLjFiM/OuVTe8Z29hvowJ03EVgWJM5PisvA44VP89ddxCiP6vfJyEY+DiCASp7rRRa5kMxCPErnaGEAuoI9ZrUyva1k7l7cNWCsjKgRuq373Ro+BVw4J4qK9GJM6YtHgHOvd3hQLmFo5aS9jRGUK9tNY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699367096; 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=ZHYLdqoLGtFuY3dzHamisw3eOa1TzTuGsjgcCCYH8rk=; b=eZC9dQNgnj9/BRFs1hFxcpDrKPO7q/uf592WMAhpDRrLQpEyVPYWHBNP8rr+8U9m1PrSKjnSMiZToIf56JAsPAVrt9xsMwIqt7lMgCpRpbv8NaKOTDgtiKCQlMY8gNpQAHCIfmRdBLPkMMdhBy0cpXDp/1FBQE0UPy06c3wVxYw= 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 1699367096787522.3469449888723; Tue, 7 Nov 2023 06:24:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0N0I-0004R2-9T; Tue, 07 Nov 2023 09:24:30 -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 1r0Mzu-0004Dj-OE for qemu-devel@nongnu.org; Tue, 07 Nov 2023 09:24:06 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450: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 1r0Mzr-0007Yl-4X for qemu-devel@nongnu.org; Tue, 07 Nov 2023 09:24:06 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40859c464daso42043375e9.1 for ; Tue, 07 Nov 2023 06:24:02 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id i16-20020a5d55d0000000b0032d8354fb43sm2504414wrw.76.2023.11.07.06.23.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 06:23:58 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 59C636575E; Tue, 7 Nov 2023 14:23:55 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699367041; x=1699971841; 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=ZHYLdqoLGtFuY3dzHamisw3eOa1TzTuGsjgcCCYH8rk=; b=B+ZRwc0jSuS7pL+pbu6p+1u56svsNITOIZO7mX/W1AOjza7u9SQxsEuiluArzou7iV kQjRjfUfMpWZBrxyAu8n89xNJQgLM90oBoQN+aCq2fS/F0LzXKE+AZ4xr33SCm9vmQM1 gXGSLAA0MXRaMRNL2EKHOSwQmFhkTE4gcPoBTCySPsxcyV5BYQXwXAY5dUWlG7P9/kjK ETHwwteBrXsOUZRS7wnTke/KF+qigglngO5VZSIfhT7m9P8CDCgpPe1SCjydUV1i2gXj Jc5HhRE2RPd/FGc/UON5XyYjbeBhqdYgrsj5ra4VQ8lJDKDl8TPym3Z9lukthtgBquMS 2vcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699367041; x=1699971841; 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=ZHYLdqoLGtFuY3dzHamisw3eOa1TzTuGsjgcCCYH8rk=; b=pX8yda0ROjKuoA7uJLb8Tu5Zq4fyBQQ5K9uRhV0+0r7hfWEKne6BbZJCv+tQUHbtAQ jmgDOM5gCSf3Gtq67z3qTSQlzZgKFSychzrELUc0jnk51SWGhxsFZOaTyARECsuJlNL+ 8va+wIJpM3fGdtCPB7YHro1GNucgDcaNXiAQd84U2V2Qr0fKnwijs2pD84bZkaB5I3Be GYmjtKsoZe8sGtnuy4aiVGFhEC2bWHEuBcTiOMw/6QRVCC3CwoalIywjcCOfkx2N7AE9 0hvF/CnmBzqKmARQS2HbixGCmn1TYakowEM/+MrngRx8EA+ugbhDD5B38ZRZF8KhH1q5 bDrA== X-Gm-Message-State: AOJu0YzQ0BGgHqxWDcckWvfR52afZDuonnk20K7JcOc5/B9/0C68NEcJ uzp1jSHaF0sL+i8lBdck4BpJ2Q== X-Google-Smtp-Source: AGHT+IHFzcgOpGKvgzMhPvspSFjR6W5wrvnbTAt03RpnisTb9217TmjSFRIDesppNjEquQ31/l5y9Q== X-Received: by 2002:a05:6000:381:b0:32d:ae31:458c with SMTP id u1-20020a056000038100b0032dae31458cmr25341665wrf.33.1699367041668; Tue, 07 Nov 2023 06:24:01 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , John Snow , Cleber Rosa Subject: [PULL 08/23] gdbstub: Add num_regs member to GDBFeature Date: Tue, 7 Nov 2023 14:23:39 +0000 Message-Id: <20231107142354.3151266-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231107142354.3151266-1-alex.bennee@linaro.org> References: <20231107142354.3151266-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::329; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x329.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=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 @linaro.org) X-ZM-MESSAGEID: 1699367098956100007 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: <20231106185112.2755262-9-alex.bennee@linaro.org> 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