From 25dfed247b09f2e5c9672a8737c8208ff90928bf Mon Sep 17 00:00:00 2001 From: Sandra Loosemore Date: Wed, 22 Jul 2020 20:42:20 -0700 Subject: [PATCH] Fix more bugs in gdb testglue wrapper handling In commit 24ac169ac5a918cd82b7485935f0c40a094c625e, this patch: 2020-02-21 Shahab Vahedi * lib/gdb.exp (gdb_wrapper_init): Reset "gdb_wrapper_initialized" to 0 if "wrapper_file" does not exist. attempted to fix problems finding the gdb test wrapper gdb_tg.o in some tests that cd to some non-default directory by rebuilding also the test wrapper in that directory. This had the side-effect of leaving these .o files in various places in the GDB source directory tree. Furthermore, while the tests that cd to some non-default directory cannot run on remote host, the code that was added to probe for the presence of the wrapper file was also specific to host == build. This patch reverts the problematic parts of that commit and replaces it with forcing use of an absolute (rather than relative) pathname to the .o file for linking when host == build. While debugging this patch, I also observed that use of the construct "[info exists gdb_wrapper_file]" was not reliable for detecting when that variable had been initialized by gdb_wrapper_init. I rewrote that so that the variable is always initialized and has a value of an empty string when no wrapper file is needed. 2020-07-22 Sandra Loosemore gdb/testsuite/ * lib/gdb.exp (gdb_wrapper_file, gdb_wrapper_flags): Initialize to empty string at top level. (gdb_wrapper_init): Revert check for file existence on build. Build the wrapper in its default place, not a build-specific location. When host == build, make the pathname absolute. (gdb_compile): Delete leftover declaration of gdb_wrapper_initialized. Check gdb_wrapper_file being an empty string instead of uninitialized. --- gdb/testsuite/ChangeLog | 11 +++++++++++ gdb/testsuite/lib/gdb.exp | 23 +++++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index a9f624dfd35..06bafcebc9d 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2020-07-22 Sandra Loosemore + + * lib/gdb.exp (gdb_wrapper_file, gdb_wrapper_flags): + Initialize to empty string at top level. + (gdb_wrapper_init): Revert check for file existence on build. + Build the wrapper in its default place, not a build-specific + location. When host == build, make the pathname absolute. + (gdb_compile): Delete leftover declaration of + gdb_wrapper_initialized. Check gdb_wrapper_file being an empty + string instead of uninitialized. + 2020-07-22 Kevin Buettner * gdb.base/corefile2.exp: New file. diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 78dae17b0c7..5bdeed70f30 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -3694,6 +3694,8 @@ proc current_target_name { } { set gdb_wrapper_initialized 0 set gdb_wrapper_target "" +set gdb_wrapper_file "" +set gdb_wrapper_flags "" proc gdb_wrapper_init { args } { global gdb_wrapper_initialized @@ -3701,27 +3703,25 @@ proc gdb_wrapper_init { args } { global gdb_wrapper_flags global gdb_wrapper_target - # If the wrapper is initialized but the wrapper file cannot be - # found anymore, the wrapper file must be built again. - if { $gdb_wrapper_initialized == 1 && \ - [info exists gdb_wrapper_file] && \ - ![file exists $gdb_wrapper_file] } { - verbose "reinitializing the wrapper" - set gdb_wrapper_initialized 0 - } - if { $gdb_wrapper_initialized == 1 } { return; } if {[target_info exists needs_status_wrapper] && \ [target_info needs_status_wrapper] != "0"} { - set result [build_wrapper [standard_output_file "testglue.o"]] + set result [build_wrapper "testglue.o"] if { $result != "" } { set gdb_wrapper_file [lindex $result 0] + if ![is_remote host] { + set gdb_wrapper_file [file join [pwd] $gdb_wrapper_file] + } set gdb_wrapper_flags [lindex $result 1] } else { warning "Status wrapper failed to build." } + } else { + set gdb_wrapper_file "" + set gdb_wrapper_flags "" } + verbose "set gdb_wrapper_file = $gdb_wrapper_file" set gdb_wrapper_initialized 1 set gdb_wrapper_target [current_target_name] } @@ -3857,7 +3857,6 @@ proc gdb_compile {source dest type options} { global GDB_TESTCASE_OPTIONS global gdb_wrapper_file global gdb_wrapper_flags - global gdb_wrapper_initialized global srcdir global objdir global gdb_saved_set_unbuffered_mode_obj @@ -3994,7 +3993,7 @@ proc gdb_compile {source dest type options} { if {[target_info exists needs_status_wrapper] && \ [target_info needs_status_wrapper] != "0" && \ - [info exists gdb_wrapper_file]} { + $gdb_wrapper_file != "" } { lappend options "libs=${gdb_wrapper_file}" lappend options "ldflags=${gdb_wrapper_flags}" } -- 2.30.2