diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-06-12 15:09:33 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2020-06-12 15:09:33 +0200 |
commit | a29d5112814e7a6744f03bddfe6756e2aa5e7a50 (patch) | |
tree | 9475dd9d41c62c3fa2c7c021b8c548fdcc240978 /gdbserver | |
parent | 8c74a764f2cf5ea5e6997e35ba0f755fe2c09889 (diff) | |
download | gdb-a29d5112814e7a6744f03bddfe6756e2aa5e7a50.zip gdb-a29d5112814e7a6744f03bddfe6756e2aa5e7a50.tar.gz gdb-a29d5112814e7a6744f03bddfe6756e2aa5e7a50.tar.bz2 |
gdb/testsuite: Prevent globals leaking between test scripts
Many of the test scripts create variables in the global namespace,
these variables will then be present for the following test scripts.
In most cases this is harmless, but in some cases this can cause
problems.
For example, if a variable is created as an array in one script, but
then assigned as a scalar in a different script, this will cause a TCL
error.
The solution proposed in this patch is to have the GDB test harness
record a list of all known global variables at the point just before
we source the test script. Then, after the test script has run, we
again iterate over all global variables. Any variable that was not in
the original list is deleted, unless it was marked as a persistent global
variable using gdb_persistent_global.
The assumption here is that no test script should need to create a
global variable that will outlive the lifetime of the test script
itself. With this patch in place all tests currently seem to pass, so
the assumption seems to hold.
gdb/testsuite/ChangeLog:
2020-06-12 Andrew Burgess <andrew.burgess@embecosm.com>
Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_known_globals, gdb_persistent_globals): New global.
(gdb_persistent_global, gdb_persistent_global_no_decl): New proc.
(gdb_setup_known_globals): New proc.
(gdb_cleanup_globals): New proc.
* lib/gdb.exp (load_lib): New override proc.
(gdb_stdin_log_init): Set var in_file as persistent global.
* lib/pascal.exp (gdb_stdin_log_init): Set vars
pascal_compiler_is_gpc, pascal_compiler_is_fpc, gpc_compiler and
fpc_compiler as persistent global.
Diffstat (limited to 'gdbserver')
0 files changed, 0 insertions, 0 deletions