diff options
author | Markus Metzger <markus.t.metzger@intel.com> | 2015-09-07 15:41:00 +0200 |
---|---|---|
committer | Markus Metzger <markus.t.metzger@intel.com> | 2015-09-18 14:32:00 +0200 |
commit | f2665db5f2c20f3f47673ad5343738b10ce81dde (patch) | |
tree | 4c92cf0fb7e8520751379a00d6b660f6b6420380 /gdb/infrun.c | |
parent | 7ff27e9babb1564a9c0e213c4a42396aa420f8cc (diff) | |
download | gdb-f2665db5f2c20f3f47673ad5343738b10ce81dde.zip gdb-f2665db5f2c20f3f47673ad5343738b10ce81dde.tar.gz gdb-f2665db5f2c20f3f47673ad5343738b10ce81dde.tar.bz2 |
infrun: scheduler-locking replay
Record targets behave as if scheduler-locking were on in replay mode. Add a
new scheduler-locking option "replay" to make this implicit behaviour explicit.
It behaves like "on" in replay mode and like "off" in record mode.
By making the current behaviour a scheduler-locking option, we allow the user
to change it. Since it is the current behaviour, this new option is also
the new default.
One caveat is that when resuming a thread that is at the end of its execution
history, record btrace implicitly stops replaying other threads and resumes
the entire process. This is a convenience feature to not require the user
to explicitly move all other threads to the end of their execution histories
before being able to resume the process.
We mimick this behaviour with scheduler-locking replay and move it from
record-btrace into infrun. With all-stop on top of non-stop, we can't do
this in record-btrace anymore.
Record full does not really support multi-threading and is therefore not
impacted. If it were extended to support multi-threading, it would 'benefit'
from this change. The good thing is that all record targets will behave the
same with respect to scheduler-locking.
I put the code for this into clear_proceed_status. It also sends the
about_to_proceed notification.
gdb/
* NEWS: Announce new scheduler-locking mode.
* infrun.c (schedlock_replay): New.
(scheduler_enums): Add schedlock_replay.
(scheduler_mode): Change default to schedlock_replay.
(user_visible_resume_ptid): Handle schedlock_replay.
(clear_proceed_status_thread): Stop replaying if resumed thread is
not replaying.
(schedlock_applies): Handle schedlock_replay.
(_initialize_infrun): Document new scheduler-locking mode.
* record-btrace.c (record_btrace_resume): Remove code to stop other
threads when not replaying the resumed thread.
doc/
* gdb.texinfo (All-Stop Mode): Describe new scheduler-locking mode.
Diffstat (limited to 'gdb/infrun.c')
-rw-r--r-- | gdb/infrun.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/gdb/infrun.c b/gdb/infrun.c index 75ac80a..701ea37 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -2166,13 +2166,15 @@ resume_cleanups (void *ignore) static const char schedlock_off[] = "off"; static const char schedlock_on[] = "on"; static const char schedlock_step[] = "step"; +static const char schedlock_replay[] = "replay"; static const char *const scheduler_enums[] = { schedlock_off, schedlock_on, schedlock_step, + schedlock_replay, NULL }; -static const char *scheduler_mode = schedlock_off; +static const char *scheduler_mode = schedlock_replay; static void show_scheduler_mode (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) @@ -2238,6 +2240,13 @@ user_visible_resume_ptid (int step) resume. */ resume_ptid = inferior_ptid; } + else if ((scheduler_mode == schedlock_replay) + && target_record_will_replay (minus_one_ptid, execution_direction)) + { + /* User-settable 'scheduler' mode requires solo thread resume in replay + mode. */ + resume_ptid = inferior_ptid; + } else if (!sched_multi && target_supports_multi_process ()) { /* Resume all threads of the current process (and none of other @@ -2803,6 +2812,18 @@ clear_proceed_status_thread (struct thread_info *tp) void clear_proceed_status (int step) { + /* With scheduler-locking replay, stop replaying other threads if we're + not replaying the user-visible resume ptid. + + This is a convenience feature to not require the user to explicitly + stop replaying the other threads. We're assuming that the user's + intent is to resume tracing the recorded process. */ + if (!non_stop && scheduler_mode == schedlock_replay + && target_record_is_replaying (minus_one_ptid) + && !target_record_will_replay (user_visible_resume_ptid (step), + execution_direction)) + target_record_stop_replaying (); + if (!non_stop) { struct thread_info *tp; @@ -2890,7 +2911,10 @@ schedlock_applies (struct thread_info *tp) { return (scheduler_mode == schedlock_on || (scheduler_mode == schedlock_step - && tp->control.stepping_command)); + && tp->control.stepping_command) + || (scheduler_mode == schedlock_replay + && target_record_will_replay (minus_one_ptid, + execution_direction))); } /* Basic routine for continuing the program in various fashions. @@ -9187,10 +9211,13 @@ By default, the debugger will use the same inferior."), scheduler_enums, &scheduler_mode, _("\ Set mode for locking scheduler during execution."), _("\ Show mode for locking scheduler during execution."), _("\ -off == no locking (threads may preempt at any time)\n\ -on == full locking (no thread except the current thread may run)\n\ -step == scheduler locked during stepping commands (step, next, stepi, nexti).\n\ - In this mode, other threads may run during other commands."), +off == no locking (threads may preempt at any time)\n\ +on == full locking (no thread except the current thread may run)\n\ + This applies to both normal execution and replay mode.\n\ +step == scheduler locked during stepping commands (step, next, stepi, nexti).\n\ + In this mode, other threads may run during other commands.\n\ + This applies to both normal execution and replay mode.\n\ +replay == scheduler locked in replay mode and unlocked during normal execution."), set_schedlock_func, /* traps on target vector */ show_scheduler_mode, &setlist, &showlist); |