[v4,1/6] gdb: use schedlock_applies in user_visible_resume_ptid.
Commit Message
From: Natalia Saiapova <natalia.saiapova@intel.com>
This is a refactoring. The logic in user_visible_resume_ptid is very
similar to schedlock_applies, but uses `step` and `record_will_replay`
parameter instead of `tp->control.stepping_command`.
Refactor schedlock_applies logic into the following two overloaded methods:
bool schedlock_applies (thread_info *tp)
and
bool schedlock_applies (bool step, bool record_will_replay)
such that they share the logic.
Update the call-sites accordingly, where we have only the thread, use
the former, and where we have the bool step or record_will_replay use the
latter.
---
gdb/infrun.c | 40 +++++++++++++++++++++++++---------------
1 file changed, 25 insertions(+), 15 deletions(-)
@@ -106,6 +106,7 @@ static bool start_step_over (void);
static bool step_over_info_valid_p (void);
static bool schedlock_applies (struct thread_info *tp);
+static bool schedlock_applies (bool step, bool record_will_replay);
/* Asynchronous signal handler registered as event loop source for
when we have pending events ready to be passed to the core. */
@@ -2389,20 +2390,14 @@ user_visible_resume_ptid (int step)
individually. */
resume_ptid = inferior_ptid;
}
- else if ((scheduler_mode == schedlock_on)
- || (scheduler_mode == schedlock_step && step))
+ else if
+ (schedlock_applies
+ (step, target_record_will_replay (inferior_ptid, execution_direction)))
{
/* User-settable 'scheduler' mode requires solo thread
resume. */
resume_ptid = inferior_ptid;
}
- else if ((scheduler_mode == schedlock_replay)
- && target_record_will_replay (inferior_ptid, execution_direction))
- {
- /* User-settable 'scheduler' mode requires solo thread resume in replay
- mode. */
- resume_ptid = inferior_ptid;
- }
else if (inferior_ptid != null_ptid
&& inferior_thread ()->control.in_cond_eval)
{
@@ -3190,17 +3185,32 @@ thread_still_needs_step_over (struct thread_info *tp)
return what;
}
+/* Returns true if scheduler locking applies to TP. */
+
+static bool
+schedlock_applies (thread_info *tp)
+{
+ bool step = false;
+ bool record_will_replay = false;
+ if (tp != nullptr)
+ {
+ step = tp->control.stepping_command;
+ record_will_replay
+ = target_record_will_replay (tp->ptid, execution_direction);
+ }
+ return schedlock_applies (step, record_will_replay);
+}
+
/* Returns true if scheduler locking applies. STEP indicates whether
- we're about to do a step/next-like command to a thread. */
+ we're about to do a step/next-like command and RECORD_WILL_REPLAY
+ indicates whether we're about to replay. */
static bool
-schedlock_applies (struct thread_info *tp)
+schedlock_applies (bool step, bool record_will_replay)
{
return (scheduler_mode == schedlock_on
- || (scheduler_mode == schedlock_step
- && tp->control.stepping_command)
- || (scheduler_mode == schedlock_replay
- && target_record_will_replay (tp->ptid, execution_direction)));
+ || (scheduler_mode == schedlock_step && step)
+ || (scheduler_mode == schedlock_replay && record_will_replay));
}
/* When FORCE_P is false, set process_stratum_target::COMMIT_RESUMED_STATE