* [PATCH 3/3] Build gdb "nat" files in subdirectory
2018-12-24 21:09 [PATCH 0/3] some minor Makefile improvements Tom Tromey
@ 2018-12-24 21:09 ` Tom Tromey
2018-12-27 4:29 ` Simon Marchi
2018-12-24 21:10 ` [PATCH 1/3] Remove gdbtypes special case from init.c rule Tom Tromey
2018-12-24 21:10 ` [PATCH 2/3] Make init.c depend on source files Tom Tromey
2 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2018-12-24 21:09 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This moves the various "nat" object files into the nat/ subdirectory.
This allows for the removal of a pattern rule from the gdb Makefile,
which is a small cleanup.
I made the configure.nat change in a (semi-) automated way, hopefully
meaning that it is more likely to be correct than had I done it by
hand.
Eventually I would like for the various configure scripts to only
mention source files, and let the Makefile compute the object file
names.
gdb/ChangeLog
2018-12-24 Tom Tromey <tom@tromey.com>
* configure.nat (NATDEPFILES): Use nat/ prefix.
* Makefile.in (CONFIG_SRC_SUBDIR): Add nat.
(%.o: ${srcdir}/nat/%.c): Remove rule.
(INIT_FILES): Do not filter out NATDEPFILES.
---
gdb/ChangeLog | 7 +++++
gdb/Makefile.in | 9 ++----
gdb/configure.nat | 73 ++++++++++++++++++++++++++---------------------
3 files changed, 50 insertions(+), 39 deletions(-)
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index e4d4a3449d..3111411e9d 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -525,7 +525,8 @@ CONFIG_INSTALL = @CONFIG_INSTALL@
CONFIG_UNINSTALL = @CONFIG_UNINSTALL@
HAVE_NATIVE_GCORE_TARGET = @HAVE_NATIVE_GCORE_TARGET@
-CONFIG_SRC_SUBDIR = arch cli mi common compile tui unittests guile python target
+CONFIG_SRC_SUBDIR = arch cli mi common compile tui unittests guile python \
+ target nat
CONFIG_DEP_SUBDIR = $(addsuffix /$(DEPDIR),$(CONFIG_SRC_SUBDIR))
# -I. for config files.
@@ -1636,10 +1637,6 @@ python/%.o: INTERNAL_CFLAGS += $(PYTHON_CFLAGS)
$(COMPILE) $(all_gdbtk_cflags) $<
$(POSTCOMPILE)
-%.o: ${srcdir}/nat/%.c
- $(COMPILE) $<
- $(POSTCOMPILE)
-
installcheck:
# The check target can not use subdir_do, because subdir_do does not
@@ -1838,7 +1835,7 @@ test-cp-name-parser$(EXEEXT): test-cp-name-parser.o $(LIBIBERTY)
INIT_FILES = \
$(patsubst %.o,%.c, \
$(patsubst %-exp.o,%-exp.y, \
- $(filter-out $(NATDEPFILES) init.o version.o %_S.o %_U.o,\
+ $(filter-out init.o version.o %_S.o %_U.o,\
$(COMMON_OBS))))
init.c: stamp-init; @true
diff --git a/gdb/configure.nat b/gdb/configure.nat
index 200b716924..a38a3380d8 100644
--- a/gdb/configure.nat
+++ b/gdb/configure.nat
@@ -54,40 +54,41 @@
case ${gdb_host} in
*linux*)
NAT_FILE='config/nm-linux.h'
- NATDEPFILES='inf-ptrace.o fork-child.o fork-inferior.o proc-service.o \
- linux-thread-db.o linux-nat.o linux-osdata.o linux-fork.o \
- linux-procfs.o linux-ptrace.o linux-waitpid.o \
- linux-personality.o linux-namespaces.o'
+ NATDEPFILES='inf-ptrace.o fork-child.o nat/fork-inferior.o \
+ proc-service.o \
+ linux-thread-db.o linux-nat.o nat/linux-osdata.o linux-fork.o \
+ nat/linux-procfs.o nat/linux-ptrace.o nat/linux-waitpid.o \
+ nat/linux-personality.o nat/linux-namespaces.o'
NAT_CDEPS='$(srcdir)/proc-service.list'
LOADLIBES='-ldl $(RDYNAMIC)'
;;
fbsd*)
- NATDEPFILES='fork-child.o fork-inferior.o inf-ptrace.o fbsd-nat.o'
+ NATDEPFILES='fork-child.o nat/fork-inferior.o inf-ptrace.o fbsd-nat.o'
HAVE_NATIVE_GCORE_HOST=1
LOADLIBES='-lkvm'
;;
nbsd*)
- NATDEPFILES='fork-child.o fork-inferior.o inf-ptrace.o'
+ NATDEPFILES='fork-child.o nat/fork-inferior.o inf-ptrace.o'
HAVE_NATIVE_GCORE_HOST=1
;;
obsd*)
- NATDEPFILES='fork-child.o fork-inferior.o inf-ptrace.o'
+ NATDEPFILES='fork-child.o nat/fork-inferior.o inf-ptrace.o'
;;
cygwin*)
- NATDEPFILES='x86-nat.o x86-dregs.o windows-nat.o'
+ NATDEPFILES='x86-nat.o nat/x86-dregs.o windows-nat.o'
;;
mingw*)
- NATDEPFILES='x86-nat.o x86-dregs.o windows-nat.o'
+ NATDEPFILES='x86-nat.o nat/x86-dregs.o windows-nat.o'
;;
aix)
- NATDEPFILES='fork-inferior.o fork-child.o inf-ptrace.o'
+ NATDEPFILES='nat/fork-inferior.o fork-child.o inf-ptrace.o'
;;
darwin)
- NATDEPFILES='fork-child.o fork-inferior.o darwin-nat.o \
+ NATDEPFILES='fork-child.o nat/fork-inferior.o darwin-nat.o \
darwin-nat-info.o'
;;
sol2)
- NATDEPFILES='fork-child.o fork-inferior.o \
+ NATDEPFILES='fork-child.o nat/fork-inferior.o \
procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o \
sol-thread.o'
HAVE_NATIVE_GCORE_HOST=1
@@ -145,7 +146,7 @@ case ${gdb_host} in
i386)
# Host: IA86 running Darwin
NATDEPFILES="${NATDEPFILES} i386-darwin-nat.o x86-nat.o \
- x86-dregs.o amd64-nat.o"
+ nat/x86-dregs.o amd64-nat.o"
;;
esac
;;
@@ -163,7 +164,7 @@ case ${gdb_host} in
;;
i386)
# Host: FreeBSD/i386
- NATDEPFILES="${NATDEPFILES} x86-nat.o x86-dregs.o \
+ NATDEPFILES="${NATDEPFILES} x86-nat.o nat/x86-dregs.o \
x86-bsd-nat.o i386-bsd-nat.o i386-fbsd-nat.o bsd-kvm.o"
NAT_FILE='nm-fbsd.h'
;;
@@ -193,7 +194,8 @@ case ${gdb_host} in
i386)
# Host: FreeBSD/amd64
NATDEPFILES="${NATDEPFILES} amd64-nat.o amd64-bsd-nat.o \
- amd64-fbsd-nat.o bsd-kvm.o x86-nat.o x86-dregs.o x86-bsd-nat.o"
+ amd64-fbsd-nat.o bsd-kvm.o x86-nat.o nat/x86-dregs.o \
+ x86-bsd-nat.o"
;;
esac
;;
@@ -203,7 +205,7 @@ case ${gdb_host} in
# Host: Intel x86 running DJGPP
# We include several header files from config/djgpp
MH_CFLAGS='-I$(srcdir)/config/djgpp'
- NATDEPFILES='go32-nat.o x86-nat.o x86-dregs.o'
+ NATDEPFILES='go32-nat.o x86-nat.o nat/x86-dregs.o'
XM_CLIBS='-ldbg'
;;
esac
@@ -213,7 +215,7 @@ case ${gdb_host} in
i386)
# Host: Intel 386 running the GNU Hurd
NATDEPFILES='i386-gnu-nat.o gnu-nat.o \
- x86-nat.o x86-dregs.o fork-child.o \
+ x86-nat.o nat/x86-dregs.o fork-child.o \
notify_S.o process_reply_S.o msg_reply_S.o \
msg_U.o exc_request_U.o exc_request_S.o'
HAVE_NATIVE_GCORE_HOST=1
@@ -232,8 +234,9 @@ case ${gdb_host} in
aarch64)
# Host: AArch64 based machine running GNU/Linux
NATDEPFILES="${NATDEPFILES} aarch64-linux-nat.o \
- aarch32-linux-nat.o aarch64-linux-hw-point.o aarch64-linux.o \
- aarch64-sve-linux-ptrace.o"
+ aarch32-linux-nat.o nat/aarch64-linux-hw-point.o \
+ nat/aarch64-linux.o \
+ nat/aarch64-sve-nat/linux-ptrace.o"
;;
arm)
# Host: ARM based machine running GNU/Linux
@@ -242,9 +245,9 @@ case ${gdb_host} in
;;
i386)
# Host: Intel 386 running GNU/Linux.
- NATDEPFILES="${NATDEPFILES} x86-nat.o x86-dregs.o \
- i386-linux-nat.o x86-linux-nat.o linux-btrace.o \
- x86-linux.o x86-linux-dregs.o"
+ NATDEPFILES="${NATDEPFILES} x86-nat.o nat/x86-dregs.o \
+ i386-linux-nat.o x86-linux-nat.o nat/linux-btrace.o \
+ nat/x86-linux.o nat/x86-linux-dregs.o"
;;
ia64)
# Host: Intel IA-64 running GNU/Linux
@@ -261,7 +264,7 @@ case ${gdb_host} in
mips)
# Host: Linux/MIPS
NATDEPFILES="${NATDEPFILES} linux-nat-trad.o \
- mips-linux-nat.o mips-linux-watch.o"
+ mips-linux-nat.o nat/mips-linux-watch.o"
;;
pa)
# Host: Hewlett-Packard PA-RISC machine, running Linux
@@ -269,7 +272,7 @@ case ${gdb_host} in
;;
powerpc)
# Host: PowerPC, running Linux
- NATDEPFILES="${NATDEPFILES} ppc-linux-nat.o ppc-linux.o"
+ NATDEPFILES="${NATDEPFILES} ppc-linux-nat.o nat/ppc-linux.o"
;;
riscv*)
# Host: RISC-V, running Linux
@@ -298,9 +301,11 @@ case ${gdb_host} in
case ${gdb_host_cpu} in
i386)
# Host: GNU/Linux x86-64
- NATDEPFILES="${NATDEPFILES} x86-nat.o x86-dregs.o \
- amd64-nat.o amd64-linux-nat.o x86-linux-nat.o linux-btrace.o \
- x86-linux.o x86-linux-dregs.o amd64-linux-siginfo.o"
+ NATDEPFILES="${NATDEPFILES} x86-nat.o nat/x86-dregs.o \
+ amd64-nat.o amd64-linux-nat.o x86-linux-nat.o \
+ nat/linux-btrace.o \
+ nat/x86-linux.o nat/x86-linux-dregs.o \
+ nat/amd64-linux-siginfo.o"
;;
sparc)
# Host: GNU/Linux UltraSPARC
@@ -355,7 +360,7 @@ case ${gdb_host} in
i386)
# Host: NetBSD/amd64
NATDEPFILES="${NATDEPFILES} nbsd-nat.o amd64-nat.o x86-nat.o \
- x86-dregs.o x86-bsd-nat.o amd64-bsd-nat.o amd64-nbsd-nat.o"
+ nat/x86-dregs.o x86-bsd-nat.o amd64-bsd-nat.o amd64-nbsd-nat.o"
;;
sparc)
# Host: NetBSD/sparc64
@@ -374,7 +379,8 @@ case ${gdb_host} in
;;
i386)
# Host: NetBSD/i386 ELF
- NATDEPFILES="${NATDEPFILES} nbsd-nat.o x86-nat.o x86-dregs.o \
+ NATDEPFILES="${NATDEPFILES} nbsd-nat.o x86-nat.o \
+ nat/x86-dregs.o \
x86-bsd-nat.o i386-bsd-nat.o i386-nbsd-nat.o bsd-kvm.o"
LOADLIBES='-lkvm'
;;
@@ -460,7 +466,7 @@ case ${gdb_host} in
powerpc)
# Host: PowerPC64, running Linux
XM_CLIBS=
- NATDEPFILES="${NATDEPFILES} ppc-linux-nat.o ppc-linux.o"
+ NATDEPFILES="${NATDEPFILES} ppc-linux-nat.o nat/ppc-linux.o"
;;
esac
;;
@@ -488,9 +494,10 @@ case ${gdb_host} in
NAT_CDEPS=
LOADLIBES=
NATDEPFILES='spu-linux-nat.o \
- inf-ptrace.o fork-child.o fork-inferior.o \
- linux-procfs.o linux-ptrace.o linux-waitpid.o \
- linux-personality.o linux-namespaces.o'
+ inf-ptrace.o fork-child.o nat/fork-inferior.o \
+ nat/linux-procfs.o nat/linux-ptrace.o \
+ nat/linux-waitpid.o \
+ nat/linux-personality.o nat/linux-namespaces.o'
;;
esac
;;
--
2.17.2
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 1/3] Remove gdbtypes special case from init.c rule
2018-12-24 21:09 [PATCH 0/3] some minor Makefile improvements Tom Tromey
2018-12-24 21:09 ` [PATCH 3/3] Build gdb "nat" files in subdirectory Tom Tromey
@ 2018-12-24 21:10 ` Tom Tromey
2018-12-24 21:10 ` [PATCH 2/3] Make init.c depend on source files Tom Tromey
2 siblings, 0 replies; 10+ messages in thread
From: Tom Tromey @ 2018-12-24 21:10 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
The rule to make init.c has a special case for gdbtypes, with a long
explanatory comment. All of this is obsolete, as the globals referred
to by the comment no longer exist. This patch simplifies the rule.
gdb/ChangeLog
2018-12-24 Tom Tromey <tom@tromey.com>
* Makefile.in (stamp-init): Remove gdbtypes special case.
---
gdb/ChangeLog | 4 ++++
gdb/Makefile.in | 16 +---------------
2 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index a2cf02e1a9..38d00b0632 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1836,18 +1836,6 @@ test-cp-name-parser$(EXEEXT): test-cp-name-parser.o $(LIBIBERTY)
# FIXME: There is a problem with this approach - init.c may force
# unnecessary files to be linked in.
-# FIXME: cagney/2002-06-09: gdb/564: gdb/563: Force the order so that
-# the first call is to _initialize_gdbtypes (implemented by explicitly
-# putting that function's name first in the init.l-tmp file). This is
-# a hack to ensure that all the architecture dependant global
-# builtin_type_* variables are initialized before anything else
-# (per-architecture code is called in the same order that it is
-# registered). The ``correct fix'' is to have all the builtin types
-# made part of the architecture and initialize them on-demand (using
-# gdbarch_data) just like everything else. The catch is that other
-# modules still take the address of these builtin types forcing them
-# to be variables, sigh!
-
# NOTE: cagney/2003-03-18: The sed pattern ``s|^\([^ /]...'' is
# anchored on the first column and excludes the ``/'' character so
# that it doesn't add the $(srcdir) prefix to any file that already
@@ -1861,13 +1849,11 @@ stamp-init: $(INIT_FILES)
@$(ECHO_INIT_C) echo "Making init.c"
@rm -f init.c-tmp init.l-tmp
@touch init.c-tmp
- @echo gdbtypes > init.l-tmp
@-LANG=C ; export LANG ; \
LC_ALL=C ; export LC_ALL ; \
echo $(INIT_FILES) | \
tr ' ' '\012' | \
sed \
- -e '/^gdbtypes.[co]$$/d' \
-e '/^init.[co]$$/d' \
-e '/version.[co]$$/d' \
-e '/^[a-z0-9A-Z_]*_[SU].[co]$$/d' \
@@ -1876,7 +1862,7 @@ stamp-init: $(INIT_FILES)
-e 's|^\([^ /][^ ]*\)|$(srcdir)/\1|g' | \
while read f; do \
sed -n -e 's/^_initialize_\([a-z_0-9A-Z]*\).*/\1/p' $$f 2>/dev/null; \
- done >> init.l-tmp
+ done > init.l-tmp
@echo '/* Do not modify this file. */' >>init.c-tmp
@echo '/* It is created automatically by the Makefile. */'>>init.c-tmp
@echo '#include "defs.h" /* For initialize_file_ftype. */' >>init.c-tmp
--
2.17.2
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/3] Make init.c depend on source files
2018-12-24 21:09 [PATCH 0/3] some minor Makefile improvements Tom Tromey
2018-12-24 21:09 ` [PATCH 3/3] Build gdb "nat" files in subdirectory Tom Tromey
2018-12-24 21:10 ` [PATCH 1/3] Remove gdbtypes special case from init.c rule Tom Tromey
@ 2018-12-24 21:10 ` Tom Tromey
2018-12-27 4:02 ` Simon Marchi
2 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2018-12-24 21:10 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
I noticed that init.c depends on the object files that go into gdb.
Because init.c actually only requires the contents of the
corresponding source files, this unnecessarily serializes the step
that builds init.c.
This patch changes gdb's Makefile to make init.c depend on the source
files. This also simplifies the rule to build init.c.
gdb/ChangeLog
2018-12-24 Tom Tromey <tom@tromey.com>
* Makefile.in (INIT_FILES): Redefine.
(stamp-init): Remove sed, tr invocations. Use for loop. Don't
set LANG or LC_ALL.
---
gdb/ChangeLog | 6 ++++++
gdb/Makefile.in | 35 +++++++++++------------------------
2 files changed, 17 insertions(+), 24 deletions(-)
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 38d00b0632..e4d4a3449d 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1831,37 +1831,24 @@ test-cp-name-parser$(EXEEXT): test-cp-name-parser.o $(LIBIBERTY)
#
# Note that the set of files with init functions might change, or the names
# of the functions might change, so this files needs to depend on all the
-# object files that will be linked into gdb.
+# source files that will be linked into gdb. However, due to the way
+# this Makefile has generally been written, we do this indirectly, by
+# computing the list of source files from the list of object files.
-# FIXME: There is a problem with this approach - init.c may force
-# unnecessary files to be linked in.
+INIT_FILES = \
+ $(patsubst %.o,%.c, \
+ $(patsubst %-exp.o,%-exp.y, \
+ $(filter-out $(NATDEPFILES) init.o version.o %_S.o %_U.o,\
+ $(COMMON_OBS))))
-# NOTE: cagney/2003-03-18: The sed pattern ``s|^\([^ /]...'' is
-# anchored on the first column and excludes the ``/'' character so
-# that it doesn't add the $(srcdir) prefix to any file that already
-# has an absolute path. It turns out that $(DEC)'s True64 make
-# automatically adds the $(srcdir) prefixes when it encounters files
-# in sub-directories such as cli/ and mi/.
-
-INIT_FILES = $(COMMON_OBS)
init.c: stamp-init; @true
stamp-init: $(INIT_FILES)
@$(ECHO_INIT_C) echo "Making init.c"
@rm -f init.c-tmp init.l-tmp
@touch init.c-tmp
- @-LANG=C ; export LANG ; \
- LC_ALL=C ; export LC_ALL ; \
- echo $(INIT_FILES) | \
- tr ' ' '\012' | \
- sed \
- -e '/^init.[co]$$/d' \
- -e '/version.[co]$$/d' \
- -e '/^[a-z0-9A-Z_]*_[SU].[co]$$/d' \
- -e 's/-exp\.o$$/-exp.y/' \
- -e 's/\.o$$/.c/' \
- -e 's|^\([^ /][^ ]*\)|$(srcdir)/\1|g' | \
- while read f; do \
- sed -n -e 's/^_initialize_\([a-z_0-9A-Z]*\).*/\1/p' $$f 2>/dev/null; \
+ @-for f in $(INIT_FILES); do \
+ sed -n -e 's/^_initialize_\([a-z_0-9A-Z]*\).*/\1/p' \
+ $(srcdir)/$$f 2>/dev/null; \
done > init.l-tmp
@echo '/* Do not modify this file. */' >>init.c-tmp
@echo '/* It is created automatically by the Makefile. */'>>init.c-tmp
--
2.17.2
^ permalink raw reply [flat|nested] 10+ messages in thread