* [RFA] Make sure target supports non-stop.
@ 2008-08-15 14:51 Vladimir Prus
2008-08-15 16:14 ` Eli Zaretskii
2008-08-15 17:45 ` Daniel Jacobowitz
0 siblings, 2 replies; 4+ messages in thread
From: Vladimir Prus @ 2008-08-15 14:51 UTC (permalink / raw)
To: gdb-patches
Presently, 'set non-stop 1' makes gdb core operate in non-stop mode,
even if gdb uses a non-stop non-capable target. Of course, things will
break. As discussed before:
- non-stop mode must be already requested when creating inferior, or
opening a target, since it affects things, so 'set non-stop 1' should
be emitted before running
- we don't know which target will be pushed with 'target xxx' command,
so we cannot make 'set non-stop 1' emit an error immediately
- non-stop setting cannot be changed while target has execution, and it's
enforced by the current code.
So, what we have to do is to make sure, when we run the target, that is
supports non-stop. This patch does so -- for run and attach commands.
This patch does not touch 'target xxx' (which uses to_open). I'll do that
when remote non-stop is submitted.
OK?
- Volodya
* infcmd.c (run_command_1, attach_command): If non-stop mode
is requested, verify the target supports it.
* linux-nat.c (linux_nat_supports_non_stop): New.
(linux_nat_add_target): Register the above.
* target.c (find_default_supports_non_stop)
(target_supports_non_stop): New.
(init_dummy_target): Register find_default_supports_non_stop.
* target.h (struct target_ops): New field to_supports_non_stop.
(target_supports_non_stop): New.
---
gdb/infcmd.c | 6 ++++++
gdb/linux-nat.c | 7 +++++++
gdb/target.c | 24 ++++++++++++++++++++++++
gdb/target.h | 3 +++
4 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 82d4710..02ec980 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -503,6 +503,9 @@ run_command_1 (char *args, int from_tty, int tbreak_at_main)
exec_file = (char *) get_exec_file (0);
+ if (non_stop && !target_supports_non_stop ())
+ error (_("The target does not support running in non-stop mode."));
+
/* We keep symbols from add-symbol-file, on the grounds that the
user might want to add some symbols before running the program
(right?). But sometimes (dynamic loading where the user manually
@@ -2020,6 +2023,9 @@ attach_command (char *args, int from_tty)
this function should probably be moved into target_pre_inferior. */
target_pre_inferior (from_tty);
+ if (non_stop && !target_supports_non_stop ())
+ error (_("Cannot attach to this target in non-stop mode"));
+
if (args)
{
async_exec = strip_bg_char (&args);
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index a924ed8..35ddee0 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -4019,6 +4019,12 @@ linux_nat_can_async_p (void)
return linux_nat_async_mask_value;
}
+static int
+linux_nat_supports_non_stop (void)
+{
+ return 1;
+}
+
/* target_async_mask implementation. */
static int
@@ -4375,6 +4381,7 @@ linux_nat_add_target (struct target_ops *t)
t->to_can_async_p = linux_nat_can_async_p;
t->to_is_async_p = linux_nat_is_async_p;
+ t->to_supports_non_stop = linux_nat_supports_non_stop;
t->to_async = linux_nat_async;
t->to_async_mask = linux_nat_async_mask;
t->to_terminal_inferior = linux_nat_terminal_inferior;
diff --git a/gdb/target.c b/gdb/target.c
index f21fa9e..f30d23b 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2143,6 +2143,29 @@ find_default_is_async_p (void)
return 0;
}
+int
+find_default_supports_non_stop (void)
+{
+ struct target_ops *t;
+
+ t = find_default_run_target (NULL);
+ if (t && t->to_supports_non_stop)
+ return (t->to_supports_non_stop) ();
+ return 0;
+}
+
+int
+target_supports_non_stop ()
+{
+ struct target_ops *t;
+ for (t = ¤t_target; t != NULL; t = t->beneath)
+ if (t->to_supports_non_stop)
+ return t->to_supports_non_stop ();
+
+ return 0;
+}
+
+
static int
default_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
{
@@ -2419,6 +2442,7 @@ init_dummy_target (void)
dummy_target.to_create_inferior = find_default_create_inferior;
dummy_target.to_can_async_p = find_default_can_async_p;
dummy_target.to_is_async_p = find_default_is_async_p;
+ dummy_target.to_supports_non_stop = find_default_supports_non_stop;
dummy_target.to_pid_to_str = normal_pid_to_str;
dummy_target.to_stratum = dummy_stratum;
dummy_target.to_find_memory_regions = dummy_find_memory_regions;
diff --git a/gdb/target.h b/gdb/target.h
index d12c048..9722674 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -423,6 +423,7 @@ struct target_ops
int (*to_is_async_p) (void);
void (*to_async) (void (*) (enum inferior_event_type, void *), void *);
int (*to_async_mask) (int);
+ int (*to_supports_non_stop) (void);
int (*to_find_memory_regions) (int (*) (CORE_ADDR,
unsigned long,
int, int, int,
@@ -964,6 +965,8 @@ extern int target_async_permitted;
/* Is the target in asynchronous execution mode? */
#define target_is_async_p() (current_target.to_is_async_p ())
+int target_supports_non_stop (void);
+
/* Put the target in async mode with the specified callback function. */
#define target_async(CALLBACK,CONTEXT) \
(current_target.to_async ((CALLBACK), (CONTEXT)))
--
1.5.3.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] Make sure target supports non-stop.
2008-08-15 14:51 [RFA] Make sure target supports non-stop Vladimir Prus
@ 2008-08-15 16:14 ` Eli Zaretskii
2008-08-15 17:02 ` Vladimir Prus
2008-08-15 17:45 ` Daniel Jacobowitz
1 sibling, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2008-08-15 16:14 UTC (permalink / raw)
To: Vladimir Prus; +Cc: gdb-patches
> From: Vladimir Prus <vladimir@codesourcery.com>
> Date: Fri, 15 Aug 2008 18:50:47 +0400
>
> + if (non_stop && !target_supports_non_stop ())
> + error (_("Cannot attach to this target in non-stop mode"));
Won't it be more elegant to define a method enter_non_stop_mode for
each target, and have the target complain if it cannot?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] Make sure target supports non-stop.
2008-08-15 16:14 ` Eli Zaretskii
@ 2008-08-15 17:02 ` Vladimir Prus
0 siblings, 0 replies; 4+ messages in thread
From: Vladimir Prus @ 2008-08-15 17:02 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
On Friday 15 August 2008 20:13:20 Eli Zaretskii wrote:
> > From: Vladimir Prus <vladimir@codesourcery.com>
> > Date: Fri, 15 Aug 2008 18:50:47 +0400
> >
> > + if (non_stop && !target_supports_non_stop ())
> > + error (_("Cannot attach to this target in non-stop mode"));
>
> Won't it be more elegant to define a method enter_non_stop_mode for
> each target, and have the target complain if it cannot?
I'm not sure it will be better. Non-stop mode is not purely a property
of target, encapsulated inside it. Rather, it's global property, which
must be supported by target, so enabling it in core, after making sure
that target is fine with that, seems reasonable. In other words,
'enter_non_stop_mode' target method cannot do much except for emitting
an error if non stop is not supported, therefore a method which just reports
support for non-stop seems exactly right choice.
- Volodya
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] Make sure target supports non-stop.
2008-08-15 14:51 [RFA] Make sure target supports non-stop Vladimir Prus
2008-08-15 16:14 ` Eli Zaretskii
@ 2008-08-15 17:45 ` Daniel Jacobowitz
1 sibling, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2008-08-15 17:45 UTC (permalink / raw)
To: Vladimir Prus; +Cc: gdb-patches
On Fri, Aug 15, 2008 at 06:50:47PM +0400, Vladimir Prus wrote:
> * infcmd.c (run_command_1, attach_command): If non-stop mode
> is requested, verify the target supports it.
> * linux-nat.c (linux_nat_supports_non_stop): New.
> (linux_nat_add_target): Register the above.
> * target.c (find_default_supports_non_stop)
> (target_supports_non_stop): New.
> (init_dummy_target): Register find_default_supports_non_stop.
> * target.h (struct target_ops): New field to_supports_non_stop.
> (target_supports_non_stop): New.
I believe this is OK.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-08-15 17:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-15 14:51 [RFA] Make sure target supports non-stop Vladimir Prus
2008-08-15 16:14 ` Eli Zaretskii
2008-08-15 17:02 ` Vladimir Prus
2008-08-15 17:45 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox