This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] 04/10 per-thread commands in non-stop mode


This patch deprecates the previous patches posted in this thread:
 [RFA] Make continuations per-thread.
 http://sourceware.org/ml/gdb-patches/2008-04/

Given that,

Âall-stop mode:
 - There can only be one exec command active at any time.

Ânon-stop mode:
 - There can be more than one exec command active at any time.
 - Any given thread can only have one command active at any time.

A continuation is a mechanism to finish a command. ÂIn all-stop
mode, when the inferior stops and GDB finishes handling that
event, we give the user the control again. ÂThe previous command
is finished at this point. ÂIt is up to the user to decide
what to do next. ÂSince we only allow one exec command at any
given time, the next exec command the user issues fully
replaces the previous one.

In non-stop, we can have more than one exec command active, but
only one per thread. ÂSince continuations are a mechanism of
finishing a command, that is, they implement 3) below:

Â1) prepare inferior (insert internal breakpoints, etc.)
Â2) resume inferior and wait for stop
Â3) finish off the command (remove internal breakpoints, etc.)

... and we can have a command per thread, it makes sense to
make each thread have a continuation.

Now, some commands carry "command state" with them. ÂThe biggest
example is the "step"-like commands: Âstep/stepi/next. ÂWhen
we have per-thread commands, we also need to store
individual step-like command state per thread.

So, in non-stop, we context switch all of these:

Âenum step_over_calls_kind step_over_calls;
Âint stop_step;
Âint step_multi;
Âenum target_signal stop_signal;
Âint step_current_line;
Âstruct symtab *step_current_symtab;
Âstruct symbol *step_start_function;

... which define the state of a stepping command.

So, 
 In all-stop, there's one allowed global command (and its continuations).
 In non-stop, there can be one command per thread (and their continuations).

We can come back to this afterwards and do some abstraction,
like adding a "struct command_state" encapsulating the state.

-- 
Pedro Alves
2008-05-06  Pedro Alves  <pedro@codesourcery.com>
	    Vladimir Prus  <vladimir@codesourcery.com>

	* gdbthread.h: Remove unneeded forward declarations.
	Include "inferior.h".
	(struct thread_info): Add continuations,
	intermediate_continuations, proceed_to_finish, step_over_calls,
	stop_step, step_multi and stop_signal members.
	(save_infrun_state): Add continuations,
	intermediate_continuations, proceed_to_finish, step_over_calls,
	stop_step, step_multi and stop_signal parameters.
	(load_infrun_state): Add continuations,
	intermediate_continuations, proceed_to_finish, step_over_calls,
	stop_step, step_multi and stop_signal parameters.
	* thread.c (load_infrun_state): In non-stop mode, load
	continuations, intermediate_continuations, proceed_to_finish,
	step_over_calls, stop_step, step_multi and stop_signal.
	(save_infrun_state): Store continuations,
	intermediate_continuations, proceed_to_finish, step_over_calls,
	stop_step, step_multi and stop_signal.
	* infrun.c (context_switch): Context switch continuations,
	intermediate_continuations, proceed_to_finish, step_over_calls,
	stop_step, step_multi and stop_signal.
	* Makefile.in (gdbthread_h): Depend on $(inferior_h).

---
 gdb/Makefile.in |    2 +-
 gdb/gdbthread.h |   35 +++++++++++++++++++++++++++--------
 gdb/infrun.c    |   16 ++++++++++++++--
 gdb/thread.c    |   38 ++++++++++++++++++++++++++++++++++++--
 4 files changed, 78 insertions(+), 13 deletions(-)

Index: src/gdb/gdbthread.h
===================================================================
--- src.orig/gdb/gdbthread.h	2008-05-06 15:02:06.000000000 +0100
+++ src/gdb/gdbthread.h	2008-05-06 15:02:12.000000000 +0100
@@ -22,17 +22,12 @@
 #ifndef GDBTHREAD_H
 #define GDBTHREAD_H
 
-struct breakpoint;
-struct frame_id;
 struct symtab;
 
-/* For bpstat */
 #include "breakpoint.h"
-
-/* For struct frame_id.  */
 #include "frame.h"
-
 #include "ui-out.h"
+#include "inferior.h"
 
 struct thread_info
 {
@@ -82,6 +77,16 @@ struct thread_info
      when we finally do stop stepping.  */
   bpstat stepping_through_solib_catchpoints;
 
+  /* Per-thread command support.  */
+  struct continuation *continuations;
+  struct continuation *intermediate_continations;
+  int proceed_to_finish;
+  enum step_over_calls_kind step_over_calls;
+  int stop_step;
+  int step_multi;
+
+  enum target_signal stop_signal;
+
   /* Private data used by the target vector implementation.  */
   struct private_thread_info *private;
 };
@@ -145,7 +150,14 @@ extern void save_infrun_state (ptid_t pt
 			       int       stepping_through_solib_after_catch,
 			       bpstat    stepping_through_solib_catchpoints,
 			       int       current_line,
-			       struct symtab *current_symtab);
+			       struct symtab *current_symtab,
+			       struct continuation *continuations,
+			       struct continuation *intermediate_continations,
+			       int proceed_to_finish,
+			       enum step_over_calls_kind step_over_calls,
+			       int stop_step,
+			       int step_multi,
+			       enum target_signal stop_signal);
 
 /* infrun context switch: load the debugger state previously saved
    for the given thread.  */
@@ -160,7 +172,14 @@ extern void load_infrun_state (ptid_t pt
 			       int       *stepping_through_solib_affter_catch,
 			       bpstat    *stepping_through_solib_catchpoints,
 			       int       *current_line,
-			       struct symtab **current_symtab);
+			       struct symtab **current_symtab,
+			       struct continuation **continuations,
+			       struct continuation **intermediate_continations,
+			       int *proceed_to_finish,
+			       enum step_over_calls_kind *step_over_calls,
+			       int *stop_step,
+			       int *step_multi,
+			       enum target_signal *stop_signal);
 
 /* Switch from one thread to another.  */
 extern void switch_to_thread (ptid_t ptid);
Index: src/gdb/thread.c
===================================================================
--- src.orig/gdb/thread.c	2008-05-06 15:02:06.000000000 +0100
+++ src/gdb/thread.c	2008-05-06 15:02:12.000000000 +0100
@@ -329,7 +329,14 @@ load_infrun_state (ptid_t ptid,
 		   int *stepping_through_solib_after_catch,
 		   bpstat *stepping_through_solib_catchpoints,
 		   int *current_line,
-		   struct symtab **current_symtab)
+		   struct symtab **current_symtab,
+		   struct continuation **continuations,
+		   struct continuation **intermediate_continations,
+		   int *proceed_to_finish,
+		   enum step_over_calls_kind *step_over_calls,
+		   int *stop_step,
+		   int *step_multi,
+		   enum target_signal *stop_signal)
 {
   struct thread_info *tp;
 
@@ -352,6 +359,19 @@ load_infrun_state (ptid_t ptid,
     tp->stepping_through_solib_catchpoints;
   *current_line = tp->current_line;
   *current_symtab = tp->current_symtab;
+
+  /* In all-stop mode, these are global state, while in non-stop mode,
+     they are per thread.  */
+  if (non_stop)
+    {
+      *continuations = tp->continuations;
+      *intermediate_continations = tp->intermediate_continations;
+      *proceed_to_finish = tp->proceed_to_finish;
+      *step_over_calls = tp->step_over_calls;
+      *stop_step = tp->stop_step;
+      *step_multi = tp->step_multi;
+      *stop_signal = tp->stop_signal;
+    }
 }
 
 /* Save infrun state for the thread PID.  */
@@ -368,7 +388,14 @@ save_infrun_state (ptid_t ptid,
 		   int stepping_through_solib_after_catch,
 		   bpstat stepping_through_solib_catchpoints,
 		   int current_line,
-		   struct symtab *current_symtab)
+		   struct symtab *current_symtab,
+		   struct continuation *continuations,
+		   struct continuation *intermediate_continations,
+		   int proceed_to_finish,
+		   enum step_over_calls_kind step_over_calls,
+		   int stop_step,
+		   int step_multi,
+		   enum target_signal stop_signal)
 {
   struct thread_info *tp;
 
@@ -389,6 +416,13 @@ save_infrun_state (ptid_t ptid,
   tp->stepping_through_solib_catchpoints = stepping_through_solib_catchpoints;
   tp->current_line = current_line;
   tp->current_symtab = current_symtab;
+  tp->continuations = continuations;
+  tp->intermediate_continations = intermediate_continations;
+  tp->proceed_to_finish = proceed_to_finish;
+  tp->step_over_calls = step_over_calls;
+  tp->stop_step = stop_step;
+  tp->step_multi = step_multi;
+  tp->stop_signal = stop_signal;
 }
 
 /* Return true if TP is an active thread. */
Index: src/gdb/infrun.c
===================================================================
--- src.orig/gdb/infrun.c	2008-05-06 15:02:12.000000000 +0100
+++ src/gdb/infrun.c	2008-05-06 15:02:12.000000000 +0100
@@ -1605,7 +1605,13 @@ context_switch (struct execution_control
 			 ecs->stepping_over_breakpoint,
 			 ecs->stepping_through_solib_after_catch,
 			 ecs->stepping_through_solib_catchpoints,
-			 ecs->current_line, ecs->current_symtab);
+			 ecs->current_line, ecs->current_symtab,
+			 cmd_continuation, intermediate_continuation,
+			 proceed_to_finish,
+			 step_over_calls,
+			 stop_step,
+			 step_multi,
+			 stop_signal);
 
       /* Load infrun state for the new thread.  */
       load_infrun_state (ecs->ptid, &prev_pc,
@@ -1615,7 +1621,13 @@ context_switch (struct execution_control
 			 &ecs->stepping_over_breakpoint,
 			 &ecs->stepping_through_solib_after_catch,
 			 &ecs->stepping_through_solib_catchpoints,
-			 &ecs->current_line, &ecs->current_symtab);
+			 &ecs->current_line, &ecs->current_symtab,
+			 &cmd_continuation, &intermediate_continuation,
+			 &proceed_to_finish,
+			 &step_over_calls,
+			 &stop_step,
+			 &step_multi,
+			 &stop_signal);
     }
 
   switch_to_thread (ecs->ptid);
Index: src/gdb/Makefile.in
===================================================================
--- src.orig/gdb/Makefile.in	2008-05-06 15:02:06.000000000 +0100
+++ src/gdb/Makefile.in	2008-05-06 15:02:12.000000000 +0100
@@ -802,7 +802,7 @@ gdb_stabs_h = gdb-stabs.h
 gdb_stat_h = gdb_stat.h
 gdb_string_h = gdb_string.h
 gdb_thread_db_h = gdb_thread_db.h
-gdbthread_h = gdbthread.h $(breakpoint_h) $(frame_h) $(ui_out_h)
+gdbthread_h = gdbthread.h $(breakpoint_h) $(frame_h) $(ui_out_h) $(inferior_h)
 gdbtypes_h = gdbtypes.h $(hashtab_h)
 gdb_vfork_h = gdb_vfork.h
 gdb_wait_h = gdb_wait.h

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]