From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 10/11] [gdb/testsuite] Refactor exception handling in tentative_rename
Date: Mon, 24 Aug 2026 15:58:54 +0200 [thread overview]
Message-ID: <20260824135855.1195963-11-tdevries@suse.de> (raw)
In-Reply-To: <20260824135855.1195963-1-tdevries@suse.de>
Use try/on-error to simplify tentative_rename.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34552
---
gdb/testsuite/lib/gdb.exp | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 99468ac3ef3..e69a598bb10 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -8639,17 +8639,18 @@ proc standard_temp_file {basename} {
# as is and delete A. Return 1 if rename happened.
proc tentative_rename { a b } {
- global errorInfo errorCode
- set code [catch {file rename -- $a $b} result]
- if { $code == 1 && [lindex $errorCode 0] == "POSIX" \
- && [lindex $errorCode 1] == "EEXIST" } {
- file delete $a
- return 0
- }
- if {$code == 1} {
- return -code error -errorinfo $errorInfo -errorcode $errorCode $result
- } elseif {$code > 1} {
- return -code $code $result
+ try {
+ file rename -- $a $b
+ } on error {result opts} {
+ set errorcode [dict get $opts -errorcode]
+ if { [lindex $errorcode 0] == "POSIX" \
+ && [lindex $errorcode 1] == "EEXIST" } {
+ file delete $a
+ return 0
+ }
+
+ # Rethrow.
+ return -options $opts $result
}
return 1
}
--
2.51.0
next prev parent reply other threads:[~2026-08-24 14:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 13:58 [PATCH 00/11] [gdb/testsuite] Refactor exception handling Tom de Vries
2026-08-24 13:58 ` [PATCH 01/11] [gdb/testsuite] Normalize indentation in with_test_prefix Tom de Vries
2026-08-24 13:58 ` [PATCH 02/11] [gdb/testsuite] Fix return -level 2 bug " Tom de Vries
2026-08-24 13:58 ` [PATCH 03/11] [gdb/testsuite] Simplify foreach_with_prefix Tom de Vries
2026-08-24 13:58 ` [PATCH 04/11] [gdb/testsuite] Refactor exception handling in foreach_with_prefix Tom de Vries
2026-08-24 13:58 ` [PATCH 05/11] [gdb/testsuite] Add transparent_uplevel Tom de Vries
2026-08-24 13:58 ` [PATCH 06/11] [gdb/testsuite] Refactor exception handling Tom de Vries
2026-08-24 13:58 ` [PATCH 07/11] [gdb/testsuite] Refactor exception handling in gdb_expect Tom de Vries
2026-08-24 13:58 ` [PATCH 08/11] [gdb/testsuite] Refactor exception handling in gdb_test_multiple Tom de Vries
2026-08-25 7:29 ` Tom de Vries
2026-08-24 13:58 ` [PATCH 09/11] [gdb/testsuite] Refactor exception handling in lock_file_acquire/release Tom de Vries
2026-08-24 13:58 ` Tom de Vries [this message]
2026-08-24 13:58 ` [PATCH 11/11] [gdb/testsuite] Refactor exception handling in with_stub_devices Tom de Vries
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=20260824135855.1195963-11-tdevries@suse.de \
--to=tdevries@suse.de \
--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