Fix more bugs in gdb testglue wrapper handling

In commit 24ac169ac5a918cd82b7485935f0c40a094c625e, this patch:

	2020-02-21  Shahab Vahedi  <shahab@synopsys.com>

	* 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  <sandra@codesourcery.com>

	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.
This commit is contained in:
Sandra Loosemore
2020-07-22 20:42:20 -07:00
parent 25322a133a
commit 25dfed247b
2 changed files with 22 additions and 12 deletions

View File

@ -1,3 +1,14 @@
2020-07-22 Sandra Loosemore <sandra@codesourcery.com>
* 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 <kevinb@redhat.com>
* gdb.base/corefile2.exp: New file.

View File

@ -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}"
}