From patchwork Fri Nov 3 19:59:35 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: 740717 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp9602wrr; Fri, 3 Nov 2023 13:05:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgETNRmBSMLcQPAEeRUbux50oWBS7VMLtUP7GLdYStkTsjma8sdr19B3NiQLzYy6P5pqqW X-Received: by 2002:a05:620a:f0d:b0:77a:1fc7:a5d4 with SMTP id v13-20020a05620a0f0d00b0077a1fc7a5d4mr20834009qkl.34.1699041900345; Fri, 03 Nov 2023 13:05:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041900; cv=none; d=google.com; s=arc-20160816; b=wHTNsi65BcArjihIMToaxvcfDSoY1Gqzlayh9qGsEOPeT6RzdrGz+jD49ZslEg0yDP XKHNsLXMWk425R4b0Yh4L5R4wspYZv2t1bxLJWsrckeqRXQYnH/UzHfrBIznOkTr7UAF oJJpHC0rBMa+J1IDLaO69IDUG/P45r9NnoLBIZdjLNoa9KmVQcGxLWXCbS77noFtWvuC ZR2XBUiZXZYJg5SOBMWuSlNmOkteFGwSjN2eQyN4DVLKpGHONDDxaWw3Du8cHd4AFsjv jr67P/EB4s/gepToPH9ROku2Y9XGrDRw+JCB3tEb/2DEvxl6cokbhmLDvvmVt+/7OVa2 zY6Q== 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=gQBmthjE4Bad5l9sCVp+GlTua9zlFcXkP6f/oLdBKC4=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=nHs8uYRqlPr3uWj0eKAFeFD0Mi/c0JJIrPkGWqnrLxr5DluUX8xxcy5jeZw9vykShY fW3AK8nHMMPnnwB46kKGTNteCOlpcqZeyIbZuGytWNLfONPotAsif2yeoqBcdF7fVLvY pq1aJ8sHn2iMEGk+/1luSF2FBJIM9AKbVzw/tT9BkYEloninVnhr8lCNQAC4SSdZW3vl yWAwXosiw7OBCHuXBLje/PzR4YeO7i69ndYjd4wXINtNUbhJSZ4FoE8xk5VZtgDsdSm0 lYzY5HLda1vxbnIrtBzYBRkr6i//zX/34piePgAYzPrf8+Kcv4zTQajf5zXQ4V6hYW0C 387g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Uiu1e0lK; 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 pr13-20020a05620a86cd00b00776f8b50c40si2074614qkn.201.2023.11.03.13.05.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:05:00 -0700 (PDT) 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=Uiu1e0lK; 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 1qz0Lp-0000R6-0Q; Fri, 03 Nov 2023 16:01:05 -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 1qz0L6-0008E7-HZ for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:31 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Kt-0005Zo-I4 for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:19 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4084095722aso18038505e9.1 for ; Fri, 03 Nov 2023 13:00:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041605; x=1699646405; 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=gQBmthjE4Bad5l9sCVp+GlTua9zlFcXkP6f/oLdBKC4=; b=Uiu1e0lKk26Ch7mB6iK5CApVrS6He7SykNOKdw3a8K78Guha2Vp+hXduSQxi5pmcKs U7Oa19GOg+8bZ3Th1l0N/PZiUCCd+mCodQLGz8MDA8sMiNymp+B5IANDQEcFIXRQoEIz cgRPD+qbHJjnuz27q1kVPX0mk8xqX5GvDAWVbpfS2QmLwUjeVSwSshmzzTx+r5HmNbdh kaiUW4KJNOq51ApccZ/DrJqBH5yidQqdJcL5E77ze7pTila/5dKhwG6BhH8piFZtIW2E uiC8nGjZJhZZO0TlHZ6iGjmRFOGH2kIV9ONBLFnUzha9pk1MWYRUzJtoWjtCcVyoViwC rZZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041605; x=1699646405; 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=gQBmthjE4Bad5l9sCVp+GlTua9zlFcXkP6f/oLdBKC4=; b=bgXKnwH9/CsGXxAfld0fewJuQWE/g+MdM8AMvB5yIAkVBRJ24a4hLfx+u5NHNId4Va x4aQBbwevaiObPGq9hQGi96Xd9EQAtFZ82iT+d95NTnsK09yXhvq6Dknm9s1Ruvt6Zgx WGvqpaLA3zpA9R+A74+o4AUGcBecple4+O12i7PQOvIlIspRiViI548xNpN6gHwoe02X PASwQq4b0hwuPa1OOm26NBqunCObQrYKO5lJo1jVVgOS86r5yUA7qoEgwhtJhzVvX1Hb 3n9mK65cFZDFyGOkuoHk82VPZzI/F0pc3vtD3ZLudj96XlGxDlqSezx6uifv9RTgyc4V Z+5w== X-Gm-Message-State: AOJu0Yz/ToXpqw61NgWnQ1TdNRw3XkhM0D5uII4Gfmh2iRr8NtZ+sAT3 Y4+MDJUHEklZ4KAoH+H/Ve4kCA== X-Received: by 2002:a05:600c:d8:b0:409:718b:33e0 with SMTP id u24-20020a05600c00d800b00409718b33e0mr2193666wmm.16.1699041605356; Fri, 03 Nov 2023 13:00:05 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id f14-20020a05600c154e00b004097881d7a8sm385873wmg.0.2023.11.03.12.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:00:00 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 6EDA865747; Fri, 3 Nov 2023 19:59:57 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 08/29] gdbstub: Add num_regs member to GDBFeature Date: Fri, 3 Nov 2023 19:59:35 +0000 Message-Id: <20231103195956.1998255-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.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 --- 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')