[PATCH] gdb/testsuite: introduce save_procs proc
Tom Tromey
tom@tromey.com
Thu May 28 14:43:05 GMT 2020
>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
Simon> The test gdb.base/dbx.exp redefines gdb_file_cmd, which is normally
Simon> defined in lib/gdb.exp. It restores the original version of the proc at
Simon> the end. But the problem is that if the test fails and an
Simon> exception is thrown, it won't be restored and the following tests will
Simon> be affected.
Although I'd rather we not encourage proc overriding like this, on the
other hand I guess there's nothing really wrong with what you're doing.
Simon> # file into gdb for a dbx session. So why not just override gdb_file_cmd with the
Simon> # right sequence of events, allowing gdb_load to do its normal thing? This way
Simon> # remotes and simulators will work, too.
This comment indicates that this has always been a hack :)
Simon> + # Save args and bodies of specified procs.
Simon> + foreach proc_name $procs {
Simon> + set proc_args [info args $proc_name]
Simon> + set proc_body [info body $proc_name]
Simon> +
Simon> + set saved($proc_name) [list $proc_args $proc_body]
Here you could store [list proc $proc_name $proc_args $proc_body]
Simon> + # Restore procs.
Simon> + foreach {proc_name value} [array get saved] {
Simon> + set proc_args [lindex $value 0]
Simon> + set proc_body [lindex $value 1]
Simon> +
Simon> + eval proc $proc_name {$proc_args} {$proc_body}
Then this weird-looking construct could be replaced with the simpler
eval $value
Tom
More information about the Gdb-patches
mailing list