From: Pedro Alves <pedro@palves.net>
To: gdb-patches@sourceware.org
Subject: [PATCH 05/27] gdb/testsuite: Recognize windows-msvc across lib/gdb.exp procedures
Date: Thu, 23 Jul 2026 14:00:56 +0100 [thread overview]
Message-ID: <20260723130118.206735-6-pedro@palves.net> (raw)
In-Reply-To: <20260723130118.206735-1-pedro@palves.net>
The testsuite has many istarget checks like e.g.:
[istarget *-*-mingw*] || [istarget *-*-cygwin*]
and
[istarget *-*-mingw*] || [istarget *-*-cygwin*] || [istarget *-*-pe*]
to decide Windows- or PE/COFF-specific behavior. These do not match a
windows-msvc target, whose triplets are
{x86_64,aarch64,i686}-pc-windows-msvc, so on such a configuration the
testsuite would take the non-Windows paths and misbehave in many
places.
Rather than adding windows-msvc to each site by hand, introduce two
predicates and replace the existing checks in lib/gdb.exp with them:
- is_windows_native_target -- mingw* or windows* triplets, as opposed
to Cygwin.
- is_pecoff_target -- any Windows-based target or a bare PE target.
is_windows_based_target is extended to build on
is_windows_native_target so it too picks up windows-msvc.
Following patches will go over the testcases throughout using these
predicates.
Change-Id: I786285c009565ec2d3ddc06c0ba57d466d42e4d0
---
gdb/testsuite/lib/gdb.exp | 62 +++++++++++++++++++--------------------
1 file changed, 31 insertions(+), 31 deletions(-)
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index fb9f29ee03d..db22d2bc320 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2528,7 +2528,7 @@ proc default_gdb_exit {} {
}
if { ([is_remote host] && [board_info host exists fileid])
- || [istarget *-*-mingw*] } {
+ || [is_windows_native_target] } {
send_gdb "quit\n"
gdb_expect 10 {
-re "y or n" {
@@ -3102,9 +3102,7 @@ proc allow_shlib_tests {} {
if {([istarget *-*-linux*]
|| [istarget *-*-*bsd*]
|| [istarget *-*-solaris2*]
- || [istarget *-*-mingw*]
- || [istarget *-*-cygwin*]
- || [istarget *-*-pe*])} {
+ || [is_pecoff_target])} {
return 1
}
@@ -3210,7 +3208,7 @@ gdb_caching_proc allow_dlmopen_tests {} {
# Return 1 if we should allow TUI-related tests.
gdb_caching_proc allow_tui_tests {} {
- if { [istarget *-*-mingw*] } {
+ if { [is_windows_native_target] } {
# Avoid "Cannot enable the TUI when output is not a terminal".
return 0
}
@@ -4217,10 +4215,25 @@ proc is_aarch64_target {} {
return [expr {![is_aarch32_target]}]
}
+# Return true if the target is Windows native (as opposed to Cygwin).
+
+proc is_windows_native_target {} {
+ return [expr {[istarget *-*-mingw*]
+ || [istarget *-*-windows*]}]
+}
+
# Return true if the target is Windows-based.
proc is_windows_based_target {} {
- return [expr {[istarget *-*-cygwin*] || [istarget *-*-mingw*]}]
+ return [expr {[istarget *-*-cygwin*]
+ || [is_windows_native_target]}]
+}
+
+# Return true if the target is PE/COFF-based.
+
+proc is_pecoff_target {} {
+ return [expr {[is_windows_based_target]
+ || [istarget *-*-pe*]}]
}
# Return true if this is a native configuration in GDB's sense. This
@@ -5736,7 +5749,7 @@ proc skip_inline_var_tests {} {
# time out sequences.
proc allow_fork_tests {} {
- if {[istarget "*-*-cygwin*"] || [istarget "*-*-mingw*"]} {
+ if {[is_windows_based_target]} {
return 0
}
@@ -5750,7 +5763,7 @@ proc allow_fork_tests {} {
# false.
proc allow_multi_inferior_tests {} {
- if {[istarget "*-*-cygwin*"] || [istarget "*-*-mingw*"]} {
+ if {[is_windows_based_target]} {
return 0
}
@@ -6792,17 +6805,14 @@ proc gdb_compile {source dest type options} {
# IBM xlc compiler doesn't accept shared library named other
# than .so: use "-Wl," to bypass this
lappend source "-Wl,$shlib_name"
- } elseif { ([istarget "*-*-mingw*"]
- || [istarget *-*-cygwin*]
- || [istarget *-*-pe*])} {
+ } elseif { [is_pecoff_target] } {
lappend source "${shlib_name}.a"
} else {
lappend source $shlib_name
}
if { $shlib_found == 0 } {
set shlib_found 1
- if { ([istarget "*-*-mingw*"]
- || [istarget *-*-cygwin*]) } {
+ if { [is_pecoff_target] } {
lappend new_options "ldflags=-Wl,--enable-auto-import"
}
if { [test_compiler_info "gcc-*"] || [test_compiler_info "clang-*"] } {
@@ -6924,9 +6934,7 @@ proc gdb_compile {source dest type options} {
# (depending on the platform) to set a special rpath value, to allow
# the executable to find the libraries it depends on.
if { $shlib_load || $shlib_found } {
- if { ([istarget "*-*-mingw*"]
- || [istarget *-*-cygwin*]
- || [istarget *-*-pe*]) } {
+ if { [is_pecoff_target] } {
# Do not need anything.
} elseif { [istarget *-*-freebsd*] || [istarget *-*-openbsd*] } {
lappend new_options "ldflags=-Wl,-rpath,${outdir}"
@@ -7022,9 +7030,7 @@ proc gdb_compile {source dest type options} {
}
if { $type == "executable" } {
- if { ([istarget "*-*-mingw*"]
- || [istarget "*-*-*djgpp"]
- || [istarget "*-*-cygwin*"])} {
+ if { [is_windows_based_target] || [istarget "*-*-*djgpp"] } {
# Force output to unbuffered mode, by linking in an object file
# with a global constructor that calls setvbuf.
#
@@ -7299,9 +7305,7 @@ proc gdb_compile_shlib_1 {sources dest options} {
} else {
lappend link_options "additional_flags=-shared"
- if { ([istarget "*-*-mingw*"]
- || [istarget *-*-cygwin*]
- || [istarget *-*-pe*]) } {
+ if { [is_pecoff_target] } {
if { [is_remote host] } {
set name [file tail ${dest}]
} else {
@@ -7325,10 +7329,7 @@ proc gdb_compile_shlib_1 {sources dest options} {
if {[gdb_compile "${objects}" "${dest}" executable $link_options] != ""} {
return -1
}
- if { [is_remote host]
- && ([istarget "*-*-mingw*"]
- || [istarget *-*-cygwin*]
- || [istarget *-*-pe*]) } {
+ if { [is_remote host] && [is_pecoff_target] } {
set dest_tail_name [file tail ${dest}]
remote_upload host $dest_tail_name.a ${dest}.a
remote_file host delete $dest_tail_name.a
@@ -7841,7 +7842,7 @@ proc kill_wait_spawned_process { proc_spawn_id } {
proc spawn_id_get_pid { spawn_id } {
set testpid [exp_pid -i $spawn_id]
- if { [istarget "*-*-cygwin*"] || [istarget "*-*-mingw*"] } {
+ if { [is_windows_based_target] } {
# testpid is the Cygwin PID, GDB uses the Windows PID, which
# might be different due to the way fork/exec works.
set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
@@ -9102,7 +9103,7 @@ proc gdb_continue_to_end {{mssg ""} {command continue} {allow_extra 0}} {
if {$allow_extra} {
set extra ".*"
- } elseif {[istarget *-*-cygwin*] || [istarget *-*-mingw*]} {
+ } elseif {[is_windows_based_target]} {
# On Windows, even on supposedly single-threaded programs, we
# may see thread exit output when running to end, for threads
# spawned by the runtime. E.g.:
@@ -9479,7 +9480,7 @@ gdb_caching_proc gdb_has_argv0 {} {
|| [istarget *-*-solaris*]
|| [istarget *-*-aix*]
|| [istarget *-*-gnu*]
- || [istarget *-*-cygwin*] || [istarget *-*-mingw32*]
+ || [is_windows_based_target]
|| [istarget *-*-*djgpp*] || [istarget *-*-go32*]
|| [istarget *-wince-pe] || [istarget *-*-mingw32ce*]
|| [istarget *-*-osf*]
@@ -9512,8 +9513,7 @@ gdb_caching_proc gdb_has_argv0 {} {
# Returns "" if there is none.
proc get_build_id { filename } {
- if { ([istarget "*-*-mingw*"]
- || [istarget *-*-cygwin*]) } {
+ if { ([is_windows_based_target]) } {
set objdump_program [gdb_find_objdump]
set result [catch {set data [exec $objdump_program -p $filename | grep signature | cut "-d " -f4]} output]
verbose "result is $result"
--
2.54.0
next prev parent reply other threads:[~2026-07-23 13:03 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 13:00 [PATCH 00/27] Teach the testsuite about the Windows/MSVC target Pedro Alves
2026-07-23 13:00 ` [PATCH 01/27] gdb/testsuite: Don't link with -lm on windows-msvc Pedro Alves
2026-07-23 13:00 ` [PATCH 02/27] gdb/testsuite: Use unprefixed runtest for a native Windows/MSVC build Pedro Alves
2026-07-23 13:00 ` [PATCH 03/27] gdb/testsuite: Find host binutils in a native Windows/MSVC config Pedro Alves
2026-07-23 13:00 ` [PATCH 04/27] gdb/testsuite: Compile with -Wno-deprecated-declarations on windows-msvc Pedro Alves
2026-07-23 13:00 ` Pedro Alves [this message]
2026-07-23 13:00 ` [PATCH 06/27] gdb/testsuite: Don't pass -fPIC on PE/COFF targets Pedro Alves
2026-07-23 13:00 ` [PATCH 07/27] gdb/testsuite: Use /IMPLIB on windows-msvc to name import libraries Pedro Alves
2026-07-23 13:00 ` [PATCH 08/27] gdb/testsuite: Export all DLL symbols on windows-msvc via generated .def Pedro Alves
2026-07-23 13:01 ` [PATCH 09/27] gdb/testsuite: Restrict --no-as-needed to ELF targets Pedro Alves
2026-07-23 13:01 ` [PATCH 10/27] gdb.base/set-cwd.exp: Use is_windows_native_target Pedro Alves
2026-07-23 13:01 ` [PATCH 11/27] gdb.base/exitsignal.exp: " Pedro Alves
2026-07-23 13:01 ` [PATCH 12/27] gdb.base/exitsignal.exp: Relax SIGSEGV second-chance pattern Pedro Alves
2026-07-23 13:01 ` [PATCH 13/27] gdb/testsuite: Skip -Ttext-segment on PE Pedro Alves
2026-07-23 13:01 ` [PATCH 14/27] gdb/testsuite: Support text_segment on windows-msvc via /BASE Pedro Alves
2026-07-23 13:01 ` [PATCH 15/27] gdb.base/shreloc.exp: Use gdb_compile text_segment to set image base Pedro Alves
2026-07-23 13:01 ` [PATCH 16/27] gdb/coffread: Don't relocate absolute symbols Pedro Alves
2026-07-23 13:01 ` [PATCH 17/27] gdb.base/shreloc.exp: Test absolute symbols portably Pedro Alves
2026-07-23 13:01 ` [PATCH 18/27] gdb: %p => host_address_to_string, target-section owner token Pedro Alves
2026-07-23 13:01 ` [PATCH 19/27] gdb: %p => host_address_to_string, dump_for_expression Pedro Alves
2026-07-23 13:01 ` [PATCH 20/27] gdb: %p => host_address_to_string, find_symtab_matching_filename Pedro Alves
2026-07-23 13:01 ` [PATCH 21/27] gdb: %p => host_address_to_string, handle_output_debug_string Pedro Alves
2026-07-23 13:01 ` [PATCH 22/27] gdb.base/maint-info-sections.exp: Match exec file name with optional .exe Pedro Alves
2026-07-23 13:01 ` [PATCH 23/27] gdb.base/maint-info-sections.exp: Remove stale Windows DATA xfail Pedro Alves
2026-07-23 13:01 ` [PATCH 24/27] gdb.base/solib-weak.exp: Skip on all PE/COFF targets Pedro Alves
2026-07-23 13:01 ` [PATCH 25/27] gdb.server/wrapper.exp: Skip on all Windows targets Pedro Alves
2026-07-23 13:01 ` [PATCH 26/27] gdb/testsuite: Factor out dlopen/LoadLibrary shim into lib/gdb-dlfcn.h Pedro Alves
2026-07-23 13:01 ` [PATCH 27/27] gdb/testsuite/lib/gdb-dlfcn.h: __WIN32__ => _WIN32 Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260723130118.206735-6-pedro@palves.net \
--to=pedro@palves.net \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox