Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb/Windows testsuite: Avoid "bad" words in exe names
@ 2026-07-09 17:43 Pedro Alves
  2026-07-10  5:18 ` Eli Zaretskii
  2026-07-10 14:41 ` [PATCH] gdb/Windows testsuite: Avoid "bad" words in exe names Andrew Burgess
  0 siblings, 2 replies; 8+ messages in thread
From: Pedro Alves @ 2026-07-09 17:43 UTC (permalink / raw)
  To: gdb-patches

Running gdb.base/execl-update-breakpoints.exp on Windows 11 shows this
FAIL:

 (gdb) run
 Starting program: .../gdb.base/execl-update-breakpoints/execl-update-breakpoints1.exe
 Error creating process .../gdb.base/execl-update-breakpoints/execl-update-breakpoints1.exe (error 740): The requested operation requires elevation.
 (gdb) FAIL: gdb.base/execl-update-breakpoints.exp: runto: run to main

Error 740 is ERROR_ELEVATION_REQUIRED.

Turns out that Windows has an "installer detection" heuristic that
refuses to launch executables whose filename contains keywords like
"update", "setup", and "install" without elevation (admin rights),
unless the PE embeds a manifest declaring
requestedExecutionLevel="asInvoker".

I found some older Microsoft documentation claiming that the heuristic
only applies to 32-bit binaries, but what I observe is that:

 - It triggers with 64-bit PEs on current Windows.

And also:

 - Matches the word (e.g. "update") as a substring anywhere in the
   filename (not just as a prefix).

 - Is not drive-dependent.  I thought moving the process to a dev
   drive might suppress the check, but it does not.

I saw this problem first in a downstream ROCgdb testcase, and there I
fixed it by adjusting the name of that particular testcase.

Since this is the second case I'm seeing this already, I thought I'd
fix it in a more general way this time, one that avoids adding the
same explanatory comment to several testcases.

Fix it by making standard_testfile tweak the resulting "binfile"
output variable to avoid the "bad" words, on Windows.  This way, in
theory we only need to handle this once, in a central place.

Change-Id: I93c7d733fb8870b4ec6ff97ca59013211b362061
---
 gdb/testsuite/lib/gdb.exp | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 8eeaf2fc8e6..1201b615ee6 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4130,6 +4130,12 @@ proc is_aarch64_target {} {
     return [expr {![is_aarch32_target]}]
 }
 
+# Return true if the target is Windows-based.
+
+proc is_windows_based_target {} {
+    return [expr {[istarget *-*-cygwin*] || [istarget *-*-mingw*]}]
+}
+
 # Return 1 if displaced stepping is supported on target, otherwise, return 0.
 proc support_displaced_stepping {} {
 
@@ -8414,7 +8420,23 @@ proc standard_testfile {args} {
     global testfile binfile
 
     set testfile $gdb_test_file_name
-    set binfile [standard_output_file ${testfile}]
+
+    if {[is_windows_based_target]} {
+	# Windows' installer detection heuristic refuses to launch
+	# executables whose name contains the following words without
+	# elevation, failing with ERROR_ELEVATION_REQUIRED (740).
+	#
+	# Map of WORD => REPLACEMENT.
+	set word_map {
+	    "update" "up_date"
+	    "setup" "set_up"
+	    "install" "inst_all"
+	}
+	set binfile_basename [string map $word_map $testfile]
+    } else {
+	set binfile_basename $testfile
+    }
+    set binfile [standard_output_file ${binfile_basename}]
 
     if {[llength $args] == 0} {
 	set args .c

base-commit: 4c4e1dd5a02c1a03e7eb408987404ffd1adfd1e4
-- 
2.54.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-07-22 14:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-09 17:43 [PATCH] gdb/Windows testsuite: Avoid "bad" words in exe names Pedro Alves
2026-07-10  5:18 ` Eli Zaretskii
2026-07-10 18:59   ` [PATCH] gdb/Windows testsuite: Embed asInvoker manifest in test executables Pedro Alves
2026-07-10 19:09     ` Pedro Alves
2026-07-11  6:07     ` Eli Zaretskii
2026-07-22 14:16       ` Pedro Alves
2026-07-10 14:41 ` [PATCH] gdb/Windows testsuite: Avoid "bad" words in exe names Andrew Burgess
2026-07-10 19:14   ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox