public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] [gdb] Rewrite RETHROW_ON_TARGET_CLOSE_ERROR into function
@ 2022-10-25 9:32 Tom de Vries
0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2022-10-25 9:32 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=47e2c30aacff6c50a2557c86cc00f411b750805b
commit 47e2c30aacff6c50a2557c86cc00f411b750805b
Author: Tom de Vries <tdevries@suse.de>
Date: Tue Oct 25 11:32:41 2022 +0200
[gdb] Rewrite RETHROW_ON_TARGET_CLOSE_ERROR into function
Recent commit b2829fcf9b5 ("[gdb] Fix rethrow exception slicing in
insert_bp_location") introduced macro RETHROW_ON_TARGET_CLOSE_ERROR.
I wrote this as a macro in order to have the rethrowing throw be part of the
same function as the catch, but as it turns out that's not necessary.
Rewrite into a function.
Tested on x86_64-linux.
Diff:
---
gdb/breakpoint.c | 45 +++++++++++++++++++++++++--------------------
1 file changed, 25 insertions(+), 20 deletions(-)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index a001e78cfb4..30826032360 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2647,23 +2647,28 @@ breakpoint_kind (const struct bp_location *bl, CORE_ADDR *addr)
return gdbarch_breakpoint_kind_from_pc (bl->gdbarch, addr);
}
-#define RETHROW_ON_TARGET_CLOSE_ERROR(E) \
- do \
- { \
- if ((E).reason != 0) \
- { \
- /* Can't set the breakpoint. */ \
- \
- if ((E).error == TARGET_CLOSE_ERROR) \
- /* If the target has closed then it will have deleted any \
- breakpoints inserted within the target inferior, as a \
- result any further attempts to interact with the \
- breakpoint objects is not possible. Just rethrow the \
- error. Don't use E to rethrow, to prevent object \
- slicing of the exception. */ \
- throw; \
- } \
- } while (0)
+/* Rethrow the currently handled exception, if it's a TARGET_CLOSE_ERROR.
+ E is either the currently handled exception, or a copy, or a sliced copy,
+ so we can't rethrow that one, but we can use it to inspect the properties
+ of the currently handled exception. */
+
+static void
+rethrow_on_target_close_error (const gdb_exception &e)
+{
+ if (e.reason == 0)
+ return;
+ /* Can't set the breakpoint. */
+
+ if (e.error != TARGET_CLOSE_ERROR)
+ return;
+
+ /* If the target has closed then it will have deleted any breakpoints
+ inserted within the target inferior, as a result any further attempts
+ to interact with the breakpoint objects is not possible. Just rethrow
+ the error. Don't use e to rethrow, to prevent object slicing of the
+ exception. */
+ throw;
+}
/* Insert a low-level "breakpoint" of some type. BL is the breakpoint
location. Any error messages are printed to TMP_ERROR_STREAM; and
@@ -2752,7 +2757,7 @@ insert_bp_location (struct bp_location *bl,
}
catch (gdb_exception &e)
{
- RETHROW_ON_TARGET_CLOSE_ERROR (e);
+ rethrow_on_target_close_error (e);
bp_excpt = std::move (e);
}
}
@@ -2792,7 +2797,7 @@ insert_bp_location (struct bp_location *bl,
}
catch (gdb_exception &e)
{
- RETHROW_ON_TARGET_CLOSE_ERROR (e);
+ rethrow_on_target_close_error (e);
bp_excpt = std::move (e);
}
@@ -2817,7 +2822,7 @@ insert_bp_location (struct bp_location *bl,
}
catch (gdb_exception &e)
{
- RETHROW_ON_TARGET_CLOSE_ERROR (e);
+ rethrow_on_target_close_error (e);
bp_excpt = std::move (e);
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-25 9:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-25 9:32 [binutils-gdb] [gdb] Rewrite RETHROW_ON_TARGET_CLOSE_ERROR into function Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).