From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id z4BuDUpZj2rQdwQAWB0awg (envelope-from ) for ; Wed, 26 Aug 2026 17:23:22 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=kEnmKYxN; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Kne0E1Vf; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Vfglq32f; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=63in+Uyl; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 231E11E0A3; Wed, 26 Aug 2026 17:23:22 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 43A081E033 for ; Wed, 26 Aug 2026 17:23:19 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5220F4BA9011 for ; Wed, 26 Aug 2026 21:23:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5220F4BA9011 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=kEnmKYxN; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Kne0E1Vf; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Vfglq32f; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=63in+Uyl Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 1683A4BA2E39 for ; Wed, 26 Aug 2026 21:22:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1683A4BA2E39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1683A4BA2E39 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787779339; cv=none; b=VBissBqSssBlLqHlti87u0gbQybItUDCqY4t5t423MGWpeO/BNyvYZp7phzo/FzqRZzXxKIoRp3ZsMfvikqrK6+yVFVOcuvE+E8fFZ+YdJi8cxhlQNZIWmGYdw5LQIKBYlLyYJQbAeLh6ZHz9GO7xP0O8SRTd0HZrQPVAfJR00c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787779339; c=relaxed/simple; bh=cm0nzXhZcNXGHAg+55QB+tUkmI9KMpONmqPwC9o3ueU=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=BJA61SICCGV8pH/5YdbjawyagrktbfR9QoGgTjtWYsdSP1YTix7InWXuw0T+iiLMFGW8fxQK2KDQH2a/lNaFD4ldzvNwYgeEYz7+3glraOQTMVKkySlxmrXg+9MGOWJcqDsvTzMQO8RCgQhjBVNRazVOU8uMuztmXLAT9SLiN20= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=kEnmKYxN; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Kne0E1Vf; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Vfglq32f; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=63in+Uyl DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1683A4BA2E39 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D1BF621172 for ; Wed, 26 Aug 2026 21:22:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787779334; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QMD0fTXtlUlnXSDn0DZptAcZ8rck4L+2MbnJmgdwH6c=; b=kEnmKYxNAKuBXdSVZ4wjJu1bUmiV4a9hJSXeWSBtkBxEWtvSTCnxfqiZRP3oJUW5pR6h4M e9zZapRhI4GxyH0LydIeH34Fzl7IULsGLAZQogR3OnFTJiO+kj5QymuS1hQgRijJn/6Ltf IKL1rXNG3EVdkJJHEvYDbI8PtM6m59c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787779334; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QMD0fTXtlUlnXSDn0DZptAcZ8rck4L+2MbnJmgdwH6c=; b=Kne0E1VfC5iK4nFULnfdZwWQRnMBIQzW6aLdPmxS6T/Xj1ux3JCAd6n03TzI1GiOyTk9vR Mxb+ZUi5e76dvUCg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787779329; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QMD0fTXtlUlnXSDn0DZptAcZ8rck4L+2MbnJmgdwH6c=; b=Vfglq32fWNHk0YLz91POkqRiq+vPbvQicNZPi8Pp0h8cgL/gNAEVNOEcN2NG8HfiBKHOYb 6VoQ8PZiJ9VMay9KfOTJnqamk953bcakvhkRz4TrjnEk6u3gXDtN6yK/sQehag50qVPvza GpVnL8k2JV6ffPgeo7sSBzB7hGNLTVU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787779329; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QMD0fTXtlUlnXSDn0DZptAcZ8rck4L+2MbnJmgdwH6c=; b=63in+UylQaiUqnTD5Be08p92BSApGyDkGO2a9/hDqu/FSgyl4Ho/X+n2lPEZI893oWdX0o tt2jBa7yNlEyOuBQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B98541361C for ; Wed, 26 Aug 2026 21:22:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id gNcXLAFZj2q+OAAAD6G6ig (envelope-from ) for ; Wed, 26 Aug 2026 21:22:09 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH v2 1/5] [pre-commit] Check xml files Date: Wed, 26 Aug 2026 23:22:05 +0200 Message-ID: <20260826212209.925066-2-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260826212209.925066-1-tdevries@suse.de> References: <20260826212209.925066-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[gnome.org:url,gnu.org:url,suse.de:mid,xmllint.sh:url,imap1.dmz-prg2.suse.org:helo]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; RCVD_TLS_ALL(0.00)[] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Add two pre-commit checks to check xml files (*.xml, *.xsl and ./gdb/doc/stack_frame.svg). The first one is check-xml [1]. This just checks for well-formedness. It's enabled by default. The second one is xmllint [2]. This has more elaborate checks. But because it's C-based, it's not enabled by default. [1] https://github.com/pre-commit/pre-commit-hooks#check-xml [2] https://gnome.pages.gitlab.gnome.org/libxml2/xmllint.html --- .pre-commit-config.yaml | 27 +++++++++++++ gdb/contrib/xmllint.sh | 87 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100755 gdb/contrib/xmllint.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 53e4c5033c1..622d56936fb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -109,6 +109,19 @@ repos: - id: yamllint files: '^\.pre-commit-config.yaml$' + # Out-of-the-box hooks. + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + # This just checks for well-formedness. For better xml checking, see + # xmllint (disabled by default) below. + - id: &id5 check-xml + name: *id5 + files: &gdb_xml_files '^(gdb|gdbserver|gdbsupport)/.*\.(xml|xsl|svg)$' + # Exclude: + # - gdb.xml/tdesc-bogus.xml (malformed) + exclude: ^gdb/testsuite/gdb.xml/tdesc-bogus.xml$ + # Local hooks. - repo: local hooks: @@ -146,6 +159,20 @@ repos: language: unsupported_script entry: gdb/contrib/check-file-mode.sh files: *gdb_files + - id: &id6 xmllint + name: *id6 + # The xmllint.sh script calls xmllint. Users need to install xmllint + # and its dependencies. It's not clear what the supported versions + # are, but this has been tested with libxml version 21308. + language: unsupported_script + entry: gdb/contrib/xmllint.sh + files: *gdb_xml_files + # Disabled by default, because pre-commit doesn't install xmllint for + # you. To use this hook, do: + # $ pre-commit run --hook-stage manual xmllint --files ... + # $ pre-commit run --hook-stage manual xmllint --all-files + # or similar. + stages: [manual] # Local Variables: # indent-tabs-mode: nil diff --git a/gdb/contrib/xmllint.sh b/gdb/contrib/xmllint.sh new file mode 100755 index 00000000000..748e096bbef --- /dev/null +++ b/gdb/contrib/xmllint.sh @@ -0,0 +1,87 @@ +#!/bin/sh + +# Copyright (C) 2026 Free Software Foundation, Inc. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Wrapper around xmllint to make it exit with non-zero if there is any output. + +tmp="" + +cleanup() +{ + if [ "$tmp" != "" ]; then + rm -f "$tmp" + fi +} + +# Schedule cleanup. +trap cleanup EXIT + +tmp=$(mktemp) + +check_basic="" +check_includes="" +for f in "$@"; do + case $f in + gdb/testsuite/gdb.xml/tdesc-bogus.xml) + # Malformed. + continue + ;; + gdb/testsuite/gdb.xml/bad-include.xml \ + | gdb/testsuite/gdb.xml/core-only.xml \ + | gdb/testsuite/gdb.xml/extra-regs.xml \ + | gdb/testsuite/gdb.xml/loop.xml) + # Don't check includes for: + # - gdb.xml/bad-include.xml (XInclude error: nonexistent.xml) + # - gdb.xml/{core-only,extra-regs}.xml (XInclude error: core-regs.xml) + # - gdb.xml/loop.xml (XInclude error: loop.xml) + check_basic="$check_basic $f" + ;; + *) + check_includes="$check_includes $f" + ;; + esac +done + +st1=0 +if [ "$check_basic" != "" ]; then + xmllint --noout \ + $check_basic \ + > "$tmp" \ + 2>&1; st1=$? +fi + +st2=0 +if [ "$check_includes" != "" ]; then + # Provide the --path parts to let xmllint find the .dtd files. + xmllint --noout --xinclude --path gdb/syscalls --path gdb/features \ + $check_includes \ + >> "$tmp" \ + 2>&1; st2=$? +fi + +if [ $st1 -eq 0 ] && [ $st2 -eq 0 ]; then + st=0 +else + st=1 +fi + +if [ -s "$tmp" ]; then + cat "$tmp" + if [ $st -eq 0 ]; then + st=1 + fi +fi + +exit $st -- 2.51.0