aboutsummaryrefslogtreecommitdiff
path: root/gdb/make-init-c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-05-27 13:59:01 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-05-27 14:00:08 -0400
commitd5a6313e1c4c748a7e744514dbabfa001636f09a (patch)
treebeebd72f21765cddff02dd70b5facce426d61da9 /gdb/make-init-c
parentf39632d9579d3c97f1e50a728efed3c5409747d2 (diff)
downloadgdb-d5a6313e1c4c748a7e744514dbabfa001636f09a.zip
gdb-d5a6313e1c4c748a7e744514dbabfa001636f09a.tar.gz
gdb-d5a6313e1c4c748a7e744514dbabfa001636f09a.tar.bz2
gdb: add option to reverse order of _initialize function calls
An earlier patch in this series fixed a dependency problem between two _initialize functions. That problem was uncovered by reversing the order of the initialize function calls. In short, symtab.c tried to add the alias "maintenance flush-symbol-cache" for the command "maintenance flush symbol-cache". Because the "maintenance flush" prefix command was not yet created (it happens in maint.c, initialized later in this reversed order), the add_alias_cmd function returned NULL. That result was passed to deprecate_cmd, which didn't expected that value, and that caused a segfault. This was fixed by changing alias creation functions to take the target command as a cmd_list_element, instead of by name. This patch adds a runtime option to reverse the order of the initialize calls at will. I chose to use an environment variable for this, over a parameter (even a "maintenance" one), because: - The init functions are called before the early init commands are executed, so we could use -iex to turn this mode on early enough. This is obvious when you remember that commands / parameters are created by initialize funcitions :). - This is not something anybody would want to tweak after startup anyway. gdb/ChangeLog: * make-init-c: Add option to reverse function calls. gdb/testsuite/ChangeLog: * gdb.base/reverse-init-functions.exp: New. Change-Id: I543e609cf526e7cb145a006a794d0e6851b63f45
Diffstat (limited to 'gdb/make-init-c')
-rwxr-xr-xgdb/make-init-c15
1 files changed, 14 insertions, 1 deletions
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 "}"