diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-05-27 13:59:01 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-05-27 14:00:08 -0400 |
commit | d5a6313e1c4c748a7e744514dbabfa001636f09a (patch) | |
tree | beebd72f21765cddff02dd70b5facce426d61da9 /gdb/testsuite | |
parent | f39632d9579d3c97f1e50a728efed3c5409747d2 (diff) | |
download | gdb-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/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/reverse-init-functions.exp | 29 |
2 files changed, 33 insertions, 0 deletions
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" |