gdbserver: Suffix generated C files with -generated
Commit Message
I noticed that there were some missing files in gdbserver's gitignore
(some generated register format .c files). Of course the easy fix would
be to add those files to .gitignore, but I think we can do a better job,
so that we don't have to worry about adding generated files to
.gitignore or the clean Makefile target.
I suggest naming all generated source files -generated.c. This way, we
can use a single rule in .gitignore and do a "rm -f *-generated.c" to
clean them up.
gdb/gdbserver/ChangeLog:
* .gitignore: Remove generated files, replace with wildcard.
* Makefile.in (OBS): Change version.o to version-generated.o.
(GDBREPLAY_OBS): Likewise.
(clean): Replace removal of generated files with wildcard.
(version.c): Replace with...
(version-generated.c): ...this.
(xml-builtin.c): Replace with...
(xml-builtin-generated.c): ...this.
(%-ipa.o: %-generated.c, %.o: %-generated.c): New rules.
(%.c: *regformats*): Replace with...
(%-generated.c: *regformats*): ...this.
* configure.ac: Update xml-builtin.o to xml-builtin-generated.o.
* configure: Re-generate.
---
gdb/gdbserver/.gitignore | 18 +-----------
gdb/gdbserver/Makefile.in | 72 ++++++++++++++--------------------------------
gdb/gdbserver/configure | 8 +++---
gdb/gdbserver/configure.ac | 2 +-
4 files changed, 28 insertions(+), 72 deletions(-)
Comments
On 2017-03-29 23:14, Simon Marchi wrote:
> diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
> index 6ae486539f..44a44f4712 100755
> --- a/gdb/gdbserver/configure
> +++ b/gdb/gdbserver/configure
> @@ -7498,9 +7498,9 @@ _ACEOF
> fi
>
>
> -# See if <sys/user.h> supports the %fs_base and %gs_base amd64 segment
> -# registers. Older amd64 Linux's don't have the fs_base and gs_base
> -# members of `struct user_regs_struct'.
> +# See if <sys/user.h> supports the %fs_base and %gs_bas amd64 segment
> registers.
> +# Older amd64 Linux's don't have the fs_base and gs_base members of
> +# `struct user_regs_struct'.
> ac_fn_c_check_member "$LINENO" "struct user_regs_struct" "fs_base"
> "ac_cv_member_struct_user_regs_struct_fs_base" "#include <sys/user.h>
> "
> if test "x$ac_cv_member_struct_user_regs_struct_fs_base" = x""yes;
> then :
> @@ -8252,7 +8252,7 @@ $as_echo "#define USE_LIBTHREAD_DB_DIRECTLY 1"
> >>confdefs.h
> fi
>
> if test "$srv_xmlfiles" != ""; then
> - srv_xmlbuiltin="xml-builtin.o"
> + srv_xmlbuiltin="xml-builtin-generated.o"
Hmm actually we don't need to rename this, the other .o files are not
named -generated. You can forget changes to configure/configure.ac (I
removed them locally).
Hi Simon,
On 03/30/2017 04:31 AM, Simon Marchi wrote:
>> @@ -8252,7 +8252,7 @@ $as_echo "#define USE_LIBTHREAD_DB_DIRECTLY 1"
>> >>confdefs.h
>> fi
>>
>> if test "$srv_xmlfiles" != ""; then
>> - srv_xmlbuiltin="xml-builtin.o"
>> + srv_xmlbuiltin="xml-builtin-generated.o"
>
> Hmm actually we don't need to rename this, the other .o files are not
> named -generated. You can forget changes to configure/configure.ac (I
> removed them locally).
I'm confused on what the result will be. The patch had this in Makefile.in,
for example:
- version.o \
+ version-generated.o \
Can you post the updated patch?
Thanks,
Pedro Alves
On 2017-03-31 08:23, Pedro Alves wrote:
> Hi Simon,
>
> On 03/30/2017 04:31 AM, Simon Marchi wrote:
>
>>> @@ -8252,7 +8252,7 @@ $as_echo "#define USE_LIBTHREAD_DB_DIRECTLY 1"
>>> >>confdefs.h
>>> fi
>>>
>>> if test "$srv_xmlfiles" != ""; then
>>> - srv_xmlbuiltin="xml-builtin.o"
>>> + srv_xmlbuiltin="xml-builtin-generated.o"
>>
>> Hmm actually we don't need to rename this, the other .o files are not
>> named -generated. You can forget changes to configure/configure.ac (I
>> removed them locally).
>
> I'm confused on what the result will be. The patch had this in
> Makefile.in,
> for example:
>
> - version.o \
> + version-generated.o \
>
> Can you post the updated patch?
Ah, yes, same mistake with that one. It probably shouldn't change as
well (although it would still work).
To explain the mistake, I first started changing the pattern to have:
foo-generated.c -> foo-generated.o
But then realized I would have to change everything in configure.srv,
and that would be ugly. So I decided to add the "%.o: %-generated.c"
and "%-ipa.o: %-generated.c" rules instead, which allows keeping the
change to a minimum. I however forgot to change version-generated.o
back to version.o and xml-builtin-generated.o to xml-builtin.o. It
still works, because they get picked up by the "%.o: %.c" rule.
I'll post the updated patch.
Simon
@@ -7,20 +7,4 @@ libinproctrace.so
build-gnulib-gdbserver
build-libiberty-gdbserver
-amd64-avx-linux.c
-amd64-avx-mpx-linux.c
-amd64-avx512-linux.c
-amd64-linux.c
-amd64-mpx-linux.c
-i386-avx-linux.c
-i386-avx-mpx-linux.c
-i386-avx512-linux.c
-i386-linux.c
-i386-mmx-linux.c
-i386-mpx-linux.c
-reg-*.c
-version.c
-x32-avx-linux.c
-x32-avx512-linux.c
-x32-linux.c
-xml-builtin.c
+*-generated.c
@@ -264,14 +264,14 @@ OBS = \
tracepoint.o \
utils.o \
vec.o \
- version.o \
+ version-generated.o \
waitstatus.o \
xml-utils.o \
$(DEPFILES) \
$(LIBOBJS) \
$(XML_BUILTIN)
-GDBREPLAY_OBS = gdbreplay.o version.o
+GDBREPLAY_OBS = gdbreplay.o version-generated.o
GDBSERVER_LIBS = @GDBSERVER_LIBS@
XM_CLIBS = @LIBS@
CDEPS = $(srcdir)/proc-service.list
@@ -413,47 +413,10 @@ tags: TAGS
clean:
rm -f *.o ${ADD_FILES} *~
- rm -f version.c
rm -f gdbserver$(EXEEXT) gdbreplay$(EXEEXT) core make.log
rm -f $(IPA_LIB)
- rm -f aarch64.c
- rm -f reg-arm.c reg-bfin.c i386.c reg-ia64.c reg-m32r.c reg-m68k.c
- rm -f reg-sh.c reg-sparc.c reg-spu.c amd64.c i386-linux.c
- rm -f reg-cris.c reg-crisv32.c amd64-linux.c reg-xtensa.c
- rm -f reg-tilegx.c reg-tilegx32.c
- rm -f arm-with-iwmmxt.c
- rm -f arm-with-vfpv2.c arm-with-vfpv3.c arm-with-neon.c
- rm -f mips-linux.c mips-dsp-linux.c
- rm -f mips64-linux.c mips64-dsp-linux.c
- rm -f nios2-linux.c
- rm -f powerpc-32.c powerpc-32l.c powerpc-64l.c powerpc-e500l.c
- rm -f powerpc-altivec32l.c powerpc-cell32l.c powerpc-vsx32l.c
- rm -f powerpc-altivec64l.c powerpc-cell64l.c powerpc-vsx64l.c
- rm -f powerpc-isa205-32l.c powerpc-isa205-64l.c
- rm -f powerpc-isa205-altivec32l.c powerpc-isa205-vsx32l.c powerpc-isa205-altivec64l.c
- rm -f powerpc-isa205-vsx64l.c
- rm -f s390-linux32.c s390-linux64.c s390x-linux64.c
- rm -f s390-linux32v1.c s390-linux32v2.c s390-linux64v1.c
- rm -f s390-linux64v2.c s390x-linux64v1.c s390x-linux64v2.c
- rm -f s390-te-linux64.c s390x-te-linux64.c
- rm -f s390-vx-linux64.c s390x-vx-linux64.c
- rm -f s390-tevx-linux64.c s390x-tevx-linux64.c
- rm -f tic6x-c64xp-linux.c tic6x-c64x-linux.c tic6x-c62x-linux.c
- rm -f xml-builtin.c stamp-xml
- rm -f i386-avx.c i386-avx-linux.c
- rm -f i386-mpx.c i386-mpx-linux.c
- rm -f i386-avx-mpx.c i386-avx-mpx-linux.c
- rm -f i386-avx-avx512.c i386-avx-avx512-linux.c
- rm -f i386-avx-mpx-avx512-pku.c i386-avx-mpx-avx512-pku-linux.c
- rm -f amd64-avx.c amd64-avx-linux.c
- rm -f amd64-mpx.c amd64-mpx-linux.c
- rm -f amd64-avx-mpx.c amd64-avx-mpx-linux.c
- rm -f amd64-avx-avx512.c amd64-avx-avx512-linux.c
- rm -f amd64-avx-mpx-avx512-pku.c amd64-avx-mpx-avx512-pku-linux.c
- rm -f i386-mmx.c i386-mmx-linux.c
- rm -f x32.c x32-linux.c
- rm -f x32-avx.c x32-avx-linux.c
- rm -f x32-avx-avx512.c x32-avx-avx512-linux.c
+ rm -f *-generated.c
+ rm -f stamp-xml
@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
maintainer-clean realclean distclean: clean
@@ -504,15 +467,15 @@ am--refresh:
force:
-version.c: Makefile $(srcdir)/../version.in $(srcdir)/../../bfd/version.h $(srcdir)/../common/create-version.sh
+version-generated.c: Makefile $(srcdir)/../version.in $(srcdir)/../../bfd/version.h $(srcdir)/../common/create-version.sh
$(SHELL) $(srcdir)/../common/create-version.sh $(srcdir)/.. \
- $(host_alias) $(target_alias) version.c
+ $(host_alias) $(target_alias) $@
-xml-builtin.c: stamp-xml; @true
+xml-builtin-generated.c: stamp-xml; @true
stamp-xml: $(XML_DIR)/feature_to_c.sh Makefile $(XML_FILES)
rm -f xml-builtin.tmp
$(SHELL) $(XML_DIR)/feature_to_c.sh xml-builtin.tmp $(XML_FILES)
- $(SHELL) $(srcdir)/../../move-if-change xml-builtin.tmp xml-builtin.c
+ $(SHELL) $(srcdir)/../../move-if-change xml-builtin.tmp xml-builtin-generated.c
echo stamp > stamp-xml
.PRECIOUS: xml-builtin.c
@@ -552,6 +515,10 @@ ax.o: ax.c
# Rules for objects that go in the in-process agent.
+%-ipa.o: %-generated.c
+ $(IPAGENT_COMPILE) $<
+ $(POSTCOMPILE)
+
%-ipa.o: %.c
$(IPAGENT_COMPILE) $<
$(POSTCOMPILE)
@@ -573,6 +540,10 @@ ax.o: ax.c
# Rules for objects that go in the gdbserver binary.
+%.o: %-generated.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
+
%.o: %.c
$(COMPILE) $<
$(POSTCOMPILE)
@@ -593,18 +564,19 @@ ax.o: ax.c
$(COMPILE) $<
$(POSTCOMPILE)
-# Rules for register format descriptions.
+# Rules for register format descriptions. Suffix destination files with
+# -generated to identify and clean them easily.
-%.c: ../regformats/%.dat | $(regdat_sh)
+%-generated.c: ../regformats/%.dat | $(regdat_sh)
$(SHELL) $(regdat_sh) $< $@
-%.c: ../regformats/arm/%.dat | $(regdat_sh)
+%-generated.c: ../regformats/arm/%.dat | $(regdat_sh)
$(SHELL) $(regdat_sh) $< $@
-%.c: ../regformats/i386/%.dat | $(regdat_sh)
+%-generated.c: ../regformats/i386/%.dat | $(regdat_sh)
$(SHELL) $(regdat_sh) $< $@
-%.c: ../regformats/rs6000/%.dat | $(regdat_sh)
+%-generated.c: ../regformats/rs6000/%.dat | $(regdat_sh)
$(SHELL) $(regdat_sh) $< $@
#
@@ -7498,9 +7498,9 @@ _ACEOF
fi
-# See if <sys/user.h> supports the %fs_base and %gs_base amd64 segment
-# registers. Older amd64 Linux's don't have the fs_base and gs_base
-# members of `struct user_regs_struct'.
+# See if <sys/user.h> supports the %fs_base and %gs_bas amd64 segment registers.
+# Older amd64 Linux's don't have the fs_base and gs_base members of
+# `struct user_regs_struct'.
ac_fn_c_check_member "$LINENO" "struct user_regs_struct" "fs_base" "ac_cv_member_struct_user_regs_struct_fs_base" "#include <sys/user.h>
"
if test "x$ac_cv_member_struct_user_regs_struct_fs_base" = x""yes; then :
@@ -8252,7 +8252,7 @@ $as_echo "#define USE_LIBTHREAD_DB_DIRECTLY 1" >>confdefs.h
fi
if test "$srv_xmlfiles" != ""; then
- srv_xmlbuiltin="xml-builtin.o"
+ srv_xmlbuiltin="xml-builtin-generated.o"
$as_echo "#define USE_XML 1" >>confdefs.h
@@ -383,7 +383,7 @@ if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
fi
if test "$srv_xmlfiles" != ""; then
- srv_xmlbuiltin="xml-builtin.o"
+ srv_xmlbuiltin="xml-builtin-generated.o"
AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
tmp_xmlfiles=$srv_xmlfiles