aboutsummaryrefslogtreecommitdiff
path: root/gdb/target.h
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2015-08-07 17:24:01 +0100
committerPedro Alves <palves@redhat.com>2015-08-07 17:24:01 +0100
commitfbea99ea8a062e5cd96e2d88336984ed3adc93d4 (patch)
tree8ddafd610809df1cec1e2aa60f0fabd4dbdf791e /gdb/target.h
parent372316f12874a30c62e6d71079ca3b86c786fb7e (diff)
downloadgdb-fbea99ea8a062e5cd96e2d88336984ed3adc93d4.zip
gdb-fbea99ea8a062e5cd96e2d88336984ed3adc93d4.tar.gz
gdb-fbea99ea8a062e5cd96e2d88336984ed3adc93d4.tar.bz2
Implement all-stop on top of a target running non-stop mode
This finally implements user-visible all-stop mode running with the target_ops backend always in non-stop mode. This is a stepping stone towards finer-grained control of threads, being able to do interesting things like thread groups, associating groups with breakpoints, etc. From the user's perspective, all-stop mode is really just a special case of being able to stop and resume specific sets of threads, so it makes sense to do this step first. With this, even in all-stop, the target is no longer in charge of stopping all threads before reporting an event to the core -- the core takes care of it when it sees fit. For example, when "next"- or "step"-ing, we can avoid stopping and resuming all threads at each internal single-step, and instead only stop all threads when we're about to present the stop to the user. The implementation is almost straight forward, as the heavy lifting has been done already in previous patches. Basically, we replace checks for "set non-stop on/off" (the non_stop global), with calls to a new target_is_non_stop_p function. In a few places, if "set non-stop off", we stop all threads explicitly, and in a few other places we resume all threads explicitly, making use of existing methods that were added for teaching non-stop to step over breakpoints without displaced stepping. This adds a new "maint set target-non-stop on/off/auto" knob that allows both disabling the feature if we find problems, and force-enable it for development (useful when teaching a target about this. The default is "auto", which means the feature is enabled if a new target method says it should be enabled. The patch implements the method in linux-nat.c, just for illustration, because it still returns false. We'll need a few follow up fixes before turning it on by default. This is a separate target method from indicating regular non-stop support, because e.g., while e.g., native linux-nat.c is close to regression free with all-stop-non-stop (with following patches will fixing the remaining regressions), remote.c+gdbserver will still need more fixing, even though it supports "set non-stop on". Tested on x86_64 Fedora 20, native, with and without "set displaced off", and with and without "maint set target-non-stop on"; and also against gdbserver. gdb/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * NEWS: Mention "maint set/show target-non-stop". * breakpoint.c (update_global_location_list): Check target_is_non_stop_p instead of non_stop. * infcmd.c (attach_command_post_wait, attach_command): Likewise. * infrun.c (show_can_use_displaced_stepping) (can_use_displaced_stepping_p, start_step_over_inferior): Likewise. (internal_resume_ptid): New function. (resume): Use it. (proceed): Check target_is_non_stop_p instead of non_stop. If in all-stop mode but the target is always in non-stop mode, start all the other threads that are implicitly resumed too. (for_each_just_stopped_thread, fetch_inferior_event) (adjust_pc_after_break, stop_all_threads): Check target_is_non_stop_p instead of non_stop. (handle_inferior_event): Likewise. Handle detach-fork in all-stop with the target always in non-stop mode. (handle_signal_stop) <random signal>: Check target_is_non_stop_p instead of non_stop. (switch_back_to_stepped_thread): Check target_is_non_stop_p instead of non_stop. (keep_going_stepped_thread): Use internal_resume_ptid. (stop_waiting): If in all-stop mode, and the target is in non-stop mode, stop all threads. (keep_going_pass): Likewise, when starting a new in-line step-over sequence. * linux-nat.c (get_pending_status, select_event_lwp) (linux_nat_filter_event, linux_nat_wait_1, linux_nat_wait): Check target_is_non_stop_p instead of non_stop. (linux_nat_always_non_stop_p): New function. (linux_nat_stop): Check target_is_non_stop_p instead of non_stop. (linux_nat_add_target): Install linux_nat_always_non_stop_p. * target-delegates.c: Regenerate. * target.c (target_is_non_stop_p): New function. (target_non_stop_enabled, target_non_stop_enabled_1): New globals. (maint_set_target_non_stop_command) (maint_show_target_non_stop_command): New functions. (_initilize_target): Install "maint set/show target-non-stop" commands. * target.h (struct target_ops) <to_always_non_stop_p>: New field. (target_non_stop_enabled): New declaration. (target_is_non_stop_p): New declaration. gdb/doc/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * gdb.texinfo (Maintenance Commands): Document "maint set/show target-non-stop".
Diffstat (limited to 'gdb/target.h')
-rw-r--r--gdb/target.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/gdb/target.h b/gdb/target.h
index ac21c43..741f858 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -669,6 +669,10 @@ struct target_ops
comment on 'to_can_run'. */
int (*to_supports_non_stop) (struct target_ops *)
TARGET_DEFAULT_RETURN (0);
+ /* Return true if the target operates in non-stop mode even with
+ "set non-stop off". */
+ int (*to_always_non_stop_p) (struct target_ops *)
+ TARGET_DEFAULT_RETURN (0);
/* find_memory_regions support method for gcore */
int (*to_find_memory_regions) (struct target_ops *,
find_memory_region_ftype func, void *data)
@@ -1744,6 +1748,15 @@ extern int target_async_permitted;
/* Enables/disabled async target events. */
extern void target_async (int enable);
+/* Whether support for controlling the target backends always in
+ non-stop mode is enabled. */
+extern enum auto_boolean target_non_stop_enabled;
+
+/* Is the target in non-stop mode? Some targets control the inferior
+ in non-stop mode even with "set non-stop off". Always true if "set
+ non-stop" is on. */
+extern int target_is_non_stop_p (void);
+
#define target_execution_direction() \
(current_target.to_execution_direction (&current_target))