@@ -227,16 +227,48 @@ do-check-parallel: $(TEST_TARGETS)
@GMAKE_TRUE@check/%.exp:
@GMAKE_TRUE@ -mkdir -p outputs/$*
-@GMAKE_TRUE@ @$(DO_RUNTEST) GDB_PARALLEL=yes --outdir=outputs/$* $*.exp
$(RUNTESTFLAGS)
+@GMAKE_TRUE@ @$(DO_RUNTEST) GDB_PARALLEL=. --outdir=outputs/$* $*.exp
$(RUNTESTFLAGS)
check/no-matching-tests-found:
@echo ""
@echo "No matching tests found."
@echo ""
+# Utility rule invoked by step 2 of the build-perf rule.
+@GMAKE_TRUE@workers/%.worker:
+@GMAKE_TRUE@ mkdir -p gdb.perf/outputs/$*
+@GMAKE_TRUE@ $(DO_RUNTEST) --status --outdir=gdb.perf/outputs/$*
lib/build-piece.exp WORKER=$* GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS)
GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=build-pieces
+
+# Utility rule to build tests that support it in parallel.
+# The build is broken into 3 steps distinguished by GDB_PERFTEST_SUBMODE:
+# gen-workers, build-pieces, final.
+#
+# GDB_PERFTEST_MODE appears *after* RUNTESTFLAGS here because we don't want
+# anything in RUNTESTFLAGS to override it.
+#
+# We don't delete the outputs directory here as these programs can take
+# awhile to build, and perftest.exp has support for deciding whether to
+# recompile them. If you want to remove these directories, make clean.
+#
+# The point of step 1 is to construct the set of worker tasks for step 2.
+# All of the information needed by build-piece.exp is contained in the name
+# of the generated .worker file.
+@GMAKE_TRUE@build-perf: $(abs_builddir)/site.exp
+@GMAKE_TRUE@ rm -rf gdb.perf/workers
+@GMAKE_TRUE@ mkdir -p gdb.perf/workers
+@GMAKE_TRUE@ @: Step 1: Generate the build .worker files.
+@GMAKE_TRUE@ $(DO_RUNTEST) --status --directory=gdb.perf --outdir
gdb.perf/workers GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS)
GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=gen-workers
+@GMAKE_TRUE@ @: Step 2: Compile the pieces. Here is the build parallelism.
+@GMAKE_TRUE@ $(MAKE) $$(cd gdb.perf && echo workers/*/*.worker)
+@GMAKE_TRUE@ @: Step 3: Do the final link.
+@GMAKE_TRUE@ $(DO_RUNTEST) --status --directory=gdb.perf --outdir gdb.perf
GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS) GDB_PERFTEST_MODE=compile
GDB_PERFTEST_SUBMODE=final
+
+# The default is to both compile and run the tests.
+GDB_PERFTEST_MODE = both
+
check-perf: all $(abs_builddir)/site.exp
@if test ! -d gdb.perf; then mkdir gdb.perf; fi
- $(DO_RUNTEST) --directory=gdb.perf --outdir gdb.perf
GDB_PERFTEST_MODE=both $(RUNTESTFLAGS)
+ $(DO_RUNTEST) --directory=gdb.perf --outdir gdb.perf
GDB_PERFTEST_MODE=$(GDB_PERFTEST_MODE) $(RUNTESTFLAGS)
force:;
@@ -245,6 +277,7 @@ clean mostlyclean:
-rm -f core.* *.tf *.cl tracecommandsscript copy1.txt zzz-gdbscript
-rm -f *.dwo *.dwp
-rm -rf outputs temp cache
+ -rm -rf gdb.perf/workers gdb.perf/outputs gdb.perf/temp gdb.perf/cache
-rm -f read1.so expect-read1
if [ x"${ALL_SUBDIRS}" != x ] ; then \
for dir in ${ALL_SUBDIRS}; \
b/gdb/testsuite/gdb.base/watchpoint.exp
@@ -464,12 +464,11 @@ proc test_complex_watchpoint {} {
pass $test
}
-re "can't compute CFA for this frame.*\r\n$gdb_prompt $" {
- global compiler_info no_hw
+ global no_hw
# GCC < 4.5.0 does not get LOCATIONS_VALID set by dwarf2read.c.
# Therefore epilogue unwinder gets applied which is
# incompatible with dwarf2_frame_cfa.
- verbose -log "compiler_info: $compiler_info"
if {$no_hw && ([test_compiler_info {gcc-[0-3]-*}]
|| [test_compiler_info {gcc-4-[0-4]-*}])} {
xfail "$test (old GCC has broken watchpoints in epilogues)"
b/gdb/testsuite/gdb.cp/temargs.exp
@@ -34,7 +34,6 @@ if {![runto_main]} {
# NOTE: prepare_for_testing calls get_compiler_info, which we need
# for the test_compiler_info calls.
# gcc 4.4 and earlier don't emit enough info for some of our template
tests.
-verbose -log "compiler_info: $compiler_info"
set have_older_template_gcc 0
set have_pr_41736_fixed 1
set have_pr_45024_fixed 1
new file mode 100644
@@ -0,0 +1,192 @@
+The GDB Performance Testsuite
+=============================
+
+This README contains notes on hacking on GDB's performance testsuite.
+For notes on GDB's regular testsuite or how to run the performance
testsuite,
+see ../README.
+
+Generated tests
+***************
+
+The testcase generator lets us easily test GDB on large programs.
+The "monster" tests are mocks of real programs where GDB's
+performance has been a problem. Often it is difficult to build
+these monster programs, but when measuring performance one doesn't
+need the "real" program, all one needs is something that looks like
+the real program along the axis one is measuring; for example, the
+number of CUs (compilation units).
+
+Structure of generated tests
+****************************
+
+Generated tests consist of a binary and potentially any number of
+shared libraries. One of these shared libraries, called "tail", is
+special. It is used to provide mocks of system provided code, and
+contains no generated code. Typically system-provided libraries
+are searched last which can have significant performance consequences,
+so we provide a means to exercise that.
+
+The binary and the generated shared libraries can have a mix of
+manually written and generated code. Manually written code is
+specified with the {binary,gen_shlib}_extra_sources config parameters,
+which are lists of source files in testsuite/gdb.perf. Generated
+files are controlled with various configuration knobs.
+
+Once a large test program is built, it makes sense to use it as much
+as possible (i.e., with multiple tests). Therefore perf data collection
+for generated tests is split into two passes: the first pass builds
+all the generated tests, and the second pass runs all the performance
+tests. The first pass is called "build-perf" and the second pass is
+called "check-perf". See ../README for instructions on running the tests.
+
+Generated test directory layout
+*******************************
+
+All output lives under testsuite/gdb.perf in the build directory.
+
+Because some of the tests can get really large (and take potentially
+minutes to compile), parallelism is built into their compilation.
+Note however that we don't run the tests in parallel as it can skew
+the results.
+
+To keep things simple and stay consistent, we use the same
+mechanism used by "make check-parallel". There is one catch: we need
+one .exp for each "worker" but the .exp file must come from the source
+tree. To avoid generating .exp files for each worker we invoke
+lib/build-piece.exp for each worker with different arguments.
+The file build.piece.exp lives in "lib" to prevent dejagnu from finding
+it when it goes to look for .exp scripts to run.
+
+Another catch is that each parallel build worker needs its own directory
+so that their gdb.{log,sum} files don't collide. On the other hand
+its easier if their output (all the object files and shared libraries)
+are in the same directory.
+
+The above considerations yield the resulting layout:
+
+$objdir/testsuite/gdb.perf/
+
+ gdb.log, gdb.sum: result of doing final link and running tests
+
+ workers/
+
+ gdb.log, gdb.sum: result of gen-workers step
+
+ $program_name/
+
+ ${program_name}-0.worker
+ ...
+ ${program_name}-N.worker: input to build-pieces step
+
+ outputs/
+
+ ${program_name}/
+
+ ${program_name}-0/
+ ...
+ ${program_name}-N/
+
+ gdb.log, gdb.sum: for each build-piece worker
+
+ pieces/
+
+ generated sources, object files, shlibs
+
+ ${run_name_1}: binary for test config #1
+ ...
+ ${run_name_N}: binary for test config #N
+
+Generated test configuration knobs
+**********************************
+
+The monster program generator provides various knobs for building various
+kinds of monster programs. For a list of the knobs see function
+GenPerfTest::init_testcase in testsuite/lib/perftest.exp.
+Most knobs are self-explanatory.
+Here is a description of the less obvious ones.
+
+binary_extra_sources
+
+ This is the list of non-machine generated sources that go
+ into the test binary. There must be at least one: the one
+ with main.
+
+class_specs
+
+ List of pairs of class depth and number of classes at that depth.
+ By "depth" here we mean nesting within a namespace.
+
+ E.g.,
+ class foo {};
+ namespace n { class foo {}; class bar {}; }
+ would be represented as { { 0 1 } { 1 2 } }.
+
+ The naming of each namespace is "ns_<depth>".
+ The naming of each class is "class_<cu_nr>_<class_nr>",
+ where <cu_nr> is the number of the compilation unit the
+ class is defined in.
+ There is currently no support for defining classes in headers
+ (something to be added when needed).
+
+ There's currently no support for nesting classes in classes.
+
+Misc. configuration knobs
+*************************
+
+These knobs control building or running of the test and are specified
+like any global Tcl variable.
+
+CAT_PROGRAM
+
+ Default is /bin/cat, you shouldn't need to change this.
+
+SHA1SUM_PROGRAM
+
+ Default is /usr/bin/sha1sum.
+
+PERF_TEST_COMPILE_PARALLELISM
+
+ An integer, specifies the amount of parallelism in the builds.
+ Akin to make's -j flag. The default is 10.
+
+Writing a generated test program
+********************************
+
+The best way to write a generated test program is to take an existing
+one as boilerplate. Two good examples are gmonster1.exp and gmonster2.exp.
+gmonster1.exp builds a big binary with various custom manually written
+code, and gmonster2 is (essentially) the equivalent binary split up over
+several shared libraries.
+
+Writing a performance test that uses a generated program
+********************************************************
+
+The best way to write a test is to take an existing one as boilerplate.
+Good examples are gmonster1-*.exp and gmonster2-*.exp.
+
+The naming used thus far is that "foo.exp" builds the test program
+and there is one "foo-bar.exp" file for each performance test
+that uses test program "foo".
+
+In addition to writing the test driver .exp script, one must also
+write a python script that is used to run the test.
+This contents of this script is defined by the performance testsuite
+harness. It defines a class, which is a subclass of one of the
+classes in gdb.perf/lib/perftest/perftest.py.
+See gmonster-null-lookup.py for an example.
+
+Note: Since gmonster1 and gmonster2 are treated as being variations of
+the same program, each test shares the same python script.
+E.g., gmonster1-null-lookup.exp and gmonster2-null-lookup.exp
+both use gmonster-null-lookup.py.
+
+Running performance tests for generated programs
+************************************************
+
+There are two steps: build and run.
+
+Example:
+
+bash$ make -j10 build-perf RUNTESTFLAGS="gmonster1.exp"
+bash$ make -j10 check-perf RUNTESTFLAGS="gmonster1-null-lookup.exp" \
+ GDB_PERFTEST_MODE=run
b/gdb/testsuite/gdb.perf/backtrace.exp
@@ -58,9 +58,12 @@ PerfTest::assemble {
gdb_breakpoint "fun2"
gdb_continue_to_breakpoint "fun2"
+
+ return 0
} {
global BACKTRACE_DEPTH
gdb_test "python BackTrace\($BACKTRACE_DEPTH\).run()"
+ return 0
}
b/gdb/testsuite/gdb.perf/disassemble.exp
@@ -52,6 +52,9 @@ PerfTest::assemble {
if ![runto_main] {
return -1
}
+
+ return 0
} {
gdb_test "python Disassemble\(\).run()"
+ return 0
}
b/gdb/testsuite/gdb.perf/gm-hello.cc
new file mode 100644
@@ -0,0 +1,25 @@
+/* Copyright (C) 2015 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
+#include <string>
+#include "gm-utils.h"
+
+#ifdef SHLIB
+#define HELLO CONCAT2 (hello_, SHLIB)
+#else
+#define HELLO hello
+#endif
+
+std::string HELLO ("Hello.");
b/gdb/testsuite/gdb.perf/gm-pervasive-typedef.cc
new file mode 100644
@@ -0,0 +1,30 @@
+/* Copyright (C) 2015 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
+#include "gm-pervasive-typedef.h"
+
+my_int use_of_my_int;
+
+void
+call_use_my_int_1 (my_int x)
+{
+ use_of_my_int = use_my_int (x);
+}
+
+void
+call_use_my_int ()
+{
+ call_use_my_int_1 (42);
+}
b/gdb/testsuite/gdb.perf/gm-pervasive-typedef.h
new file mode 100644
@@ -0,0 +1,30 @@
+/* Copyright (C) 2015 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
+/* This file is used to create the conditions for the perf regression
+ in pr 16253. */
+
+#ifndef GM_PERVASIVE_TYPEDEF_H
+#define GM_PERVASIVE_TYPEDEF_H
+
+typedef int my_int;
+
+static my_int
+use_my_int (my_int x)
+{
+ return x + 1;
+}
+
+#endif /* GM_PERVASIVE_TYPEDEF_H */
b/gdb/testsuite/gdb.perf/gm-std.cc
new file mode 100644
@@ -0,0 +1,36 @@
+/* Copyright (C) 2015 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
+#include <iostream>
+#include "gm-std.h"
+
+namespace gm_std
+{
+
+ostream cerr;
+
+void
+init ()
+{
+ cerr.stream = &std::cerr;
+}
+
+template class basic_ostream<char>;
+
+template
+ostream&
+operator<< (ostream& out, const char* s);
+
+}
b/gdb/testsuite/gdb.perf/gm-std.h
new file mode 100644
@@ -0,0 +1,57 @@
+/* Copyright (C) 2015 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
+#ifndef GM_STD_H
+#define GM_STD_H
+
+#include <iostream>
+
+namespace gm_std
+{
+
+// Mock std::cerr, so we don't have to worry about the vagaries of the
+// system-provided one. E.g., gcc pr 65669.
+// This contains just enough to exercise what we want to.
+template<typename T>
+ class basic_ostream
+{
+ public:
+ std::ostream *stream;
+};
+
+template<typename T>
+ basic_ostream<T>&
+operator<< (basic_ostream<T>& out, const char* s)
+{
+ (*out.stream) << s;
+ return out;
+}
+
+typedef basic_ostream<char> ostream;
+
+// Inhibit implicit instantiations for required instantiations,
+// which are defined via explicit instantiations elsewhere.
+extern template class basic_ostream<char>;
+extern template ostream& operator<< (ostream&, const char*);
+
+extern ostream cerr;
+
+// Call this from main so we don't have to do the same tricks that
+// libstcd++ does with ios init'n.
+extern void init ();
+
+}
+
+#endif /* GM_STD_H */
b/gdb/testsuite/gdb.perf/gm-use-cerr.cc
new file mode 100644
@@ -0,0 +1,29 @@
+/* Copyright (C) 2015 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
+#include "gm-std.h"
+#include "gm-utils.h"
+
+#ifdef SHLIB
+#define WRITE_CERR XCONCAT2 (write_cerr_, SHLIB)
+#else
+#define WRITE_CERR write_cerr
+#endif
+
+void
+WRITE_CERR ()
+{
+ gm_std::cerr << "Yikes!\n";
+}
b/gdb/testsuite/gdb.perf/gm-utils.h
new file mode 100644
@@ -0,0 +1,25 @@
+/* Copyright (C) 2015 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
+#ifndef GM_UTILS_H
+#define GM_UTILS_H
+
+/* Names borrowed from include/symcat.h. */
+#define CONCAT2(a,b) a ## b
+#define XCONCAT2(a,b) CONCAT2 (a, b)
+#define STRINGX(s) #s
+#define XSTRING(s) STRINGX (s)
+
+#endif /* GM_UTILS_H */
b/gdb/testsuite/gdb.perf/gmonster-backtrace.py
new file mode 100644
@@ -0,0 +1,44 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Measure performance of selecting a file to debug and then running to
main.
+
+from perftest import perftest
+from perftest import measure
+from perftest import utils
+
+class GmonsterRuntoMain(perftest.TestCaseWithBasicMeasurements):
+ def __init__(self, name, run_names, binfile):
+ # We want to measure time in this test.
+ super(GmonsterRuntoMain, self).__init__(name)
+ self.run_names = run_names
+ self.binfile = binfile
+
+ def warm_up(self):
+ pass
+
+ def _doit(self, binfile):
+ utils.select_file(binfile)
+ utils.runto_main()
+
+ def execute_test(self):
+ for run in self.run_names:
+ this_run_binfile = "%s-%s" % (self.binfile,
+ utils.convert_spaces(run))
+ iteration = 5
+ while iteration > 0:
+ func = lambda: self._doit(this_run_binfile)
+ self.measure.measure(func, run)
+ iteration -= 1
b/gdb/testsuite/gdb.perf/gmonster-null-lookup.py
new file mode 100644
@@ -0,0 +1,44 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test handling of lookup of a symbol that doesn't exist.
+
+from perftest import perftest
+from perftest import measure
+from perftest import utils
+
+class NullLookup(perftest.TestCaseWithBasicMeasurements):
+ def __init__(self, name, run_names, binfile):
+ # We want to measure time in this test.
+ super(NullLookup, self).__init__(name)
+ self.run_names = run_names
+ self.binfile = binfile
+
+ def warm_up(self):
+ pass
+
+ def execute_test(self):
+ for run in self.run_names:
+ this_run_binfile = "%s-%s" % (self.binfile,
+ utils.convert_spaces(run))
+ utils.select_file(this_run_binfile)
+ utils.runto_main()
+ utils.safe_execute("mt expand-symtabs")
+ iteration = 5
+ while iteration > 0:
+ utils.safe_execute("mt flush-symbol-cache")
+ func = lambda: utils.safe_execute("p symbol_not_found")
+ self.measure.measure(func, run)
+ iteration -= 1
b/gdb/testsuite/gdb.perf/gmonster-pervasive-typedef.py
new file mode 100644
@@ -0,0 +1,43 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Exercise the perf issue from pr 16253.
+
+from perftest import perftest
+from perftest import measure
+from perftest import utils
+
+class PervasiveTypedef(perftest.TestCaseWithBasicMeasurements):
+ def __init__(self, name, run_names, binfile):
+ # We want to measure time in this test.
+ super(PervasiveTypedef, self).__init__(name)
+ self.run_names = run_names
+ self.binfile = binfile
+
+ def warm_up(self):
+ pass
+
+ def func(self):
+ utils.select_file(self.this_run_binfile)
+ utils.safe_execute("ptype call_use_my_int_1")
+
+ def execute_test(self):
+ for run in self.run_names:
+ self.this_run_binfile = "%s-%s" % (self.binfile,
+ utils.convert_spaces(run))
+ iteration = 5
+ while iteration > 0:
+ self.measure.measure(self.func, run)
+ iteration -= 1
b/gdb/testsuite/gdb.perf/gmonster-print-cerr.py
new file mode 100644
@@ -0,0 +1,44 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test printing of std::cerr.
+
+from perftest import perftest
+from perftest import measure
+from perftest import utils
+
+class PrintCerr(perftest.TestCaseWithBasicMeasurements):
+ def __init__(self, name, run_names, binfile):
+ # We want to measure time in this test.
+ super(PrintCerr, self).__init__(name)
+ self.run_names = run_names
+ self.binfile = binfile
+
+ def warm_up(self):
+ pass
+
+ def execute_test(self):
+ for run in self.run_names:
+ this_run_binfile = "%s-%s" % (self.binfile,
+ utils.convert_spaces(run))
+ utils.select_file(this_run_binfile)
+ utils.runto_main()
+ #utils.safe_execute("mt expand-symtabs")
+ iteration = 5
+ while iteration > 0:
+ utils.safe_execute("mt flush-symbol-cache")
+ func = lambda: utils.safe_execute("print gm_std::cerr")
+ self.measure.measure(func, run)
+ iteration -= 1
b/gdb/testsuite/gdb.perf/gmonster-ptype-string.py
new file mode 100644
@@ -0,0 +1,45 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Measure speed of ptype of a std::string object.
+
+from perftest import perftest
+from perftest import measure
+from perftest import utils
+
+class GmonsterPtypeString(perftest.TestCaseWithBasicMeasurements):
+ def __init__(self, name, run_names, binfile):
+ # We want to measure time in this test.
+ super(GmonsterPtypeString, self).__init__(name)
+ self.run_names = run_names
+ self.binfile = binfile
+
+ def warm_up(self):
+ pass
+
+ def execute_test(self):
+ for run in self.run_names:
+ this_run_binfile = "%s-%s" % (self.binfile,
+ utils.convert_spaces(run))
+ utils.select_file(this_run_binfile)
+ utils.runto_main()
+ utils.safe_execute("mt expand-symtabs")
+ iteration = 5
+ while iteration > 0:
+ utils.safe_execute("mt flush-symbol-cache")
+ func1 = lambda: utils.safe_execute("ptype hello")
+ func = lambda: utils.run_n_times(2, func1)
+ self.measure.measure(func, run)
+ iteration -= 1
b/gdb/testsuite/gdb.perf/gmonster-runto-main.py
new file mode 100644
@@ -0,0 +1,44 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Measure performance of selecting a file to debug and then running to
main.
+
+from perftest import perftest
+from perftest import measure
+from perftest import utils
+
+class GmonsterRuntoMain(perftest.TestCaseWithBasicMeasurements):
+ def __init__(self, name, run_names, binfile):
+ # We want to measure time in this test.
+ super(GmonsterRuntoMain, self).__init__(name)
+ self.run_names = run_names
+ self.binfile = binfile
+
+ def warm_up(self):
+ pass
+
+ def _doit(self, binfile):
+ utils.select_file(binfile)
+ utils.runto_main()
+
+ def execute_test(self):
+ for run in self.run_names:
+ this_run_binfile = "%s-%s" % (self.binfile,
+ utils.convert_spaces(run))
+ iteration = 5
+ while iteration > 0:
+ func = lambda: self._doit(this_run_binfile)
+ self.measure.measure(func, run)
+ iteration -= 1
b/gdb/testsuite/gdb.perf/gmonster1-backtrace.exp
new file mode 100644
@@ -0,0 +1,25 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Measure performance of a backtrace in a large executable.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+
+if [skip_perf_tests] {
+ return 0
+}
+
+GenPerfTest::standard_run_driver gmonster1.exp gmonster-backtrace.py
make_testcase_config GmonsterBacktrace
b/gdb/testsuite/gdb.perf/gmonster1-null-lookup.exp
new file mode 100644
@@ -0,0 +1,25 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Measure speed of lookup of a symbol that doesn't exist.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+
+if [skip_perf_tests] {
+ return 0
+}
+
+GenPerfTest::standard_run_driver gmonster1.exp make_testcase_config
gmonster-null-lookup.py NullLookup
b/gdb/testsuite/gdb.perf/gmonster1-pervasive-typedef.exp
new file mode 100644
@@ -0,0 +1,27 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Measure the speed of "ptype func" where a parameter of the function is a
+# typedef used pervasively. This exercises the perf regression introduced
by
+# the original patch to pr 16253.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+
+if [skip_perf_tests] {
+ return 0
+}
+
+GenPerfTest::standard_run_driver gmonster1.exp make_testcase_config
gmonster-pervasive-typedef.py PervasiveTypedef
b/gdb/testsuite/gdb.perf/gmonster1-print-cerr.exp
new file mode 100644
@@ -0,0 +1,25 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Measure speed of printing std::cerr.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+
+if [skip_perf_tests] {
+ return 0
+}
+
+GenPerfTest::standard_run_driver gmonster1.exp make_testcase_config
gmonster-print-cerr.py PrintCerr
b/gdb/testsuite/gdb.perf/gmonster1-ptype-string.exp
new file mode 100644
@@ -0,0 +1,25 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Measure speed of ptype on a simple class in a library that is searched
late.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+
+if [skip_perf_tests] {
+ return 0
+}
+
+GenPerfTest::standard_run_driver gmonster1.exp make_testcase_config
gmonster-ptype-string.py GmonsterPtypeString
b/gdb/testsuite/gdb.perf/gmonster1-runto-main.exp
new file mode 100644
@@ -0,0 +1,25 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Measure performance of selecting a file to debug and then running to
main.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+
+if [skip_perf_tests] {
+ return 0
+}
+
+GenPerfTest::standard_run_driver gmonster1.exp make_testcase_config
gmonster-runto-main.py GmonsterRuntoMain
b/gdb/testsuite/gdb.perf/gmonster1.cc
new file mode 100644
@@ -0,0 +1,24 @@
+/* Copyright (C) 2015 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
+#include "gm-std.h"
+
+int
+main ()
+{
+ gm_std::init ();
+
+ return 0;
+}
b/gdb/testsuite/gdb.perf/gmonster1.exp
new file mode 100644
@@ -0,0 +1,86 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Perftest description file for building the "gmonster1" benchmark.
+# Where does the name come from? The benchmark is derived from one of the
+# monster programs at Google.
+#
+# Perftest descriptions are loaded thrice:
+# 1) To generate the build .exp files
+# GDB_PERFTEST_MODE=gen-build-exps
+# This step allows for parallel builds of the majority of pieces of the
+# test binary and shlibs.
+# 2) To compile the "pieces" of the binary and shlibs.
+# "Pieces" are the bulk of the machine-generated sources of the test.
+# This step is driven by lib/build-piece.exp.
+# GDB_PERFTEST_MODE=build-pieces
+# 3) To perform the final link of the binary and shlibs.
+# GDB_PERFTEST_MODE=compile
+#
+# Example usage:
+# bash$ make -j5 build-perf RUNTESTFLAGS="gmonster1.exp gmonster2.exp"
+# bash$ make check-perf RUNTESTFLAGS="gdb.perf/gm*-*.exp GDB=/path/to/gdb"
+
+load_lib perftest.exp
+
+if [skip_perf_tests] {
+ return 0
+}
+
+if ![info exists MONSTER] {
+ set MONSTER "n"
+}
+
+proc make_testcase_config { } {
+ global MONSTER
+
+ set program_name "gmonster1"
+ array set testcase [GenPerfTest::init_testcase $program_name]
+
+ set testcase(language) c++
+
+ # *_{sources,headers} need to be embedded in an outer list
+ # because remember each element of the outer list is for each run, and
+ # here we want to use the same value for all runs.
+ set testcase(binary_extra_sources) { { gmonster1.cc gm-hello.cc
gm-use-cerr.cc gm-pervasive-typedef.cc } }
+ set testcase(binary_extra_headers) { { <stdint.h> gm-utils.h gm-std.h
gm-pervasive-typedef.h } }
+ set testcase(tail_shlib_sources) { { gm-std.cc } }
+ set testcase(tail_shlib_headers) { { gm-std.h } }
+
+ if { $MONSTER == "y" } {
+ set testcase(run_names) { 10-cus 100-cus 1000-cus 10000-cus }
+ set testcase(nr_compunits) { 10 100 1000 10000 }
+ } else {
+ set testcase(run_names) { 1-cu 10-cus 100-cus }
+ set testcase(nr_compunits) { 1 10 100 }
+ }
+ set testcase(nr_gen_shlibs) { 0 }
+
+ set testcase(nr_extern_functions) 10
+ set testcase(nr_static_functions) 10
+
+ # class_specs needs to be embedded in an outer list because remember
+ # each element of the outer list is for each run, and here we want to
use
+ # the same value for all runs.
+ set testcase(class_specs) { { { 0 10 } { 1 10 } { 2 10 } } }
+ set testcase(nr_members) 10
+ set testcase(nr_static_members) 10
+ set testcase(nr_methods) 10
+ set testcase(nr_static_methods) 10
+
+ return [array get testcase]
+}
+
+GenPerfTest::standard_compile_driver gmonster1.exp make_testcase_config
b/gdb/testsuite/gdb.perf/gmonster2-backtrace.exp
new file mode 100644
@@ -0,0 +1,26 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Measure performance of a backtrace in a large executable
+# with lots of shared libraries.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+
+if [skip_perf_tests] {
+ return 0
+}
+
+GenPerfTest::standard_run_driver gmonster2.exp gmonster-backtrace.py
make_testcase_config GmonsterBacktrace
b/gdb/testsuite/gdb.perf/gmonster2-null-lookup.exp
new file mode 100644
@@ -0,0 +1,26 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Measure speed of lookup of a symbol that doesn't exist
+# with lots of shared libraries.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+
+if [skip_perf_tests] {
+ return 0
+}
+
+GenPerfTest::standard_run_driver gmonster2.exp make_testcase_config
gmonster-null-lookup.py NullLookup
b/gdb/testsuite/gdb.perf/gmonster2-pervasive-typedef.exp
new file mode 100644
@@ -0,0 +1,27 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Measure the speed of "ptype func" where a parameter of the function is a
+# typedef used pervasively. This exercises the perf regression introduced
by
+# the original patch to pr 16253.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+
+if [skip_perf_tests] {
+ return 0
+}
+
+GenPerfTest::standard_run_driver gmonster2.exp make_testcase_config
gmonster-pervasive-typedef.py PervasiveTypedef
b/gdb/testsuite/gdb.perf/gmonster2-print-cerr.exp
new file mode 100644
@@ -0,0 +1,25 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Measure speed of printing std::cerr with lots of shared libraries.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+
+if [skip_perf_tests] {
+ return 0
+}
+
+GenPerfTest::standard_run_driver gmonster2.exp make_testcase_config
gmonster-print-cerr.py PrintCerr
b/gdb/testsuite/gdb.perf/gmonster2-ptype-string.exp
new file mode 100644
@@ -0,0 +1,26 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Measure speed of ptype on a simple class in a library that is searched
late
+# with lots of shared libraries
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+
+if [skip_perf_tests] {
+ return 0
+}
+
+GenPerfTest::standard_run_driver gmonster2.exp make_testcase_config
gmonster-ptype-string.py GmonsterPtypeString
b/gdb/testsuite/gdb.perf/gmonster2-runto-main.exp
new file mode 100644
@@ -0,0 +1,26 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Measure performance of selecting a file to debug and then running to main
+# with lots of shared libraries
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+
+if [skip_perf_tests] {
+ return 0
+}
+
+GenPerfTest::standard_run_driver gmonster2.exp make_testcase_config
gmonster-runto-main.py GmonsterRuntoMain
b/gdb/testsuite/gdb.perf/gmonster2.cc
new file mode 100644
@@ -0,0 +1,24 @@
+/* Copyright (C) 2015 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
+#include "gm-std.h"
+
+int
+main ()
+{
+ gm_std::init ();
+
+ return 0;
+}
b/gdb/testsuite/gdb.perf/gmonster2.exp
new file mode 100644
@@ -0,0 +1,88 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Perftest description file for building the "gmonster2" benchmark.
+# Where does the name come from? The benchmark is derived from one of the
+# monster programs at Google.
+#
+# Perftest descriptions are loaded thrice:
+# 1) To generate the build .exp files
+# GDB_PERFTEST_MODE=gen-build-exps
+# This step allows for parallel builds of the majority of pieces of the
+# test binary and shlibs.
+# 2) To compile the "pieces" of the binary and shlibs.
+# "Pieces" are the bulk of the machine-generated sources of the test.
+# This step is driven by lib/build-piece.exp.
+# GDB_PERFTEST_MODE=build-pieces
+# 3) To perform the final link of the binary and shlibs.
+# GDB_PERFTEST_MODE=compile
+#
+# Example usage:
+# bash$ make -j5 build-perf RUNTESTFLAGS="gmonster1.exp gmonster2.exp"
+# bash$ make check-perf RUNTESTFLAGS="gdb.perf/gm*-*.exp GDB=/path/to/gdb"
+
+load_lib perftest.exp
+
+if [skip_perf_tests] {
+ return 0
+}
+
+if ![info exists MONSTER] {
+ set MONSTER "n"
+}
+
+proc make_testcase_config { } {
+ global MONSTER
+
+ set program_name "gmonster2"
+ array set testcase [GenPerfTest::init_testcase $program_name]
+
+ set testcase(language) c++
+
+ # *_{sources,headers} need to be embedded in an outer list
+ # because remember each element of the outer list is for each run, and
+ # here we want to use the same value for all runs.
+ set testcase(binary_extra_sources) { { gmonster2.cc gm-hello.cc
gm-use-cerr.cc } }
+ set testcase(binary_extra_headers) { { gm-utils.h gm-std.h } }
+ set testcase(gen_shlib_extra_sources) { { gm-hello.cc gm-use-cerr.cc }
}
+ set testcase(gen_shlib_extra_headers) { { gm-utils.h gm-std.h } }
+ set testcase(tail_shlib_sources) { { gm-std.cc } }
+ set testcase(tail_shlib_headers) { { gm-std.h } }
+
+ if { $MONSTER == "y" } {
+ set testcase(run_names) { 10-sos 100-sos 1000-sos }
+ set testcase(nr_gen_shlibs) { 10 100 1000 }
+ } else {
+ set testcase(run_names) { 1-so 10-sos 100-sos }
+ set testcase(nr_gen_shlibs) { 1 10 100 }
+ }
+ set testcase(nr_compunits) 10
+
+ set testcase(nr_extern_functions) 10
+ set testcase(nr_static_functions) 10
+
+ # class_specs needs to be embedded in an outer list because remember
+ # each element of the outer list is for each run, and here we want to
use
+ # the same value for all runs.
+ set testcase(class_specs) { { { 0 10 } { 1 10 } { 2 10 } } }
+ set testcase(nr_members) 10
+ set testcase(nr_static_members) 10
+ set testcase(nr_methods) 10
+ set testcase(nr_static_methods) 10
+
+ return [array get testcase]
+}
+
+GenPerfTest::standard_compile_driver gmonster2.exp make_testcase_config
b/gdb/testsuite/gdb.perf/lib/perftest/measure.py
@@ -103,6 +103,7 @@ class MeasurementCpuTime(Measurement):
else:
cpu_time = time.clock() - self.start_time
self.result.record (id, cpu_time)
+ print ("elapsed cpu time %s" % (cpu_time))
class MeasurementWallTime(Measurement):
"""Measurement on Wall time."""
@@ -117,6 +118,7 @@ class MeasurementWallTime(Measurement):
def stop(self, id):
wall_time = time.time() - self.start_time
self.result.record (id, wall_time)
+ print ("elapsed wall time %s" % (wall_time))
class MeasurementVmSize(Measurement):
"""Measurement on memory usage represented by VmSize."""
@@ -144,3 +146,4 @@ class MeasurementVmSize(Measurement):
def stop(self, id):
memory_used = self._compute_process_memory_usage("VmSize:")
self.result.record (id, memory_used)
+ print ("vm used %s" % (memory_used))
b/gdb/testsuite/gdb.perf/lib/perftest/utils.py
new file mode 100644
@@ -0,0 +1,65 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import gdb
+
+def safe_execute(command):
+ """Execute command, ignoring any gdb errors."""
+ result = None
+ try:
+ result = gdb.execute(command, to_string=True)
+ except gdb.error:
+ pass
+ return result
+
+
+def convert_spaces(file_name):
+ """Return file_name with all spaces replaced with "-"."""
+ return file_name.replace(" ", "-")
+
+
+def select_file(file_name):
+ """Select a file for debugging.
+
+ N.B. This turns confirmation off.
+ """
+ safe_execute("set confirm off")
+ print ("Selecting file %s" % (file_name))
+ gdb.execute("file %s" % (file_name))
+
+
+def runto(location):
+ """Run the program to location.
+
+ N.B. This turns confirmation off.
+ """
+ safe_execute("set confirm off")
+ gdb.execute("tbreak %s" % (location))
+ gdb.execute("run")
+
+
+def runto_main():
+ """Run the program to "main".
+
+ N.B. This turns confirmation off.
+ """
+ runto("main")
+
+
+def run_n_times(count, func):
+ """Execute func count times."""
+ while count > 0:
+ func()
+ count -= 1
b/gdb/testsuite/gdb.perf/single-step.exp
@@ -47,10 +47,12 @@ PerfTest::assemble {
fail "Can't run to main"
return -1
}
+ return 0
} {
global SINGLE_STEP_COUNT
gdb_test_no_output "python SingleStep\(${SINGLE_STEP_COUNT}\).run()"
# Terminate the loop.
gdb_test "set variable flag = 0"
+ return 0
}
b/gdb/testsuite/gdb.perf/skip-prologue.exp
@@ -52,6 +52,7 @@ PerfTest::assemble {
fail "Can't run to main"
return -1
}
+ return 0
} {
global SKIP_PROLOGUE_COUNT
@@ -66,4 +67,5 @@ PerfTest::assemble {
pass $test
}
}
+ return 0
}
b/gdb/testsuite/gdb.perf/solib.exp
@@ -80,8 +80,10 @@ PerfTest::assemble {
fail "Can't run to main"
return -1
}
+ return 0
} {
global SOLIB_COUNT
gdb_test_no_output "python SolibLoadUnload\($SOLIB_COUNT\).run()"
+ return 0
}
b/gdb/testsuite/lib/build-piece.exp
new file mode 100644
@@ -0,0 +1,39 @@
+# Copyright (C) 2014 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Utility to bootstrap building a piece of a performance test in a
+# parallel build.
+# See testsuite/Makefile.in:workers/%.worker.
+# WORKER is set by the makefile and is
+# "{program_name}/{program_name}-{worker_nr}".
+
+regexp "^\(.+\)/\(.+\)-\(\[0-9\]+\)$" $WORKER entire_match PROGRAM_NAME
pname2 WORKER_NR
+
+if { ![info exists entire_match] || $entire_match != $WORKER } {
+ error "Bad value for WORKER: $WORKER"
+}
+if { $PROGRAM_NAME != $pname2 } {
+ error "Bad value for WORKER: $WORKER"
+}
+
+# $subdir is set to "lib", because that is where this file lives,
+# which is not what tests expect.
+set subdir "gdb.perf"
+
+# $gdb_test_file_name is set to this file, build-piece, which is not what
+# tests expect.
+set gdb_test_file_name $PROGRAM_NAME
+
+source $srcdir/$subdir/${gdb_test_file_name}.exp
@@ -35,7 +35,7 @@ proc gdb_do_cache {name} {
}
if {[info exists GDB_PARALLEL]} {
- set cache_filename [file join $objdir cache $cache_name]
+ set cache_filename [file join $objdir $GDB_PARALLEL cache $cache_name]
if {[file exists $cache_filename]} {
set fd [open $cache_filename]
set gdb_data_cache($cache_name) [read -nonewline $fd]
@@ -124,14 +124,15 @@ proc gdb_default_target_compile {source destfile type
options} {
error "Must supply an output filename for the compile to
default_target_compile"
}
+ set early_flags ""
set add_flags ""
set libs ""
set compiler_type "c"
set compiler ""
set linker ""
# linker_opts_order is one
of "sources-then-flags", "flags-then-sources".
- # The order shouldn't matter. It's done this way to preserve
- # existing behavior.
+ # The order matters for things like -Wl,--as-needed. The default is to
+ # preserve existing behavior.
set linker_opts_order "sources-then-flags"
set ldflags ""
set dest [target_info name]
@@ -229,6 +230,10 @@ proc gdb_default_target_compile {source destfile type
options} {
regsub "^compiler=" $i "" tmp
set compiler $tmp
}
+ if {[regexp "^early_flags=" $i]} {
+ regsub "^early_flags=" $i "" tmp
+ append early_flags " $tmp"
+ }
if {[regexp "^additional_flags=" $i]} {
regsub "^additional_flags=" $i "" tmp
append add_flags " $tmp"
@@ -462,15 +467,15 @@ proc gdb_default_target_compile {source destfile type
options} {
# become confused about the name of the actual source file.
switch $type {
"object" {
- set opts "$add_flags $sources"
+ set opts "$early_flags $add_flags $sources"
}
"executable" {
switch $linker_opts_order {
"flags-then-sources" {
- set opts "$add_flags $sources"
+ set opts "$early_flags $add_flags $sources"
}
"sources-then-flags" {
- set opts "$sources $add_flags"
+ set opts "$early_flags $sources $add_flags"
}
default {
error "Invalid value for board_info linker_opts_order"
@@ -478,7 +483,7 @@ proc gdb_default_target_compile {source destfile type
options} {
}
}
default {
- set opts "$sources $add_flags"
+ set opts "$early_flags $sources $add_flags"
}
}
@@ -2728,12 +2728,20 @@ gdb_caching_proc target_is_gdbserver {
return $is_gdbserver
}
-set compiler_info "unknown"
+# N.B. compiler_info is intended to be local to this file.
+# Call test_compiler_info with no arguments to fetch its value.
+# Yes, this is counterintuitive when there's get_compiler_info,
+# but that's the current API.
+if [info exists compiler_info] {
+ unset compiler_info
+}
+
set gcc_compiled 0
set hp_cc_compiler 0
set hp_aCC_compiler 0
# Figure out what compiler I am using.
+# The result is cached so only the first invocation runs the compiler.
#
# ARG can be empty or "C++". If empty, "C" is assumed.
#
@@ -2800,6 +2808,11 @@ proc get_compiler_info {{arg ""}} {
global hp_cc_compiler
global hp_aCC_compiler
+ if [info exists compiler_info] {
+ # Already computed.
+ return 0
+ }
+
# Choose which file to preprocess.
set ifile "${srcdir}/lib/compiler.c"
if { $arg == "c++" } {
@@ -2841,8 +2854,14 @@ proc get_compiler_info {{arg ""}} {
}
}
- # Reset to unknown compiler if any diagnostics happened.
+ # Set to unknown if for some reason compiler_info didn't get defined.
+ if ![info exists compiler_info] {
+ verbose -log "get_compiler_info: compiler_info not provided"
+ set compiler_info "unknown"
+ }
+ # Also set to unknown compiler if any diagnostics happened.
if { $unknown } {
+ verbose -log "get_compiler_info: got unexpected diagnostics"
set compiler_info "unknown"
}
@@ -2876,18 +2895,18 @@ proc get_compiler_info {{arg ""}} {
return 0
}
+# Return the compiler_info string if no arg is provided.
+# Otherwise the argument is a glob-style expression to match against
+# compiler_info.
+
proc test_compiler_info { {compiler ""} } {
global compiler_info
+ get_compiler_info
- # if no arg, return the compiler_info string
-
- if [string match "" $compiler] {
- if [info exists compiler_info] {
- return $compiler_info
- } else {
- perror "No compiler info found."
- }
- }
+ # If no arg, return the compiler_info string.
+ if [string match "" $compiler] {
+ return $compiler_info
+ }
return [string match $compiler $compiler_info]
}
@@ -2966,6 +2985,13 @@ proc gdb_compile {source dest type options} {
|| [istarget *-*-cygwin*]) } {
lappend new_options "additional_flags=-Wl,--enable-auto-import"
}
+ if { [test_compiler_info "gcc-*"] || [test_compiler_info "clang-*"] } {
+ # Undo debian's change in the default.
+ # Put it at the front to not override any user-provided
+ # value, and to make sure it appears in front of all the
+ # shlibs!
+ lappend new_options "early_flags=-Wl,--no-as-needed"
+ }
}
} elseif { $opt == "shlib_load" } {
set shlib_load 1
@@ -3894,7 +3920,7 @@ proc standard_output_file {basename} {
global objdir subdir gdb_test_file_name GDB_PARALLEL
if {[info exists GDB_PARALLEL]} {
- set dir [file join $objdir outputs $subdir $gdb_test_file_name]
+ set dir [file join $objdir $GDB_PARALLEL outputs $subdir
$gdb_test_file_name]
file mkdir $dir
return [file join $dir $basename]
} else {
@@ -3908,7 +3934,7 @@ proc standard_temp_file {basename} {
global objdir GDB_PARALLEL
if {[info exists GDB_PARALLEL]} {
- return [file join $objdir temp $basename]
+ return [file join $objdir $GDB_PARALLEL temp $basename]
} else {
return $basename
}
@@ -4796,18 +4822,27 @@ proc build_executable { testname executable
{sources ""} {options {debug}} } {
return [eval build_executable_from_specs $arglist]
}
-# Starts fresh GDB binary and loads EXECUTABLE into GDB. EXECUTABLE is
-# the basename of the binary.
-# The return value is 0 for success, -1 for failure.
-proc clean_restart { executable } {
+# Starts fresh GDB binary and loads an optional executable into GDB.
+# Usage: clean_restart [executable]
+# EXECUTABLE is the basename of the binary.
+
+proc clean_restart { args } {
global srcdir
global subdir
- set binfile [standard_output_file ${executable}]
+
+ if { [llength $args] > 1 } {
+ error "bad number of args: [llength $args]"
+ }
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
- return [gdb_load ${binfile}]
+
+ if { [llength $args] >= 1 } {
+ set executable [lindex $args 0]
+ set binfile [standard_output_file ${executable}]
+ gdb_load ${binfile}
+ }
}
# Prepares for testing by calling build_executable_full, then
@@ -5011,7 +5046,10 @@ if {[info exists GDB_PARALLEL]} {
if {[is_remote host]} {
unset GDB_PARALLEL
} else {
- file mkdir outputs temp cache
+ file mkdir \
+ [file join $GDB_PARALLEL outputs] \
+ [file join $GDB_PARALLEL temp] \
+ [file join $GDB_PARALLEL cache]
}
}
@@ -12,6 +12,10 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Notes:
+# 1) This follows a Python convention for marking internal vs public
functions.
+# Internal functions are prefixed with "_".
namespace eval PerfTest {