From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id geS0DiH6mmrw5CgAWB0awg (envelope-from ) for ; Fri, 04 Sep 2026 13:04:33 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=CKFJQ7gO; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 3659F1E033; Fri, 04 Sep 2026 13:04:33 -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 9731F1E033 for ; Fri, 04 Sep 2026 13:04:31 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4DE324BB58AE for ; Fri, 4 Sep 2026 17:04:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4DE324BB58AE Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=CKFJQ7gO Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 05A624BB58A8 for ; Fri, 4 Sep 2026 17:03:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 05A624BB58A8 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 05A624BB58A8 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788541435; cv=none; b=csqOJ/Re9f1HzP26pvcROjt1qVw+lZ3bstyJr6NAECqjHk6fuGtLrJIl8aAWP9XP7CcQyVV5JoqrZEW0xCtEKPzfOWqpSwz3ECEvXcdTvidP+A+2BAwJ/6aZpRSeWX2CtSCdJGPegn04rxmvVSFO8duoU0HohPfHPS9YdA08QWM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788541435; c=relaxed/simple; bh=OZWNv8LvwrCt0NfDBM2CUiF9n9odB3QwLegCREVP4wo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=bWf8Hwj51zq+fs9/2uW0izFHgIE5TUFWHTfgM14Ccv45Yszt++8GloBk2LHWTiaBFpxTnJvGNHDn1H+O3+ekZDbh497xr2B9FRCujFmjPP3TJeszA3fLAOiSXiC08TrZF3/rt9+Mxlg0GF1/+YYeXiY8FU0wX1x9aNuCcOPlH20= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=CKFJQ7gO DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 05A624BB58A8 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 684H3lcc141082 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Sep 2026 13:03:52 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 684H3lcc141082 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1788541432; bh=XF4vSFxTHme5lvxSSGSgd3k/y8i+Wpb0Z5+jH5l+NO8=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=CKFJQ7gOSr0uAOQrXPBWbyFQXjPlAx4txBv77tVjug+VSeO/PCHs+rGxhmWKHLRsQ oui7fVzmPydqumN3Uu6DLC5+T/l9yRr8tMdpCe63b0G8bm2hOJm9Aza2dprEZwizvh r3Wqht1pWEm1gW2r5PRl6YdkS7Yaqq22xgVD3VlmoZZUcBKN2cWSs4blLddbuuHJm2 /mmI12XcPufuat6uooWksj8QvP9MDb2nIjFM1snholfJSHfff/gp7/v3dBkcuIfd3Q yDOsGrOrHI6rec5ffq0Zkcrsmlu8BLGfnf1+KTNjpMhPSi9P3whg6XCU9ogUPxvK9x dMacwQP2/TdkQ== Received: by simark.ca (Postfix) id D5FFE1E167; Fri, 04 Sep 2026 13:03:46 -0400 (EDT) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 03/17] gdb: suffix flex/bison output files with -gen.c Date: Fri, 4 Sep 2026 12:56:35 -0400 Message-ID: <20260904170338.1643894-4-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260904170338.1643894-1-simon.marchi@polymtl.ca> References: <20260904170338.1643894-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 4 Sep 2026 17:03:47 +0000 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 From: Simon Marchi We already have some generated files using the -gen.c suffix. I think it's useful to quickly spot that a file is generated and should generally not be modified by hand. Change the output bison files to use that suffix too, as well as ada-lex.c while at it. The other reason I want to do this change is that I want to move as much C++ code out of the .y files, into dedicated C++ files. Logically, I would move code out from foo-exp.y into a new file called foo-exp.c. Naming the generated file foo-exp-gen.c instead of foo-exp.c allows me to do this. Until now, our own %.c: %.y and %.c: %.l pattern rules overrode make's built-in rules of the same name. Renaming ours to %-gen.c re-enables the built-in ones, which is a problem for my intended use case of having a hand-written /foo-exp.c, as make would generate /foo-exp.c from /foo-exp.y, thus hiding /foo-exp.c. Cancel the built-in rules to avoid this. Change-Id: I2a80e9e4c73c6a19b0e5a86b1eb2e28b9e9ee6bb --- gdb/.gitignore | 18 ++++++++--------- gdb/Makefile.in | 53 ++++++++++++++++++++++++++++--------------------- gdb/ada-exp.y | 4 ++-- 3 files changed, 41 insertions(+), 34 deletions(-) diff --git a/gdb/.gitignore b/gdb/.gitignore index a68ed4e33178..c4d0f0595448 100644 --- a/gdb/.gitignore +++ b/gdb/.gitignore @@ -5,16 +5,16 @@ /version.c /xml-builtin.c -/ada-exp.c -/ada-lex.c -/c-exp.c -/cp-name-parser.c -/d-exp.c -/f-exp.c +/ada-exp-gen.c +/ada-lex-gen.c +/c-exp-gen.c +/cp-name-parser-gen.c +/d-exp-gen.c +/f-exp-gen.c /gdb /gcore -/go-exp.c +/go-exp-gen.c /init.c /jit-reader.h -/m2-exp.c -/p-exp.c +/m2-exp-gen.c +/p-exp-gen.c diff --git a/gdb/Makefile.in b/gdb/Makefile.in index d1574ec2d2cb..aeafb9394d7b 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -128,8 +128,8 @@ COMPILE = $(ECHO_CXX) $(COMPILE.pre) $(INTERNAL_CFLAGS) $(CXXFLAGS) \ YACC = @YACC@ -# This is used to rebuild ada-lex.c from ada-lex.l. If the program is -# not defined, but ada-lex.c is present, compilation will continue, +# This is used to rebuild ada-lex-gen.c from ada-lex.l. If the program +# is not defined, but ada-lex-gen.c is present, compilation will continue, # possibly with a warning. FLEX = flex @@ -2058,19 +2058,19 @@ REQUIRED_SUBDIRS = doc | testsuite | data-directory # Parser intermediate files. YYFILES = \ - ada-exp.c \ - ada-lex.c \ - c-exp.c \ - cp-name-parser.c \ - d-exp.c \ - f-exp.c \ - go-exp.c \ - m2-exp.c \ - p-exp.c - -# ada-lex.c is included by another file, so it shouldn't wind up as a -# .o itself. -YYOBJ = $(filter-out ada-lex.o,$(patsubst %.c,%.o,$(YYFILES))) + ada-exp-gen.c \ + ada-lex-gen.c \ + c-exp-gen.c \ + cp-name-parser-gen.c \ + d-exp-gen.c \ + f-exp-gen.c \ + go-exp-gen.c \ + m2-exp-gen.c \ + p-exp-gen.c + +# ada-lex-gen.c is included by another file, so it shouldn't wind up as +# a .o itself. +YYOBJ = $(filter-out ada-lex-gen.o,$(patsubst %.c,%.o,$(YYFILES))) # Things which need to be built when making a distribution. @@ -2079,7 +2079,7 @@ DISTSTUFF = $(YYFILES) # All generated files which can be included by another file. generated_files = \ - ada-lex.c \ + ada-lex-gen.c \ config.h \ jit-reader.h \ $(NAT_GENERATED_FILES) \ @@ -2339,7 +2339,7 @@ INIT_FILES_FILTER_OUT = \ INIT_FILES = \ $(patsubst %.o,%.c, \ - $(patsubst %-exp.o,%-exp.y, \ + $(patsubst %-exp-gen.o,%-exp.y, \ $(filter-out $(INIT_FILES_FILTER_OUT), $(COMMON_OBS)))) init.c: stamp-init; @true @@ -2678,15 +2678,22 @@ po/$(PACKAGE).pot: force # # YACC/LEX dependencies # -# LANG-exp.c is generated in objdir from LANG-exp.y if it doesn't -# exist in srcdir, then compiled in objdir to LANG-exp.o. If we -# said LANG-exp.c rather than ./c-exp.c some makes would -# sometimes re-write it into $(srcdir)/c-exp.c. Remove bogus +# LANG-exp-gen.c is generated in objdir from LANG-exp.y if it doesn't +# exist in srcdir, then compiled in objdir to LANG-exp-gen.o. If we +# said LANG-exp-gen.c rather than ./c-exp-gen.c some makes would +# sometimes re-write it into $(srcdir)/c-exp-gen.c. Remove bogus # decls for malloc/realloc/free which conflict with everything else. -# Strictly speaking c-exp.c should therefore depend on +# Strictly speaking c-exp-gen.c should therefore depend on # Makefile.in, but that was a pretty big annoyance. +# Cancel make's built-in rules for producing a .c file from a .y or .l +# file, to avoid them producing a /foo-exp.c file from +# /foo-exp.y, when we also have a hand-written /foo-exp.c +# file. %.c: %.y +%.c: %.l + +%-gen.c: %.y $(ECHO_YACC) $(SHELL) $(YLWRAP) $< y.tab.c $@.tmp -- \ $(YACC) $(YFLAGS) || (rm -f $@.tmp; false) @sed -e '/extern.*malloc/d' \ @@ -2705,7 +2712,7 @@ po/$(PACKAGE).pot: force < $@.tmp > $@.new && \ rm -f $@.tmp && \ mv $@.new $@ -%.c: %.l +%-gen.c: %.l $(ECHO_LEX) $(FLEX) -t $< > $@.tmp || (rm -f $@.tmp; false) @sed -e '/extern.*malloc/d' \ -e '/extern.*realloc/d' \ diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 7fd0e6d7c7db..bffe94a8de9b 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -1234,7 +1234,7 @@ primary : '*' primary %prec '.' %% -/* yylex defined in ada-lex.c: Reads one token, getting characters */ +/* yylex defined in ada-lex-gen.c: Reads one token, getting characters */ /* through lexptr. */ /* Remap normal flex interface names (yylex) as well as gratuitously */ @@ -1254,7 +1254,7 @@ primary : '*' primary %prec '.' /* The following kludge was found necessary to prevent conflicts between */ /* defs.h and non-standard stdlib.h files. */ #define qsort __qsort__dummy -#include "ada-lex.c" +#include "ada-lex-gen.c" int ada_parse (struct parser_state *par_state) -- 2.55.0