* [PATCH][gdb/testsuite] Remove dependence on tcl_unknown
@ 2020-06-17 13:18 Tom de Vries
2020-06-17 13:28 ` Pedro Alves
0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2020-06-17 13:18 UTC (permalink / raw)
To: gdb-patches
Hi,
In gdb_init we install a local version of ::unknown, which relies on
::tcl_unknown, which is defined by dejagnu.
This proc may be moved in to a namespace, or disappear altogether, as
indicated by dejagnu maintainers, so we can't rely on it.
Fix this by recreating tcl's version of unknown, and using that instead.
Tested on x86_64-linux.
Any comments?
Thanks,
- Tom
[gdb/testsuite] Remove dependence on tcl_unknown
gdb/testsuite/ChangeLog:
2020-06-17 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_tcl_unknown): New proc.
(gdb_init): Use gdb_tcl_unknown for ::unknown override. Make override
conditional on presence of gdb_tcl_unknown.
(gdb_finish): Make override undo conditional on presence of
gdb_tcl_unknown.
---
gdb/testsuite/lib/gdb.exp | 37 ++++++++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 11 deletions(-)
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index f502eb157d..02867fb5bd 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5177,6 +5177,17 @@ proc gdb_cleanup_globals {} {
}
}
+# Create gdb_tcl_unknown, a copy tcl's ::unknown, provided it's present as a
+# proc.
+set temp [interp create]
+if { [interp eval $temp "info procs ::unknown"] != "" } {
+ set old_args [interp eval $temp "info args ::unknown"]
+ set old_body [interp eval $temp "info body ::unknown"]
+ eval proc gdb_tcl_unknown {$old_args} {$old_body}
+}
+interp delete $temp
+unset temp
+
proc gdb_init { test_file_name } {
# Reset the timeout value to the default. This way, any testcase
# that changes the timeout value without resetting it cannot affect
@@ -5283,14 +5294,16 @@ proc gdb_init { test_file_name } {
gdb_setup_known_globals
- # Dejagnu overrides proc unknown. The dejagnu version may trigger in a
- # test-case but abort the entire test run. To fix this, we install a
- # local version here, which reverts dejagnu's override, and restore
- # dejagnu's version in gdb_finish.
- rename ::unknown ::dejagnu_unknown
- proc unknown { args } {
- # Dejagnu saves the original version in ::tcl_unknown, use it.
- return [uplevel 1 ::tcl_unknown $args]
+ if { [info procs ::gdb_tcl_unknown] != "" } {
+ # Dejagnu overrides proc unknown. The dejagnu version may trigger in a
+ # test-case but abort the entire test run. To fix this, we install a
+ # local version here, which reverts dejagnu's override, and restore
+ # dejagnu's version in gdb_finish.
+ rename ::unknown ::dejagnu_unknown
+ proc unknown { args } {
+ # Use tcl's unknown.
+ return [uplevel 1 ::gdb_tcl_unknown $args]
+ }
}
return $res
@@ -5302,9 +5315,11 @@ proc gdb_finish { } {
global cleanfiles
global known_globals
- # Restore dejagnu's version of proc unknown.
- rename ::unknown ""
- rename ::dejagnu_unknown ::unknown
+ if { [info procs ::gdb_tcl_unknown] != "" } {
+ # Restore dejagnu's version of proc unknown.
+ rename ::unknown ""
+ rename ::dejagnu_unknown ::unknown
+ }
# Exit first, so that the files are no longer in use.
gdb_exit
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH][gdb/testsuite] Remove dependence on tcl_unknown
2020-06-17 13:18 [PATCH][gdb/testsuite] Remove dependence on tcl_unknown Tom de Vries
@ 2020-06-17 13:28 ` Pedro Alves
0 siblings, 0 replies; 2+ messages in thread
From: Pedro Alves @ 2020-06-17 13:28 UTC (permalink / raw)
To: Tom de Vries, gdb-patches
On 6/17/20 2:18 PM, Tom de Vries wrote:
>
> +# Create gdb_tcl_unknown, a copy tcl's ::unknown, provided it's present as a
> +# proc.
> +set temp [interp create]
> +if { [interp eval $temp "info procs ::unknown"] != "" } {
> + set old_args [interp eval $temp "info args ::unknown"]
> + set old_body [interp eval $temp "info body ::unknown"]
> + eval proc gdb_tcl_unknown {$old_args} {$old_body}
> +}
> +interp delete $temp
> +unset temp
Smart.
LGTM.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-17 13:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-17 13:18 [PATCH][gdb/testsuite] Remove dependence on tcl_unknown Tom de Vries
2020-06-17 13:28 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).