From patchwork Tue Nov 7 14:23:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 741891 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp1647081wrr; Tue, 7 Nov 2023 06:24:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTXxULDxBAm4JSj1seBiHL1Aw7VoBLHKhCfUV/2KsyNrMUwVdXruwGI6f6ZPm4IizZ3Z0C X-Received: by 2002:a05:6000:1562:b0:32d:a01a:9573 with SMTP id 2-20020a056000156200b0032da01a9573mr29005168wrz.8.1699367096922; Tue, 07 Nov 2023 06:24:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699367096; cv=none; d=google.com; s=arc-20160816; b=f3qh93zUwinWP/tWafoeDmZAwY0ebJsC0kr+eSMJxKKcFOmvIot/q1Sc2BpjtfZkDi Ubr95OxiltI2cDOHXc6cg6RQTL78qjdZN5UyOKZI16GSVKcbcnC2ftHnbfrwdl18l5tX 4bk1wkEhA+fleHW8rZhw2uS/fGu6wCpRdmVZxdbQyszEOcd1oUxak4xyDPw3BEm647ZU JmvKGqi0IRftPtQzQK+ccYFFS6y7gF+0m4Pp26HsP0fl094Jb2zAtIgxz6GzPxBXO0aq ButXDN67ogdskQamgbat8wg6XtOt7ZP1Z5wYK1/vwKuIMQUDawhWyqEJZlFh84WDJjVN nnBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZHYLdqoLGtFuY3dzHamisw3eOa1TzTuGsjgcCCYH8rk=; fh=tWIi/uzJLOZ9bc0IiB2+lFDI8Rnk1SvAEm9Q1ACUlhQ=; b=RkvGdeOi9Udsz02KoDTuHmQXNV9axwSQJ6q89NVQdCPXRIPPwb5j06YyfXwkR7M6xh 1cJOC0Kl6XdR2KQDCkxRpr68hH20cjDndUL59/I6jGX27/1PUj2GCJXfjyjNJIEAgBHf R2IvTgEdn697TdOspGyjkaC5ahv8TZOP1cWre6cxIWyvxi2m6a8dlKrTTb4/Pm7DGO7z nUy3slbiDydWo00lBIZOXSujavpaLtkx78yw3dEFQTPsqWT4uwG+sqMmABOUxD4hSmGr UZvnJBT1qWo4dH23rXzS8xecgDij/44oZvtGO3sJLTQPRRyrk35I34ukaf07jB/1YpRo XGCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B+ZRwc0j; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id co25-20020a0560000a1900b0032d9fce25f7si1880790wrb.364.2023.11.07.06.24.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Nov 2023 06:24:56 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B+ZRwc0j; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?q?d=C3=A9?= , =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Alex Bennée Message-Id: <20231025093128.33116-2-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée 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; 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 -import os, sys +import os, sys, xml.etree.ElementTree def writeliteral(indent, bytes): sys.stdout.write(' ' * indent) @@ -39,10 +39,52 @@ def writeliteral(indent, bytes): with open(input, 'rb') as file: read = file.read() + parser = xml.etree.ElementTree.XMLPullParser(['start', 'end']) + parser.feed(read) + events = parser.read_events() + event, element = next(events) + if event != 'start': + sys.stderr.write(f'unexpected event: {event}\n') + exit(1) + if element.tag != 'feature': + sys.stderr.write(f'unexpected start tag: {element.tag}\n') + exit(1) + + regnum = 0 + regnums = [] + tags = ['feature'] + for event, element in events: + if event == 'end': + if element.tag != tags[len(tags) - 1]: + sys.stderr.write(f'unexpected end tag: {element.tag}\n') + exit(1) + + tags.pop() + if element.tag == 'feature': + break + elif event == 'start': + if len(tags) < 2 and element.tag == 'reg': + if 'regnum' in element.attrib: + regnum = int(element.attrib['regnum']) + + regnums.append(regnum) + regnum += 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 = min(regnums) + num_regs = 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') sys.stdout.write(' { NULL }\n};\n')