From patchwork Mon Nov 6 18:50:58 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: 741424 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp1255105wrr; Mon, 6 Nov 2023 10:52:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6ByvSbdnl4aKiUobsbHcppMqCgla8IQDQJxkehVuloZRb9VjpwRkIq/tei/XgLcKp2Pgv X-Received: by 2002:a05:620a:2b86:b0:773:d86f:ec88 with SMTP id dz6-20020a05620a2b8600b00773d86fec88mr31825743qkb.35.1699296758101; Mon, 06 Nov 2023 10:52:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699296758; cv=none; d=google.com; s=arc-20160816; b=ssY4m08hD6KW2//uYN3QFtplEHUK2KrWy+kTmnhwByYDfU7VqGBEopKZ/sGv604IIK lF+OcJsYyS4+S67MgdREADkrJe5NFdMFo+IbtuMc2mjlK51RpZyA9aM0XV7UZADyNt7/ QoP6g02x19I+Zxmt4+N63sMvQEBvs1pw21lcrmI1vKZPMUM4RPgIht3NHl0oMX/6qvSS GRm5dxWGzNTGLTdtrfV08YmZez1bqFdQXponONNBzwvWqFvQPzkfLLdIC4c0n2anOv6X Zte0LQ0AEiUNzSVLSJGBZQKmejsuNQirEKofeBIqPAE+DqcIHfEZPm02JVLr+dFykhRL yruQ== 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=CXyrhp6VqJgeL6/elgmM8fEowiioTyfg620gHXDRwcg=; fh=QpeTAvHhnTko3wrHMxWRvx4UcZ87hia2zOY3VJVcfak=; b=HB1s0ZeH7Bvhd/JHMojyBbmRS8DR5XYs/XVuewTFx+5VxxO97veshwh21gjD1BFovM SUPtWOUh3QpRLyMkVEXFao31B3oB8wIRoSLiPagdjI38FZh3le4xhk41cKE1d5mv11qm pHSNdF1hKMU7gpt6YWBGxvlzOVHqD1tFqZY/7e5/ueblRoRn1HqiRiObNIKn6rXhhCvL BiKA0Db51N94hCCZDoSnN+5iO3xRU9yih/vNbjG/sCTslcWolhAguWxMDPZ0BORZmPY9 OUYyIJHe8PhD+Nrmv0BcmbLSAGFfNfiGZfBe0ZRDRXWWceu2LcdZy6pXMebyQlfgFi7F cPmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fuKBlV2w; 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 vq23-20020a05620a559700b00767f1da20c3si5674200qkn.500.2023.11.06.10.52.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Nov 2023 10:52:38 -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=fuKBlV2w; 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 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Laurent Vivier , =?utf-8?q?Alex_Benn=C3=A9e?= , Mahmoud Mandour , Cleber Rosa , Wainer dos Santos Moschetta , Paolo Bonzini , Thomas Huth , Beraldo Leal , Alexandre Iooss , John Snow , =?utf-8?q?Daniel_P=2E_Berrang=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 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+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: <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; 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')