aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog4
-rwxr-xr-xgdb/make-init-c15
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.base/reverse-init-functions.exp29
4 files changed, 51 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1db1264..9d06a77 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2021-05-27 Simon Marchi <simon.marchi@polymtl.ca>
+ * make-init-c: Add option to reverse function calls.
+
+2021-05-27 Simon Marchi <simon.marchi@polymtl.ca>
+
* Makefile.in (INIT_FILES_FILTER_OUT): New.
(INIT_FILES): Use INIT_FILES_FILTER_OUT.
(stamp-init): Use make-init-c.
diff --git a/gdb/make-init-c b/gdb/make-init-c
index 1588760..e3c5985 100755
--- a/gdb/make-init-c
+++ b/gdb/make-init-c
@@ -42,6 +42,7 @@ set -e
echo "/* Do not modify this file. */"
echo "/* It is created automatically by the Makefile. */"
echo "#include \"defs.h\" /* For initialize_file_ftype. */"
+echo "#include <algorithm>"
echo ""
sed -n -e 's/^\(_initialize_[a-zA-Z0-9_]*\) ()$/\1/p' "$@" | while read -r name; do
echo "extern initialize_file_ftype $name;"
@@ -51,7 +52,19 @@ echo "void initialize_all_files ();"
echo "void"
echo "initialize_all_files ()"
echo "{"
+echo " std::vector<initialize_file_ftype *> functions ="
+echo " {"
sed -n -e 's/^\(_initialize_[a-zA-Z0-9_]*\) ()$/\1/p' "$@" | while read -r name; do
- echo " $name ();"
+ echo " $name,"
done
+echo " };"
+echo ""
+echo " /* If GDB_REVERSE_INIT_FUNCTIONS is set (any value), reverse the"
+echo " order in which initialization functions are called. This is"
+echo " used by the testsuite. */"
+echo " if (getenv (\"GDB_REVERSE_INIT_FUNCTIONS\") != nullptr)"
+echo " std::reverse (functions.begin (), functions.end ());"
+echo ""
+echo " for (initialize_file_ftype *function : functions)"
+echo " function ();"
echo "}"
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 22a99c0..e2a95d48 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2021-05-27 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * gdb.base/reverse-init-functions.exp: New.
+
2021-05-27 Tom de Vries <tdevries@suse.de>
PR symtab/27919
diff --git a/gdb/testsuite/gdb.base/reverse-init-functions.exp b/gdb/testsuite/gdb.base/reverse-init-functions.exp
new file mode 100644
index 0000000..76fa793
--- /dev/null
+++ b/gdb/testsuite/gdb.base/reverse-init-functions.exp
@@ -0,0 +1,29 @@
+# Copyright 2020-2021 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 reversing the order of initialize functions calls, during GDB startup.
+#
+# The intent is to catch possible unintended dependencies between two
+# initialize functions, where one depends on the other running before it.
+
+standard_testfile
+
+save_vars { env(GDB_REVERSE_INIT_FUNCTIONS) } {
+ setenv GDB_REVERSE_INIT_FUNCTIONS 1
+ clean_restart
+}
+
+# Verify that GDB has started and is ready to accept commands.
+gdb_test "print 12321" " = 12321"