[PATCH] [gdb/build] Rename gdb/gdb-gdb.py.in to gdb/gdb-gdb.py

Tom de Vries <[email protected]>
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
Currently, $build/gdb/gdb-gdb.py is generated from $src/gdb/gdb-gdb.py.in, but
there's no real need for it: they are identical.

Fix this by:
- renaming gdb/gdb-gdb.py.in to gdb/gdb-gdb.py
- using AC_CONFIG_LINKS to get $build/gdb/gdb-gdb.py

Because pre-commit type classification does not consider gdb/gdb-gdb.py.in a
python file:
...
$ identify-cli gdb/gdb-gdb.py.in
["file", "non-executable", "text"]
...
.pre-commit-config.yaml has a types_or override to stop pre-commit from
ignoring the file.  Unfortunately, that never worked for flake8, which needed
a types override instead [1].

Update .pre-commit-config.yaml to reflect the new situation:
- drop the files match for gdb/gdb-gdb.py.in
- drop the types_or override that's no longer necessary

Tested on x86_64-linux, by doing a clean build and testing gdb.gdb/*.exp.

Suggested-By: Simon Marchi <[email protected]> [1]

[1] https://sourceware.org/pipermail/gdb-patches/2026-August/229394.html
---
 .pre-commit-config.yaml                 | 9 +--------
 gdb/Makefile.in                         | 7 ++-----
 gdb/configure                           | 6 ++++--
 gdb/configure.ac                        | 3 ++-
 gdb/{gdb-gdb.py.in => gdb-gdb.py}       | 0
 gdb/testsuite/gdb.gdb/python-helper.exp | 8 +++++++-
 6 files changed, 16 insertions(+), 17 deletions(-)
 rename gdb/{gdb-gdb.py.in => gdb-gdb.py} (100%)

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 3cccec45ef7..bd392a57514 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -48,32 +48,25 @@ default_stages: [pre-commit]
 repos:
   # Python hooks.  Run these for (in glob notation):
   #
-  #  - gdb/gdb-gdb.py.in
   #  - gdb/*.py
   #  - gdb/python/**/*.py
   #  - gdb/testsuite/*.py
   #
-  # Because gdb/gdb-gdb.py.in is not classified as python, we use
-  # 'types_or: [file]' to override the default type for these hooks.
-  #
   - repo: https://github.com/psf/black-pre-commit-mirror
     rev: 26.5.1
     hooks:
       - id: black
-        types_or: &gdb_python_types [file]
-        files: &gdb_python_files '^gdb/.*\.py(\.in)?$'
+        files: &gdb_python_files '^gdb/.*\.py$'
   - repo: https://github.com/pycqa/flake8
     rev: 7.3.0
     hooks:
       - id: flake8
-        types_or: *gdb_python_types
         files: *gdb_python_files
         args: [--config, gdb/setup.cfg]
   - repo: https://github.com/pycqa/isort
     rev: 9.0.0b1
     hooks:
       - id: isort
-        types_or: *gdb_python_types
         files: *gdb_python_files
         # Isort's .pre-commit-hooks.yaml sets stages, overriding default_stages,
         # so this hook needs an explicit setting.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 57f384170ab..2e2c4e20797 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2088,7 +2088,7 @@ generated_files = \
 # Flags needed to compile Python code
 PYTHON_CFLAGS = @PYTHON_CFLAGS@
 
-all: gdb$(EXEEXT) $(CONFIG_ALL) gdb-gdb.py gdb-gdb.gdb gcore gstack gdb-add-index
+all: gdb$(EXEEXT) $(CONFIG_ALL) gdb-gdb.gdb gcore gstack gdb-add-index
 	@$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=$(SUBDIRS)" subdir_do
 
 # Rule for compiling .c files in the top-level gdb directory.
@@ -2425,7 +2425,7 @@ clean mostlyclean: $(CONFIG_CLEAN)
 distclean: clean
 	@$(MAKE) $(FLAGS_TO_PASS) DO=distclean "DODIRS=$(CLEANDIRS)" subdir_do
 	rm -f nm.h config.status config.h stamp-h b jit-reader.h gcore gstack gstack.in stamp-nmh
-	rm -f gdb-gdb.py gdb-gdb.gdb
+	rm -f gdb-gdb.gdb
 	rm -f y.output yacc.acts yacc.tmp y.tab.h
 	rm -f config.log config.cache
 	rm -f config.lt libtool
@@ -2494,9 +2494,6 @@ gstack gcore gdb-add-index: % : %.in version.c
 	sed -e "s,@VERSION@,$$vv," $< > $@
 	@chmod +x $@
 
-gdb-gdb.py: $(srcdir)/gdb-gdb.py.in config.status
-	$(ECHO_GEN) $(SHELL) config.status $(SILENT_FLAG) $@
-
 gdb-gdb.gdb: $(srcdir)/gdb-gdb.gdb.in config.status
 	$(ECHO_GEN) $(SHELL) config.status $(SILENT_FLAG) $@
 
diff --git a/gdb/configure b/gdb/configure
index 303d6ea011c..c95499df3f8 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -33715,7 +33715,9 @@ ac_config_files="$ac_config_files gstack.in:gstack-1.in"
 
 ac_config_files="$ac_config_files gdb-add-index.in:contrib/gdb-add-index.sh"
 
-ac_config_files="$ac_config_files Makefile gdb-gdb.gdb gdb-gdb.py doc/Makefile data-directory/Makefile"
+ac_config_files="$ac_config_files Makefile gdb-gdb.gdb doc/Makefile data-directory/Makefile"
+
+ac_config_links="$ac_config_links gdb-gdb.py:gdb-gdb.py"
 
 
 cat >confcache <<\_ACEOF
@@ -34815,9 +34817,9 @@ do
     "gdb-add-index.in") CONFIG_FILES="$CONFIG_FILES gdb-add-index.in:contrib/gdb-add-index.sh" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "gdb-gdb.gdb") CONFIG_FILES="$CONFIG_FILES gdb-gdb.gdb" ;;
-    "gdb-gdb.py") CONFIG_FILES="$CONFIG_FILES gdb-gdb.py" ;;
     "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
     "data-directory/Makefile") CONFIG_FILES="$CONFIG_FILES data-directory/Makefile" ;;
+    "gdb-gdb.py") CONFIG_LINKS="$CONFIG_LINKS gdb-gdb.py:gdb-gdb.py" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
   esac
diff --git a/gdb/configure.ac b/gdb/configure.ac
index e55a733fba7..7ad12702786 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -2403,6 +2403,7 @@ GDB_AC_TRANSFORM([gcore], [GCORE_TRANSFORM_NAME])
 AC_CONFIG_FILES([gcore.in:gcore-1.in])
 AC_CONFIG_FILES([gstack.in:gstack-1.in])
 AC_CONFIG_FILES([gdb-add-index.in:contrib/gdb-add-index.sh])
-AC_CONFIG_FILES([Makefile gdb-gdb.gdb gdb-gdb.py doc/Makefile data-directory/Makefile])
+AC_CONFIG_FILES([Makefile gdb-gdb.gdb doc/Makefile data-directory/Makefile])
+AC_CONFIG_LINKS([gdb-gdb.py:gdb-gdb.py])
 
 AC_OUTPUT
diff --git a/gdb/gdb-gdb.py.in b/gdb/gdb-gdb.py
similarity index 100%
rename from gdb/gdb-gdb.py.in
rename to gdb/gdb-gdb.py
diff --git a/gdb/testsuite/gdb.gdb/python-helper.exp b/gdb/testsuite/gdb.gdb/python-helper.exp
index d1cca48cbb8..d84e4816699 100644
--- a/gdb/testsuite/gdb.gdb/python-helper.exp
+++ b/gdb/testsuite/gdb.gdb/python-helper.exp
@@ -29,10 +29,16 @@ if { [build_executable "failed to build" $testfile $srcfile {debug c++}] } {
     return
 }
 
+proc file_or_link {f} {
+    set type [file type $f]
+    return [expr {[string eq $type "file"] \
+		      || [string eq $type "link"]}]
+}
+
 # Find the helper script in the GDB build directory.
 set py_helper_script [file dirname $GDB]/gdb-gdb.py
 if { ![file readable $py_helper_script] \
-	 || [file type $py_helper_script] != "file" } {
+	 || ![file_or_link $py_helper_script] } {
     untested "failed to find gdb-gdb.py helper script"
     return
 }

base-commit: f33422af6d81c623871f1407e2fce0794e90739a
-- 
2.51.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.