• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisão47e2c30aacff6c50a2557c86cc00f411b750805b (tree)
Hora2022-10-25 18:32:41
AutorTom de Vries <tdevries@suse...>
CommiterTom de Vries

Mensagem de Log

[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.

Mudança Sumário

Diff

--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2647,23 +2647,28 @@ breakpoint_kind (const struct bp_location *bl, CORE_ADDR *addr)
26472647 return gdbarch_breakpoint_kind_from_pc (bl->gdbarch, addr);
26482648 }
26492649
2650-#define RETHROW_ON_TARGET_CLOSE_ERROR(E) \
2651- do \
2652- { \
2653- if ((E).reason != 0) \
2654- { \
2655- /* Can't set the breakpoint. */ \
2656- \
2657- if ((E).error == TARGET_CLOSE_ERROR) \
2658- /* If the target has closed then it will have deleted any \
2659- breakpoints inserted within the target inferior, as a \
2660- result any further attempts to interact with the \
2661- breakpoint objects is not possible. Just rethrow the \
2662- error. Don't use E to rethrow, to prevent object \
2663- slicing of the exception. */ \
2664- throw; \
2665- } \
2666- } while (0)
2650+/* Rethrow the currently handled exception, if it's a TARGET_CLOSE_ERROR.
2651+ E is either the currently handled exception, or a copy, or a sliced copy,
2652+ so we can't rethrow that one, but we can use it to inspect the properties
2653+ of the currently handled exception. */
2654+
2655+static void
2656+rethrow_on_target_close_error (const gdb_exception &e)
2657+{
2658+ if (e.reason == 0)
2659+ return;
2660+ /* Can't set the breakpoint. */
2661+
2662+ if (e.error != TARGET_CLOSE_ERROR)
2663+ return;
2664+
2665+ /* If the target has closed then it will have deleted any breakpoints
2666+ inserted within the target inferior, as a result any further attempts
2667+ to interact with the breakpoint objects is not possible. Just rethrow
2668+ the error. Don't use e to rethrow, to prevent object slicing of the
2669+ exception. */
2670+ throw;
2671+}
26672672
26682673 /* Insert a low-level "breakpoint" of some type. BL is the breakpoint
26692674 location. Any error messages are printed to TMP_ERROR_STREAM; and
@@ -2752,7 +2757,7 @@ insert_bp_location (struct bp_location *bl,
27522757 }
27532758 catch (gdb_exception &e)
27542759 {
2755- RETHROW_ON_TARGET_CLOSE_ERROR (e);
2760+ rethrow_on_target_close_error (e);
27562761 bp_excpt = std::move (e);
27572762 }
27582763 }
@@ -2792,7 +2797,7 @@ insert_bp_location (struct bp_location *bl,
27922797 }
27932798 catch (gdb_exception &e)
27942799 {
2795- RETHROW_ON_TARGET_CLOSE_ERROR (e);
2800+ rethrow_on_target_close_error (e);
27962801 bp_excpt = std::move (e);
27972802 }
27982803
@@ -2817,7 +2822,7 @@ insert_bp_location (struct bp_location *bl,
28172822 }
28182823 catch (gdb_exception &e)
28192824 {
2820- RETHROW_ON_TARGET_CLOSE_ERROR (e);
2825+ rethrow_on_target_close_error (e);
28212826 bp_excpt = std::move (e);
28222827 }
28232828 }