Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: gdb-patches@sourceware.org
Subject: [PATCH 22/27] gdb.base/maint-info-sections.exp: Match exec file name with optional .exe
Date: Thu, 23 Jul 2026 14:01:13 +0100	[thread overview]
Message-ID: <20260723130118.206735-23-pedro@palves.net> (raw)
In-Reply-To: <20260723130118.206735-1-pedro@palves.net>

Two tests of gdb.base/maint-info-sections.exp match a header line
against the expected binary name:

 1. The "maint info sections" test matches the "Exec file:" header
    with:

      Exec file: .*${binfile}., file type...

    where the trailing "." is meant to match the closing quote after
    the file name.

 2. The "maint info sections -all-objects" test matches the "Object
    file:" header, expecting the closing quote immediately after
    $binfile.  Both assume the printed name is exactly $binfile.

But on a host where the executable has a ".exe" suffix that is not
part of $binfile, the printed name is "$binfile.exe", so neither
header matches: the single "." matches the dot instead of the quote,
and the "Object file:" quote does not line up at all.  The tests then
fail, e.g., on x86_64-w64-mingw32:

  FAIL: gdb.base/maint-info-sections.exp: maint info sections
  FAIL: gdb.base/maint-info-sections.exp: maint info sections -all-objects

Fix this by allowing for an optional ".exe" between the file name and
the closing quote in both, matching the closing quote explicitly.

Tested on:

 x86_64-pc-linux-gnu
 x86_64-pc-cygwin
 x86_64-w64-mingw32
 x86_64-pc-windows-msvc

Change-Id: Icce62d69d8e23a8e859639a2e4a72c6f5c24ec0e
---
 gdb/testsuite/gdb.base/maint-info-sections.exp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/gdb.base/maint-info-sections.exp b/gdb/testsuite/gdb.base/maint-info-sections.exp
index ac712137cc6..3cc128c0ad3 100644
--- a/gdb/testsuite/gdb.base/maint-info-sections.exp
+++ b/gdb/testsuite/gdb.base/maint-info-sections.exp
@@ -123,19 +123,23 @@ gdb_test_multiple "maint info sections" "general output check" {
 set text_section ".text"
 set data_section ".data"
 
+# On some hosts the executable has a ".exe" suffix that is not part of
+# $binfile (e.g. a native Windows build), so allow for it between the
+# file name and the closing quote.
+set exec_re "Exec file: .*${binfile}(\\.exe)?', file type"
 gdb_test_multiple "maint info sections" "" {
-    -re -wrap "Exec file: .*${binfile}., file type.*ER_RO.*" {
+    -re -wrap "${exec_re}.*ER_RO.*" {
 	# Looks like RealView which uses different section names.
 	set text_section ER_RO
 	set data_section ER_RW
 	pass "maint info sections"
     }
-    -re -wrap "Exec file: .*${binfile}., file type.*neardata.*" {
+    -re -wrap "${exec_re}.*neardata.*" {
 	# c6x doesn't have .data section.  It has .neardata and .fardata section.
 	set data_section ".neardata"
 	pass "maint info sections"
     }
-    -re -wrap "Exec file: .*${binfile}., file type.*" {
+    -re -wrap "${exec_re}.*" {
 	pass "maint info sections"
     }
 }
@@ -207,7 +211,7 @@ gdb_test_no_output "maint info sections" \
 set seen_header false
 set seen_a_section false
 gdb_test_multiple "maint info sections -all-objects" "" {
-    -re "Object file: `${binfile}', file type \[^.\]+\.\r\n" {
+    -re "Object file: `${binfile}(\\.exe)?', file type \[^.\]+\.\r\n" {
 	set seen_header true
 	exp_continue
     }
-- 
2.54.0


  parent reply	other threads:[~2026-07-23 13:07 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 ` [PATCH 05/27] gdb/testsuite: Recognize windows-msvc across lib/gdb.exp procedures Pedro Alves
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 ` Pedro Alves [this message]
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-23-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