From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id B4D103858C62; Mon, 28 Nov 2022 19:21:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4D103858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669663286; bh=7wvyeID7iknSFI6YGlo303CrpdhiDe1EiFLKtOphjOs=; h=From:To:Subject:Date:From; b=O9KkiCJOjB4lO4g2g2QVhxAMb/Igz9GD7Ou9KQRfKQPKO8rUvzxMzlgDXFteDb7k0 Q8RuSDwFR2zsyD6nDWAi0NpnoYyi5VgTmufES0ym4GVeIPzQ1/L5iesGpA6r41V+rF Jt7Uys0EV1OtJc18GOtjMVrfwSZknLbIbLFl36rw= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Remove reset_ecs and execution_control_state::reset X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 79d403654266c747703359e4b4e7f3931fb53f99 X-Git-Newrev: aa563d160d5e31861850e7e685df8c494fc9e307 Message-Id: <20221128192126.B4D103858C62@sourceware.org> Date: Mon, 28 Nov 2022 19:21:26 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Daa563d160d5e= 31861850e7e685df8c494fc9e307 commit aa563d160d5e31861850e7e685df8c494fc9e307 Author: Tom Tromey Date: Sun Nov 20 15:08:06 2022 -0700 Remove reset_ecs and execution_control_state::reset =20 I noticed that execution_control_state has a 'reset' method, and there's also a 'reset_ecs' function that calls it. This patch cleans this area up a little by adding a parameter to the constructor and (a change Simon suggested) removing the reset method. Some extraneous variables are also removed, like: =20 - struct execution_control_state ecss; - struct execution_control_state *ecs =3D &ecss; =20 Here 'ecs' is never changed, so this patch removes it entirely in favor of just using the object everywhere. =20 Regression tested on x86-64 Fedora 34. =20 Approved-By: Simon Marchi Diff: --- gdb/infrun.c | 123 +++++++++++++++++++++----------------------------------= ---- 1 file changed, 44 insertions(+), 79 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 3613a4af79b..c67458b30b6 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1854,55 +1854,32 @@ displaced_step_finish (thread_info *event_thread, e= num gdb_signal signal) discarded between events. */ struct execution_control_state { - execution_control_state () + explicit execution_control_state (thread_info *thr =3D nullptr) + : ptid (thr =3D=3D nullptr ? null_ptid : thr->ptid), + event_thread (thr) { - this->reset (); } =20 - void reset () - { - this->target =3D nullptr; - this->ptid =3D null_ptid; - this->event_thread =3D nullptr; - ws =3D target_waitstatus (); - stop_func_filled_in =3D 0; - stop_func_start =3D 0; - stop_func_end =3D 0; - stop_func_name =3D nullptr; - wait_some_more =3D 0; - hit_singlestep_breakpoint =3D 0; - } - - process_stratum_target *target; + process_stratum_target *target =3D nullptr; ptid_t ptid; /* The thread that got the event, if this was a thread event; NULL otherwise. */ struct thread_info *event_thread; =20 struct target_waitstatus ws; - int stop_func_filled_in; - CORE_ADDR stop_func_start; - CORE_ADDR stop_func_end; - const char *stop_func_name; - int wait_some_more; + int stop_func_filled_in =3D 0; + CORE_ADDR stop_func_start =3D 0; + CORE_ADDR stop_func_end =3D 0; + const char *stop_func_name =3D nullptr; + int wait_some_more =3D 0; =20 /* True if the event thread hit the single-step breakpoint of another thread. Thus the event doesn't cause a stop, the thread needs to be single-stepped past the single-step breakpoint before we can switch back to the original stepping thread. */ - int hit_singlestep_breakpoint; + int hit_singlestep_breakpoint =3D 0; }; =20 -/* Clear ECS and set it to point at TP. */ - -static void -reset_ecs (struct execution_control_state *ecs, struct thread_info *tp) -{ - ecs->reset (); - ecs->event_thread =3D tp; - ecs->ptid =3D tp->ptid; -} - static void keep_going_pass_signal (struct execution_control_state *ecs); static void prepare_to_wait (struct execution_control_state *ecs); static bool keep_going_stepped_thread (struct thread_info *tp); @@ -1955,8 +1932,6 @@ start_step_over (void) =20 for (thread_info *tp : range) { - struct execution_control_state ecss; - struct execution_control_state *ecs =3D &ecss; step_over_what step_what; int must_be_in_line; =20 @@ -2027,10 +2002,10 @@ start_step_over (void) continue; =20 switch_to_thread (tp); - reset_ecs (ecs, tp); - keep_going_pass_signal (ecs); + execution_control_state ecs (tp); + keep_going_pass_signal (&ecs); =20 - if (!ecs->wait_some_more) + if (!ecs.wait_some_more) error (_("Command aborted.")); =20 /* If the thread's step over could not be initiated because no buffe= rs @@ -3161,8 +3136,6 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal) struct regcache *regcache; struct gdbarch *gdbarch; CORE_ADDR pc; - struct execution_control_state ecss; - struct execution_control_state *ecs =3D &ecss; =20 /* If we're stopped at a fork/vfork, follow the branch set by the "set follow-fork-mode" command; otherwise, we'll just proceed @@ -3374,10 +3347,10 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal) infrun_debug_printf ("resuming %s", tp->ptid.to_string ().c_str ()); =20 - reset_ecs (ecs, tp); + execution_control_state ecs (tp); switch_to_thread (tp); - keep_going_pass_signal (ecs); - if (!ecs->wait_some_more) + keep_going_pass_signal (&ecs); + if (!ecs.wait_some_more) error (_("Command aborted.")); } } @@ -3390,10 +3363,10 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal) && cur_thr->inf->thread_waiting_for_vfork_done !=3D nullptr)) { /* The thread wasn't started, and isn't queued, run it now. */ - reset_ecs (ecs, cur_thr); + execution_control_state ecs (cur_thr); switch_to_thread (cur_thr); - keep_going_pass_signal (ecs); - if (!ecs->wait_some_more) + keep_going_pass_signal (&ecs); + if (!ecs.wait_some_more) error (_("Command aborted.")); } =20 @@ -4001,8 +3974,7 @@ wait_for_inferior (inferior *inf) =20 while (1) { - struct execution_control_state ecss; - struct execution_control_state *ecs =3D &ecss; + execution_control_state ecs; =20 overlay_cache_invalid =3D 1; =20 @@ -4012,16 +3984,16 @@ wait_for_inferior (inferior *inf) don't get any event. */ target_dcache_invalidate (); =20 - ecs->ptid =3D do_target_wait_1 (inf, minus_one_ptid, &ecs->ws, 0); - ecs->target =3D inf->process_target (); + ecs.ptid =3D do_target_wait_1 (inf, minus_one_ptid, &ecs.ws, 0); + ecs.target =3D inf->process_target (); =20 if (debug_infrun) - print_target_wait_results (minus_one_ptid, ecs->ptid, ecs->ws); + print_target_wait_results (minus_one_ptid, ecs.ptid, ecs.ws); =20 /* Now figure out what to do with the result of the result. */ - handle_inferior_event (ecs); + handle_inferior_event (&ecs); =20 - if (!ecs->wait_some_more) + if (!ecs.wait_some_more) break; } =20 @@ -4147,8 +4119,7 @@ fetch_inferior_event () { INFRUN_SCOPED_DEBUG_ENTER_EXIT; =20 - struct execution_control_state ecss; - struct execution_control_state *ecs =3D &ecss; + execution_control_state ecs; int cmd_done =3D 0; =20 /* Events are always processed with the main UI as current UI. This @@ -4198,27 +4169,27 @@ fetch_inferior_event () the event. */ scoped_disable_commit_resumed disable_commit_resumed ("handling event"= ); =20 - if (!do_target_wait (ecs, TARGET_WNOHANG)) + if (!do_target_wait (&ecs, TARGET_WNOHANG)) { infrun_debug_printf ("do_target_wait returned no event"); disable_commit_resumed.reset_and_commit (); return; } =20 - gdb_assert (ecs->ws.kind () !=3D TARGET_WAITKIND_IGNORE); + gdb_assert (ecs.ws.kind () !=3D TARGET_WAITKIND_IGNORE); =20 /* Switch to the target that generated the event, so we can do target calls. */ - switch_to_target_no_thread (ecs->target); + switch_to_target_no_thread (ecs.target); =20 if (debug_infrun) - print_target_wait_results (minus_one_ptid, ecs->ptid, ecs->ws); + print_target_wait_results (minus_one_ptid, ecs.ptid, ecs.ws); =20 /* If an error happens while handling the event, propagate GDB's knowledge of the executing state to the frontend/user running state. */ - ptid_t finish_ptid =3D !target_is_non_stop_p () ? minus_one_ptid : ecs= ->ptid; - scoped_finish_thread_state finish_state (ecs->target, finish_ptid); + ptid_t finish_ptid =3D !target_is_non_stop_p () ? minus_one_ptid : ecs= .ptid; + scoped_finish_thread_state finish_state (ecs.target, finish_ptid); =20 /* Get executed before scoped_restore_current_thread above to apply still for the thread which has thrown the exception. */ @@ -4228,13 +4199,13 @@ fetch_inferior_event () =3D make_scope_exit (delete_just_stopped_threads_infrun_breakpoints); =20 /* Now figure out what to do with the result of the result. */ - handle_inferior_event (ecs); + handle_inferior_event (&ecs); =20 - if (!ecs->wait_some_more) + if (!ecs.wait_some_more) { - struct inferior *inf =3D find_inferior_ptid (ecs->target, ecs->ptid); + struct inferior *inf =3D find_inferior_ptid (ecs.target, ecs.ptid); bool should_stop =3D true; - struct thread_info *thr =3D ecs->event_thread; + struct thread_info *thr =3D ecs.event_thread; =20 delete_just_stopped_threads_infrun_breakpoints (); =20 @@ -4243,7 +4214,7 @@ fetch_inferior_event () =20 if (!should_stop) { - keep_going (ecs); + keep_going (&ecs); } else { @@ -4252,7 +4223,7 @@ fetch_inferior_event () =20 stop_all_threads_if_all_stop_mode (); =20 - clean_up_just_stopped_threads_fsms (ecs); + clean_up_just_stopped_threads_fsms (&ecs); =20 if (thr !=3D nullptr && thr->thread_fsm () !=3D nullptr) should_notify_stop @@ -4281,7 +4252,7 @@ fetch_inferior_event () selected.". */ if (!non_stop && cmd_done - && ecs->ws.kind () !=3D TARGET_WAITKIND_NO_RESUMED) + && ecs.ws.kind () !=3D TARGET_WAITKIND_NO_RESUMED) restore_thread.dont_restore (); } } @@ -5977,14 +5948,11 @@ restart_threads (struct thread_info *event_thread, = inferior *inf) } else { - struct execution_control_state ecss; - struct execution_control_state *ecs =3D &ecss; - infrun_debug_printf ("restart threads: [%s] continuing", tp->ptid.to_string ().c_str ()); - reset_ecs (ecs, tp); + execution_control_state ecs (tp); switch_to_thread (tp); - keep_going_pass_signal (ecs); + keep_going_pass_signal (&ecs); } } } @@ -7660,8 +7628,7 @@ restart_after_all_stop_detach (process_stratum_target= *proc_target) if (thr->state !=3D THREAD_RUNNING) continue; =20 - execution_control_state ecs; - reset_ecs (&ecs, thr); + execution_control_state ecs (thr); switch_to_thread (thr); keep_going (&ecs); return; @@ -7676,8 +7643,6 @@ static bool keep_going_stepped_thread (struct thread_info *tp) { frame_info_ptr frame; - struct execution_control_state ecss; - struct execution_control_state *ecs =3D &ecss; =20 /* If the stepping thread exited, then don't try to switch back and resume it, which could fail in several different ways depending @@ -7708,7 +7673,7 @@ keep_going_stepped_thread (struct thread_info *tp) =20 infrun_debug_printf ("resuming previously stepped thread"); =20 - reset_ecs (ecs, tp); + execution_control_state ecs (tp); switch_to_thread (tp); =20 tp->set_stop_pc (regcache_read_pc (get_thread_regcache (tp))); @@ -7757,7 +7722,7 @@ keep_going_stepped_thread (struct thread_info *tp) { infrun_debug_printf ("expected thread still hasn't advanced"); =20 - keep_going_pass_signal (ecs); + keep_going_pass_signal (&ecs); } =20 return true;