From: Tom Tromey Date: Thu, 14 Jun 2018 23:54:04 +0000 (-0700) Subject: Remove release_stop_context_cleanup X-Git-Tag: users/ARM/embedded-binutils-master-2018q4~718 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2d844eaf9c60832756cff80af67e16969c0e11fc;p=external%2Fbinutils.git Remove release_stop_context_cleanup This removes release_stop_context_cleanup, replacing it with a stop_context destructor. It also mildly c++-ifies this struct. gdb/ChangeLog 2018-09-17 Tom Tromey * infrun.c (struct stop_context): Declare constructor, destructor, "changed" method. (stop_context::stop_context): Rename from save_stop_context. (stop_context::~stop_context): Rename from release_stop_context_cleanup. (normal_stop): Update. (stop_context::changed): Rename from stop_context_changed. Return bool. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3c5ebb5..cfb3e7b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,16 @@ 2018-09-17 Tom Tromey + * infrun.c (struct stop_context): Declare constructor, + destructor, "changed" method. + (stop_context::stop_context): Rename from save_stop_context. + (stop_context::~stop_context): Rename from + release_stop_context_cleanup. + (normal_stop): Update. + (stop_context::changed): Rename from stop_context_changed. Return + bool. + +2018-09-17 Tom Tromey + * inferior.h (struct infcall_suspend_state_deleter): New. (infcall_suspend_state_up): New typedef. (struct infcall_control_state_deleter): New. diff --git a/gdb/infrun.c b/gdb/infrun.c index 4828720..3c3bb96 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -8095,6 +8095,13 @@ maybe_remove_breakpoints (void) struct stop_context { + stop_context (); + ~stop_context (); + + DISABLE_COPY_AND_ASSIGN (stop_context); + + bool changed () const; + /* The stop ID. */ ULONGEST stop_id; @@ -8110,59 +8117,50 @@ struct stop_context int inf_num; }; -/* Returns a new stop context. If stopped for a thread event, this +/* Initializes a new stop context. If stopped for a thread event, this takes a strong reference to the thread. */ -static struct stop_context * -save_stop_context (void) +stop_context::stop_context () { - struct stop_context *sc = XNEW (struct stop_context); - - sc->stop_id = get_stop_id (); - sc->ptid = inferior_ptid; - sc->inf_num = current_inferior ()->num; + stop_id = get_stop_id (); + ptid = inferior_ptid; + inf_num = current_inferior ()->num; if (inferior_ptid != null_ptid) { /* Take a strong reference so that the thread can't be deleted yet. */ - sc->thread = inferior_thread (); - sc->thread->incref (); + thread = inferior_thread (); + thread->incref (); } else - sc->thread = NULL; - - return sc; + thread = NULL; } /* Release a stop context previously created with save_stop_context. Releases the strong reference to the thread as well. */ -static void -release_stop_context_cleanup (void *arg) +stop_context::~stop_context () { - struct stop_context *sc = (struct stop_context *) arg; - - if (sc->thread != NULL) - sc->thread->decref (); - xfree (sc); + if (thread != NULL) + thread->decref (); } /* Return true if the current context no longer matches the saved stop context. */ -static int -stop_context_changed (struct stop_context *prev) -{ - if (prev->ptid != inferior_ptid) - return 1; - if (prev->inf_num != current_inferior ()->num) - return 1; - if (prev->thread != NULL && prev->thread->state != THREAD_STOPPED) - return 1; - if (get_stop_id () != prev->stop_id) - return 1; - return 0; +bool +stop_context::changed () const +{ + if (ptid != inferior_ptid) + return true; + if (inf_num != current_inferior ()->num) + return true; + if (thread != NULL && thread->state != THREAD_STOPPED) + return true; + if (get_stop_id () != stop_id) + return true; + return false; } /* See infrun.h. */ @@ -8305,9 +8303,7 @@ normal_stop (void) of stop_command's pre-hook not existing). */ if (stop_command != NULL) { - struct stop_context *saved_context = save_stop_context (); - struct cleanup *old_chain - = make_cleanup (release_stop_context_cleanup, saved_context); + stop_context saved_context; TRY { @@ -8325,12 +8321,8 @@ normal_stop (void) gone. Likewise if the command switches thread or inferior -- the observers would print a stop for the wrong thread/inferior. */ - if (stop_context_changed (saved_context)) - { - do_cleanups (old_chain); - return 1; - } - do_cleanups (old_chain); + if (saved_context.changed ()) + return 1; } /* Notify observers about the stop. This is where the interpreters