Makefile.in 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. # Makefile for regression testing the GNU debugger.
  2. # Copyright 1992-2022 Free Software Foundation, Inc.
  3. # This file is part of GDB.
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. VPATH = @srcdir@
  17. srcdir = @srcdir@
  18. prefix = @prefix@
  19. exec_prefix = @exec_prefix@
  20. abs_builddir = @abs_builddir@
  21. abs_srcdir = @abs_srcdir@
  22. target_alias = @target_noncanonical@
  23. program_transform_name = @program_transform_name@
  24. build_canonical = @build@
  25. host_canonical = @host@
  26. target_canonical = @target@
  27. enable_libctf = @enable_libctf@
  28. SHELL = @SHELL@
  29. EXEEXT = @EXEEXT@
  30. SUBDIRS = @subdirs@
  31. RPATH_ENVVAR = @RPATH_ENVVAR@
  32. CC=@CC@
  33. EXPECT = `if [ "$${READ1}" != "" ] ; then \
  34. echo $${rootme}/expect-read1; \
  35. elif [ "$${READMORE}" != "" ] ; then \
  36. echo $${rootme}/expect-readmore; \
  37. elif [ -f $${rootme}/../../expect/expect ] ; then \
  38. echo $${rootme}/../../expect/expect ; \
  39. else \
  40. echo expect ; \
  41. fi`
  42. RUNTEST = $(RUNTEST_FOR_TARGET)
  43. RUNTESTFLAGS =
  44. FORCE_PARALLEL =
  45. GDB_DEBUG =
  46. GDBSERVER_DEBUG =
  47. # Default number of iterations that we will use to run the testsuite
  48. # if the user does not specify the RACY_ITER environment variable
  49. # (e.g., when the user calls the make rule directly from the command
  50. # line).
  51. DEFAULT_RACY_ITER = 3
  52. RUNTEST_FOR_TARGET = `\
  53. if [ -f $${srcdir}/../../dejagnu/runtest ]; then \
  54. echo $${srcdir}/../../dejagnu/runtest; \
  55. else \
  56. if [ "$(host_canonical)" = "$(target_canonical)" ]; then \
  57. echo runtest; \
  58. else \
  59. t='$(program_transform_name)'; echo runtest | sed -e $$t; \
  60. fi; \
  61. fi`
  62. #### host, target, and site specific Makefile frags come in here.
  63. # The use of $$(x_FOR_TARGET) reduces the command line length by not
  64. # duplicating the lengthy definition.
  65. TARGET_FLAGS_TO_PASS = \
  66. "prefix=$(prefix)" \
  67. "exec_prefix=$(exec_prefix)" \
  68. "against=$(against)" \
  69. 'CC=$$(CC_FOR_TARGET)' \
  70. "CC_FOR_TARGET=$(CC_FOR_TARGET)" \
  71. "CFLAGS=$(TESTSUITE_CFLAGS)" \
  72. 'CXX=$$(CXX_FOR_TARGET)' \
  73. "CXX_FOR_TARGET=$(CXX_FOR_TARGET)" \
  74. "CXXFLAGS=$(CXXFLAGS)" \
  75. "MAKEINFO=$(MAKEINFO)" \
  76. "INSTALL=$(INSTALL)" \
  77. "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
  78. "INSTALL_DATA=$(INSTALL_DATA)" \
  79. "LDFLAGS=$(LDFLAGS)" \
  80. "LIBS=$(LIBS)" \
  81. "RUNTEST=$(RUNTEST)" \
  82. "RUNTESTFLAGS=$(RUNTESTFLAGS)"
  83. all:
  84. @:
  85. .NOEXPORT:
  86. INFODIRS=doc
  87. info:
  88. install-info:
  89. dvi:
  90. pdf:
  91. install-pdf:
  92. html:
  93. install-html:
  94. install:
  95. uninstall: force
  96. # Use absolute `site.exp' path everywhere to suppress VPATH lookups for it.
  97. # Bare `site.exp' is used as a target here if user requests it explicitly.
  98. # $(RUNTEST) is looking up `site.exp' only in the current directory.
  99. $(abs_builddir)/site.exp site.exp: Makefile
  100. $(ECHO_GEN) \
  101. rm -f ./tmp?; \
  102. touch site.exp; \
  103. mv site.exp site.bak; \
  104. echo "## these variables are automatically generated by make ##" > ./tmp0; \
  105. echo "# Do not edit here. If you wish to override these values" >> ./tmp0; \
  106. echo "# add them to the last section" >> ./tmp0; \
  107. echo "set host_triplet ${host_canonical}" >> ./tmp0; \
  108. echo "set target_alias $(target_alias)" >> ./tmp0; \
  109. echo "set target_triplet ${target_canonical}" >> ./tmp0; \
  110. echo "set build_triplet ${build_canonical}" >> ./tmp0; \
  111. echo "set srcdir ${abs_srcdir}" >> ./tmp0; \
  112. echo "set tool gdb" >> ./tmp0; \
  113. echo "set enable_libctf ${enable_libctf}" >> ./tmp0; \
  114. echo 'source $${srcdir}/lib/append_gdb_boards_dir.exp' >> ./tmp0; \
  115. echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0; \
  116. cat ./tmp0 > site.exp; \
  117. cat site.bak | sed \
  118. -e '1,/^## All variables above are.*##/ d' >> site.exp; \
  119. rm -f ./tmp?
  120. installcheck:
  121. # See whether -j was given to make. Before GNU make 4.2, either it was
  122. # given with no arguments, and appears as "j" in the first word, or it was
  123. # given an argument and appears as "-j" in a separate word. Starting with
  124. # GNU make 4.2, it always appears as "-j"/"-jN" in a separate word.
  125. saw_dash_j = $(or $(findstring j,$(firstword $(MAKEFLAGS))),$(filter -j%,$(MAKEFLAGS)))
  126. # Try to run the tests in parallel if any -j option is given. If RUNTESTFLAGS
  127. # is not empty, then by default the tests will be serialized. This can be
  128. # overridden by setting FORCE_PARALLEL to any non-empty value.
  129. CHECK_TARGET_TMP = $(if $(FORCE_PARALLEL),check-parallel,$(if $(RUNTESTFLAGS),check-single,$(if $(saw_dash_j),check-parallel,check-single)))
  130. CHECK_TARGET = $(if $(RACY_ITER),$(addsuffix -racy,$(CHECK_TARGET_TMP)),$(CHECK_TARGET_TMP))
  131. # Note that we must resort to a recursive make invocation here,
  132. # because GNU make 3.82 has a bug preventing MAKEFLAGS from being used
  133. # in conditions.
  134. check: all $(abs_builddir)/site.exp
  135. $(MAKE) $(CHECK_TARGET)
  136. check-read1: read1.so expect-read1
  137. $(MAKE) READ1="1" check
  138. check-readmore: readmore.so expect-readmore
  139. $(MAKE) READMORE="1" check
  140. # Check whether we need to print the timestamp for each line of
  141. # status.
  142. TIMESTAMP = $(if $(TS),| $(srcdir)/print-ts.py $(if $(TS_FORMAT),$(TS_FORMAT),),)
  143. gdb_debug = $(if $(GDB_DEBUG),GDB_DEBUG=$(GDB_DEBUG) ; export GDB_DEBUG ;,)
  144. gdbserver_debug = $(if $(GDBSERVER_DEBUG),GDBSERVER_DEBUG=$(GDBSERVER_DEBUG) ; export GDBSERVER_DEBUG ;,)
  145. # All the hair to invoke dejagnu. A given invocation can just append
  146. # $(RUNTESTFLAGS)
  147. DO_RUNTEST = \
  148. rootme=`pwd`; export rootme; \
  149. srcdir=${srcdir} ; export srcdir ; \
  150. EXPECT=${EXPECT} ; export EXPECT ; \
  151. EXEEXT=${EXEEXT} ; export EXEEXT ; $(gdb_debug) $(gdbserver_debug) \
  152. $(RPATH_ENVVAR)=$$rootme/../../expect:$$rootme/../../libstdc++:$$rootme/../../tk/unix:$$rootme/../../tcl/unix:$$rootme/../../bfd:$$rootme/../../opcodes:$$$(RPATH_ENVVAR); \
  153. export $(RPATH_ENVVAR); \
  154. if [ -f $${rootme}/../../expect/expect ] ; then \
  155. TCL_LIBRARY=$${srcdir}/../../tcl/library ; \
  156. export TCL_LIBRARY ; fi ; \
  157. $(RUNTEST) --status
  158. # TESTS exists for the user to pass on the command line to easily
  159. # say "Only run these tests." With check-single it's not necessary, but
  160. # with check-parallel there's no other way to (easily) specify a subset
  161. # of tests. For consistency we support it for check-single as well.
  162. # To specify all tests in a subdirectory, use TESTS=gdb.subdir/*.exp.
  163. # E.g., make check TESTS="gdb.server/*.exp gdb.threads/*.exp".
  164. TESTS :=
  165. ifeq ($(strip $(TESTS)),)
  166. expanded_tests_or_none :=
  167. else
  168. expanded_tests := $(patsubst $(srcdir)/%,%,$(wildcard $(addprefix $(srcdir)/,$(TESTS))))
  169. expanded_tests_or_none := $(or $(expanded_tests),no-matching-tests-found)
  170. endif
  171. # Shorthand for running all the tests in a single directory.
  172. check-gdb.%:
  173. $(MAKE) check TESTS="gdb.$*/*.exp"
  174. check-single:
  175. $(DO_RUNTEST) $(RUNTESTFLAGS) $(expanded_tests_or_none) $(TIMESTAMP)
  176. check-single-racy:
  177. -rm -rf cache racy_outputs temp
  178. mkdir -p racy_outputs; \
  179. racyiter="$(RACY_ITER)"; \
  180. test "x$$racyiter" = "x" && \
  181. racyiter=$(DEFAULT_RACY_ITER); \
  182. if test $$racyiter -lt 2 ; then \
  183. echo "RACY_ITER must be at least 2."; \
  184. exit 1; \
  185. fi; \
  186. trap "exit" INT; \
  187. for n in `seq $$racyiter` ; do \
  188. mkdir -p racy_outputs/$$n; \
  189. $(DO_RUNTEST) --outdir=racy_outputs/$$n $(RUNTESTFLAGS) \
  190. $(expanded_tests_or_none) $(TIMESTAMP); \
  191. done; \
  192. $(srcdir)/analyze-racy-logs.py \
  193. `ls racy_outputs/*/gdb.sum` > racy.sum; \
  194. sed -n '/=== gdb Summary ===/,$$ p' racy.sum
  195. check-parallel:
  196. -rm -rf cache outputs temp
  197. $(MAKE) -k do-check-parallel; \
  198. result=$$?; \
  199. $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh \
  200. `find outputs -name gdb.sum -print` > gdb.sum; \
  201. $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh -L \
  202. `find outputs -name gdb.log -print` > gdb.log; \
  203. sed -n '/=== gdb Summary ===/,$$ p' gdb.sum; \
  204. exit $$result
  205. check-parallel-racy:
  206. -rm -rf cache racy_outputs temp
  207. racyiter="$(RACY_ITER)"; \
  208. test "x$$racyiter" = "x" && \
  209. racyiter=$(DEFAULT_RACY_ITER); \
  210. if test $$racyiter -lt 2 ; then \
  211. echo "RACY_ITER must be at least 2."; \
  212. exit 1; \
  213. fi; \
  214. trap "exit" INT; \
  215. for n in `seq $$racyiter` ; do \
  216. $(MAKE) -k do-check-parallel-racy \
  217. RACY_OUTPUT_N=$$n; \
  218. $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh \
  219. `find racy_outputs/$$n -name gdb.sum -print` > \
  220. racy_outputs/$$n/gdb.sum; \
  221. $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh -L \
  222. `find racy_outputs/$$n -name gdb.log -print` > \
  223. racy_outputs/$$n/gdb.log; \
  224. sed -n '/=== gdb Summary ===/,$$ p' racy_outputs/$$n/gdb.sum; \
  225. done; \
  226. $(srcdir)/analyze-racy-logs.py \
  227. `ls racy_outputs/*/gdb.sum` > racy.sum; \
  228. sed -n '/=== gdb Summary ===/,$$ p' racy.sum
  229. # Turn a list of .exp files into "check/" targets. Only examine .exp
  230. # files appearing in a gdb.* directory -- we don't want to pick up
  231. # lib/ by mistake. For example, gdb.linespec/linespec.exp becomes
  232. # check/gdb.linespec/linespec.exp. The list is generally sorted
  233. # alphabetically, but we take a few tests known to be slow and push
  234. # them to the front of the list to try to lessen the overall time
  235. # taken by the test suite -- if one of these tests happens to be run
  236. # late, it will cause the overall time to increase.
  237. ifeq ($(strip $(TESTS)),)
  238. slow_tests = gdb.base/break-interp.exp gdb.base/interp.exp \
  239. gdb.base/multi-forks.exp
  240. all_tests := $(shell cd $(srcdir) && find gdb.* -name '*.exp' -print)
  241. reordered_tests := $(slow_tests) $(filter-out $(slow_tests),$(all_tests))
  242. TEST_TARGETS := $(addprefix $(if $(RACY_ITER),check-racy,check)/,$(reordered_tests))
  243. else
  244. TEST_TARGETS := $(addprefix $(if $(RACY_ITER),check-racy,check)/,$(expanded_tests_or_none))
  245. endif
  246. do-check-parallel: $(TEST_TARGETS)
  247. @:
  248. check/%.exp:
  249. -mkdir -p outputs/$*
  250. @$(DO_RUNTEST) GDB_PARALLEL=yes --outdir=outputs/$* $*.exp $(RUNTESTFLAGS) $(TIMESTAMP)
  251. do-check-parallel-racy: $(TEST_TARGETS)
  252. @:
  253. check-racy/%.exp:
  254. -mkdir -p racy_outputs/$(RACY_OUTPUT_N)/$*
  255. $(DO_RUNTEST) GDB_PARALLEL=yes \
  256. --outdir=racy_outputs/$(RACY_OUTPUT_N)/$* $*.exp \
  257. $(RUNTESTFLAGS) $(TIMESTAMP)
  258. check/no-matching-tests-found:
  259. @echo ""
  260. @echo "No matching tests found."
  261. @echo ""
  262. # Utility rule invoked by step 2 of the build-perf rule.
  263. workers/%.worker:
  264. mkdir -p gdb.perf/outputs/$*
  265. $(DO_RUNTEST) --outdir=gdb.perf/outputs/$* lib/build-piece.exp WORKER=$* GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS) GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=build-pieces $(TIMESTAMP)
  266. # Utility rule to build tests that support it in parallel.
  267. # The build is broken into 3 steps distinguished by GDB_PERFTEST_SUBMODE:
  268. # gen-workers, build-pieces, final.
  269. #
  270. # GDB_PERFTEST_MODE appears *after* RUNTESTFLAGS here because we don't want
  271. # anything in RUNTESTFLAGS to override it.
  272. #
  273. # We don't delete the outputs directory here as these programs can take
  274. # awhile to build, and perftest.exp has support for deciding whether to
  275. # recompile them. If you want to remove these directories, make clean.
  276. #
  277. # The point of step 1 is to construct the set of worker tasks for step 2.
  278. # All of the information needed by build-piece.exp is contained in the name
  279. # of the generated .worker file.
  280. build-perf: $(abs_builddir)/site.exp
  281. rm -rf gdb.perf/workers
  282. mkdir -p gdb.perf/workers
  283. @: Step 1: Generate the build .worker files.
  284. $(DO_RUNTEST) --directory=gdb.perf --outdir gdb.perf/workers GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS) GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=gen-workers $(TIMESTAMP)
  285. @: Step 2: Compile the pieces. Here is the build parallelism.
  286. $(MAKE) $$(cd gdb.perf && echo workers/*/*.worker)
  287. @: Step 3: Do the final link.
  288. $(DO_RUNTEST) --directory=gdb.perf --outdir gdb.perf GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS) GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=final $(TIMESTAMP)
  289. # The default is to both compile and run the tests.
  290. GDB_PERFTEST_MODE = both
  291. check-perf: all $(abs_builddir)/site.exp
  292. @if test ! -d gdb.perf; then mkdir gdb.perf; fi
  293. $(DO_RUNTEST) --directory=gdb.perf --outdir gdb.perf GDB_PERFTEST_MODE=$(GDB_PERFTEST_MODE) $(RUNTESTFLAGS) $(TIMESTAMP)
  294. force:;
  295. clean mostlyclean:
  296. -rm -f *~ core *.o a.out xgdb *.x *.grt bigcore.corefile .gdb_history
  297. -rm -f core.* *.tf *.cl tracecommandsscript copy1.txt zzz-gdbscript
  298. -rm -f *.dwo *.dwp
  299. -rm -rf outputs temp cache
  300. -rm -rf gdb.perf/workers gdb.perf/outputs gdb.perf/temp gdb.perf/cache
  301. -rm -f read1.so expect-read1 readmore.so expect-readmore
  302. distclean maintainer-clean realclean: clean
  303. -rm -f *~ core
  304. -rm -f Makefile config.status *-init.exp lib/pdtrace
  305. -rm -fr *.log summary detail *.plog *.sum *.psum site.*
  306. Makefile : Makefile.in config.status $(host_makefile_frag)
  307. $(SHELL) config.status Makefile
  308. lib/pdtrace: pdtrace.in config.status
  309. $(SHELL) config.status lib/pdtrace
  310. config.status: configure
  311. $(SHELL) config.status --recheck
  312. TAGS: force
  313. find $(srcdir) -name '*.exp' -print | \
  314. etags \
  315. --regex='/\(proc\|proc_with_prefix\|gdb_caching_proc\)[ \t]+\([^ \t]+\)/\2/' \
  316. -
  317. # Build the expect wrapper script that preloads the read1.so library.
  318. expect-read1 expect-readmore:
  319. $(ECHO_GEN) \
  320. rm -f $@-tmp; \
  321. touch $@-tmp; \
  322. echo "# THIS FILE IS GENERATED -*- buffer-read-only: t -*- \n" >>$@-tmp; \
  323. echo "# vi:set ro: */\n\n" >>$@-tmp; \
  324. echo "# To regenerate this file, run:\n" >>$@-tmp; \
  325. echo "# make clean; make/\n" >>$@-tmp; \
  326. if [ $@ = expect-read1 ]; then \
  327. echo "export LD_PRELOAD=`pwd`/read1.so" >>$@-tmp; \
  328. else \
  329. echo "export LD_PRELOAD=`pwd`/readmore.so" >>$@-tmp; \
  330. fi; \
  331. echo 'exec expect "$$@"' >>$@-tmp; \
  332. chmod +x $@-tmp; \
  333. mv $@-tmp $@
  334. # Build the read1.so preload library. This overrides the `read'
  335. # function, making it read one byte at a time. Running the testsuite
  336. # with this catches racy tests.
  337. read1.so: lib/read1.c
  338. $(ECHO_CC) $(CC) -o $@ ${srcdir}/lib/read1.c -Wall -g -shared -fPIC $(CFLAGS)
  339. # Build the readmore.so preload library. This overrides the `read'
  340. # function, making it try harder to read more at a time. Running the
  341. # testsuite with this catches racy tests.
  342. readmore.so: lib/read1.c
  343. $(ECHO_CC) $(CC) -o $@ ${srcdir}/lib/read1.c -Wall -g -shared -fPIC \
  344. $(CFLAGS) -DREADMORE
  345. # Build the read1 machinery.
  346. .PHONY: read1 readmore
  347. read1: read1.so expect-read1
  348. readmore: readmore.so expect-readmore
  349. # Disable implicit make rules.
  350. include $(srcdir)/../disable-implicit-rules.mk
  351. include $(srcdir)/../silent-rules.mk