* [non-stop] 01/10 Add "executing" property
@ 2008-06-15 21:04 Pedro Alves
2008-06-15 22:18 ` Eli Zaretskii
2008-06-25 19:02 ` Vladimir Prus
0 siblings, 2 replies; 29+ messages in thread
From: Pedro Alves @ 2008-06-15 21:04 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 621 bytes --]
The "running" thread property recently added represents the frontend view
of the thread running state. While doing a step for instance, the inferior
starts/stops several times while single-stepping. We only clear
the "running" state of the inferior when it does a normal_stop.
This patch adds a new field, that altough similar to "running"
has a different usage. It replaces the current target_executing
global with a similar per-thread concept. Inferior and frame/stack
control then can then use this property to know when it is possible
to read registers and memory from a thread.
--
Pedro Alves
[-- Attachment #2: 001-is_executing.diff --]
[-- Type: text/x-diff, Size: 22337 bytes --]
2008-06-15 Pedro Alves <pedro@codesourcery.com>
Add "executing" property to threads.
* inferior.h (target_executing): Delete.
* gdbthread.h (struct thread_info): Add executing_ field.
(set_executing, is_executing): New.
* thread.c (main_thread_executing): New.
(init_thread_list): Clear it and also main_thread_running.
(is_running): Return false if target has no execution.
(any_running, is_executing, set_executing): New.
* top.c: Include "gdbthread.h".
(target_executing): Delete.
(execute_command): Replace target_executing check by any_running.
* event-top.c: Include "gdbthread.h".
(display_gdb_prompt, command_handler): Replace target_executing by
is_running.
* inf-loop.c: Include "gdbthread.h". Don't mark as not executing
here. Replace target_executing by is_running.
* infrun.c (handle_inferior_event): Mark all threads as
not-executing.
* linux-nat.c (linux_nat_resume): Don't mark thread as executing
here.
* stack.c (get_selected_block): Return null if inferior is
executing.
* target.c (target_resume): Mark resumed ptid as executing.
* breakpoint.c (until_break_command): Replace target_executing
check by is_executing.
* remote.c (remote_async_resume): Don't mark inferior as executing
here.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Replace target_executing
by any_running.
* mi/mi-main.c (mi_cmd_exec_interrupt, mi_cmd_execute)
(mi_execute_async_cli_command): Replace target_executing by
is_running.
* frame.c (get_current_frame): Error out if the current thread is
executing.
(has_stack_frames): New.
(get_selected_frame, deprecated_safe_get_selected_frame): Check
has_stack_frames.
* Makefile.in (event-top.o, frame.o, inf-loop.o, top.o):
Update.
---
gdb/Makefile.in | 9 +++---
gdb/breakpoint.c | 2 -
gdb/event-top.c | 5 ++-
gdb/frame.c | 24 ++++++++++++++---
gdb/gdbthread.h | 35 ++++++++++++++++++++++---
gdb/inf-loop.c | 13 ++-------
gdb/inferior.h | 6 ----
gdb/infrun.c | 6 ++++
gdb/linux-nat.c | 5 ---
gdb/mi/mi-interp.c | 2 -
gdb/mi/mi-main.c | 10 +++----
gdb/remote.c | 7 -----
gdb/stack.c | 4 ++
gdb/target.c | 2 -
gdb/thread.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++--
gdb/top.c | 14 ++++------
16 files changed, 156 insertions(+), 60 deletions(-)
Index: src/gdb/inferior.h
===================================================================
--- src.orig/gdb/inferior.h 2008-06-10 11:50:57.000000000 +0100
+++ src/gdb/inferior.h 2008-06-10 11:52:00.000000000 +0100
@@ -111,12 +111,6 @@ extern const char *get_inferior_io_termi
extern ptid_t inferior_ptid;
-/* Is the inferior running right now, as a result of a 'run&',
- 'continue&' etc command? This is used in asycn gdb to determine
- whether a command that the user enters while the target is running
- is allowed or not. */
-extern int target_executing;
-
/* Are we simulating synchronous execution? This is used in async gdb
to implement the 'run', 'continue' etc commands, which will not
redisplay the prompt until the execution is actually over. */
Index: src/gdb/gdbthread.h
===================================================================
--- src.orig/gdb/gdbthread.h 2008-06-10 11:50:57.000000000 +0100
+++ src/gdb/gdbthread.h 2008-06-10 11:52:00.000000000 +0100
@@ -41,6 +41,25 @@ struct thread_info
In fact, this may be overloaded with
kernel thread id, etc. */
int num; /* Convenient handle (GDB thread id) */
+
+ /* Non-zero means the thread is executing. Note: this is different
+ from saying that there is an active target and we are stopped at
+ a breakpoint, for instance. This is a real indicator whether the
+ thread is off and running. */
+ /* This field is internal to thread.c. Never access it directly,
+ use is_executing instead. */
+ int executing_;
+
+ /* Frontend view of the running state. Note that this is different
+ from EXECUTING. When the thread is stopped internally while
+ handling an internal event, like a software single-step
+ breakpoint, executing will be false, but running will still be
+ true. As a possible future extension, this could turn into
+ enum { stopped, stepping, finishing, until(ling), ... } */
+ /* This field is internal to thread.c. Never access it directly,
+ use is_running instead. */
+ int running_;
+
/* State from wait_for_inferior */
CORE_ADDR prev_pc;
struct breakpoint *step_resume_breakpoint;
@@ -63,10 +82,6 @@ struct thread_info
when we finally do stop stepping. */
bpstat stepping_through_solib_catchpoints;
- /* This field is internal for thread.c. Never access it directly,
- use is_running instead. */
- int running_;
-
/* Private data used by the target vector implementation. */
struct private_thread_info *private;
};
@@ -154,9 +169,19 @@ extern void switch_to_thread (ptid_t pti
If PIDGET (PTID) is -1, marks all threads. */
extern void set_running (ptid_t ptid, int running);
-/* Reports if thread PTID is know to be running right now. */
+/* Reports if thread PTID is known to be running right now. */
extern int is_running (ptid_t ptid);
+/* Reports if any thread is known to be running right now. */
+extern int any_running (void);
+
+/* Marks thread PTID as executing, or as stopped.
+ If PIDGET (PTID) is -1, marks all threads. */
+extern void set_executing (ptid_t ptid, int executing);
+
+/* Reports if thread PTID is executing. */
+extern int is_executing (ptid_t ptid);
+
/* Commands with a prefix of `thread'. */
extern struct cmd_list_element *thread_cmd_list;
Index: src/gdb/thread.c
===================================================================
--- src.orig/gdb/thread.c 2008-06-10 11:50:57.000000000 +0100
+++ src/gdb/thread.c 2008-06-10 11:52:00.000000000 +0100
@@ -63,6 +63,9 @@ static void thread_apply_command (char *
static void restore_current_thread (ptid_t);
static void prune_threads (void);
+static int main_thread_running = 0;
+static int main_thread_executing = 0;
+
void
delete_step_resume_breakpoint (void *arg)
{
@@ -104,6 +107,9 @@ init_thread_list (void)
struct thread_info *tp, *tpnext;
highest_thread_num = 0;
+ main_thread_running = 0;
+ main_thread_executing = 0;
+
if (!thread_list)
return;
@@ -414,8 +420,6 @@ prune_threads (void)
}
}
-static int main_thread_running = 0;
-
void
set_running (ptid_t ptid, int running)
{
@@ -467,6 +471,9 @@ is_running (ptid_t ptid)
{
struct thread_info *tp;
+ if (!target_has_execution)
+ return 0;
+
if (!thread_list)
return main_thread_running;
@@ -475,6 +482,67 @@ is_running (ptid_t ptid)
return tp->running_;
}
+int
+any_running (void)
+{
+ struct thread_info *tp;
+
+ if (!target_has_execution)
+ return 0;
+
+ if (!thread_list)
+ return main_thread_running;
+
+ for (tp = thread_list; tp; tp = tp->next)
+ if (tp->running_)
+ return 1;
+
+ return 0;
+}
+
+int
+is_executing (ptid_t ptid)
+{
+ struct thread_info *tp;
+
+ if (!target_has_execution)
+ return 0;
+
+ if (!thread_list)
+ return main_thread_executing;
+
+ tp = find_thread_pid (ptid);
+ gdb_assert (tp);
+ return tp->executing_;
+}
+
+void
+set_executing (ptid_t ptid, int executing)
+{
+ struct thread_info *tp;
+
+ if (!thread_list)
+ {
+ /* This target does not add the main thread to the thread list.
+ Use a global flag to indicate that the thread is
+ executing. */
+ main_thread_executing = executing;
+ return;
+ }
+
+ if (PIDGET (ptid) == -1)
+ {
+ for (tp = thread_list; tp; tp = tp->next)
+ tp->executing_ = executing;
+ }
+ else
+ {
+ tp = find_thread_pid (ptid);
+ gdb_assert (tp);
+ tp->executing_ = executing;
+ }
+}
+
/* Prints the list of threads and their details on UIOUT.
This is a version of 'info_thread_command' suitable for
use from MI.
Index: src/gdb/top.c
===================================================================
--- src.orig/gdb/top.c 2008-06-10 11:49:22.000000000 +0100
+++ src/gdb/top.c 2008-06-10 11:52:00.000000000 +0100
@@ -46,6 +46,7 @@
#include "gdb_assert.h"
#include "main.h"
#include "event-loop.h"
+#include "gdbthread.h"
/* readline include files */
#include "readline/readline.h"
@@ -181,12 +182,6 @@ int remote_timeout = 2;
int remote_debug = 0;
-/* Non-zero means the target is running. Note: this is different from
- saying that there is an active target and we are stopped at a
- breakpoint, for instance. This is a real indicator whether the
- target is off and running, which gdb is doing something else. */
-int target_executing = 0;
-
/* Sbrk location on entry to main. Used for statistics only. */
#ifdef HAVE_SBRK
char *lim_at_start;
@@ -422,7 +417,10 @@ execute_command (char *p, int from_tty)
/* If the target is running, we allow only a limited set of
commands. */
- if (target_can_async_p () && target_executing && !get_cmd_async_ok (c))
+ if (target_can_async_p ()
+ && target_has_execution
+ && any_running ()
+ && !get_cmd_async_ok (c))
error (_("Cannot execute this command while the target is running."));
/* Pass null arg rather than an empty one. */
@@ -486,7 +484,7 @@ execute_command (char *p, int from_tty)
/* FIXME: This should be cacheing the frame and only running when
the frame changes. */
- if (!target_executing && target_has_stack)
+ if (target_has_stack && !is_running (inferior_ptid))
{
flang = get_frame_language ();
if (!warned
Index: src/gdb/event-top.c
===================================================================
--- src.orig/gdb/event-top.c 2008-06-10 11:49:22.000000000 +0100
+++ src/gdb/event-top.c 2008-06-10 11:52:00.000000000 +0100
@@ -32,6 +32,7 @@
#include "exceptions.h"
#include "cli/cli-script.h" /* for reset_command_nest_depth */
#include "main.h"
+#include "gdbthread.h"
/* For dont_repeat() */
#include "gdbcmd.h"
@@ -268,7 +269,7 @@ display_gdb_prompt (char *new_prompt)
if (!current_interp_display_prompt_p ())
return;
- if (target_executing && sync_execution)
+ if (sync_execution && is_running (inferior_ptid))
{
/* This is to trick readline into not trying to display the
prompt. Even though we display the prompt using this
@@ -516,7 +517,7 @@ command_handler (char *command)
/* Do any commands attached to breakpoint we stopped at. Only if we
are always running synchronously. Or if we have just executed a
command that doesn't start the target. */
- if (!target_can_async_p () || !target_executing)
+ if (!target_can_async_p () || !is_running (inferior_ptid))
{
bpstat_do_actions (&stop_bpstat);
do_cleanups (old_chain);
Index: src/gdb/inf-loop.c
===================================================================
--- src.orig/gdb/inf-loop.c 2008-06-10 11:49:22.000000000 +0100
+++ src/gdb/inf-loop.c 2008-06-10 11:52:00.000000000 +0100
@@ -26,6 +26,7 @@
#include "remote.h"
#include "exceptions.h"
#include "language.h"
+#include "gdbthread.h"
static int fetch_inferior_event_wrapper (gdb_client_data client_data);
@@ -72,14 +73,6 @@ inferior_event_handler (enum inferior_ev
break;
case INF_EXEC_COMPLETE:
-
- /* This is the first thing to do -- so that continuations know that
- the target is stopped. For example, command_line_handler_continuation
- will run breakpoint commands, and if we think that the target is
- running, we'll refuse to execute most commands. MI continuation
- presently uses target_executing to either print or not print *stopped. */
- target_executing = 0;
-
/* Unregister the inferior from the event loop. This is done so that
when the inferior is not running we don't get distracted by
spurious inferior output. */
@@ -121,8 +114,8 @@ inferior_event_handler (enum inferior_ev
/* If no breakpoint command resumed the inferior, prepare for
interaction with the user. */
- if (!target_executing)
- {
+ if (!is_running (inferior_ptid))
+ {
if (was_sync)
{
display_gdb_prompt (0);
Index: src/gdb/infrun.c
===================================================================
--- src.orig/gdb/infrun.c 2008-06-10 11:50:57.000000000 +0100
+++ src/gdb/infrun.c 2008-06-10 11:52:00.000000000 +0100
@@ -1766,6 +1766,12 @@ handle_inferior_event (struct execution_
&& ecs->ws.kind != TARGET_WAITKIND_SIGNALLED && ecs->new_thread_event)
add_thread (ecs->ptid);
+ /* Mark all threads as not-executing. In non-stop, this should be
+ adjusted to only mark ecs->ptid. */
+ if (ecs->ws.kind != TARGET_WAITKIND_IGNORE
+ && stop_soon != STOP_QUIETLY)
+ set_executing (pid_to_ptid (-1), 0);
+
switch (ecs->ws.kind)
{
case TARGET_WAITKIND_LOADED:
Index: src/gdb/linux-nat.c
===================================================================
--- src.orig/gdb/linux-nat.c 2008-06-10 11:49:22.000000000 +0100
+++ src/gdb/linux-nat.c 2008-06-10 11:52:00.000000000 +0100
@@ -1554,10 +1554,7 @@ linux_nat_resume (ptid_t ptid, int step,
signo ? strsignal (signo) : "0");
if (target_can_async_p ())
- {
- target_executing = 1;
- target_async (inferior_event_handler, 0);
- }
+ target_async (inferior_event_handler, 0);
}
/* Issue kill to specified lwp. */
Index: src/gdb/stack.c
===================================================================
--- src.orig/gdb/stack.c 2008-06-10 11:49:22.000000000 +0100
+++ src/gdb/stack.c 2008-06-10 11:52:00.000000000 +0100
@@ -43,6 +43,7 @@
#include "regcache.h"
#include "solib.h"
#include "valprint.h"
+#include "gdbthread.h"
#include "gdb_assert.h"
#include <ctype.h>
@@ -1643,6 +1644,9 @@ get_selected_block (CORE_ADDR *addr_in_b
if (!target_has_stack)
return 0;
+ if (is_executing (inferior_ptid))
+ return 0;
+
return get_frame_block (get_selected_frame (NULL), addr_in_block);
}
Index: src/gdb/target.c
===================================================================
--- src.orig/gdb/target.c 2008-06-10 11:50:57.000000000 +0100
+++ src/gdb/target.c 2008-06-10 11:52:00.000000000 +0100
@@ -1721,8 +1721,8 @@ target_resume (ptid_t ptid, int step, en
{
dcache_invalidate (target_dcache);
(*current_target.to_resume) (ptid, step, signal);
+ set_executing (ptid, 1);
set_running (ptid, 1);
-
}
/* Look through the list of possible targets for a target that can
follow forks. */
Index: src/gdb/breakpoint.c
===================================================================
--- src.orig/gdb/breakpoint.c 2008-06-10 11:50:56.000000000 +0100
+++ src/gdb/breakpoint.c 2008-06-10 11:52:00.000000000 +0100
@@ -6208,7 +6208,7 @@ until_break_command (char *arg, int from
deleted when the target stops. Otherwise, we're already stopped and
delete breakpoints via cleanup chain. */
- if (target_can_async_p () && target_executing)
+ if (target_can_async_p () && is_running (inferior_ptid))
{
arg1 =
(struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
Index: src/gdb/remote.c
===================================================================
--- src.orig/gdb/remote.c 2008-06-10 11:50:57.000000000 +0100
+++ src/gdb/remote.c 2008-06-10 11:52:00.000000000 +0100
@@ -3149,13 +3149,6 @@ remote_resume (ptid_t ptid, int step, en
NOT asynchronously. */
if (target_can_async_p ())
target_async (inferior_event_handler, 0);
- /* Tell the world that the target is now executing. */
- /* FIXME: cagney/1999-09-23: Is it the targets responsibility to set
- this? Instead, should the client of target just assume (for
- async targets) that the target is going to start executing? Is
- this information already found in the continuation block? */
- if (target_is_async_p ())
- target_executing = 1;
}
\f
Index: src/gdb/mi/mi-interp.c
===================================================================
--- src.orig/gdb/mi/mi-interp.c 2008-06-10 11:50:58.000000000 +0100
+++ src/gdb/mi/mi-interp.c 2008-06-10 11:52:00.000000000 +0100
@@ -222,7 +222,7 @@ mi_cmd_interpreter_exec (char *command,
changing the interpreter will clear out all the continuations for
that interpreter... */
- if (target_can_async_p () && target_executing)
+ if (target_can_async_p () && any_running ())
{
fputs_unfiltered ("^running\n", raw_stdout);
}
Index: src/gdb/mi/mi-main.c
===================================================================
--- src.orig/gdb/mi/mi-main.c 2008-06-10 11:50:58.000000000 +0100
+++ src/gdb/mi/mi-main.c 2008-06-10 11:52:00.000000000 +0100
@@ -214,8 +214,8 @@ mi_cmd_exec_continue (char *command, cha
enum mi_cmd_result
mi_cmd_exec_interrupt (char *command, char **argv, int argc)
{
- if (!target_executing)
- error ("mi_cmd_exec_interrupt: Inferior not executing.");
+ if (!is_running (inferior_ptid))
+ error ("mi_cmd_exec_interrupt: Inferior not running.");
interrupt_target_command (NULL, 0);
if (current_token)
@@ -1062,7 +1062,7 @@ captured_mi_execute_command (struct ui_o
if (do_timings)
timestamp (&cmd_finished);
- if (!target_can_async_p () || !target_executing)
+ if (!target_can_async_p () || !is_running (inferior_ptid))
{
/* Print the result if there were no errors.
@@ -1195,7 +1195,7 @@ mi_cmd_execute (struct mi_parse *parse)
if (parse->cmd->argv_func != NULL)
{
- if (target_executing)
+ if (is_running (inferior_ptid))
{
if (strcmp (parse->command, "exec-interrupt"))
{
@@ -1310,7 +1310,7 @@ mi_execute_async_cli_command (char *cli_
if (target_can_async_p ())
{
/* If we're not executing, an exception should have been throw. */
- gdb_assert (target_executing);
+ gdb_assert (is_running (inferior_ptid));
do_cleanups (old_cleanups);
}
else
Index: src/gdb/Makefile.in
===================================================================
--- src.orig/gdb/Makefile.in 2008-06-10 11:50:56.000000000 +0100
+++ src/gdb/Makefile.in 2008-06-10 11:52:00.000000000 +0100
@@ -2118,7 +2118,7 @@ event-loop.o: event-loop.c $(defs_h) $(e
event-top.o: event-top.c $(defs_h) $(top_h) $(inferior_h) $(target_h) \
$(terminal_h) $(event_loop_h) $(event_top_h) $(interps_h) \
$(exceptions_h) $(cli_script_h) $(gdbcmd_h) $(readline_h) \
- $(readline_history_h) $(main_h)
+ $(readline_history_h) $(main_h) $(gdbthread_h)
exceptions.o: exceptions.c $(defs_h) $(exceptions_h) $(breakpoint_h) \
$(target_h) $(inferior_h) $(annotate_h) $(ui_out_h) $(gdb_assert_h) \
$(gdb_string_h) $(serial_h)
@@ -2153,7 +2153,8 @@ frame.o: frame.c $(defs_h) $(frame_h) $(
$(regcache_h) $(gdb_assert_h) $(gdb_string_h) $(user_regs_h) \
$(gdb_obstack_h) $(dummy_frame_h) $(sentinel_frame_h) $(gdbcore_h) \
$(annotate_h) $(language_h) $(frame_unwind_h) $(frame_base_h) \
- $(command_h) $(gdbcmd_h) $(observer_h) $(objfiles_h) $(exceptions_h)
+ $(command_h) $(gdbcmd_h) $(observer_h) $(objfiles_h) $(exceptions_h) \
+ $(gdbthread_h)
frame-unwind.o: frame-unwind.c $(defs_h) $(frame_h) $(frame_unwind_h) \
$(gdb_assert_h) $(dummy_frame_h) $(gdb_obstack_h) $(value_h) \
$(regcache_h)
@@ -2334,7 +2335,7 @@ infcmd.o: infcmd.c $(defs_h) $(gdb_strin
$(user_regs_h) $(exceptions_h) $(cli_decode_h) $(gdbthread_h)
inf-loop.o: inf-loop.c $(defs_h) $(inferior_h) $(target_h) $(event_loop_h) \
$(event_top_h) $(inf_loop_h) $(remote_h) $(exceptions_h) \
- $(language_h)
+ $(language_h) $(gdbthread_h)
inflow.o: inflow.c $(defs_h) $(frame_h) $(inferior_h) $(command_h) \
$(serial_h) $(terminal_h) $(target_h) $(gdbthread_h) $(gdb_string_h) \
$(inflow_h) $(gdb_select_h)
@@ -2941,7 +2942,7 @@ top.o: top.c $(defs_h) $(gdbcmd_h) $(cal
$(annotate_h) $(completer_h) $(top_h) $(version_h) $(serial_h) \
$(doublest_h) $(gdb_assert_h) $(readline_h) $(readline_history_h) \
$(event_top_h) $(gdb_string_h) $(gdb_stat_h) $(ui_out_h) \
- $(cli_out_h) $(main_h) $(event_loop_h)
+ $(cli_out_h) $(main_h) $(event_loop_h) $(gdbthread_h)
tracepoint.o: tracepoint.c $(defs_h) $(symtab_h) $(frame_h) $(gdbtypes_h) \
$(expression_h) $(gdbcmd_h) $(value_h) $(target_h) $(language_h) \
$(gdb_string_h) $(inferior_h) $(tracepoint_h) $(remote_h) \
Index: src/gdb/frame.c
===================================================================
--- src.orig/gdb/frame.c 2008-06-10 11:49:22.000000000 +0100
+++ src/gdb/frame.c 2008-06-10 11:52:00.000000000 +0100
@@ -40,6 +40,7 @@
#include "observer.h"
#include "objfiles.h"
#include "exceptions.h"
+#include "gdbthread.h"
static struct frame_info *get_prev_frame_1 (struct frame_info *this_frame);
@@ -930,6 +931,9 @@ get_current_frame (void)
error (_("No stack."));
if (!target_has_memory)
error (_("No memory."));
+ if (is_executing (inferior_ptid))
+ error (_("Target is executing."));
+
if (current_frame == NULL)
{
struct frame_info *sentinel_frame =
@@ -950,6 +954,20 @@ get_current_frame (void)
static struct frame_info *selected_frame;
+static int
+has_stack_frames (void)
+{
+ if (!target_has_registers || !target_has_stack || !target_has_memory)
+ return 0;
+
+ /* If the current thread is executing, don't try to read from
+ it. */
+ if (is_executing (inferior_ptid))
+ return 0;
+
+ return 1;
+}
+
/* Return the selected frame. Always non-NULL (unless there isn't an
inferior sufficient for creating a frame) in which case an error is
thrown. */
@@ -959,9 +977,7 @@ get_selected_frame (const char *message)
{
if (selected_frame == NULL)
{
- if (message != NULL && (!target_has_registers
- || !target_has_stack
- || !target_has_memory))
+ if (message != NULL && !has_stack_frames ())
error (("%s"), message);
/* Hey! Don't trust this. It should really be re-finding the
last selected frame of the currently selected thread. This,
@@ -980,7 +996,7 @@ get_selected_frame (const char *message)
struct frame_info *
deprecated_safe_get_selected_frame (void)
{
- if (!target_has_registers || !target_has_stack || !target_has_memory)
+ if (!has_stack_frames ())
return NULL;
return get_selected_frame (NULL);
}
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-15 21:04 [non-stop] 01/10 Add "executing" property Pedro Alves
@ 2008-06-15 22:18 ` Eli Zaretskii
2008-06-16 1:42 ` Daniel Jacobowitz
2008-06-17 16:14 ` Joel Brobecker
2008-06-25 19:02 ` Vladimir Prus
1 sibling, 2 replies; 29+ messages in thread
From: Eli Zaretskii @ 2008-06-15 22:18 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
> From: Pedro Alves <pedro@codesourcery.com>
> Date: Sun, 15 Jun 2008 22:03:14 +0100
>
> The "running" thread property recently added represents the frontend view
> of the thread running state. While doing a step for instance, the inferior
> starts/stops several times while single-stepping. Â We only clear
> the "running" state of the inferior when it does a normal_stop.
> This patch adds a new field, that altough similar to "running"
> has a different usage. Â It replaces the current target_executing
> global with a similar per-thread concept. Â Inferior and frame/stack
> control then can then use this property to know when it is possible
> to read registers and memory from a thread.
Thanks, but isn't any of the significant changes in these series of
patches worthy of being mentioned in gdbint.texinfo?
> * Makefile.in (event-top.o, frame.o, inf-loop.o, top.o):
> Update.
I think you should tell what prerequisites were added to each target.
A simple "update" will never reveal when a prerequisite was added, if
someone will ever want to know.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-15 22:18 ` Eli Zaretskii
@ 2008-06-16 1:42 ` Daniel Jacobowitz
2008-06-16 3:23 ` Eli Zaretskii
2008-06-16 7:22 ` [non-stop] 01/10 Add "executing" property Vladimir Prus
2008-06-17 16:14 ` Joel Brobecker
1 sibling, 2 replies; 29+ messages in thread
From: Daniel Jacobowitz @ 2008-06-16 1:42 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Pedro Alves, gdb-patches
On Mon, Jun 16, 2008 at 12:47:43AM +0300, Eli Zaretskii wrote:
> > * Makefile.in (event-top.o, frame.o, inf-loop.o, top.o):
> > Update.
>
> I think you should tell what prerequisites were added to each target.
> A simple "update" will never reveal when a prerequisite was added, if
> someone will ever want to know.
I don't think it's necessary to duplicate the contents of the patch in
the changelog. Do you really think it's useful? We've never asked to
do this (see the cvs log of Makefile.in for plenty of examples), and I
would resist; changelogs already take a long time to write.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-16 1:42 ` Daniel Jacobowitz
@ 2008-06-16 3:23 ` Eli Zaretskii
2008-06-16 6:45 ` ChangeLog entries [was Re: [non-stop] 01/10 Add "executing" property] Nick Roberts
2008-06-16 7:22 ` [non-stop] 01/10 Add "executing" property Vladimir Prus
1 sibling, 1 reply; 29+ messages in thread
From: Eli Zaretskii @ 2008-06-16 3:23 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: pedro, gdb-patches
> Date: Sun, 15 Jun 2008 21:26:17 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: Pedro Alves <pedro@codesourcery.com>, gdb-patches@sourceware.org
>
> On Mon, Jun 16, 2008 at 12:47:43AM +0300, Eli Zaretskii wrote:
> > > * Makefile.in (event-top.o, frame.o, inf-loop.o, top.o):
> > > Update.
> >
> > I think you should tell what prerequisites were added to each target.
> > A simple "update" will never reveal when a prerequisite was added, if
> > someone will ever want to know.
>
> I don't think it's necessary to duplicate the contents of the patch in
> the changelog.
How else would one know when a certain change was done to a certain
file? For that matter, why do we bother writing log entries at all?
> Do you really think it's useful? We've never asked to
> do this (see the cvs log of Makefile.in for plenty of examples), and I
> would resist; changelogs already take a long time to write.
It's common practice in GNU projects. I'm quite shocked to learn that
some of us resist it. Yes, our log entries are already quite sloppy
and unhelpful, but there are limits.
^ permalink raw reply [flat|nested] 29+ messages in thread
* ChangeLog entries [was Re: [non-stop] 01/10 Add "executing" property]
2008-06-16 3:23 ` Eli Zaretskii
@ 2008-06-16 6:45 ` Nick Roberts
0 siblings, 0 replies; 29+ messages in thread
From: Nick Roberts @ 2008-06-16 6:45 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Daniel Jacobowitz, pedro, gdb-patches
> > Do you really think it's useful? We've never asked to
> > do this (see the cvs log of Makefile.in for plenty of examples), and I
> > would resist; changelogs already take a long time to write.
>
> It's common practice in GNU projects. I'm quite shocked to learn that
> some of us resist it. Yes, our log entries are already quite sloppy
> and unhelpful, but there are limits.
I find the ChangeLog useful as a starting point to understand when and why
changes to individual files were made. It's probably hard to prescribe
_exactly_ what should go in but I've never looked at a ChangeLog to understand
when and why a dependency was added to a Makefile. So I'm inclined to agree
with Daniel. It's pretty straightforward to determine whether a dependency is
needed or not - no need to go trawling through the CVS history.
--
Nick http://www.inet.net.nz/~nickrob
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-16 1:42 ` Daniel Jacobowitz
2008-06-16 3:23 ` Eli Zaretskii
@ 2008-06-16 7:22 ` Vladimir Prus
2008-06-17 0:40 ` Eli Zaretskii
2008-06-23 17:27 ` Tom Tromey
1 sibling, 2 replies; 29+ messages in thread
From: Vladimir Prus @ 2008-06-16 7:22 UTC (permalink / raw)
To: gdb-patches
Daniel Jacobowitz wrote:
> On Mon, Jun 16, 2008 at 12:47:43AM +0300, Eli Zaretskii wrote:
>> > * Makefile.in (event-top.o, frame.o, inf-loop.o, top.o):
>> > Update.
>>
>> I think you should tell what prerequisites were added to each target.
>> A simple "update" will never reveal when a prerequisite was added, if
>> someone will ever want to know.
>
> I don't think it's necessary to duplicate the contents of the patch in
> the changelog. Do you really think it's useful? We've never asked to
> do this (see the cvs log of Makefile.in for plenty of examples), and I
> would resist; changelogs already take a long time to write.
It's actually fairly weird that one has to maintain dependencies by hand,
I don't think I know any single project still alive that needs that. And
duplicating that dependency information in ChangeLog entries will make
a painful thing twice as painful. Not that the question "who added this
dependency" seems like a common question to ask.
- Volodya
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-16 7:22 ` [non-stop] 01/10 Add "executing" property Vladimir Prus
@ 2008-06-17 0:40 ` Eli Zaretskii
2008-06-17 17:10 ` Vladimir Prus
2008-06-23 17:27 ` Tom Tromey
1 sibling, 1 reply; 29+ messages in thread
From: Eli Zaretskii @ 2008-06-17 0:40 UTC (permalink / raw)
To: Vladimir Prus; +Cc: gdb-patches
> From: Vladimir Prus <vladimir@codesourcery.com>
> Date: Mon, 16 Jun 2008 10:42:09 +0400
>
> It's actually fairly weird that one has to maintain dependencies by hand,
We are obviously miscommunicating. What I meant was simple entries
like:
* Makefile.in (foo.o): Add bar.c and bar.h to prerequisites.
or
* Makefile.in (foo.o): Remove foobar.h from prerequisites.
That's a far cry from ``maintaining dependencies by hand''. It's
simply a description of what was modified in the rules for target
`foo.o'.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-15 22:18 ` Eli Zaretskii
2008-06-16 1:42 ` Daniel Jacobowitz
@ 2008-06-17 16:14 ` Joel Brobecker
2008-06-17 18:24 ` Eli Zaretskii
1 sibling, 1 reply; 29+ messages in thread
From: Joel Brobecker @ 2008-06-17 16:14 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Pedro Alves, gdb-patches
> > * Makefile.in (event-top.o, frame.o, inf-loop.o, top.o):
> > Update.
>
> I think you should tell what prerequisites were added to each target.
> A simple "update" will never reveal when a prerequisite was added, if
> someone will ever want to know.
I can only speak for myself, but in my few years of GDB development,
I have never missed having the exact dependencies in the ChangeLog.
I really like concise ChangeLogs because they tell me what files
were modified as part of a change set, and also give me a very rough
idea of what was done inside each file. When the ChangeLog becomes
too verbose, it becomes more difficult for me to use them.
--
Joel
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-17 0:40 ` Eli Zaretskii
@ 2008-06-17 17:10 ` Vladimir Prus
2008-06-17 20:38 ` Eli Zaretskii
0 siblings, 1 reply; 29+ messages in thread
From: Vladimir Prus @ 2008-06-17 17:10 UTC (permalink / raw)
To: gdb-patches
Eli Zaretskii wrote:
>> From: Vladimir Prus <vladimir@codesourcery.com>
>> Date: Mon, 16 Jun 2008 10:42:09 +0400
>>
>> It's actually fairly weird that one has to maintain dependencies by hand,
>
> We are obviously miscommunicating. What I meant was simple entries
> like:
>
> * Makefile.in (foo.o): Add bar.c and bar.h to prerequisites.
> or
> * Makefile.in (foo.o): Remove foobar.h from prerequisites.
>
> That's a far cry from ``maintaining dependencies by hand''.
In fact, it is the same. Why do we, in 2008, need to add 'bar.h' to dependencies of
foo.o? That's painful and, honestly, laughable at, thing. And the sample
changelog entries above exactly duplicate that information that we should not
maintain in the first place.
- Volodya
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-17 16:14 ` Joel Brobecker
@ 2008-06-17 18:24 ` Eli Zaretskii
2008-06-17 18:32 ` Joel Brobecker
2008-06-17 18:34 ` Pedro Alves
0 siblings, 2 replies; 29+ messages in thread
From: Eli Zaretskii @ 2008-06-17 18:24 UTC (permalink / raw)
To: Joel Brobecker; +Cc: pedro, gdb-patches
> Date: Mon, 16 Jun 2008 22:53:54 -0700
> From: Joel Brobecker <brobecker@adacore.com>
> Cc: Pedro Alves <pedro@codesourcery.com>, gdb-patches@sourceware.org
>
> I really like concise ChangeLogs because they tell me what files
> were modified as part of a change set, and also give me a very rough
> idea of what was done inside each file.
Well, "Makefile.in (foo): Update." doesn't give any idea WHAT was
done, it only says WHERE it was done.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-17 18:24 ` Eli Zaretskii
@ 2008-06-17 18:32 ` Joel Brobecker
2008-06-18 0:22 ` Eli Zaretskii
2008-06-17 18:34 ` Pedro Alves
1 sibling, 1 reply; 29+ messages in thread
From: Joel Brobecker @ 2008-06-17 18:32 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: pedro, gdb-patches
> Well, "Makefile.in (foo): Update." doesn't give any idea WHAT was
> done, it only says WHERE it was done.
Actually, it does, at least as far I what I want to know (I want to
know that the author did an update of the Makefile rules). I don't
remember checking exactly what dependencies were added or removed,
but I don't mind using CVS for that.
--
Joel
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-17 18:24 ` Eli Zaretskii
2008-06-17 18:32 ` Joel Brobecker
@ 2008-06-17 18:34 ` Pedro Alves
2008-06-17 20:58 ` Eli Zaretskii
2008-06-23 1:13 ` Daniel Jacobowitz
1 sibling, 2 replies; 29+ messages in thread
From: Pedro Alves @ 2008-06-17 18:34 UTC (permalink / raw)
To: gdb-patches, Eli Zaretskii
[-- Attachment #1: Type: text/plain, Size: 53 bytes --]
Ok, here goes.
Same patch, updated ChangeLog entry.
[-- Attachment #2: 001-is_executing.diff --]
[-- Type: text/x-diff, Size: 22355 bytes --]
2008-06-17 Pedro Alves <pedro@codesourcery.com>
Add "executing" property to threads.
* inferior.h (target_executing): Delete.
* gdbthread.h (struct thread_info): Add executing_ field.
(set_executing, is_executing): New.
* thread.c (main_thread_executing): New.
(init_thread_list): Clear it and also main_thread_running.
(is_running): Return false if target has no execution.
(any_running, is_executing, set_executing): New.
* top.c: Include "gdbthread.h".
(target_executing): Delete.
(execute_command): Replace target_executing check by any_running.
* event-top.c: Include "gdbthread.h".
(display_gdb_prompt, command_handler): Replace target_executing by
is_running.
* inf-loop.c: Include "gdbthread.h". Don't mark as not executing
here. Replace target_executing by is_running.
* infrun.c (handle_inferior_event): Mark all threads as
not-executing.
* linux-nat.c (linux_nat_resume): Don't mark thread as executing
here.
* stack.c (get_selected_block): Return null if inferior is
executing.
* target.c (target_resume): Mark resumed ptid as executing.
* breakpoint.c (until_break_command): Replace target_executing
check by is_executing.
* remote.c (remote_async_resume): Don't mark inferior as executing
here.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Replace target_executing
by any_running.
* mi/mi-main.c (mi_cmd_exec_interrupt, mi_cmd_execute)
(mi_execute_async_cli_command): Replace target_executing by
is_running.
* frame.c (get_current_frame): Error out if the current thread is
executing.
(has_stack_frames): New.
(get_selected_frame, deprecated_safe_get_selected_frame): Check
has_stack_frames.
* Makefile.in (event-top.o, frame.o, inf-loop.o, top.o): Depend on
$(gdbthread_h).
---
gdb/Makefile.in | 9 +++---
gdb/breakpoint.c | 2 -
gdb/event-top.c | 5 ++-
gdb/frame.c | 24 ++++++++++++++---
gdb/gdbthread.h | 35 ++++++++++++++++++++++---
gdb/inf-loop.c | 13 ++-------
gdb/inferior.h | 6 ----
gdb/infrun.c | 6 ++++
gdb/linux-nat.c | 5 ---
gdb/mi/mi-interp.c | 2 -
gdb/mi/mi-main.c | 10 +++----
gdb/remote.c | 7 -----
gdb/stack.c | 4 ++
gdb/target.c | 2 -
gdb/thread.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++--
gdb/top.c | 14 ++++------
16 files changed, 156 insertions(+), 60 deletions(-)
Index: src/gdb/inferior.h
===================================================================
--- src.orig/gdb/inferior.h 2008-06-17 19:15:14.000000000 +0100
+++ src/gdb/inferior.h 2008-06-17 19:15:17.000000000 +0100
@@ -111,12 +111,6 @@ extern const char *get_inferior_io_termi
extern ptid_t inferior_ptid;
-/* Is the inferior running right now, as a result of a 'run&',
- 'continue&' etc command? This is used in asycn gdb to determine
- whether a command that the user enters while the target is running
- is allowed or not. */
-extern int target_executing;
-
/* Are we simulating synchronous execution? This is used in async gdb
to implement the 'run', 'continue' etc commands, which will not
redisplay the prompt until the execution is actually over. */
Index: src/gdb/gdbthread.h
===================================================================
--- src.orig/gdb/gdbthread.h 2008-06-17 19:15:14.000000000 +0100
+++ src/gdb/gdbthread.h 2008-06-17 19:15:17.000000000 +0100
@@ -41,6 +41,25 @@ struct thread_info
In fact, this may be overloaded with
kernel thread id, etc. */
int num; /* Convenient handle (GDB thread id) */
+
+ /* Non-zero means the thread is executing. Note: this is different
+ from saying that there is an active target and we are stopped at
+ a breakpoint, for instance. This is a real indicator whether the
+ thread is off and running. */
+ /* This field is internal to thread.c. Never access it directly,
+ use is_executing instead. */
+ int executing_;
+
+ /* Frontend view of the running state. Note that this is different
+ from EXECUTING. When the thread is stopped internally while
+ handling an internal event, like a software single-step
+ breakpoint, executing will be false, but running will still be
+ true. As a possible future extension, this could turn into
+ enum { stopped, stepping, finishing, until(ling), ... } */
+ /* This field is internal to thread.c. Never access it directly,
+ use is_running instead. */
+ int running_;
+
/* State from wait_for_inferior */
CORE_ADDR prev_pc;
struct breakpoint *step_resume_breakpoint;
@@ -63,10 +82,6 @@ struct thread_info
when we finally do stop stepping. */
bpstat stepping_through_solib_catchpoints;
- /* This field is internal for thread.c. Never access it directly,
- use is_running instead. */
- int running_;
-
/* Private data used by the target vector implementation. */
struct private_thread_info *private;
};
@@ -154,9 +169,19 @@ extern void switch_to_thread (ptid_t pti
If PIDGET (PTID) is -1, marks all threads. */
extern void set_running (ptid_t ptid, int running);
-/* Reports if thread PTID is know to be running right now. */
+/* Reports if thread PTID is known to be running right now. */
extern int is_running (ptid_t ptid);
+/* Reports if any thread is known to be running right now. */
+extern int any_running (void);
+
+/* Marks thread PTID as executing, or as stopped.
+ If PIDGET (PTID) is -1, marks all threads. */
+extern void set_executing (ptid_t ptid, int executing);
+
+/* Reports if thread PTID is executing. */
+extern int is_executing (ptid_t ptid);
+
/* Commands with a prefix of `thread'. */
extern struct cmd_list_element *thread_cmd_list;
Index: src/gdb/thread.c
===================================================================
--- src.orig/gdb/thread.c 2008-06-17 19:15:14.000000000 +0100
+++ src/gdb/thread.c 2008-06-17 19:15:17.000000000 +0100
@@ -63,6 +63,9 @@ static void thread_apply_command (char *
static void restore_current_thread (ptid_t);
static void prune_threads (void);
+static int main_thread_running = 0;
+static int main_thread_executing = 0;
+
void
delete_step_resume_breakpoint (void *arg)
{
@@ -104,6 +107,9 @@ init_thread_list (void)
struct thread_info *tp, *tpnext;
highest_thread_num = 0;
+ main_thread_running = 0;
+ main_thread_executing = 0;
+
if (!thread_list)
return;
@@ -414,8 +420,6 @@ prune_threads (void)
}
}
-static int main_thread_running = 0;
-
void
set_running (ptid_t ptid, int running)
{
@@ -467,6 +471,9 @@ is_running (ptid_t ptid)
{
struct thread_info *tp;
+ if (!target_has_execution)
+ return 0;
+
if (!thread_list)
return main_thread_running;
@@ -475,6 +482,67 @@ is_running (ptid_t ptid)
return tp->running_;
}
+int
+any_running (void)
+{
+ struct thread_info *tp;
+
+ if (!target_has_execution)
+ return 0;
+
+ if (!thread_list)
+ return main_thread_running;
+
+ for (tp = thread_list; tp; tp = tp->next)
+ if (tp->running_)
+ return 1;
+
+ return 0;
+}
+
+int
+is_executing (ptid_t ptid)
+{
+ struct thread_info *tp;
+
+ if (!target_has_execution)
+ return 0;
+
+ if (!thread_list)
+ return main_thread_executing;
+
+ tp = find_thread_pid (ptid);
+ gdb_assert (tp);
+ return tp->executing_;
+}
+
+void
+set_executing (ptid_t ptid, int executing)
+{
+ struct thread_info *tp;
+
+ if (!thread_list)
+ {
+ /* This target does not add the main thread to the thread list.
+ Use a global flag to indicate that the thread is
+ executing. */
+ main_thread_executing = executing;
+ return;
+ }
+
+ if (PIDGET (ptid) == -1)
+ {
+ for (tp = thread_list; tp; tp = tp->next)
+ tp->executing_ = executing;
+ }
+ else
+ {
+ tp = find_thread_pid (ptid);
+ gdb_assert (tp);
+ tp->executing_ = executing;
+ }
+}
+
/* Prints the list of threads and their details on UIOUT.
This is a version of 'info_thread_command' suitable for
use from MI.
Index: src/gdb/top.c
===================================================================
--- src.orig/gdb/top.c 2008-06-17 19:15:14.000000000 +0100
+++ src/gdb/top.c 2008-06-17 19:15:17.000000000 +0100
@@ -46,6 +46,7 @@
#include "gdb_assert.h"
#include "main.h"
#include "event-loop.h"
+#include "gdbthread.h"
/* readline include files */
#include "readline/readline.h"
@@ -181,12 +182,6 @@ int remote_timeout = 2;
int remote_debug = 0;
-/* Non-zero means the target is running. Note: this is different from
- saying that there is an active target and we are stopped at a
- breakpoint, for instance. This is a real indicator whether the
- target is off and running, which gdb is doing something else. */
-int target_executing = 0;
-
/* Sbrk location on entry to main. Used for statistics only. */
#ifdef HAVE_SBRK
char *lim_at_start;
@@ -422,7 +417,10 @@ execute_command (char *p, int from_tty)
/* If the target is running, we allow only a limited set of
commands. */
- if (target_can_async_p () && target_executing && !get_cmd_async_ok (c))
+ if (target_can_async_p ()
+ && target_has_execution
+ && any_running ()
+ && !get_cmd_async_ok (c))
error (_("Cannot execute this command while the target is running."));
/* Pass null arg rather than an empty one. */
@@ -486,7 +484,7 @@ execute_command (char *p, int from_tty)
/* FIXME: This should be cacheing the frame and only running when
the frame changes. */
- if (!target_executing && target_has_stack)
+ if (target_has_stack && !is_running (inferior_ptid))
{
flang = get_frame_language ();
if (!warned
Index: src/gdb/event-top.c
===================================================================
--- src.orig/gdb/event-top.c 2008-06-17 19:15:14.000000000 +0100
+++ src/gdb/event-top.c 2008-06-17 19:15:17.000000000 +0100
@@ -32,6 +32,7 @@
#include "exceptions.h"
#include "cli/cli-script.h" /* for reset_command_nest_depth */
#include "main.h"
+#include "gdbthread.h"
/* For dont_repeat() */
#include "gdbcmd.h"
@@ -268,7 +269,7 @@ display_gdb_prompt (char *new_prompt)
if (!current_interp_display_prompt_p ())
return;
- if (target_executing && sync_execution)
+ if (sync_execution && is_running (inferior_ptid))
{
/* This is to trick readline into not trying to display the
prompt. Even though we display the prompt using this
@@ -516,7 +517,7 @@ command_handler (char *command)
/* Do any commands attached to breakpoint we stopped at. Only if we
are always running synchronously. Or if we have just executed a
command that doesn't start the target. */
- if (!target_can_async_p () || !target_executing)
+ if (!target_can_async_p () || !is_running (inferior_ptid))
{
bpstat_do_actions (&stop_bpstat);
do_cleanups (old_chain);
Index: src/gdb/inf-loop.c
===================================================================
--- src.orig/gdb/inf-loop.c 2008-06-17 19:15:14.000000000 +0100
+++ src/gdb/inf-loop.c 2008-06-17 19:15:17.000000000 +0100
@@ -26,6 +26,7 @@
#include "remote.h"
#include "exceptions.h"
#include "language.h"
+#include "gdbthread.h"
static int fetch_inferior_event_wrapper (gdb_client_data client_data);
@@ -72,14 +73,6 @@ inferior_event_handler (enum inferior_ev
break;
case INF_EXEC_COMPLETE:
-
- /* This is the first thing to do -- so that continuations know that
- the target is stopped. For example, command_line_handler_continuation
- will run breakpoint commands, and if we think that the target is
- running, we'll refuse to execute most commands. MI continuation
- presently uses target_executing to either print or not print *stopped. */
- target_executing = 0;
-
/* Unregister the inferior from the event loop. This is done so that
when the inferior is not running we don't get distracted by
spurious inferior output. */
@@ -121,8 +114,8 @@ inferior_event_handler (enum inferior_ev
/* If no breakpoint command resumed the inferior, prepare for
interaction with the user. */
- if (!target_executing)
- {
+ if (!is_running (inferior_ptid))
+ {
if (was_sync)
{
display_gdb_prompt (0);
Index: src/gdb/infrun.c
===================================================================
--- src.orig/gdb/infrun.c 2008-06-17 19:15:14.000000000 +0100
+++ src/gdb/infrun.c 2008-06-17 19:15:17.000000000 +0100
@@ -1766,6 +1766,12 @@ handle_inferior_event (struct execution_
&& ecs->ws.kind != TARGET_WAITKIND_SIGNALLED && ecs->new_thread_event)
add_thread (ecs->ptid);
+ /* Mark all threads as not-executing. In non-stop, this should be
+ adjusted to only mark ecs->ptid. */
+ if (ecs->ws.kind != TARGET_WAITKIND_IGNORE
+ && stop_soon != STOP_QUIETLY)
+ set_executing (pid_to_ptid (-1), 0);
+
switch (ecs->ws.kind)
{
case TARGET_WAITKIND_LOADED:
Index: src/gdb/linux-nat.c
===================================================================
--- src.orig/gdb/linux-nat.c 2008-06-17 19:15:14.000000000 +0100
+++ src/gdb/linux-nat.c 2008-06-17 19:15:17.000000000 +0100
@@ -1554,10 +1554,7 @@ linux_nat_resume (ptid_t ptid, int step,
signo ? strsignal (signo) : "0");
if (target_can_async_p ())
- {
- target_executing = 1;
- target_async (inferior_event_handler, 0);
- }
+ target_async (inferior_event_handler, 0);
}
/* Issue kill to specified lwp. */
Index: src/gdb/stack.c
===================================================================
--- src.orig/gdb/stack.c 2008-06-17 19:15:14.000000000 +0100
+++ src/gdb/stack.c 2008-06-17 19:15:17.000000000 +0100
@@ -43,6 +43,7 @@
#include "regcache.h"
#include "solib.h"
#include "valprint.h"
+#include "gdbthread.h"
#include "gdb_assert.h"
#include <ctype.h>
@@ -1643,6 +1644,9 @@ get_selected_block (CORE_ADDR *addr_in_b
if (!target_has_stack)
return 0;
+ if (is_executing (inferior_ptid))
+ return 0;
+
return get_frame_block (get_selected_frame (NULL), addr_in_block);
}
Index: src/gdb/target.c
===================================================================
--- src.orig/gdb/target.c 2008-06-17 19:15:14.000000000 +0100
+++ src/gdb/target.c 2008-06-17 19:15:17.000000000 +0100
@@ -1721,8 +1721,8 @@ target_resume (ptid_t ptid, int step, en
{
dcache_invalidate (target_dcache);
(*current_target.to_resume) (ptid, step, signal);
+ set_executing (ptid, 1);
set_running (ptid, 1);
-
}
/* Look through the list of possible targets for a target that can
follow forks. */
Index: src/gdb/breakpoint.c
===================================================================
--- src.orig/gdb/breakpoint.c 2008-06-17 19:15:14.000000000 +0100
+++ src/gdb/breakpoint.c 2008-06-17 19:15:17.000000000 +0100
@@ -6208,7 +6208,7 @@ until_break_command (char *arg, int from
deleted when the target stops. Otherwise, we're already stopped and
delete breakpoints via cleanup chain. */
- if (target_can_async_p () && target_executing)
+ if (target_can_async_p () && is_running (inferior_ptid))
{
arg1 =
(struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
Index: src/gdb/remote.c
===================================================================
--- src.orig/gdb/remote.c 2008-06-17 19:15:14.000000000 +0100
+++ src/gdb/remote.c 2008-06-17 19:15:17.000000000 +0100
@@ -3149,13 +3149,6 @@ remote_resume (ptid_t ptid, int step, en
NOT asynchronously. */
if (target_can_async_p ())
target_async (inferior_event_handler, 0);
- /* Tell the world that the target is now executing. */
- /* FIXME: cagney/1999-09-23: Is it the targets responsibility to set
- this? Instead, should the client of target just assume (for
- async targets) that the target is going to start executing? Is
- this information already found in the continuation block? */
- if (target_is_async_p ())
- target_executing = 1;
}
\f
Index: src/gdb/mi/mi-interp.c
===================================================================
--- src.orig/gdb/mi/mi-interp.c 2008-06-17 19:15:14.000000000 +0100
+++ src/gdb/mi/mi-interp.c 2008-06-17 19:15:17.000000000 +0100
@@ -222,7 +222,7 @@ mi_cmd_interpreter_exec (char *command,
changing the interpreter will clear out all the continuations for
that interpreter... */
- if (target_can_async_p () && target_executing)
+ if (target_can_async_p () && any_running ())
{
fputs_unfiltered ("^running\n", raw_stdout);
}
Index: src/gdb/mi/mi-main.c
===================================================================
--- src.orig/gdb/mi/mi-main.c 2008-06-17 19:15:14.000000000 +0100
+++ src/gdb/mi/mi-main.c 2008-06-17 19:15:17.000000000 +0100
@@ -214,8 +214,8 @@ mi_cmd_exec_continue (char *command, cha
enum mi_cmd_result
mi_cmd_exec_interrupt (char *command, char **argv, int argc)
{
- if (!target_executing)
- error ("mi_cmd_exec_interrupt: Inferior not executing.");
+ if (!is_running (inferior_ptid))
+ error ("mi_cmd_exec_interrupt: Inferior not running.");
interrupt_target_command (NULL, 0);
if (current_token)
@@ -1062,7 +1062,7 @@ captured_mi_execute_command (struct ui_o
if (do_timings)
timestamp (&cmd_finished);
- if (!target_can_async_p () || !target_executing)
+ if (!target_can_async_p () || !is_running (inferior_ptid))
{
/* Print the result if there were no errors.
@@ -1195,7 +1195,7 @@ mi_cmd_execute (struct mi_parse *parse)
if (parse->cmd->argv_func != NULL)
{
- if (target_executing)
+ if (is_running (inferior_ptid))
{
if (strcmp (parse->command, "exec-interrupt"))
{
@@ -1310,7 +1310,7 @@ mi_execute_async_cli_command (char *cli_
if (target_can_async_p ())
{
/* If we're not executing, an exception should have been throw. */
- gdb_assert (target_executing);
+ gdb_assert (is_running (inferior_ptid));
do_cleanups (old_cleanups);
}
else
Index: src/gdb/Makefile.in
===================================================================
--- src.orig/gdb/Makefile.in 2008-06-17 19:15:14.000000000 +0100
+++ src/gdb/Makefile.in 2008-06-17 19:15:17.000000000 +0100
@@ -2118,7 +2118,7 @@ event-loop.o: event-loop.c $(defs_h) $(e
event-top.o: event-top.c $(defs_h) $(top_h) $(inferior_h) $(target_h) \
$(terminal_h) $(event_loop_h) $(event_top_h) $(interps_h) \
$(exceptions_h) $(cli_script_h) $(gdbcmd_h) $(readline_h) \
- $(readline_history_h) $(main_h)
+ $(readline_history_h) $(main_h) $(gdbthread_h)
exceptions.o: exceptions.c $(defs_h) $(exceptions_h) $(breakpoint_h) \
$(target_h) $(inferior_h) $(annotate_h) $(ui_out_h) $(gdb_assert_h) \
$(gdb_string_h) $(serial_h)
@@ -2153,7 +2153,8 @@ frame.o: frame.c $(defs_h) $(frame_h) $(
$(regcache_h) $(gdb_assert_h) $(gdb_string_h) $(user_regs_h) \
$(gdb_obstack_h) $(dummy_frame_h) $(sentinel_frame_h) $(gdbcore_h) \
$(annotate_h) $(language_h) $(frame_unwind_h) $(frame_base_h) \
- $(command_h) $(gdbcmd_h) $(observer_h) $(objfiles_h) $(exceptions_h)
+ $(command_h) $(gdbcmd_h) $(observer_h) $(objfiles_h) $(exceptions_h) \
+ $(gdbthread_h)
frame-unwind.o: frame-unwind.c $(defs_h) $(frame_h) $(frame_unwind_h) \
$(gdb_assert_h) $(dummy_frame_h) $(gdb_obstack_h) $(value_h) \
$(regcache_h)
@@ -2334,7 +2335,7 @@ infcmd.o: infcmd.c $(defs_h) $(gdb_strin
$(user_regs_h) $(exceptions_h) $(cli_decode_h) $(gdbthread_h)
inf-loop.o: inf-loop.c $(defs_h) $(inferior_h) $(target_h) $(event_loop_h) \
$(event_top_h) $(inf_loop_h) $(remote_h) $(exceptions_h) \
- $(language_h)
+ $(language_h) $(gdbthread_h)
inflow.o: inflow.c $(defs_h) $(frame_h) $(inferior_h) $(command_h) \
$(serial_h) $(terminal_h) $(target_h) $(gdbthread_h) $(gdb_string_h) \
$(inflow_h) $(gdb_select_h)
@@ -2941,7 +2942,7 @@ top.o: top.c $(defs_h) $(gdbcmd_h) $(cal
$(annotate_h) $(completer_h) $(top_h) $(version_h) $(serial_h) \
$(doublest_h) $(gdb_assert_h) $(readline_h) $(readline_history_h) \
$(event_top_h) $(gdb_string_h) $(gdb_stat_h) $(ui_out_h) \
- $(cli_out_h) $(main_h) $(event_loop_h)
+ $(cli_out_h) $(main_h) $(event_loop_h) $(gdbthread_h)
tracepoint.o: tracepoint.c $(defs_h) $(symtab_h) $(frame_h) $(gdbtypes_h) \
$(expression_h) $(gdbcmd_h) $(value_h) $(target_h) $(language_h) \
$(gdb_string_h) $(inferior_h) $(tracepoint_h) $(remote_h) \
Index: src/gdb/frame.c
===================================================================
--- src.orig/gdb/frame.c 2008-06-17 19:15:14.000000000 +0100
+++ src/gdb/frame.c 2008-06-17 19:15:17.000000000 +0100
@@ -40,6 +40,7 @@
#include "observer.h"
#include "objfiles.h"
#include "exceptions.h"
+#include "gdbthread.h"
static struct frame_info *get_prev_frame_1 (struct frame_info *this_frame);
@@ -930,6 +931,9 @@ get_current_frame (void)
error (_("No stack."));
if (!target_has_memory)
error (_("No memory."));
+ if (is_executing (inferior_ptid))
+ error (_("Target is executing."));
+
if (current_frame == NULL)
{
struct frame_info *sentinel_frame =
@@ -950,6 +954,20 @@ get_current_frame (void)
static struct frame_info *selected_frame;
+static int
+has_stack_frames (void)
+{
+ if (!target_has_registers || !target_has_stack || !target_has_memory)
+ return 0;
+
+ /* If the current thread is executing, don't try to read from
+ it. */
+ if (is_executing (inferior_ptid))
+ return 0;
+
+ return 1;
+}
+
/* Return the selected frame. Always non-NULL (unless there isn't an
inferior sufficient for creating a frame) in which case an error is
thrown. */
@@ -959,9 +977,7 @@ get_selected_frame (const char *message)
{
if (selected_frame == NULL)
{
- if (message != NULL && (!target_has_registers
- || !target_has_stack
- || !target_has_memory))
+ if (message != NULL && !has_stack_frames ())
error (("%s"), message);
/* Hey! Don't trust this. It should really be re-finding the
last selected frame of the currently selected thread. This,
@@ -980,7 +996,7 @@ get_selected_frame (const char *message)
struct frame_info *
deprecated_safe_get_selected_frame (void)
{
- if (!target_has_registers || !target_has_stack || !target_has_memory)
+ if (!has_stack_frames ())
return NULL;
return get_selected_frame (NULL);
}
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-17 17:10 ` Vladimir Prus
@ 2008-06-17 20:38 ` Eli Zaretskii
0 siblings, 0 replies; 29+ messages in thread
From: Eli Zaretskii @ 2008-06-17 20:38 UTC (permalink / raw)
To: Vladimir Prus; +Cc: gdb-patches
> From: Vladimir Prus <vladimir@codesourcery.com>
> Date: Tue, 17 Jun 2008 13:50:45 +0400
>
> Eli Zaretskii wrote:
>
> >> From: Vladimir Prus <vladimir@codesourcery.com>
> >> Date: Mon, 16 Jun 2008 10:42:09 +0400
> >>
> >> It's actually fairly weird that one has to maintain dependencies by hand,
> >
> > We are obviously miscommunicating. What I meant was simple entries
> > like:
> >
> > * Makefile.in (foo.o): Add bar.c and bar.h to prerequisites.
> > or
> > * Makefile.in (foo.o): Remove foobar.h from prerequisites.
> >
> > That's a far cry from ``maintaining dependencies by hand''.
>
> In fact, it is the same. Why do we, in 2008, need to add 'bar.h' to dependencies of
> foo.o?
I didn't say we needed to, I said that if we do, we should mention it
in the ChangeLog, that's all. The simple fact is that in this
particular case, the change was to add $(gdbthread_h) to the list of
prerequisites of several targets, like this:
inf-loop.o: inf-loop.c $(defs_h) $(inferior_h) $(target_h) $(event_loop_h) \
$(event_top_h) $(inf_loop_h) $(remote_h) $(exceptions_h) \
- $(language_h)
+ $(language_h) $(gdbthread_h)
If you think this kind of change is ``laughable'' in the year 2008,
please complain to Pedro, who suggested such a change; I didn't.
> That's painful and, honestly, laughable at, thing.
Well, entries such as "Makefile.in (event-top.o): Update." are no less
laughable, because they convey exactly zero useful information beyond
what "cvs log Makefile.in" already tells. If we want to accept such
entries, why don't we abandon ChangeLog files at all?
By contrast, saying _what_ was changed in the rules of a target gives
me valuable information that is a pain to glean from CVS, unless I'm
interested in the very last change, or know exactly in what version
the change I'm interested in was committed.
That said, I'm no longer young enough to fight Quixotic battles. If
this is the kind of coding standards the other GDB maintainers want to
adhere to, let's codify them somewhere, and be done with that, so that
I will never again need to start arguments like this one just to be
predictably voted down.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-17 18:34 ` Pedro Alves
@ 2008-06-17 20:58 ` Eli Zaretskii
2008-06-23 1:13 ` Daniel Jacobowitz
1 sibling, 0 replies; 29+ messages in thread
From: Eli Zaretskii @ 2008-06-17 20:58 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
> From: Pedro Alves <pedro@codesourcery.com>
> Date: Tue, 17 Jun 2008 19:24:04 +0100
>
> Same patch, updated ChangeLog entry.
Thank you, I'm quite happy now.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-17 18:32 ` Joel Brobecker
@ 2008-06-18 0:22 ` Eli Zaretskii
0 siblings, 0 replies; 29+ messages in thread
From: Eli Zaretskii @ 2008-06-18 0:22 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
> Date: Tue, 17 Jun 2008 14:20:50 -0400
> From: Joel Brobecker <brobecker@adacore.com>
> Cc: pedro@codesourcery.com, gdb-patches@sourceware.org
>
> > Well, "Makefile.in (foo): Update." doesn't give any idea WHAT was
> > done, it only says WHERE it was done.
>
> Actually, it does, at least as far I what I want to know (I want to
> know that the author did an update of the Makefile rules).
That's exactly what "cvs log" tells you as well.
> I don't remember checking exactly what dependencies were added or
> removed, but I don't mind using CVS for that.
It's a pain to do this with CVS, at least in the situations I have in
mind. Imagine that you need to find all the changes in a certain part
of a specific rule since a very old version. Perhaps you wonder why
that part of the rule has its present shape, or what other files were
modified together with that part of the rule, or who did those
changes. "cvs annotate" only gives you the last version, and "cvs
log" doesn't say _what_ was changed. The only way I know of is to use
"cvs diff -rVn -rVn+1" until you have all the history figured out and
find those changes that matter. The fact that the ChangeLog tells you
the name of the rule is of little help, because you are still facing a
lot of changes in the same rule, even if you now can skip some of the
versions.
By contrast, if the ChangeLog states what was changed in the rule, you
can find the information you want or at least dramatically narrow the
number of version diffs you need to review just by looking up the
target's name in the log file, and then reading what was modified in
the rule.
I've been there quite a few times, and I came to appreciate a few
details in the log entry.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-17 18:34 ` Pedro Alves
2008-06-17 20:58 ` Eli Zaretskii
@ 2008-06-23 1:13 ` Daniel Jacobowitz
2008-06-23 11:54 ` Vladimir Prus
2008-07-02 3:29 ` Pedro Alves
1 sibling, 2 replies; 29+ messages in thread
From: Daniel Jacobowitz @ 2008-06-23 1:13 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, Eli Zaretskii
On Tue, Jun 17, 2008 at 07:24:04PM +0100, Pedro Alves wrote:
> @@ -422,7 +417,10 @@ execute_command (char *p, int from_tty)
>
> /* If the target is running, we allow only a limited set of
> commands. */
> - if (target_can_async_p () && target_executing && !get_cmd_async_ok (c))
> + if (target_can_async_p ()
> + && target_has_execution
> + && any_running ()
> + && !get_cmd_async_ok (c))
> error (_("Cannot execute this command while the target is running."));
>
> /* Pass null arg rather than an empty one. */
Don't need target_has_execution here anymore, do we?
The patch otherwise looks OK.
Before we start checking these in, how do you plan to handle
documentation (internals also, but mostly user) and test cases?
I'd like to know there's at least a plan for this before we merge
non-stop.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-23 1:13 ` Daniel Jacobowitz
@ 2008-06-23 11:54 ` Vladimir Prus
2008-06-23 14:41 ` Pedro Alves
2008-06-23 18:14 ` Eli Zaretskii
2008-07-02 3:29 ` Pedro Alves
1 sibling, 2 replies; 29+ messages in thread
From: Vladimir Prus @ 2008-06-23 11:54 UTC (permalink / raw)
To: gdb-patches
Daniel Jacobowitz wrote:
> On Tue, Jun 17, 2008 at 07:24:04PM +0100, Pedro Alves wrote:
>> @@ -422,7 +417,10 @@ execute_command (char *p, int from_tty)
>>
>> /* If the target is running, we allow only a limited set of
>> commands. */
>> - if (target_can_async_p () && target_executing && !get_cmd_async_ok (c))
>> + if (target_can_async_p ()
>> + && target_has_execution
>> + && any_running ()
>> + && !get_cmd_async_ok (c))
>> error (_("Cannot execute this command while the target is running."));
>>
>> /* Pass null arg rather than an empty one. */
>
> Don't need target_has_execution here anymore, do we?
>
> The patch otherwise looks OK.
>
> Before we start checking these in, how do you plan to handle
> documentation (internals also, but mostly user) and test cases?
Test cases are on my plate, FWIW, as well as MI docs. I'm not sure
if there's general docs to be written, and I'm not not sure about
internals docs.
- Volodya
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-23 11:54 ` Vladimir Prus
@ 2008-06-23 14:41 ` Pedro Alves
2008-06-23 18:22 ` Eli Zaretskii
2008-06-23 18:14 ` Eli Zaretskii
1 sibling, 1 reply; 29+ messages in thread
From: Pedro Alves @ 2008-06-23 14:41 UTC (permalink / raw)
To: gdb-patches; +Cc: Vladimir Prus
A Monday 23 June 2008 09:52:13, Vladimir Prus wrote:
> > Before we start checking these in, how do you plan to handle
> > documentation (internals also, but mostly user) and test cases?
>
> Test cases are on my plate, FWIW, as well as MI docs.
> I'm not sure
> if there's general docs to be written, and I'm not not sure about
> internals docs.
These are on my plate.
--
Pedro Alves
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-16 7:22 ` [non-stop] 01/10 Add "executing" property Vladimir Prus
2008-06-17 0:40 ` Eli Zaretskii
@ 2008-06-23 17:27 ` Tom Tromey
1 sibling, 0 replies; 29+ messages in thread
From: Tom Tromey @ 2008-06-23 17:27 UTC (permalink / raw)
To: Vladimir Prus; +Cc: gdb-patches
>>>>> "Vladimir" == Vladimir Prus <vladimir@codesourcery.com> writes:
Vladimir> It's actually fairly weird that one has to maintain
Vladimir> dependencies by hand, I don't think I know any single
Vladimir> project still alive that needs that.
I can send out my unfinished Makefile.am for gdb if you really want
it. That would solve this problem.
"Unfinished" means it is like 30% done :-(
If we didn't mind requiring GNU make we could probably implement
dependency tracking more simply. I suspect that is still a no-go ...
Tom
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-23 11:54 ` Vladimir Prus
2008-06-23 14:41 ` Pedro Alves
@ 2008-06-23 18:14 ` Eli Zaretskii
1 sibling, 0 replies; 29+ messages in thread
From: Eli Zaretskii @ 2008-06-23 18:14 UTC (permalink / raw)
To: Vladimir Prus; +Cc: gdb-patches
> From: Vladimir Prus <vladimir@codesourcery.com>
> Date: Mon, 23 Jun 2008 12:52:13 +0400
>
> I'm not sure if there's general docs to be written
If the new feature is visible to the user via CLI, some general docs
are in order; otherwise, the MI docs will do.
> and I'm not not sure about internals docs.
They are always welcome, but I don't feel I can insist here, since so
many others don't do that.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-23 14:41 ` Pedro Alves
@ 2008-06-23 18:22 ` Eli Zaretskii
2008-06-23 18:25 ` Vladimir Prus
0 siblings, 1 reply; 29+ messages in thread
From: Eli Zaretskii @ 2008-06-23 18:22 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, vladimir
> From: Pedro Alves <pedro@codesourcery.com>
> Date: Mon, 23 Jun 2008 13:26:19 +0100
> Cc: Vladimir Prus <vladimir@codesourcery.com>
>
> A Monday 23 June 2008 09:52:13, Vladimir Prus wrote:
>
> > > Before we start checking these in, how do you plan to handle
> > > documentation (internals also, but mostly user) and test cases?
> >
> > Test cases are on my plate, FWIW, as well as MI docs.
>
> > I'm not sure
> > if there's general docs to be written, and I'm not not sure about
> > internals docs.
>
> These are on my plate.
What, you mean I will be in a position to choose which one of you
writes better docs? ;-)
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-23 18:22 ` Eli Zaretskii
@ 2008-06-23 18:25 ` Vladimir Prus
2008-06-23 19:52 ` Pedro Alves
0 siblings, 1 reply; 29+ messages in thread
From: Vladimir Prus @ 2008-06-23 18:25 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Pedro Alves, gdb-patches
On Monday 23 June 2008 22:02:25 Eli Zaretskii wrote:
> > From: Pedro Alves <pedro@codesourcery.com>
> > Date: Mon, 23 Jun 2008 13:26:19 +0100
> > Cc: Vladimir Prus <vladimir@codesourcery.com>
> >
> > A Monday 23 June 2008 09:52:13, Vladimir Prus wrote:
> >
> > > > Before we start checking these in, how do you plan to handle
> > > > documentation (internals also, but mostly user) and test cases?
> > >
> > > Test cases are on my plate, FWIW, as well as MI docs.
> >
> > > I'm not sure
> > > if there's general docs to be written, and I'm not not sure about
> > > internals docs.
> >
> > These are on my plate.
>
> What, you mean I will be in a position to choose which one of you
> writes better docs? ;-)
Yea, let's have two non-native speakers have a doc-writing contest :-)
I think Pedro meant that he'll write general/CLI docs and internal docs.
- Volodya
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-23 18:25 ` Vladimir Prus
@ 2008-06-23 19:52 ` Pedro Alves
2008-06-24 1:13 ` Eli Zaretskii
0 siblings, 1 reply; 29+ messages in thread
From: Pedro Alves @ 2008-06-23 19:52 UTC (permalink / raw)
To: Vladimir Prus; +Cc: Eli Zaretskii, gdb-patches
A Monday 23 June 2008 19:13:59, Vladimir Prus wrote:
> Yea, let's have two non-native speakers have a doc-writing contest :-)
> I think Pedro meant that he'll write general/CLI docs and internal docs.
>
Yes, that's what I meant :-)
--
Pedro Alves
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-23 19:52 ` Pedro Alves
@ 2008-06-24 1:13 ` Eli Zaretskii
0 siblings, 0 replies; 29+ messages in thread
From: Eli Zaretskii @ 2008-06-24 1:13 UTC (permalink / raw)
To: Pedro Alves; +Cc: vladimir, gdb-patches
> From: Pedro Alves <pedro@codesourcery.com>
> Date: Mon, 23 Jun 2008 19:25:18 +0100
> Cc: Eli Zaretskii <eliz@gnu.org>, gdb-patches@sourceware.org
>
> A Monday 23 June 2008 19:13:59, Vladimir Prus wrote:
>
> > Yea, let's have two non-native speakers have a doc-writing contest :-)
> > I think Pedro meant that he'll write general/CLI docs and internal docs.
> >
>
> Yes, that's what I meant :-)
Hey, I'm not a native English speaker as well. So it's hardly rocket
science.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-15 21:04 [non-stop] 01/10 Add "executing" property Pedro Alves
2008-06-15 22:18 ` Eli Zaretskii
@ 2008-06-25 19:02 ` Vladimir Prus
2008-06-25 19:13 ` Pedro Alves
1 sibling, 1 reply; 29+ messages in thread
From: Vladimir Prus @ 2008-06-25 19:02 UTC (permalink / raw)
To: gdb-patches
Pedro Alves wrote:
> +
> +/* Reports if thread PTID is executing. Â */
> +extern int is_executing (ptid_t ptid);
I know if follows is_running, introduced by me, but I think this is not
the best interface. Say, somewhere later in this patch series we have
this function:
static int
proceed_thread_callback (struct thread_info *thread, void *arg)
{
if (!is_stopped (thread->ptid))
....
Here, we already have thread_info, and using ptid to search for thread
again, and get its state seems not nice. How about:
extern int is_executing (struct thread_info *thread);
extern int is_executing_ptid (ptid_t ptid);
and a similar change for is_running?
- Volodya
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-25 19:02 ` Vladimir Prus
@ 2008-06-25 19:13 ` Pedro Alves
2008-06-25 19:22 ` Daniel Jacobowitz
0 siblings, 1 reply; 29+ messages in thread
From: Pedro Alves @ 2008-06-25 19:13 UTC (permalink / raw)
To: gdb-patches; +Cc: Vladimir Prus
A Wednesday 25 June 2008 18:48:27, Vladimir Prus escreveu:
> Pedro Alves wrote:
> > +
> > +/* Reports if thread PTID is executing. */
> > +extern int is_executing (ptid_t ptid);
>
> I know if follows is_running, introduced by me, but I think this is not
> the best interface. Say, somewhere later in this patch series we have
> this function:
>
Right. I actually think I introduced is_running in one of those early
non-stop patches :-) It goes hand in hand with set_running. By
your reasoning, we should make it set_running_ptid too.
> static int
> proceed_thread_callback (struct thread_info *thread, void *arg)
> {
> if (!is_stopped (thread->ptid))
> ....
>
> Here, we already have thread_info, and using ptid to search for thread
> again, and get its state seems not nice. How about:
>
> extern int is_executing (struct thread_info *thread);
> extern int is_executing_ptid (ptid_t ptid);
>
There are actually very few places that need to check for
is_executing, (frame.c, stack.c), and I don't expect much more.
None of these places have a thread_info pointer around. I can change
the interface, no problem with me, but in this case, we only need the
ptid form currently.
> static int
> proceed_thread_callback (struct thread_info *thread, void *arg)
> {
> if (!is_stopped (thread->ptid))
> ....
> and a similar change for is_running?
The is_stopped method is only introduced in patch 10 actually.
We could also do is_stopped_thread (struct thread_info *) instead,
as I expect the ptid versions to be used more often.
I'll wait for review on it (as it is the patch that will probably need
more adjustement) before making interface changes, OK?
--
Pedro Alves
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-25 19:13 ` Pedro Alves
@ 2008-06-25 19:22 ` Daniel Jacobowitz
2008-06-26 13:37 ` Vladimir Prus
0 siblings, 1 reply; 29+ messages in thread
From: Daniel Jacobowitz @ 2008-06-25 19:22 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, Vladimir Prus
On Wed, Jun 25, 2008 at 08:02:27PM +0100, Pedro Alves wrote:
> I'll wait for review on it (as it is the patch that will probably need
> more adjustement) before making interface changes, OK?
Speaking for myself, I wouldn't mind getting these patches in and
then making this sort of change immediately afterwards... I dread
having to re-review cascading revised patches.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-25 19:22 ` Daniel Jacobowitz
@ 2008-06-26 13:37 ` Vladimir Prus
0 siblings, 0 replies; 29+ messages in thread
From: Vladimir Prus @ 2008-06-26 13:37 UTC (permalink / raw)
To: gdb-patches
Daniel Jacobowitz wrote:
> On Wed, Jun 25, 2008 at 08:02:27PM +0100, Pedro Alves wrote:
>> I'll wait for review on it (as it is the patch that will probably need
>> more adjustement) before making interface changes, OK?
>
> Speaking for myself, I wouldn't mind getting these patches in and
> then making this sort of change immediately afterwards... I dread
> having to re-review cascading revised patches.
Yes. I think that Pedro's patches are in good shape already, and they
don't break all-stop mode, so it's more efficient to get everything in
and then tweak things, if necessary.
- Volodya
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [non-stop] 01/10 Add "executing" property
2008-06-23 1:13 ` Daniel Jacobowitz
2008-06-23 11:54 ` Vladimir Prus
@ 2008-07-02 3:29 ` Pedro Alves
1 sibling, 0 replies; 29+ messages in thread
From: Pedro Alves @ 2008-07-02 3:29 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1015 bytes --]
A Monday 23 June 2008 02:03:53, Daniel Jacobowitz wrote:
> On Tue, Jun 17, 2008 at 07:24:04PM +0100, Pedro Alves wrote:
> > @@ -422,7 +417,10 @@ execute_command (char *p, int from_tty)
> >
> > /* If the target is running, we allow only a limited set of
> > commands. */
> > - if (target_can_async_p () && target_executing && !get_cmd_async_ok
> > (c)) + if (target_can_async_p ()
> > + && target_has_execution
> > + && any_running ()
> > + && !get_cmd_async_ok (c))
> > error (_("Cannot execute this command while the target is running."));
> >
> > /* Pass null arg rather than an empty one. */
>
> Don't need target_has_execution here anymore, do we?
That's correct. I've fixed it. I've also removed the stop_soon check
that you noticed I was dropping in a later patch in the series. I
couldn't find a reason it is needed now.
> The patch otherwise looks OK.
Thanks. Here's the updated patch that I'll commit unless there
are more comments to it.
--
Pedro Alves
[-- Attachment #2: 001-is_executing.diff --]
[-- Type: text/x-diff, Size: 21349 bytes --]
2008-07-02 Pedro Alves <pedro@codesourcery.com>
Add "executing" property to threads.
* inferior.h (target_executing): Delete.
* gdbthread.h (struct thread_info): Add executing_ field.
(set_executing, is_executing): New.
* thread.c (main_thread_executing): New.
(init_thread_list): Clear it and also main_thread_running.
(is_running): Return false if target has no execution.
(any_running, is_executing, set_executing): New.
* top.c: Include "gdbthread.h".
(target_executing): Delete.
(execute_command): Replace target_executing check by any_running.
* event-top.c: Include "gdbthread.h".
(display_gdb_prompt, command_handler): Replace target_executing by
is_running.
* inf-loop.c: Include "gdbthread.h". Don't mark as not executing
here. Replace target_executing by is_running.
* infrun.c (handle_inferior_event): Mark all threads as
not-executing.
* linux-nat.c (linux_nat_resume): Don't mark thread as executing
here.
* stack.c (get_selected_block): Return null if inferior is
executing.
* target.c (target_resume): Mark resumed ptid as executing.
* breakpoint.c (until_break_command): Replace target_executing
check by is_executing.
* remote.c (remote_async_resume): Don't mark inferior as executing
here.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Replace target_executing
by any_running.
* mi/mi-main.c (mi_cmd_exec_interrupt, mi_cmd_execute)
(mi_execute_async_cli_command): Replace target_executing by
is_running.
* frame.c (get_current_frame): Error out if the current thread is
executing.
(has_stack_frames): New.
(get_selected_frame, deprecated_safe_get_selected_frame): Check
has_stack_frames.
* Makefile.in (event-top.o, frame.o, inf-loop.o, top.o): Depend on
$(gdbthread_h).
---
gdb/Makefile.in | 9 +++---
gdb/breakpoint.c | 2 -
gdb/event-top.c | 5 ++-
gdb/frame.c | 24 +++++++++++++++---
gdb/gdbthread.h | 35 ++++++++++++++++++++++----
gdb/inf-loop.c | 13 ++-------
gdb/inferior.h | 6 ----
gdb/infrun.c | 5 +++
gdb/linux-nat.c | 5 ---
gdb/mi/mi-main.c | 8 +++---
gdb/remote.c | 7 -----
gdb/stack.c | 4 +++
gdb/target.c | 2 -
gdb/thread.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
gdb/top.c | 13 +++------
15 files changed, 152 insertions(+), 58 deletions(-)
Index: src/gdb/inferior.h
===================================================================
--- src.orig/gdb/inferior.h 2008-06-29 01:39:51.000000000 +0100
+++ src/gdb/inferior.h 2008-06-29 22:33:27.000000000 +0100
@@ -111,12 +111,6 @@ extern const char *get_inferior_io_termi
extern ptid_t inferior_ptid;
-/* Is the inferior running right now, as a result of a 'run&',
- 'continue&' etc command? This is used in asycn gdb to determine
- whether a command that the user enters while the target is running
- is allowed or not. */
-extern int target_executing;
-
/* Are we simulating synchronous execution? This is used in async gdb
to implement the 'run', 'continue' etc commands, which will not
redisplay the prompt until the execution is actually over. */
Index: src/gdb/gdbthread.h
===================================================================
--- src.orig/gdb/gdbthread.h 2008-06-29 01:41:45.000000000 +0100
+++ src/gdb/gdbthread.h 2008-06-29 22:33:27.000000000 +0100
@@ -41,6 +41,25 @@ struct thread_info
In fact, this may be overloaded with
kernel thread id, etc. */
int num; /* Convenient handle (GDB thread id) */
+
+ /* Non-zero means the thread is executing. Note: this is different
+ from saying that there is an active target and we are stopped at
+ a breakpoint, for instance. This is a real indicator whether the
+ thread is off and running. */
+ /* This field is internal to thread.c. Never access it directly,
+ use is_executing instead. */
+ int executing_;
+
+ /* Frontend view of the running state. Note that this is different
+ from EXECUTING. When the thread is stopped internally while
+ handling an internal event, like a software single-step
+ breakpoint, executing will be false, but running will still be
+ true. As a possible future extension, this could turn into
+ enum { stopped, stepping, finishing, until(ling), ... } */
+ /* This field is internal to thread.c. Never access it directly,
+ use is_running instead. */
+ int running_;
+
/* State from wait_for_inferior */
CORE_ADDR prev_pc;
struct breakpoint *step_resume_breakpoint;
@@ -63,10 +82,6 @@ struct thread_info
when we finally do stop stepping. */
bpstat stepping_through_solib_catchpoints;
- /* This field is internal for thread.c. Never access it directly,
- use is_running instead. */
- int running_;
-
/* Private data used by the target vector implementation. */
struct private_thread_info *private;
};
@@ -156,9 +171,19 @@ extern void switch_to_thread (ptid_t pti
If PIDGET (PTID) is -1, marks all threads. */
extern void set_running (ptid_t ptid, int running);
-/* Reports if thread PTID is know to be running right now. */
+/* Reports if thread PTID is known to be running right now. */
extern int is_running (ptid_t ptid);
+/* Reports if any thread is known to be running right now. */
+extern int any_running (void);
+
+/* Marks thread PTID as executing, or as stopped.
+ If PIDGET (PTID) is -1, marks all threads. */
+extern void set_executing (ptid_t ptid, int executing);
+
+/* Reports if thread PTID is executing. */
+extern int is_executing (ptid_t ptid);
+
/* Commands with a prefix of `thread'. */
extern struct cmd_list_element *thread_cmd_list;
Index: src/gdb/thread.c
===================================================================
--- src.orig/gdb/thread.c 2008-06-29 01:41:46.000000000 +0100
+++ src/gdb/thread.c 2008-06-29 22:33:27.000000000 +0100
@@ -63,6 +63,9 @@ static void thread_apply_command (char *
static void restore_current_thread (ptid_t);
static void prune_threads (void);
+static int main_thread_running = 0;
+static int main_thread_executing = 0;
+
void
delete_step_resume_breakpoint (void *arg)
{
@@ -104,6 +107,9 @@ init_thread_list (void)
struct thread_info *tp, *tpnext;
highest_thread_num = 0;
+ main_thread_running = 0;
+ main_thread_executing = 0;
+
if (!thread_list)
return;
@@ -426,8 +432,6 @@ prune_threads (void)
}
}
-static int main_thread_running = 0;
-
void
set_running (ptid_t ptid, int running)
{
@@ -479,6 +483,9 @@ is_running (ptid_t ptid)
{
struct thread_info *tp;
+ if (!target_has_execution)
+ return 0;
+
if (!thread_list)
return main_thread_running;
@@ -487,6 +494,67 @@ is_running (ptid_t ptid)
return tp->running_;
}
+int
+any_running (void)
+{
+ struct thread_info *tp;
+
+ if (!target_has_execution)
+ return 0;
+
+ if (!thread_list)
+ return main_thread_running;
+
+ for (tp = thread_list; tp; tp = tp->next)
+ if (tp->running_)
+ return 1;
+
+ return 0;
+}
+
+int
+is_executing (ptid_t ptid)
+{
+ struct thread_info *tp;
+
+ if (!target_has_execution)
+ return 0;
+
+ if (!thread_list)
+ return main_thread_executing;
+
+ tp = find_thread_pid (ptid);
+ gdb_assert (tp);
+ return tp->executing_;
+}
+
+void
+set_executing (ptid_t ptid, int executing)
+{
+ struct thread_info *tp;
+
+ if (!thread_list)
+ {
+ /* This target does not add the main thread to the thread list.
+ Use a global flag to indicate that the thread is
+ executing. */
+ main_thread_executing = executing;
+ return;
+ }
+
+ if (PIDGET (ptid) == -1)
+ {
+ for (tp = thread_list; tp; tp = tp->next)
+ tp->executing_ = executing;
+ }
+ else
+ {
+ tp = find_thread_pid (ptid);
+ gdb_assert (tp);
+ tp->executing_ = executing;
+ }
+}
+
/* Prints the list of threads and their details on UIOUT.
This is a version of 'info_thread_command' suitable for
use from MI.
Index: src/gdb/top.c
===================================================================
--- src.orig/gdb/top.c 2008-06-29 01:39:51.000000000 +0100
+++ src/gdb/top.c 2008-06-29 22:33:27.000000000 +0100
@@ -46,6 +46,7 @@
#include "gdb_assert.h"
#include "main.h"
#include "event-loop.h"
+#include "gdbthread.h"
/* readline include files */
#include "readline/readline.h"
@@ -181,12 +182,6 @@ int remote_timeout = 2;
int remote_debug = 0;
-/* Non-zero means the target is running. Note: this is different from
- saying that there is an active target and we are stopped at a
- breakpoint, for instance. This is a real indicator whether the
- target is off and running, which gdb is doing something else. */
-int target_executing = 0;
-
/* Sbrk location on entry to main. Used for statistics only. */
#ifdef HAVE_SBRK
char *lim_at_start;
@@ -422,7 +417,9 @@ execute_command (char *p, int from_tty)
/* If the target is running, we allow only a limited set of
commands. */
- if (target_can_async_p () && target_executing && !get_cmd_async_ok (c))
+ if (target_can_async_p ()
+ && any_running ()
+ && !get_cmd_async_ok (c))
error (_("Cannot execute this command while the target is running."));
/* Pass null arg rather than an empty one. */
@@ -486,7 +483,7 @@ execute_command (char *p, int from_tty)
/* FIXME: This should be cacheing the frame and only running when
the frame changes. */
- if (!target_executing && target_has_stack)
+ if (target_has_stack && !is_running (inferior_ptid))
{
flang = get_frame_language ();
if (!warned
Index: src/gdb/event-top.c
===================================================================
--- src.orig/gdb/event-top.c 2008-06-29 01:39:51.000000000 +0100
+++ src/gdb/event-top.c 2008-06-29 22:33:27.000000000 +0100
@@ -32,6 +32,7 @@
#include "exceptions.h"
#include "cli/cli-script.h" /* for reset_command_nest_depth */
#include "main.h"
+#include "gdbthread.h"
/* For dont_repeat() */
#include "gdbcmd.h"
@@ -268,7 +269,7 @@ display_gdb_prompt (char *new_prompt)
if (!current_interp_display_prompt_p ())
return;
- if (target_executing && sync_execution)
+ if (sync_execution && is_running (inferior_ptid))
{
/* This is to trick readline into not trying to display the
prompt. Even though we display the prompt using this
@@ -516,7 +517,7 @@ command_handler (char *command)
/* Do any commands attached to breakpoint we stopped at. Only if we
are always running synchronously. Or if we have just executed a
command that doesn't start the target. */
- if (!target_can_async_p () || !target_executing)
+ if (!target_can_async_p () || !is_running (inferior_ptid))
{
bpstat_do_actions (&stop_bpstat);
do_cleanups (old_chain);
Index: src/gdb/inf-loop.c
===================================================================
--- src.orig/gdb/inf-loop.c 2008-06-29 01:39:51.000000000 +0100
+++ src/gdb/inf-loop.c 2008-06-29 22:33:27.000000000 +0100
@@ -26,6 +26,7 @@
#include "remote.h"
#include "exceptions.h"
#include "language.h"
+#include "gdbthread.h"
static int fetch_inferior_event_wrapper (gdb_client_data client_data);
@@ -72,14 +73,6 @@ inferior_event_handler (enum inferior_ev
break;
case INF_EXEC_COMPLETE:
-
- /* This is the first thing to do -- so that continuations know that
- the target is stopped. For example, command_line_handler_continuation
- will run breakpoint commands, and if we think that the target is
- running, we'll refuse to execute most commands. MI continuation
- presently uses target_executing to either print or not print *stopped. */
- target_executing = 0;
-
/* Unregister the inferior from the event loop. This is done so that
when the inferior is not running we don't get distracted by
spurious inferior output. */
@@ -121,8 +114,8 @@ inferior_event_handler (enum inferior_ev
/* If no breakpoint command resumed the inferior, prepare for
interaction with the user. */
- if (!target_executing)
- {
+ if (!is_running (inferior_ptid))
+ {
if (was_sync)
{
display_gdb_prompt (0);
Index: src/gdb/infrun.c
===================================================================
--- src.orig/gdb/infrun.c 2008-06-29 01:41:45.000000000 +0100
+++ src/gdb/infrun.c 2008-06-29 22:33:27.000000000 +0100
@@ -1767,6 +1767,11 @@ handle_inferior_event (struct execution_
&& ecs->ws.kind != TARGET_WAITKIND_SIGNALLED && ecs->new_thread_event)
add_thread (ecs->ptid);
+ /* Mark all threads as not-executing. In non-stop, this should be
+ adjusted to only mark ecs->ptid. */
+ if (ecs->ws.kind != TARGET_WAITKIND_IGNORE)
+ set_executing (pid_to_ptid (-1), 0);
+
switch (ecs->ws.kind)
{
case TARGET_WAITKIND_LOADED:
Index: src/gdb/linux-nat.c
===================================================================
--- src.orig/gdb/linux-nat.c 2008-06-29 01:41:45.000000000 +0100
+++ src/gdb/linux-nat.c 2008-06-29 22:33:27.000000000 +0100
@@ -1624,10 +1624,7 @@ linux_nat_resume (ptid_t ptid, int step,
signo ? strsignal (signo) : "0");
if (target_can_async_p ())
- {
- target_executing = 1;
- target_async (inferior_event_handler, 0);
- }
+ target_async (inferior_event_handler, 0);
}
/* Issue kill to specified lwp. */
Index: src/gdb/stack.c
===================================================================
--- src.orig/gdb/stack.c 2008-06-29 01:39:51.000000000 +0100
+++ src/gdb/stack.c 2008-06-29 22:33:27.000000000 +0100
@@ -43,6 +43,7 @@
#include "regcache.h"
#include "solib.h"
#include "valprint.h"
+#include "gdbthread.h"
#include "gdb_assert.h"
#include <ctype.h>
@@ -1643,6 +1644,9 @@ get_selected_block (CORE_ADDR *addr_in_b
if (!target_has_stack)
return 0;
+ if (is_executing (inferior_ptid))
+ return 0;
+
return get_frame_block (get_selected_frame (NULL), addr_in_block);
}
Index: src/gdb/target.c
===================================================================
--- src.orig/gdb/target.c 2008-06-29 01:41:46.000000000 +0100
+++ src/gdb/target.c 2008-06-29 22:33:27.000000000 +0100
@@ -1786,8 +1786,8 @@ target_resume (ptid_t ptid, int step, en
{
dcache_invalidate (target_dcache);
(*current_target.to_resume) (ptid, step, signal);
+ set_executing (ptid, 1);
set_running (ptid, 1);
-
}
/* Look through the list of possible targets for a target that can
follow forks. */
Index: src/gdb/breakpoint.c
===================================================================
--- src.orig/gdb/breakpoint.c 2008-06-29 01:41:44.000000000 +0100
+++ src/gdb/breakpoint.c 2008-06-29 22:33:27.000000000 +0100
@@ -6229,7 +6229,7 @@ until_break_command (char *arg, int from
deleted when the target stops. Otherwise, we're already stopped and
delete breakpoints via cleanup chain. */
- if (target_can_async_p () && target_executing)
+ if (target_can_async_p () && is_running (inferior_ptid))
{
arg1 =
(struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
Index: src/gdb/remote.c
===================================================================
--- src.orig/gdb/remote.c 2008-06-29 01:41:46.000000000 +0100
+++ src/gdb/remote.c 2008-06-29 22:33:27.000000000 +0100
@@ -3232,13 +3232,6 @@ remote_resume (ptid_t ptid, int step, en
NOT asynchronously. */
if (target_can_async_p ())
target_async (inferior_event_handler, 0);
- /* Tell the world that the target is now executing. */
- /* FIXME: cagney/1999-09-23: Is it the targets responsibility to set
- this? Instead, should the client of target just assume (for
- async targets) that the target is going to start executing? Is
- this information already found in the continuation block? */
- if (target_is_async_p ())
- target_executing = 1;
}
\f
Index: src/gdb/mi/mi-main.c
===================================================================
--- src.orig/gdb/mi/mi-main.c 2008-06-29 22:26:59.000000000 +0100
+++ src/gdb/mi/mi-main.c 2008-06-29 22:33:27.000000000 +0100
@@ -175,8 +175,8 @@ mi_cmd_exec_continue (char *command, cha
void
mi_cmd_exec_interrupt (char *command, char **argv, int argc)
{
- if (!target_executing)
- error ("mi_cmd_exec_interrupt: Inferior not executing.");
+ if (!is_running (inferior_ptid))
+ error ("mi_cmd_exec_interrupt: Inferior not running.");
interrupt_target_command (NULL, 0);
}
@@ -1059,7 +1059,7 @@ mi_cmd_execute (struct mi_parse *parse)
if (parse->cmd->argv_func != NULL)
{
- if (target_executing)
+ if (is_running (inferior_ptid))
{
if (strcmp (parse->command, "exec-interrupt"))
{
@@ -1144,7 +1144,7 @@ mi_execute_async_cli_command (char *cli_
if (target_can_async_p ())
{
/* If we're not executing, an exception should have been throw. */
- gdb_assert (target_executing);
+ gdb_assert (is_running (inferior_ptid));
do_cleanups (old_cleanups);
}
else
Index: src/gdb/Makefile.in
===================================================================
--- src.orig/gdb/Makefile.in 2008-06-29 01:41:44.000000000 +0100
+++ src/gdb/Makefile.in 2008-06-29 22:33:27.000000000 +0100
@@ -2106,7 +2106,7 @@ event-loop.o: event-loop.c $(defs_h) $(e
event-top.o: event-top.c $(defs_h) $(top_h) $(inferior_h) $(target_h) \
$(terminal_h) $(event_loop_h) $(event_top_h) $(interps_h) \
$(exceptions_h) $(cli_script_h) $(gdbcmd_h) $(readline_h) \
- $(readline_history_h) $(main_h)
+ $(readline_history_h) $(main_h) $(gdbthread_h)
exceptions.o: exceptions.c $(defs_h) $(exceptions_h) $(breakpoint_h) \
$(target_h) $(inferior_h) $(annotate_h) $(ui_out_h) $(gdb_assert_h) \
$(gdb_string_h) $(serial_h)
@@ -2141,7 +2141,8 @@ frame.o: frame.c $(defs_h) $(frame_h) $(
$(regcache_h) $(gdb_assert_h) $(gdb_string_h) $(user_regs_h) \
$(gdb_obstack_h) $(dummy_frame_h) $(sentinel_frame_h) $(gdbcore_h) \
$(annotate_h) $(language_h) $(frame_unwind_h) $(frame_base_h) \
- $(command_h) $(gdbcmd_h) $(observer_h) $(objfiles_h) $(exceptions_h)
+ $(command_h) $(gdbcmd_h) $(observer_h) $(objfiles_h) $(exceptions_h) \
+ $(gdbthread_h)
frame-unwind.o: frame-unwind.c $(defs_h) $(frame_h) $(frame_unwind_h) \
$(gdb_assert_h) $(dummy_frame_h) $(gdb_obstack_h) $(value_h) \
$(regcache_h)
@@ -2322,7 +2323,7 @@ infcmd.o: infcmd.c $(defs_h) $(gdb_strin
$(user_regs_h) $(exceptions_h) $(cli_decode_h) $(gdbthread_h)
inf-loop.o: inf-loop.c $(defs_h) $(inferior_h) $(target_h) $(event_loop_h) \
$(event_top_h) $(inf_loop_h) $(remote_h) $(exceptions_h) \
- $(language_h)
+ $(language_h) $(gdbthread_h)
inflow.o: inflow.c $(defs_h) $(frame_h) $(inferior_h) $(command_h) \
$(serial_h) $(terminal_h) $(target_h) $(gdbthread_h) $(gdb_string_h) \
$(inflow_h) $(gdb_select_h)
@@ -2928,7 +2929,7 @@ top.o: top.c $(defs_h) $(gdbcmd_h) $(cal
$(annotate_h) $(completer_h) $(top_h) $(version_h) $(serial_h) \
$(doublest_h) $(gdb_assert_h) $(readline_h) $(readline_history_h) \
$(event_top_h) $(gdb_string_h) $(gdb_stat_h) $(ui_out_h) \
- $(cli_out_h) $(main_h) $(event_loop_h)
+ $(cli_out_h) $(main_h) $(event_loop_h) $(gdbthread_h)
tracepoint.o: tracepoint.c $(defs_h) $(symtab_h) $(frame_h) $(gdbtypes_h) \
$(expression_h) $(gdbcmd_h) $(value_h) $(target_h) $(language_h) \
$(gdb_string_h) $(inferior_h) $(tracepoint_h) $(remote_h) \
Index: src/gdb/frame.c
===================================================================
--- src.orig/gdb/frame.c 2008-06-29 01:39:51.000000000 +0100
+++ src/gdb/frame.c 2008-06-29 22:33:27.000000000 +0100
@@ -40,6 +40,7 @@
#include "observer.h"
#include "objfiles.h"
#include "exceptions.h"
+#include "gdbthread.h"
static struct frame_info *get_prev_frame_1 (struct frame_info *this_frame);
@@ -930,6 +931,9 @@ get_current_frame (void)
error (_("No stack."));
if (!target_has_memory)
error (_("No memory."));
+ if (is_executing (inferior_ptid))
+ error (_("Target is executing."));
+
if (current_frame == NULL)
{
struct frame_info *sentinel_frame =
@@ -950,6 +954,20 @@ get_current_frame (void)
static struct frame_info *selected_frame;
+static int
+has_stack_frames (void)
+{
+ if (!target_has_registers || !target_has_stack || !target_has_memory)
+ return 0;
+
+ /* If the current thread is executing, don't try to read from
+ it. */
+ if (is_executing (inferior_ptid))
+ return 0;
+
+ return 1;
+}
+
/* Return the selected frame. Always non-NULL (unless there isn't an
inferior sufficient for creating a frame) in which case an error is
thrown. */
@@ -959,9 +977,7 @@ get_selected_frame (const char *message)
{
if (selected_frame == NULL)
{
- if (message != NULL && (!target_has_registers
- || !target_has_stack
- || !target_has_memory))
+ if (message != NULL && !has_stack_frames ())
error (("%s"), message);
/* Hey! Don't trust this. It should really be re-finding the
last selected frame of the currently selected thread. This,
@@ -980,7 +996,7 @@ get_selected_frame (const char *message)
struct frame_info *
deprecated_safe_get_selected_frame (void)
{
- if (!target_has_registers || !target_has_stack || !target_has_memory)
+ if (!has_stack_frames ())
return NULL;
return get_selected_frame (NULL);
}
^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2008-07-02 3:29 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-15 21:04 [non-stop] 01/10 Add "executing" property Pedro Alves
2008-06-15 22:18 ` Eli Zaretskii
2008-06-16 1:42 ` Daniel Jacobowitz
2008-06-16 3:23 ` Eli Zaretskii
2008-06-16 6:45 ` ChangeLog entries [was Re: [non-stop] 01/10 Add "executing" property] Nick Roberts
2008-06-16 7:22 ` [non-stop] 01/10 Add "executing" property Vladimir Prus
2008-06-17 0:40 ` Eli Zaretskii
2008-06-17 17:10 ` Vladimir Prus
2008-06-17 20:38 ` Eli Zaretskii
2008-06-23 17:27 ` Tom Tromey
2008-06-17 16:14 ` Joel Brobecker
2008-06-17 18:24 ` Eli Zaretskii
2008-06-17 18:32 ` Joel Brobecker
2008-06-18 0:22 ` Eli Zaretskii
2008-06-17 18:34 ` Pedro Alves
2008-06-17 20:58 ` Eli Zaretskii
2008-06-23 1:13 ` Daniel Jacobowitz
2008-06-23 11:54 ` Vladimir Prus
2008-06-23 14:41 ` Pedro Alves
2008-06-23 18:22 ` Eli Zaretskii
2008-06-23 18:25 ` Vladimir Prus
2008-06-23 19:52 ` Pedro Alves
2008-06-24 1:13 ` Eli Zaretskii
2008-06-23 18:14 ` Eli Zaretskii
2008-07-02 3:29 ` Pedro Alves
2008-06-25 19:02 ` Vladimir Prus
2008-06-25 19:13 ` Pedro Alves
2008-06-25 19:22 ` Daniel Jacobowitz
2008-06-26 13:37 ` Vladimir Prus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox